diff --git a/workspace_robo/.gitignore b/workspace_robo/.gitignore deleted file mode 100644 index 4a87a74..0000000 --- a/workspace_robo/.gitignore +++ /dev/null @@ -1,11 +0,0 @@ -.metadata -target -build.xml -maven-build.xml -maven-build.properties -/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.sln -/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.suo -ucdetector_reports -/plugins/dotnet/*.suo -*.class -.recommenders diff --git a/workspace_robo/LICENSE.txt b/workspace_robo/LICENSE.txt deleted file mode 100644 index 43c631d..0000000 --- a/workspace_robo/LICENSE.txt +++ /dev/null @@ -1,14 +0,0 @@ -Robocode is licensed under the Eclipse Public License v1.0 (EPL), which is available at -http://robocode.sourceforge.net/license/epl-v10.html - -Notable exceptions are: ------------------------ - -Ant and Maven tools: -- Files/tools located under the directory /tools/bin are licensed under the Apache Software Foundation (Apache-2.0): - http://www.apache.org/licenses/LICENSE-2.0.html - The license files for the Ant and Maven tools are provided under the /tools/licenses directory. - -CILReader.cs: -- The file /plugins/dotnet/robocode.dotnet.nhost/src/mono/reflection/CILReader.cs is copyrighted (C) 2009 Novell, Inc. - (http://www.novell.com) \ No newline at end of file diff --git a/workspace_robo/README.md b/workspace_robo/README.md deleted file mode 100644 index 02440aa..0000000 --- a/workspace_robo/README.md +++ /dev/null @@ -1,12 +0,0 @@ -Robocode -=================== -*Build the best - destroy the rest!* - -Robocode is a programming game, where the goal is to develop a robot battle tank to battle against other tanks in Java or .NET. The robot battles are running in real-time and on-screen. - -Read [Introduction] (http://robocode.sourceforge.net/docs/ReadMe.html) -Continue reading on [Robocode home page] (http://robocode.sourceforge.net/) -Learn from community at [RoboWiki] (http://robowiki.net/) -Talk to developers at [robocode-developers] (http://groups.google.com/group/robocode-developers) - -Enjoy! \ No newline at end of file diff --git a/workspace_robo/RemoteSystemsTempFiles/.project b/workspace_robo/RemoteSystemsTempFiles/.project deleted file mode 100644 index 5447a64..0000000 --- a/workspace_robo/RemoteSystemsTempFiles/.project +++ /dev/null @@ -1,12 +0,0 @@ - - - RemoteSystemsTempFiles - - - - - - - org.eclipse.rse.ui.remoteSystemsTempNature - - diff --git a/workspace_robo/jacobe.cmd b/workspace_robo/jacobe.cmd deleted file mode 100644 index 6c4a0e8..0000000 --- a/workspace_robo/jacobe.cmd +++ /dev/null @@ -1,17 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - - -@rem NOTE: Here we expect jacobe.exe to be installed on system PATH - -@echo off -if exist "%~dp0\tools\lib\jacobe.jar" goto jacobe -call "%~dp0\tools\loadTools.cmd" - -:jacobe -call "%~dp0\tools\bin\ant.bat" -buildfile "%~dp0\tools\jacobe\build.xml" \ No newline at end of file diff --git a/workspace_robo/jacobe.sh b/workspace_robo/jacobe.sh deleted file mode 100644 index 4450e4e..0000000 --- a/workspace_robo/jacobe.sh +++ /dev/null @@ -1,24 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - -# NOTE: Here we expect the jacobe tools to be installed on PATH - -dp0=${0%/*} - -if [ ! -f $dp0/tools/lib/ant-launcher.jar ]; then - $dp0/tools/loadTools.sh -elif [ ! -f $dp0/tools/lib/ant.jar ]; then - $dp0/tools/loadTools.sh -elif [ ! -f $dp0/tools/lib/jacobe.jar ]; then - $dp0/tools/loadTools.sh -fi - -export CLASSPATH=$CLASSPATH:$dp0/tools/lib/ant-launcher.jar:$dp0/tools/lib/ant.jar:$dp0/tools/lib/jacobe.jar -$dp0/tools/bin/ant.sh -buildfile $dp0/tools/jacobe/build.xml - diff --git a/workspace_robo/mvn.cmd b/workspace_robo/mvn.cmd deleted file mode 100644 index 133774c..0000000 --- a/workspace_robo/mvn.cmd +++ /dev/null @@ -1,15 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off - -if not exist "%~dp0\tools\lib\maven-*-uber.jar" ( - call "%~dp0\tools\loadTools.cmd" -) - -call "%~dp0\tools\bin\mvn.bat" %* \ No newline at end of file diff --git a/workspace_robo/mvn.sh b/workspace_robo/mvn.sh deleted file mode 100644 index 2ea9c12..0000000 --- a/workspace_robo/mvn.sh +++ /dev/null @@ -1,16 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - -dp0=${0%/*} - -if [ ! -f $dp0/tools/lib/maven-*-uber.jar ]; then - $dp0/tools/loadTools.sh -fi - -$dp0/tools/bin/mvn.sh $* \ No newline at end of file diff --git a/workspace_robo/mvnassembly.cmd b/workspace_robo/mvnassembly.cmd deleted file mode 100644 index fb10c4c..0000000 --- a/workspace_robo/mvnassembly.cmd +++ /dev/null @@ -1,12 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off - -mvn clean install ant:ant -DskipTests=false %* -rem mvn eclipse:eclipse \ No newline at end of file diff --git a/workspace_robo/mvnassembly.sh b/workspace_robo/mvnassembly.sh deleted file mode 100644 index a498a71..0000000 --- a/workspace_robo/mvnassembly.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - -./mvn.sh clean install ant:ant -DskipTests=false $* -#./mvn.sh eclipse:eclipse \ No newline at end of file diff --git a/workspace_robo/plugins/.project b/workspace_robo/plugins/.project deleted file mode 100644 index 0ab6892..0000000 --- a/workspace_robo/plugins/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - plugins - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/ReadMe.txt b/workspace_robo/plugins/dotnet/ReadMe.txt deleted file mode 100644 index 7466121..0000000 --- a/workspace_robo/plugins/dotnet/ReadMe.txt +++ /dev/null @@ -1,88 +0,0 @@ -==== - Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://robocode.sourceforge.net/license/epl-v10.html -==== - -This is guide to build Robocode for .NET - -REQUIRED TOOLS FOR BUILDING THE ROBOCODE .NET PLUG-IN -===================================================== - -Microsoft C# Compiler and .NET SDK ----------------------------------- -- You need C# compiler and .NET SDK at least 4.0: - http://www.microsoft.com/en-us/download/details.aspx?id=17851 - -- Best option is to install Visual Studio C# Express 2010 or newer. - -- NOTE: Make sure you have csc.exe on PATH. - -Microsoft HTML Help 1 Compiler and Sandcastle Help File Builder ---------------------------------------------------------------- -- 'HTML Help 1 compiler' must be installed on the system - required by the - Sandcastle Help File Builder (SHFB) - - HTML Help 1 compiler: - http://msdn.microsoft.com/en-us/library/ms669985(VS.85).aspx - -- Sandcastle Help File Builder (SHFB) must be installed on the system. - http://shfb.codeplex.com/ - - NOTE: When installing the SHFB, you don't need to install HTML Help 2 as - only version 1 is used for Robocode. - -Java Development Kit (JDK) and JAVA_HOME path ---------------------------------------------- -- Oracle JDK 6 or newer must be installed on the system: - http://www.oracle.com/technetwork/java/javase/downloads - -- NOTE: Make sure to install the proper version (32 or 64-bit) depending on the - system. - - -HOW TO BUILD THE ROBOCODE .NET PLUG-IN -====================================== - -1) Build the regular part of Robocode first with 'mvn install' - (or mvnassembly.cmd) from source code root directory of Robocode. - -2) CD (change directory) to \plugins\dotnet - -3) Run: tools\loadTools.cmd - -4) Run: tools\keys\gennetkey.cmd - -5) Run: mvnassembly.cmd (standing in the \plugins\dotnet directory) - -9) Find the resulting distribution file for the Robocode .NET plug-in named - robocode.dotnet-x.x.x.x-setup.jar within this directory: - \plugins\dotnet\robocode.dotnet.distribution\target\ - - -HOW TO BUILD NEW PROXY CLASSES USING JNI4NET -============================================ -Robocode uses Jni4net (http://jni4net.com/) to bridge the .NET and Java parts -of Robocode. Only the .NET plug-in is written for the Microsoft .NET platform. -The rest of Robocode is build for the Java platform. - -When changing the public APIs or internal classes of Robocode it is important -that the corresponding .NET classes are updated as well. Some classes for the -.NET are handwritten. Other parts are auto-generated using the Jni4Net proxygen -tool (details are provided here: http://jni4net.com/). - -In order to update all the auto-generated source files for the .NET plugin you -must: - -1) CD (change directory) to \plugins\dotnet - -2) Run: generateProxies.cmd - -NOTE: You might need to remove the 'rem' and change the following lines inside - the generateProxies.cmd in order to force the JAVA_HOME and PATH to the - correct Java version: - -rem set JAVA_HOME=%JDK6_HOME% -rem set PATH=%JAVA_HOME%\bin;%PATH% \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/generateProxies.cmd b/workspace_robo/plugins/dotnet/generateProxies.cmd deleted file mode 100644 index 4b0c808..0000000 --- a/workspace_robo/plugins/dotnet/generateProxies.cmd +++ /dev/null @@ -1,41 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off - -rem set JAVA_HOME=%JDK6_HOME% -rem set PATH=%JAVA_HOME%\bin;%PATH% - -set NET_FRAMEWORK_HOME=C:\Windows\Microsoft.NET\Framework\v3.5 -set PATH=%NET_FRAMEWORK_HOME%;%PATH% - -if exist "%~dp0\tools\lib\proxygen.exe" goto gen -call "%~dp0\tools\loadTools.cmd" - -:gen -"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.control.proxygen.xml -"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.proxygen.xml - -if exist "%~dp0\robocode.dotnet.nhost\target\robocode.dotnet.nhost.dll" goto gen1 -echo cat't find robocode.dotnet.nhost\target\robocode.dotnet.nhost.dll, please compile it -goto end - -:gen1 -if exist "%~dp0\tools\lib\robocode.dll" goto gen3 -if exist "%~dp0\robocode.dotnet.api\target\robocode.dll" goto gen2 -echo cat't find \robocode.dotnet.api\target\robocode.dll, please compile it -goto end - -:gen2 - -copy "%~dp0\robocode.dotnet.api\target\robocode.dll" "%~dp0\tools\lib" - -:gen3 -"%~dp0\tools\lib\proxygen.exe" tools\proxygen\robocode.proxygen.net.xml - -:end \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/mvn.cmd b/workspace_robo/plugins/dotnet/mvn.cmd deleted file mode 100644 index 17e6ed1..0000000 --- a/workspace_robo/plugins/dotnet/mvn.cmd +++ /dev/null @@ -1,20 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off - -if not exist "%~dp0\tools\lib" ( - mkdir "%~dp0\tools\lib" - call "%~dp0\tools\loadTools.cmd" -) - -if not exist "%~dp0\..\..\tools\lib\maven-*-uber.jar" ( - call "%~dp0\..\..\tools\loadTools.cmd" -) - -call "%~dp0\..\..\mvn" %* \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/mvnassembly.cmd b/workspace_robo/plugins/dotnet/mvnassembly.cmd deleted file mode 100644 index fb10c4c..0000000 --- a/workspace_robo/plugins/dotnet/mvnassembly.cmd +++ /dev/null @@ -1,12 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off - -mvn clean install ant:ant -DskipTests=false %* -rem mvn eclipse:eclipse \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/pom.xml b/workspace_robo/plugins/dotnet/pom.xml deleted file mode 100644 index c063b01..0000000 --- a/workspace_robo/plugins/dotnet/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 4.0.0 - robocode.dotnet - .NET Robocode - ${robocode.dotnet.version} - pom - - net.sf.robocode - robocode - ${robocode.version} - ../.. - - - - jni4net.repo - jni4net Repository - http://jni4net.googlecode.com/svn/mvnrepo - - - aduna.repo - Aduna Repository - http://repository.aduna-software.org/maven2/ - - - - robocode.dotnet.api - robocode.dotnet.control.api - robocode.dotnet.content - robocode.dotnet.distribution - robocode.dotnet.host - robocode.dotnet.nhost - robocode.dotnet.ntests - robocode.dotnet.robotscs - robocode.dotnet.installer - robocode.dotnet.samples - robocode.dotnet.tests - - - - - - org.sonatype.nmaven.plugins - maven-dotnet-compiler-plugin - true - 0.17robocode - - - org.sonatype.nmaven.plugins - maven-dotnet-test-plugin - 0.17robocode - - - org.jvnet.maven-antrun-extended-plugin - maven-antrun-extended-plugin - 1.43 - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.api/.project deleted file mode 100644 index 3b435ab..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/.project +++ /dev/null @@ -1,8 +0,0 @@ - - - robocode.dotnet.api - .NET Robot API for Robocode. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 070758f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,10 +0,0 @@ -#Tue Nov 27 22:34:10 CET 2012 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 -encoding/src/main/resources=8859_1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/test/resources=8859_1 -encoding/src=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.api/pom.xml deleted file mode 100644 index cc1a6fc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/pom.xml +++ /dev/null @@ -1,52 +0,0 @@ - - - 4.0.0 - robocode.dotnet.api - Robocode .NET Robot API - .NET Robot API for Robocode - dotnet:library - - robocode.dotnet - net.sf.robocode - ${robocode.dotnet.version} - - - robocode - src - - - org.sonatype.nmaven.plugins - maven-dotnet-compiler-plugin - - /unsafe /warn:0 /nowarn:1591 /keyfile:"${basedir}/../tools/keys/robocode.snk" - robocode.dll - - - - org.jvnet.maven-antrun-extended-plugin - maven-antrun-extended-plugin - - - process-classes - - - - - - - - - - - run - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/robocode.dotnet.api.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.api/robocode.dotnet.api.iml deleted file mode 100644 index 284265c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/robocode.dotnet.api.iml +++ /dev/null @@ -1,66 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/robotAPI.shfbproj b/workspace_robo/plugins/dotnet/robocode.dotnet.api/robotAPI.shfbproj deleted file mode 100644 index b0d9b8a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/robotAPI.shfbproj +++ /dev/null @@ -1,87 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {90f0d09b-f58d-4f2e-ac8a-164d89979ef1} - 1.9.5.0 - - Documentation - Documentation - Documentation - - .\target\Help\ - RobotAPI - - - - - AutoDocumentCtors, AutoDocumentDispose - Robocode Robot API for .NET - .NET Framework 3.5 - HtmlHelp1, Website - - - - - - - - - - - - - - - - - - - - - - - - - - InheritedMembers, Protected, SealedProtected - - Robot API used for writing robots for Robocode - Robot Interfaces used for creating new robot types, e.g. with other programming languages. - Robot peers available for implementing new robot types based on the Robot Interfaces. - Utility classes that can be used when writing robots. Kept for compatibility with legacy robots. - - Robocode Robot API for .NET - Copyright %28c%29 2001-2016 Mathew A. Nelson and Robocode contributors - fnl%40users.sourceforge.net - administator and maintainer of Robocode - vs2010 - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/.gitignore b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/.gitignore deleted file mode 100644 index 880d47a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/obj -/robocode.dotnet.api.sln -/robocode.dotnet.api.suo diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/AssemblyInf.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/AssemblyInf.cs deleted file mode 100644 index e7376c7..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/AssemblyInf.cs +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System.Security; - -[assembly: AllowPartiallyTrustedCallers] \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/io/LoggerN.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/io/LoggerN.cs deleted file mode 100644 index aeea87e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/io/LoggerN.cs +++ /dev/null @@ -1,132 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.IO; -using System.Security.Permissions; -using System.Text; -using net.sf.robocode.security; - -namespace net.sf.robocode.io -{ -#pragma warning disable 1591 - /// - /// This is a class used for logging. - /// - /// - [RobocodeInternalPermission(SecurityAction.LinkDemand)] - public class LoggerN - { - public static TextWriter realOut = Console.Out; - public static TextWriter realErr = Console.Error; - public static TextWriter robotOut = Console.Out; - - private static ILoggerN logListener; - private static readonly StringBuilder logBuffer = new StringBuilder(); - [ThreadStatic] public static bool IsSafeThread; - - public static void setLogListener(ILoggerN logListener) - { - LoggerN.logListener = logListener; - } - - public static void logMessage(string s) - { - logMessage(s, true); - } - - public static void logMessage(Exception e) - { - logMessage(e.StackTrace); - } - - public static void logMessage(string message, Exception t) - { - logMessage(message + ":\n" + t.StackTrace); - } - - public static void logError(string message, Exception t) - { - logError(message + ":\n" + t.StackTrace); - } - - public static void logError(Exception t) - { - logError(t.StackTrace); - } - - public static void logMessage(string s, bool newline) - { - if (logListener == null) - { - if (newline) - { - realOut.WriteLine(s); - } - else - { - realOut.Write(s); - realOut.Flush(); - } - } - else - { - lock (logBuffer) - { - if (!IsSafeThread) - { - // we just queue it, to not let unsafe thread travel thru system - logBuffer.Append(s); - logBuffer.Append("\n"); - } - else if (newline) - { - logMessage(logBuffer + s, true); - logBuffer.Length = 0; - } - else - { - logBuffer.Append(s); - } - } - } - } - - public static void logError(string s) - { - if (logListener == null) - { - realErr.WriteLine(s); - } - else - { - logListener.logError(s); - } - } - - public static void WriteLineToRobotsConsole(string s) - { - if (robotOut != null) - { - robotOut.WriteLine(s); - } - else - { - logMessage(s); - } - } - } - - /// - public interface ILoggerN - { - void logMessage(string s, bool newline); - void logError(string s); - } -} - -//happy \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/Buffer.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/Buffer.cs deleted file mode 100644 index f1e3056..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/Buffer.cs +++ /dev/null @@ -1,508 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -// This class is based on the source code from Sun's Java 1.5.0 API for java.nio.Buffer, but -// rewritten for C# and .NET with the purpose to bridge the .NET and Java internals of Robocode. - -using System; -using System.Security.Permissions; -using net.sf.robocode.security; - -// ReSharper disable InconsistentNaming - -namespace net.sf.robocode.nio -{ -#pragma warning disable 1591 -#pragma warning disable 1570 - - /* - * A container for data of a specific primitive type. - * - *

A buffer is a linear, finite sequence of elements of a specific - * primitive type. Aside from its content, the essential properties of a - * buffer are its capacity, limit, and position:

- * - *
- * - *

A buffer's capacity is the number of elements it contains. The - * capacity of a buffer is never negative and never changes.

- * - *

A buffer's limit is the index of the first element that should - * not be read or written. A buffer's limit is never negative and is never - * greater than its capacity.

- * - *

A buffer's position is the index of the next element to be - * read or written. A buffer's position is never negative and is never - * greater than its limit.

- * - *
- * - *

There is one subclass of this class for each non-boolean primitive type. - * - * - *

Transferring data

- * - *

Each subclass of this class defines two categories of get and - * put operations:

- * - *
- * - *

Relative operations read or write one or more elements starting - * at the current position and then increment the position by the number of - * elements transferred. If the requested transfer exceeds the limit then a - * relative get operation throws a {@link BufferUnderflowException} - * and a relative put operation throws a {@link - * BufferOverflowException}; in either case, no data is transferred.

- * - *

Absolute operations take an explicit element index and do not - * affect the position. Absolute get and put operations throw - * an {@link IndexOutOfBoundsException} if the index argument exceeds the - * limit.

- * - *
- * - *

Data may also, of course, be transferred in to or out of a buffer by the - * I/O operations of an appropriate channel, which are always relative to the - * current position. - * - * - *

Marking and resetting

- * - *

A buffer's mark is the index to which its position will be reset - * when the {@link #reset reset} method is invoked. The mark is not always - * defined, but when it is defined it is never negative and is never greater - * than the position. If the mark is defined then it is discarded when the - * position or the limit is adjusted to a value smaller than the mark. If the - * mark is not defined then invoking the {@link #reset reset} method causes an - * {@link InvalidMarkException} to be thrown. - * - * - *

Invariants

- * - *

The following invariant holds for the mark, position, limit, and - * capacity values: - * - *

- * 0 <= - * mark <= - * position <= - * limit <= - * capacity - *
- * - *

A newly-created buffer always has a position of zero and a mark that is - * undefined. The initial limit may be zero, or it may be some other value - * that depends upon the type of the buffer and the manner in which it is - * constructed. The initial content of a buffer is, in general, - * undefined. - * - * - *

Clearing, flipping, and rewinding

- * - *

In addition to methods for accessing the position, limit, and capacity - * values and for marking and resetting, this class also defines the following - * operations upon buffers: - * - *

- * - * - *

Read-only buffers

- * - *

Every buffer is readable, but not every buffer is writable. The - * mutation methods of each buffer class are specified as optional - * operations that will throw a {@link ReadOnlyBufferException} when - * invoked upon a read-only buffer. A read-only buffer does not allow its - * content to be changed, but its mark, position, and limit values are mutable. - * Whether or not a buffer is read-only may be determined by invoking its - * {@link #isReadOnly isReadOnly} method. - * - * - *

Thread safety

- * - *

Buffers are not safe for use by multiple concurrent threads. If a - * buffer is to be used by more than one thread then access to the buffer - * should be controlled by appropriate synchronization. - * - * - *

Invocation chaining

- * - *

Methods in this class that do not otherwise have a value to return are - * specified to return the buffer upon which they are invoked. This allows - * method invocations to be chained; for example, the sequence of statements - * - *

-     * b.flip();
-     * b.position(23);
-     * b.limit(42);
- * - * can be replaced by the single, more compact statement - * - *
-     * b.flip().position(23).limit(42);
- * - * - * @author Mark Reinhold - * @author JSR-51 Expert Group - * @version 1.35, 06/08/11 - * @since 1.4 - */ - - /// - [RobocodeInternalPermission(SecurityAction.LinkDemand)] - public abstract class Buffer - { - // Invariants: mark <= position <= limit <= capacity - private readonly int _capacity; - private int _limit; - private int _mark = -1; - private int _position; - - // Creates a new buffer with the given mark, position, limit, and capacity, - // after checking invariants. - // - protected Buffer(int mark, int pos, int lim, int cap) - { - // package-private - if (cap < 0) - throw new ArgumentException(); - _capacity = cap; - limit(lim); - position(pos); - if (mark >= 0) - { - if (mark > pos) - throw new ArgumentException(); - _mark = mark; - } - } - - /* - * Returns this buffer's capacity.

- * - * @return The capacity of this buffer - */ - public int capacity() - { - return _capacity; - } - - /* - * Returns this buffer's position.

- * - * @return The position of this buffer - */ - public int position() - { - return _position; - } - - /* - * Sets this buffer's position. If the mark is defined and larger than the - * new position then it is discarded.

- * - * @param newPosition - * The new position value; must be non-negative - * and no larger than the current limit - * - * @return This buffer - * - * @throws ArgumentException - * If the preconditions on newPosition do not hold - */ - public Buffer position(int newPosition) - { - if ((newPosition > _limit) || (newPosition < 0)) - throw new ArgumentException(); - _position = newPosition; - if (_mark > _position) _mark = -1; - return this; - } - - /* - * Returns this buffer's limit.

- * - * @return The limit of this buffer - */ - public int limit() - { - return _limit; - } - - /* - * Sets this buffer's limit. If the position is larger than the new limit - * then it is set to the new limit. If the mark is defined and larger than - * the new limit then it is discarded.

- * - * @param newLimit - * The new limit value; must be non-negative - * and no larger than this buffer's capacity - * - * @return This buffer - * - * @throws ArgumentException - * If the preconditions on newLimit do not hold - */ - public Buffer limit(int newLimit) - { - if ((newLimit > _capacity) || (newLimit < 0)) - throw new ArgumentException(); - _limit = newLimit; - if (_position > _limit) _position = _limit; - if (_mark > _limit) _mark = -1; - return this; - } - - /* - * Sets this buffer's mark at its position.

- * - * @return This buffer - */ - public Buffer mark() - { - _mark = _position; - return this; - } - - /* - * Resets this buffer's position to the previously-marked position. - * - *

Invoking this method neither changes nor discards the mark's - * value.

- * - * @return This buffer - * - * @throws InvalidMarkException - * If the mark has not been set - */ - public Buffer reset() - { - int m = _mark; - if (m < 0) - throw new InvalidMarkException(); - _position = m; - return this; - } - - /* - * Clears this buffer. The position is set to zero, the limit is set to - * the capacity, and the mark is discarded. - * - *

Invoke this method before using a sequence of channel-read or - * put operations to fill this buffer. For example: - * - *

-         * buf.clear();     // Prepare buffer for reading
-         * in.read(buf);    // Read data
- * - *

This method does not actually erase the data in the buffer, but it - * is named as if it did because it will most often be used in situations - * in which that might as well be the case.

- * - * @return This buffer - */ - public Buffer clear() - { - _position = 0; - _limit = _capacity; - _mark = -1; - return this; - } - - /* - * Flips this buffer. The limit is set to the current position and then - * the position is set to zero. If the mark is defined then it is - * discarded. - * - *

After a sequence of channel-read or put operations, invoke - * this method to prepare for a sequence of channel-write or relative - * get operations. For example: - * - *

-         * buf.put(magic);    // Prepend header
-         * in.read(buf);      // Read data into rest of buffer
-         * buf.flip();        // Flip buffer
-         * out.write(buf);    // Write header + data to channel
- * - *

This method is often used in conjunction with the {@link - * java.nio.ByteBuffer#compact compact} method when transferring data from - * one place to another.

- * - * @return This buffer - */ - public Buffer flip() - { - _limit = _position; - _position = 0; - _mark = -1; - return this; - } - - /* - * Rewinds this buffer. The position is set to zero and the mark is - * discarded. - * - *

Invoke this method before a sequence of channel-write or get - * operations, assuming that the limit has already been set - * appropriately. For example: - * - *

-         * out.write(buf);    // Write remaining data
-         * buf.rewind();      // Rewind buffer
-         * buf.get(array);    // Copy data into array
- * - * @return This buffer - */ - public Buffer rewind() - { - _position = 0; - _mark = -1; - return this; - } - - /* - * Returns the number of elements between the current position and the - * limit.

- * - * @return The number of elements remaining in this buffer - */ - public int remaining() - { - return _limit - _position; - } - - /* - * Tells whether there are any elements between the current position and - * the limit.

- * - * @return true if, and only if, there is at least one element - * remaining in this buffer - */ - public bool hasRemaining() - { - return _position < _limit; - } - - /* - * Tells whether or not this buffer is read-only.

- * - * @return true if, and only if, this buffer is read-only - */ - public abstract bool isReadOnly(); - - - // -- Package-private methods for bounds checking, etc. -- - - /* - * Checks the current position against the limit, throwing a {@link - * BufferUnderflowException} if it is not smaller than the limit, and then - * increments the position.

- * - * @return The current position value, before it is incremented - */ - internal int nextGetIndex() - { - // package-private - if (_position >= _limit) - throw new BufferUnderflowException(); - return _position++; - } - - internal int nextGetIndex(int nb) - { - // package-private - if (_limit - _position < nb) - throw new BufferUnderflowException(); - int p = _position; - _position += nb; - return p; - } - - /* - * Checks the current position against the limit, throwing a {@link - * BufferOverflowException} if it is not smaller than the limit, and then - * increments the position.

- * - * @return The current position value, before it is incremented - */ - internal int nextPutIndex() - { - // package-private - if (_position >= _limit) - throw new BufferOverflowException(); - return _position++; - } - - internal int nextPutIndex(int nb) - { - // package-private - if (_limit - _position < nb) - throw new BufferOverflowException(); - int p = _position; - _position += nb; - return p; - } - - /* - * Checks the given index against the limit, throwing an {@link - * IndexOutOfBoundsException} if it is not smaller than the limit - * or is smaller than zero. - */ - internal int checkIndex(int i) - { - // package-private - if ((i < 0) || (i >= _limit)) - throw new IndexOutOfRangeException(); - return i; - } - - internal int checkIndex(int i, int nb) - { - // package-private - if ((i < 0) || (nb > _limit - i)) - throw new IndexOutOfRangeException(); - return i; - } - - internal int markValue() - { - // package-private - return _mark; - } - - internal void discardMark() - { - // package-private - _mark = -1; - } - - internal static void checkBounds(int off, int len, int size) - { - // package-private - if ((off | len | (off + len) | (size - (off + len))) < 0) - throw new IndexOutOfRangeException(); - } - } -#pragma warning restore 1591 -} - -// ReSharper restore InconsistentNaming \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/ByteBuffer.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/ByteBuffer.cs deleted file mode 100644 index 761a59f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/ByteBuffer.cs +++ /dev/null @@ -1,1604 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -// This class is based on the source code from Sun's Java 1.5.0 API for java.nio.ByteBuffer, but -// rewritten for C# and .NET with the purpose to bridge the .NET and Java internals of Robocode. - -using System; -using System.Security.Permissions; -using System.Text; -using net.sf.robocode.security; - -// ReSharper disable InconsistentNaming - -namespace net.sf.robocode.nio -{ -#pragma warning disable 1591 -#pragma warning disable 1570 - /// - public enum ByteOrder - { - BIG_ENDIAN, - LITTLE_ENDIAN, - } - - /* - * A byte buffer. - * - *

This class defines six categories of operations upon - * byte buffers: - * - *

    - * - *
  • Absolute and relative {@link #get() get} and - * {@link #put(byte) put} methods that read and write - * single bytes;

  • - * - *
  • Relative {@link #get(byte[]) bulk get} - * methods that transfer contiguous sequences of bytes from this buffer - * into an array;

  • - * - *
  • Relative {@link #put(byte[]) bulk put} - * methods that transfer contiguous sequences of bytes from a - * byte array or some other byte - * buffer into this buffer;

  • - * - * - *
  • Absolute and relative {@link #getChar() get} - * and {@link #putChar(char) put} methods that read and - * write values of other primitive types, translating them to and from - * sequences of bytes in a particular byte order;

  • - * - *
  • Methods for creating view buffers, - * which allow a byte buffer to be viewed as a buffer containing values of - * some other primitive type; and

  • - * - * - *
  • Methods for {@link #compact compacting}, {@link - * #duplicate duplicating}, and {@link #slice - * slicing} a byte buffer.

  • - * - *
- * - *

Byte buffers can be created either by {@link #allocate - * allocation}, which allocates space for the buffer's - * - * - * content, or by {@link #wrap(byte[]) wrapping} an - * existing byte array into a buffer. - * - * - * - * - *

Direct vs. non-direct buffers

- * - *

A byte buffer is either direct or non-direct. Given a - * direct byte buffer, the Java virtual machine will make a best effort to - * perform native I/O operations directly upon it. That is, it will attempt to - * avoid copying the buffer's content to (or from) an intermediate buffer - * before (or after) each invocation of one of the underlying operating - * system's native I/O operations. - * - *

A direct byte buffer may be created by invoking the {@link - * #allocateDirect(int) allocateDirect} factory method of this class. The - * buffers returned by this method typically have somewhat higher allocation - * and deallocation costs than non-direct buffers. The contents of direct - * buffers may reside outside of the normal garbage-collected heap, and so - * their impact upon the memory footprint of an application might not be - * obvious. It is therefore recommended that direct buffers be allocated - * primarily for large, long-lived buffers that are subject to the underlying - * system's native I/O operations. In general it is best to allocate direct - * buffers only when they yield a measureable gain in program performance. - * - *

A direct byte buffer may also be created by {@link - * java.nio.channels.FileChannel#map mapping} a region of a file - * directly into memory. An implementation of the Java platform may optionally - * support the creation of direct byte buffers from native code via JNI. If an - * instance of one of these kinds of buffers refers to an inaccessible region - * of memory then an attempt to access that region will not change the buffer's - * content and will cause an unspecified exception to be thrown either at the - * time of the access or at some later time. - * - *

Whether a byte buffer is direct or non-direct may be determined by - * invoking its {@link #isDirect isDirect} method. This method is provided so - * that explicit buffer management can be done in performance-critical code. - * - * - * - *

Access to binary data

- * - *

This class defines methods for reading and writing values of all other - * primitive types, except boolean. Primitive values are translated - * to (or from) sequences of bytes according to the buffer's current byte - * order, which may be retrieved and modified via the {@link #order order} - * methods. Specific byte orders are represented by instances of the {@link - * ByteOrder} class. The initial order of a byte buffer is always {@link - * ByteOrder#BIG_ENDIAN BIG_ENDIAN}. - * - *

For access to heterogeneous binary data, that is, sequences of values of - * different types, this class defines a family of absolute and relative - * get and put methods for each type. For 32-bit floating-point - * values, for example, this class defines: - * - *

-     * float  {@link #getFloat()}
-     * float  {@link #getFloat(int) getFloat(int index)}
-     *  void  {@link #putFloat(float) putFloat(float f)}
-     *  void  {@link #putFloat(int,float) putFloat(int index, float f)}
- * - *

Corresponding methods are defined for the types char, - * short, int, long, and double. The index - * parameters of the absolute get and put methods are in terms of - * bytes rather than of the type being read or written. - * - * - * - *

For access to homogeneous binary data, that is, sequences of values of - * the same type, this class defines methods that can create views of a - * given byte buffer. A view buffer is simply another buffer whose - * content is backed by the byte buffer. Changes to the byte buffer's content - * will be visible in the view buffer, and vice versa; the two buffers' - * position, limit, and mark values are independent. The {@link - * #asFloatBuffer() asFloatBuffer} method, for example, creates an instance of - * the {@link FloatBuffer} class that is backed by the byte buffer upon which - * the method is invoked. Corresponding view-creation methods are defined for - * the types char, short, int, long, and - * double. - * - *

View buffers have three important advantages over the families of - * type-specific get and put methods described above: - * - *

- * - *

The byte order of a view buffer is fixed to be that of its byte buffer - * at the time that the view is created.

- * - * - *

Invocation chaining

- * - *

Methods in this class that do not otherwise have a value to return are - * specified to return the buffer upon which they are invoked. This allows - * method invocations to be chained. - * - * - * The sequence of statements - * - *

-     * bb.putInt(0xCAFEBABE);
-     * bb.putShort(3);
-     * bb.putShort(45);
- * - * can, for example, be replaced by the single statement - * - *
-     * bb.putInt(0xCAFEBABE).putShort(3).putShort(45);
- * - * - * - * @author Mark Reinhold - * @author JSR-51 Expert Group - * @version 1.56, 04/07/16 - * @since 1.4 - */ - - /// - [RobocodeInternalPermission(SecurityAction.LinkDemand)] - public abstract class ByteBuffer : Buffer //, Comparable - { - // These fields are declared here rather than in Heap-X-Buffer in order to - // reduce the number of virtual method invocations needed to access these - // values, which is especially costly when coding small buffers. - // - internal int _offset; - - internal bool bigEndian // package-private - = true; - - internal byte[] hb; // Non-null only for heap buffers - - internal bool nativeByteOrder // package-private - = true; - - // Creates a new buffer with the given mark, position, limit, capacity, - // backing array, and array offset - // - internal ByteBuffer(int mark, int pos, int lim, int cap, // package-private - byte[] hb, int offset) - : base(mark, pos, lim, cap) - { - this.hb = hb; - _offset = offset; - } - - // Creates a new buffer with the given mark, position, limit, and capacity - // - internal ByteBuffer(int mark, int pos, int lim, int cap) - : this(mark, pos, lim, cap, null, 0) - { - // package-private - } - - - /* - * Allocates a new direct byte buffer. - * - *

The new buffer's position will be zero, its limit will be its - * capacity, and its mark will be undefined. Whether or not it has a - * {@link #hasArray backing array} is unspecified.

- * - * @param capacity - * The new buffer's capacity, in bytes - * - * @return The new byte buffer - * - * @throws ArgumentException - * If the capacity is a negative integer - */ - - public static ByteBuffer allocateDirect(int capacity) - { - if (capacity < 0) - throw new ArgumentException(); - return new HeapByteBuffer(capacity, capacity); - } - - - /* - * Allocates a new byte buffer. - * - *

The new buffer's position will be zero, its limit will be its - * capacity, and its mark will be undefined. It will have a {@link #array - * backing array}, and its {@link #arrayOffset array - * offset} will be zero. - * - * @param capacity - * The new buffer's capacity, in bytes - * - * @return The new byte buffer - * - * @throws ArgumentException - * If the capacity is a negative integer - */ - - public static ByteBuffer allocate(int capacity) - { - if (capacity < 0) - throw new ArgumentException(); - return new HeapByteBuffer(capacity, capacity); - } - - /* - * Wraps a byte array into a buffer. - * - *

The new buffer will be backed by the given byte array; - * that is, modifications to the buffer will cause the array to be modified - * and vice versa. The new buffer's capacity will be - * array.length, its position will be offset, its limit - * will be offset + length, and its mark will be undefined. Its - * {@link #array backing array} will be the given array, and - * its {@link #arrayOffset array offset} will be zero.

- * - * @param array - * The array that will back the new buffer - * - * @param offset - * The offset of the subarray to be used; must be non-negative and - * no larger than array.length. The new buffer's position - * will be set to this value. - * - * @param length - * The length of the subarray to be used; - * must be non-negative and no larger than - * array.length - offset. - * The new buffer's limit will be set to offset + length. - * - * @return The new byte buffer - * - * @throws IndexOutOfBoundsException - * If the preconditions on the offset and length - * parameters do not hold - */ - - public static ByteBuffer wrap(byte[] array, - int offset, int length) - { - try - { - return new HeapByteBuffer(array, offset, length); - } - catch (ArgumentException) - { - throw new IndexOutOfRangeException(); - } - } - - /* - * Wraps a byte array into a buffer. - * - *

The new buffer will be backed by the given byte array; - * that is, modifications to the buffer will cause the array to be modified - * and vice versa. The new buffer's capacity and limit will be - * array.length, its position will be zero, and its mark will be - * undefined. Its {@link #array backing array} will be the - * given array, and its {@link #arrayOffset array offset} will - * be zero.

- * - * @param array - * The array that will back this buffer - * - * @return The new byte buffer - */ - - public static ByteBuffer wrap(byte[] array) - { - return wrap(array, 0, array.Length); - } - - - /* - * Creates a new byte buffer whose content is a shared subsequence of - * this buffer's content. - * - *

The content of the new buffer will start at this buffer's current - * position. Changes to this buffer's content will be visible in the new - * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. - * - *

The new buffer's position will be zero, its capacity and its limit - * will be the number of bytes remaining in this buffer, and its mark - * will be undefined. The new buffer will be direct if, and only if, this - * buffer is direct, and it will be read-only if, and only if, this buffer - * is read-only.

- * - * @return The new byte buffer - */ - public abstract ByteBuffer slice(); - - /* - * Creates a new byte buffer that shares this buffer's content. - * - *

The content of the new buffer will be that of this buffer. Changes - * to this buffer's content will be visible in the new buffer, and vice - * versa; the two buffers' position, limit, and mark values will be - * independent. - * - *

The new buffer's capacity, limit, position, and mark values will be - * identical to those of this buffer. The new buffer will be direct if, - * and only if, this buffer is direct, and it will be read-only if, and - * only if, this buffer is read-only.

- * - * @return The new byte buffer - */ - public abstract ByteBuffer duplicate(); - - /* - * Creates a new, read-only byte buffer that shares this buffer's - * content. - * - *

The content of the new buffer will be that of this buffer. Changes - * to this buffer's content will be visible in the new buffer; the new - * buffer itself, however, will be read-only and will not allow the shared - * content to be modified. The two buffers' position, limit, and mark - * values will be independent. - * - *

The new buffer's capacity, limit, position, and mark values will be - * identical to those of this buffer. - * - *

If this buffer is itself read-only then this method behaves in - * exactly the same way as the {@link #duplicate duplicate} method.

- * - * @return The new, read-only byte buffer - */ - public abstract ByteBuffer asReadOnlyBuffer(); - - - // -- Singleton get/put methods -- - - /* - * Relative get method. Reads the byte at this buffer's - * current position, and then increments the position.

- * - * @return The byte at the buffer's current position - * - * @throws BufferUnderflowException - * If the buffer's current position is not smaller than its limit - */ - public abstract byte get(); - - /* - * Relative put method  (optional operation). - * - *

Writes the given byte into this buffer at the current - * position, and then increments the position.

- * - * @param b - * The byte to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If this buffer's current position is not smaller than its limit - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer put(byte b); - - /* - * Absolute get method. Reads the byte at the given - * index.

- * - * @param index - * The index from which the byte will be read - * - * @return The byte at the given index - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit - */ - public abstract byte get(int index); - - /* - * Absolute put method  (optional operation). - * - *

Writes the given byte into this buffer at the given - * index.

- * - * @param index - * The index at which the byte will be written - * - * @param b - * The byte value to be written - * - * @return This buffer - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer put(int index, byte b); - - - // -- Bulk get operations -- - - /* - * Relative bulk get method. - * - *

This method transfers bytes from this buffer into the given - * destination array. If there are fewer bytes remaining in the - * buffer than are required to satisfy the request, that is, if - * length > remaining(), then no - * bytes are transferred and a {@link BufferUnderflowException} is - * thrown. - * - *

Otherwise, this method copies length bytes from this - * buffer into the given array, starting at the current position of this - * buffer and at the given offset in the array. The position of this - * buffer is then incremented by length. - * - *

In other words, an invocation of this method of the form - * src.get(dst, off, len) has exactly the same effect as - * the loop - * - *

-     *     for (int i = off; i < off + len; i++)
-     *         dst[i] = src.get(); 
- * - * except that it first checks that there are sufficient bytes in - * this buffer and it is potentially much more efficient.

- * - * @param dst - * The array into which bytes are to be written - * - * @param offset - * The offset within the array of the first byte to be - * written; must be non-negative and no larger than - * dst.length - * - * @param length - * The maximum number of bytes to be written to the given - * array; must be non-negative and no larger than - * dst.length - offset - * - * @return This buffer - * - * @throws BufferUnderflowException - * If there are fewer than length bytes - * remaining in this buffer - * - * @throws IndexOutOfBoundsException - * If the preconditions on the offset and length - * parameters do not hold - */ - - public virtual ByteBuffer get(byte[] dst, int offset, int length) - { - checkBounds(offset, length, dst.Length); - if (length > remaining()) - throw new BufferUnderflowException(); - int end = offset + length; - for (int i = offset; i < end; i++) - dst[i] = get(); - return this; - } - - /* - * Relative bulk get method. - * - *

This method transfers bytes from this buffer into the given - * destination array. An invocation of this method of the form - * src.get(a) behaves in exactly the same way as the invocation - * - *

-     *     src.get(a, 0, a.length) 
- * - * @return This buffer - * - * @throws BufferUnderflowException - * If there are fewer than length bytes - * remaining in this buffer - */ - - public ByteBuffer get(byte[] dst) - { - return get(dst, 0, dst.Length); - } - - - // -- Bulk put operations -- - - /* - * Relative bulk put method  (optional operation). - * - *

This method transfers the bytes remaining in the given source - * buffer into this buffer. If there are more bytes remaining in the - * source buffer than in this buffer, that is, if - * src.remaining() > remaining(), - * then no bytes are transferred and a {@link - * BufferOverflowException} is thrown. - * - *

Otherwise, this method copies - * n = src.remaining() bytes from the given - * buffer into this buffer, starting at each buffer's current position. - * The positions of both buffers are then incremented by n. - * - *

In other words, an invocation of this method of the form - * dst.put(src) has exactly the same effect as the loop - * - *

-     *     while (src.hasRemaining())
-     *         dst.put(src.get()); 
- * - * except that it first checks that there is sufficient space in this - * buffer and it is potentially much more efficient.

- * - * @param src - * The source buffer from which bytes are to be read; - * must not be this buffer - * - * @return This buffer - * - * @throws BufferOverflowException - * If there is insufficient space in this buffer - * for the remaining bytes in the source buffer - * - * @throws ArgumentException - * If the source buffer is this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - - public virtual ByteBuffer put(ByteBuffer src) - { - if (src == this) - throw new ArgumentException(); - int n = src.remaining(); - if (n > remaining()) - throw new BufferOverflowException(); - for (int i = 0; i < n; i++) - put(src.get()); - return this; - } - - /* - * Relative bulk put method  (optional operation). - * - *

This method transfers bytes into this buffer from the given - * source array. If there are more bytes to be copied from the array - * than remain in this buffer, that is, if - * length > remaining(), then no - * bytes are transferred and a {@link BufferOverflowException} is - * thrown. - * - *

Otherwise, this method copies length bytes from the - * given array into this buffer, starting at the given offset in the array - * and at the current position of this buffer. The position of this buffer - * is then incremented by length. - * - *

In other words, an invocation of this method of the form - * dst.put(src, off, len) has exactly the same effect as - * the loop - * - *

-     *     for (int i = off; i < off + len; i++)
-     *         dst.put(a[i]); 
- * - * except that it first checks that there is sufficient space in this - * buffer and it is potentially much more efficient.

- * - * @param src - * The array from which bytes are to be read - * - * @param offset - * The offset within the array of the first byte to be read; - * must be non-negative and no larger than array.length - * - * @param length - * The number of bytes to be read from the given array; - * must be non-negative and no larger than - * array.length - offset - * - * @return This buffer - * - * @throws BufferOverflowException - * If there is insufficient space in this buffer - * - * @throws IndexOutOfBoundsException - * If the preconditions on the offset and length - * parameters do not hold - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - - public virtual ByteBuffer put(byte[] src, int offset, int length) - { - checkBounds(offset, length, src.Length); - if (length > remaining()) - throw new BufferOverflowException(); - int end = offset + length; - for (int i = offset; i < end; i++) - put(src[i]); - return this; - } - - /* - * Relative bulk put method  (optional operation). - * - *

This method transfers the entire content of the given source - * byte array into this buffer. An invocation of this method of the - * form dst.put(a) behaves in exactly the same way as the - * invocation - * - *

-     *     dst.put(a, 0, a.length) 
- * - * @return This buffer - * - * @throws BufferOverflowException - * If there is insufficient space in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - - public ByteBuffer put(byte[] src) - { - return put(src, 0, src.Length); - } - - - // -- Other stuff -- - - /* - * Tells whether or not this buffer is backed by an accessible byte - * array. - * - *

If this method returns true then the {@link #array() array} - * and {@link #arrayOffset() arrayOffset} methods may safely be invoked. - *

- * - * @return true if, and only if, this buffer - * is backed by an array and is not read-only - */ - - public bool hasArray() - { - return (hb != null); - } - - /* - * Returns the byte array that backs this - * buffer  (optional operation). - * - *

Modifications to this buffer's content will cause the returned - * array's content to be modified, and vice versa. - * - *

Invoke the {@link #hasArray hasArray} method before invoking this - * method in order to ensure that this buffer has an accessible backing - * array.

- * - * @return The array that backs this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is backed by an array but is read-only - * - * @throws UnsupportedOperationException - * If this buffer is not backed by an accessible array - */ - - public byte[] array() - { - if (hb == null) - throw new NotSupportedException(); - return hb; - } - - /* - * Returns the offset within this buffer's backing array of the first - * element of the buffer  (optional operation). - * - *

If this buffer is backed by an array then buffer position p - * corresponds to array index p + arrayOffset(). - * - *

Invoke the {@link #hasArray hasArray} method before invoking this - * method in order to ensure that this buffer has an accessible backing - * array.

- * - * @return The offset within this buffer's array - * of the first element of the buffer - * - * @throws ReadOnlyBufferException - * If this buffer is backed by an array but is read-only - * - * @throws UnsupportedOperationException - * If this buffer is not backed by an accessible array - */ - - public int arrayOffset() - { - if (hb == null) - throw new NotSupportedException(); - return _offset; - } - - /* - * Compacts this buffer  (optional operation). - * - *

The bytes between the buffer's current position and its limit, - * if any, are copied to the beginning of the buffer. That is, the - * byte at index p = position() is copied - * to index zero, the byte at index p + 1 is copied - * to index one, and so forth until the byte at index - * limit() - 1 is copied to index - * n = limit() - 1 - p. - * The buffer's position is then set to n+1 and its limit is set to - * its capacity. The mark, if defined, is discarded. - * - *

The buffer's position is set to the number of bytes copied, - * rather than to zero, so that an invocation of this method can be - * followed immediately by an invocation of another relative put - * method.

- * - - * - *

Invoke this method after writing data from a buffer in case the - * write was incomplete. The following loop, for example, copies bytes - * from one channel to another via the buffer buf: - * - *

-     * buf.clear();          // Prepare buffer for use
-     * for (;;) {
-     *     if (in.read(buf) < 0 && !buf.hasRemaining())
-     *         break;        // No more bytes to transfer
-     *     buf.flip();
-     *     out.write(buf);
-     *     buf.compact();    // In case of partial write
-     * }
- * - - * - * @return This buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer compact(); - - /* - * Tells whether or not this byte buffer is direct.

- * - * @return true if, and only if, this buffer is direct - */ - public abstract bool isDirect(); - - - /* - * Returns a string summarizing the state of this buffer.

- * - * @return A summary string - */ - - public String toString() - { - var sb = new StringBuilder(); - sb.Append(GetType().Name); - sb.Append("[pos="); - sb.Append(position()); - sb.Append(" lim="); - sb.Append(limit()); - sb.Append(" cap="); - sb.Append(capacity()); - sb.Append("]"); - return sb.ToString(); - } - - - /* - * Returns the current hash code of this buffer. - * - *

The hash code of a byte buffer depends only upon its remaining - * elements; that is, upon the elements from position() up to, and - * including, the element at limit() - 1. - * - *

Because buffer hash codes are content-dependent, it is inadvisable - * to use buffers as keys in hash maps or similar data structures unless it - * is known that their contents will not change.

- * - * @return The current hash code of this buffer - */ - - public int hashCode() - { - int h = 1; - int p = position(); - for (int i = limit() - 1; i >= p; i--) - h = 31*h + get(i); - return h; - } - - /* - * Tells whether or not this buffer is equal to another object. - * - *

Two byte buffers are equal if, and only if, - * - *

    - * - *
  1. They have the same element type,

  2. - * - *
  3. They have the same number of remaining elements, and - *

  4. - * - *
  5. The two sequences of remaining elements, considered - * independently of their starting positions, are pointwise equal. - *

  6. - * - *
- * - *

A byte buffer is not equal to any other type of object.

- * - * @param ob The object to which this buffer is to be compared - * - * @return true if, and only if, this buffer is equal to the - * given object - */ - - public bool equals(object ob) - { - if (!(ob is ByteBuffer)) - return false; - var that = (ByteBuffer) ob; - if (remaining() != that.remaining()) - return false; - int p = position(); - for (int i = limit() - 1, j = that.limit() - 1; i >= p; i--, j--) - { - byte v1 = get(i); - byte v2 = that.get(j); - if (v1 != v2) - { - return false; - } - } - return true; - } - - /* - * Compares this buffer to another. - * - *

Two byte buffers are compared by comparing their sequences of - * remaining elements lexicographically, without regard to the starting - * position of each sequence within its corresponding buffer. - * - *

A byte buffer is not comparable to any other type of object. - * - * @return A negative integer, zero, or a positive integer as this buffer - * is less than, equal to, or greater than the given buffer - */ - - public int compareTo(ByteBuffer that) - { - int n = position() + Math.Min(remaining(), that.remaining()); - for (int i = position(), j = that.position(); i < n; i++, j++) - { - byte v1 = get(i); - byte v2 = that.get(j); - if (v1 == v2) - continue; - if (v1 < v2) - return -1; - return +1; - } - return remaining() - that.remaining(); - } - - - // -- Other char stuff -- - - - // -- Other byte stuff: Access to binary data -- - - - //= (Bits.byteOrder() == ByteOrder.BIG_ENDIAN); - - /* - * Retrieves this buffer's byte order. - * - *

The byte order is used when reading or writing multibyte values, and - * when creating buffers that are views of this byte buffer. The order of - * a newly-created byte buffer is always {@link ByteOrder#BIG_ENDIAN - * BIG_ENDIAN}.

- * - * @return This buffer's byte order - */ - - public ByteOrder order() - { - return bigEndian ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN; - } - - /* - * Modifies this buffer's byte order.

- * - * @param bo - * The new byte order, - * either {@link ByteOrder#BIG_ENDIAN BIG_ENDIAN} - * or {@link ByteOrder#LITTLE_ENDIAN LITTLE_ENDIAN} - * - * @return This buffer - */ - - public ByteBuffer order(ByteOrder bo) - { - bigEndian = (bo == ByteOrder.BIG_ENDIAN); - nativeByteOrder = - (bigEndian == (!BitConverter.IsLittleEndian)); - return this; - } - - // Unchecked accessors, for use by ByteBufferAs-X-Buffer classes - // - internal abstract byte _get(int i); // package-private - internal abstract void _put(int i, byte b); // package-private - - - /* - * Relative get method for reading a char value. - * - *

Reads the next two bytes at this buffer's current position, - * composing them into a char value according to the current byte order, - * and then increments the position by two.

- * - * @return The char value at the buffer's current position - * - * @throws BufferUnderflowException - * If there are fewer than two bytes - * remaining in this buffer - */ - public abstract char getChar(); - - /* - * Relative put method for writing a char - * value  (optional operation). - * - *

Writes two bytes containing the given char value, in the - * current byte order, into this buffer at the current position, and then - * increments the position by two.

- * - * @param value - * The char value to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If there are fewer than two bytes - * remaining in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putChar(char value); - - /* - * Absolute get method for reading a char value. - * - *

Reads two bytes at the given index, composing them into a - * char value according to the current byte order.

- * - * @param index - * The index from which the bytes will be read - * - * @return The char value at the given index - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus one - */ - public abstract char getChar(int index); - - /* - * Absolute put method for writing a char - * value  (optional operation). - * - *

Writes two bytes containing the given char value, in the - * current byte order, into this buffer at the given index.

- * - * @param index - * The index at which the bytes will be written - * - * @param value - * The char value to be written - * - * @return This buffer - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus one - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putChar(int index, char value); - - /* - * Creates a view of this byte buffer as a char buffer. - * - *

The content of the new buffer will start at this buffer's current - * position. Changes to this buffer's content will be visible in the new - * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. - * - *

The new buffer's position will be zero, its capacity and its limit - * will be the number of bytes remaining in this buffer divided by - * two, and its mark will be undefined. The new buffer will be direct - * if, and only if, this buffer is direct, and it will be read-only if, and - * only if, this buffer is read-only.

- * - * @return A new char buffer - */ - public abstract Buffer asCharBuffer(); - - - /* - * Relative get method for reading a short value. - * - *

Reads the next two bytes at this buffer's current position, - * composing them into a short value according to the current byte order, - * and then increments the position by two.

- * - * @return The short value at the buffer's current position - * - * @throws BufferUnderflowException - * If there are fewer than two bytes - * remaining in this buffer - */ - public abstract short getShort(); - - /* - * Relative put method for writing a short - * value  (optional operation). - * - *

Writes two bytes containing the given short value, in the - * current byte order, into this buffer at the current position, and then - * increments the position by two.

- * - * @param value - * The short value to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If there are fewer than two bytes - * remaining in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putShort(short value); - - /* - * Absolute get method for reading a short value. - * - *

Reads two bytes at the given index, composing them into a - * short value according to the current byte order.

- * - * @param index - * The index from which the bytes will be read - * - * @return The short value at the given index - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus one - */ - public abstract short getShort(int index); - - /* - * Absolute put method for writing a short - * value  (optional operation). - * - *

Writes two bytes containing the given short value, in the - * current byte order, into this buffer at the given index.

- * - * @param index - * The index at which the bytes will be written - * - * @param value - * The short value to be written - * - * @return This buffer - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus one - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putShort(int index, short value); - - /* - * Creates a view of this byte buffer as a short buffer. - * - *

The content of the new buffer will start at this buffer's current - * position. Changes to this buffer's content will be visible in the new - * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. - * - *

The new buffer's position will be zero, its capacity and its limit - * will be the number of bytes remaining in this buffer divided by - * two, and its mark will be undefined. The new buffer will be direct - * if, and only if, this buffer is direct, and it will be read-only if, and - * only if, this buffer is read-only.

- * - * @return A new short buffer - */ - public abstract Buffer asShortBuffer(); - - - /* - * Relative get method for reading an int value. - * - *

Reads the next four bytes at this buffer's current position, - * composing them into an int value according to the current byte order, - * and then increments the position by four.

- * - * @return The int value at the buffer's current position - * - * @throws BufferUnderflowException - * If there are fewer than four bytes - * remaining in this buffer - */ - public abstract int getInt(); - - /* - * Relative put method for writing an int - * value  (optional operation). - * - *

Writes four bytes containing the given int value, in the - * current byte order, into this buffer at the current position, and then - * increments the position by four.

- * - * @param value - * The int value to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If there are fewer than four bytes - * remaining in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putInt(int value); - - /* - * Absolute get method for reading an int value. - * - *

Reads four bytes at the given index, composing them into a - * int value according to the current byte order.

- * - * @param index - * The index from which the bytes will be read - * - * @return The int value at the given index - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus three - */ - public abstract int getInt(int index); - - /* - * Absolute put method for writing an int - * value  (optional operation). - * - *

Writes four bytes containing the given int value, in the - * current byte order, into this buffer at the given index.

- * - * @param index - * The index at which the bytes will be written - * - * @param value - * The int value to be written - * - * @return This buffer - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus three - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putInt(int index, int value); - - /* - * Creates a view of this byte buffer as an int buffer. - * - *

The content of the new buffer will start at this buffer's current - * position. Changes to this buffer's content will be visible in the new - * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. - * - *

The new buffer's position will be zero, its capacity and its limit - * will be the number of bytes remaining in this buffer divided by - * four, and its mark will be undefined. The new buffer will be direct - * if, and only if, this buffer is direct, and it will be read-only if, and - * only if, this buffer is read-only.

- * - * @return A new int buffer - */ - public abstract Buffer asIntBuffer(); - - - /* - * Relative get method for reading a long value. - * - *

Reads the next eight bytes at this buffer's current position, - * composing them into a long value according to the current byte order, - * and then increments the position by eight.

- * - * @return The long value at the buffer's current position - * - * @throws BufferUnderflowException - * If there are fewer than eight bytes - * remaining in this buffer - */ - public abstract long getLong(); - - /* - * Relative put method for writing a long - * value  (optional operation). - * - *

Writes eight bytes containing the given long value, in the - * current byte order, into this buffer at the current position, and then - * increments the position by eight.

- * - * @param value - * The long value to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If there are fewer than eight bytes - * remaining in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putLong(long value); - - /* - * Absolute get method for reading a long value. - * - *

Reads eight bytes at the given index, composing them into a - * long value according to the current byte order.

- * - * @param index - * The index from which the bytes will be read - * - * @return The long value at the given index - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus seven - */ - public abstract long getLong(int index); - - /* - * Absolute put method for writing a long - * value  (optional operation). - * - *

Writes eight bytes containing the given long value, in the - * current byte order, into this buffer at the given index.

- * - * @param index - * The index at which the bytes will be written - * - * @param value - * The long value to be written - * - * @return This buffer - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus seven - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putLong(int index, long value); - - /* - * Creates a view of this byte buffer as a long buffer. - * - *

The content of the new buffer will start at this buffer's current - * position. Changes to this buffer's content will be visible in the new - * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. - * - *

The new buffer's position will be zero, its capacity and its limit - * will be the number of bytes remaining in this buffer divided by - * eight, and its mark will be undefined. The new buffer will be direct - * if, and only if, this buffer is direct, and it will be read-only if, and - * only if, this buffer is read-only.

- * - * @return A new long buffer - */ - public abstract Buffer asLongBuffer(); - - - /* - * Relative get method for reading a float value. - * - *

Reads the next four bytes at this buffer's current position, - * composing them into a float value according to the current byte order, - * and then increments the position by four.

- * - * @return The float value at the buffer's current position - * - * @throws BufferUnderflowException - * If there are fewer than four bytes - * remaining in this buffer - */ - public abstract float getFloat(); - - /* - * Relative put method for writing a float - * value  (optional operation). - * - *

Writes four bytes containing the given float value, in the - * current byte order, into this buffer at the current position, and then - * increments the position by four.

- * - * @param value - * The float value to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If there are fewer than four bytes - * remaining in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putFloat(float value); - - /* - * Absolute get method for reading a float value. - * - *

Reads four bytes at the given index, composing them into a - * float value according to the current byte order.

- * - * @param index - * The index from which the bytes will be read - * - * @return The float value at the given index - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus three - */ - public abstract float getFloat(int index); - - /* - * Absolute put method for writing a float - * value  (optional operation). - * - *

Writes four bytes containing the given float value, in the - * current byte order, into this buffer at the given index.

- * - * @param index - * The index at which the bytes will be written - * - * @param value - * The float value to be written - * - * @return This buffer - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus three - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putFloat(int index, float value); - - /* - * Creates a view of this byte buffer as a float buffer. - * - *

The content of the new buffer will start at this buffer's current - * position. Changes to this buffer's content will be visible in the new - * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. - * - *

The new buffer's position will be zero, its capacity and its limit - * will be the number of bytes remaining in this buffer divided by - * four, and its mark will be undefined. The new buffer will be direct - * if, and only if, this buffer is direct, and it will be read-only if, and - * only if, this buffer is read-only.

- * - * @return A new float buffer - */ - public abstract Buffer asFloatBuffer(); - - - /* - * Relative get method for reading a double value. - * - *

Reads the next eight bytes at this buffer's current position, - * composing them into a double value according to the current byte order, - * and then increments the position by eight.

- * - * @return The double value at the buffer's current position - * - * @throws BufferUnderflowException - * If there are fewer than eight bytes - * remaining in this buffer - */ - public abstract double getDouble(); - - /* - * Relative put method for writing a double - * value  (optional operation). - * - *

Writes eight bytes containing the given double value, in the - * current byte order, into this buffer at the current position, and then - * increments the position by eight.

- * - * @param value - * The double value to be written - * - * @return This buffer - * - * @throws BufferOverflowException - * If there are fewer than eight bytes - * remaining in this buffer - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putDouble(double value); - - /* - * Absolute get method for reading a double value. - * - *

Reads eight bytes at the given index, composing them into a - * double value according to the current byte order.

- * - * @param index - * The index from which the bytes will be read - * - * @return The double value at the given index - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus seven - */ - public abstract double getDouble(int index); - - /* - * Absolute put method for writing a double - * value  (optional operation). - * - *

Writes eight bytes containing the given double value, in the - * current byte order, into this buffer at the given index.

- * - * @param index - * The index at which the bytes will be written - * - * @param value - * The double value to be written - * - * @return This buffer - * - * @throws IndexOutOfBoundsException - * If index is negative - * or not smaller than the buffer's limit, - * minus seven - * - * @throws ReadOnlyBufferException - * If this buffer is read-only - */ - public abstract ByteBuffer putDouble(int index, double value); - - /* - * Creates a view of this byte buffer as a double buffer. - * - *

The content of the new buffer will start at this buffer's current - * position. Changes to this buffer's content will be visible in the new - * buffer, and vice versa; the two buffers' position, limit, and mark - * values will be independent. - * - *

The new buffer's position will be zero, its capacity and its limit - * will be the number of bytes remaining in this buffer divided by - * eight, and its mark will be undefined. The new buffer will be direct - * if, and only if, this buffer is direct, and it will be read-only if, and - * only if, this buffer is read-only.

- * - * @return A new double buffer - */ - public abstract Buffer asDoubleBuffer(); - } -#pragma warning restore 1591 -} - -// ReSharper restore InconsistentNaming \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/HeapByteBuffer.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/HeapByteBuffer.cs deleted file mode 100644 index ce2ce1d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/HeapByteBuffer.cs +++ /dev/null @@ -1,380 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -// This class is based on the source code from Sun's Java 1.5.0 API for java.nio.HeapByteBuffer, but -// rewritten for C# and .NET with the purpose to bridge the .NET and Java internals of Robocode. - -using System; - -// ReSharper disable InconsistentNaming - -namespace net.sf.robocode.nio -{ - /// - /// A read/write HeapByteBuffer. - /// - /// - internal class HeapByteBuffer : ByteBuffer - { - internal HeapByteBuffer(int cap, int lim) - : base(-1, 0, lim, cap, new byte[cap], 0) - { - } - - internal HeapByteBuffer(byte[] buf, int off, int len) - : base(-1, off, off + len, buf.Length, buf, 0) - { - } - - protected HeapByteBuffer(byte[] buf, - int mark, int pos, int lim, int cap, - int off) - : base(mark, pos, lim, cap, buf, off) - { - } - - public override ByteBuffer slice() - { - return new HeapByteBuffer(hb, - -1, - 0, - remaining(), - remaining(), - position() + _offset); - } - - public override ByteBuffer duplicate() - { - return new HeapByteBuffer(hb, - markValue(), - position(), - limit(), - capacity(), - _offset); - } - - public override ByteBuffer asReadOnlyBuffer() - { - throw new NotImplementedException(); - } - - - protected int ix(int i) - { - return i + _offset; - } - - public override byte get() - { - return hb[ix(nextGetIndex())]; - } - - public override byte get(int i) - { - return hb[ix(checkIndex(i))]; - } - - public override ByteBuffer get(byte[] dst, int offset, int length) - { - checkBounds(offset, length, dst.Length); - if (length > remaining()) - throw new BufferUnderflowException(); - Array.Copy(hb, ix(position()), dst, offset, length); - position(position() + length); - return this; - } - - public override bool isDirect() - { - return false; - } - - - public override bool isReadOnly() - { - return false; - } - - public override ByteBuffer put(byte x) - { - hb[ix(nextPutIndex())] = x; - return this; - } - - public override ByteBuffer put(int i, byte x) - { - hb[ix(checkIndex(i))] = x; - return this; - } - - public override ByteBuffer put(byte[] src, int offset, int length) - { - checkBounds(offset, length, src.Length); - if (length > remaining()) - throw new BufferOverflowException(); - Array.Copy(src, offset, hb, ix(position()), length); - position(position() + length); - return this; - } - - public override ByteBuffer put(ByteBuffer src) - { - if (src is HeapByteBuffer) - { - if (src == this) - throw new ArgumentException(); - var sb = (HeapByteBuffer) src; - int n = sb.remaining(); - if (n > remaining()) - throw new BufferOverflowException(); - Array.Copy(sb.hb, sb.ix(sb.position()), - hb, ix(position()), n); - sb.position(sb.position() + n); - position(position() + n); - } - else if (src.isDirect()) - { - int n = src.remaining(); - if (n > remaining()) - throw new BufferOverflowException(); - src.get(hb, ix(position()), n); - position(position() + n); - } - else - { - base.put(src); - } - return this; - } - - public override ByteBuffer compact() - { - Array.Copy(hb, ix(position()), hb, ix(0), remaining()); - position(remaining()); - limit(capacity()); - discardMark(); - return this; - } - - - internal override byte _get(int i) - { - return hb[i]; - } - - internal override void _put(int i, byte b) - { - hb[i] = b; - } - - public override char getChar() - { - return BitConverter.ToChar(hb, ix(nextGetIndex(2))); - } - - public override char getChar(int i) - { - return BitConverter.ToChar(hb, ix(checkIndex(i, 2))); - } - - - public override ByteBuffer putChar(char x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(nextPutIndex(2)); - Array.Copy(bytes, 0, hb, index, 2); - return this; - } - - public override ByteBuffer putChar(int i, char x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(checkIndex(i, 2)); - Array.Copy(bytes, 0, hb, index, 2); - return this; - } - - public override Buffer asCharBuffer() - { - throw new NotImplementedException(); - } - - public override short getShort() - { - return BitConverter.ToInt16(hb, ix(nextGetIndex(2))); - } - - public override short getShort(int i) - { - return BitConverter.ToInt16(hb, ix(checkIndex(i, 2))); - } - - - public override ByteBuffer putShort(short x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(nextPutIndex(2)); - Array.Copy(bytes, 0, hb, index, 2); - return this; - } - - public override ByteBuffer putShort(int i, short x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(checkIndex(i, 2)); - Array.Copy(bytes, 0, hb, index, 2); - return this; - } - - public override Buffer asShortBuffer() - { - throw new NotImplementedException(); - } - - public override int getInt() - { - return BitConverter.ToInt32(hb, ix(nextGetIndex(4))); - } - - public override int getInt(int i) - { - return BitConverter.ToInt32(hb, ix(checkIndex(i, 4))); - } - - - public override ByteBuffer putInt(int x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(nextPutIndex(4)); - Array.Copy(bytes, 0, hb, index, 4); - return this; - } - - public override ByteBuffer putInt(int i, int x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(checkIndex(i, 4)); - Array.Copy(bytes, 0, hb, index, 4); - return this; - } - - public override Buffer asIntBuffer() - { - throw new NotImplementedException(); - } - - - // long - - - public override long getLong() - { - return BitConverter.ToInt64(hb, ix(nextGetIndex(8))); - } - - public override long getLong(int i) - { - return BitConverter.ToInt64(hb, ix(checkIndex(i, 8))); - } - - - public override ByteBuffer putLong(long x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(nextPutIndex(8)); - Array.Copy(bytes, 0, hb, index, 8); - return this; - } - - public override ByteBuffer putLong(int i, long x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(checkIndex(i, 8)); - Array.Copy(bytes, 0, hb, index, 8); - return this; - } - - public override Buffer asLongBuffer() - { - throw new NotImplementedException(); - } - - - // float - - - public override float getFloat() - { - return BitConverter.ToSingle(hb, ix(nextGetIndex(4))); - } - - public override float getFloat(int i) - { - return BitConverter.ToSingle(hb, ix(checkIndex(i, 4))); - } - - - public override ByteBuffer putFloat(float x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(nextPutIndex(4)); - Array.Copy(bytes, 0, hb, index, 4); - return this; - } - - public override ByteBuffer putFloat(int i, float x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(checkIndex(i, 4)); - Array.Copy(bytes, 0, hb, index, 4); - return this; - } - - public override Buffer asFloatBuffer() - { - throw new NotImplementedException(); - } - - - // double - - - public override double getDouble() - { - return BitConverter.ToDouble(hb, ix(nextGetIndex(8))); - } - - public override double getDouble(int i) - { - return BitConverter.ToDouble(hb, ix(checkIndex(i, 8))); - } - - - public override ByteBuffer putDouble(double x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(nextPutIndex(8)); - Array.Copy(bytes, 0, hb, index, 8); - return this; - } - - public override ByteBuffer putDouble(int i, double x) - { - byte[] bytes = BitConverter.GetBytes(x); - int index = ix(checkIndex(i, 8)); - Array.Copy(bytes, 0, hb, index, 8); - return this; - } - - public override Buffer asDoubleBuffer() - { - throw new NotImplementedException(); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/InvalidMarkException.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/InvalidMarkException.cs deleted file mode 100644 index 080851e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/nio/InvalidMarkException.cs +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Runtime.Serialization; - -namespace net.sf.robocode.nio -{ -#pragma warning disable 1591 - - /// - [Serializable] - public class InvalidMarkException : Exception - { - public InvalidMarkException() - { - } - - public InvalidMarkException(string message) - : base(message) - { - } - - public InvalidMarkException(string message, Exception inner) - : base(message, inner) - { - } - - protected InvalidMarkException(SerializationInfo info, - StreamingContext context) - : base(info, context) - { - } - } - - /// - [Serializable] - public class BufferUnderflowException : Exception - { - public BufferUnderflowException() - { - } - - public BufferUnderflowException(string message) - : base(message) - { - } - - public BufferUnderflowException(string message, Exception inner) - : base(message, inner) - { - } - - protected BufferUnderflowException(SerializationInfo info, - StreamingContext context) - : base(info, context) - { - } - } - - /// - [Serializable] - public class BufferOverflowException : Exception - { - public BufferOverflowException() - { - } - - public BufferOverflowException(string message) - : base(message) - { - } - - public BufferOverflowException(string message, Exception inner) - : base(message, inner) - { - } - - protected BufferOverflowException(SerializationInfo info, - StreamingContext context) - : base(info, context) - { - } - } - - /// - [Serializable] - public class ReadOnlyBufferException : Exception - { - public ReadOnlyBufferException() - { - } - - public ReadOnlyBufferException(string message) - : base(message) - { - } - - public ReadOnlyBufferException(string message, Exception inner) - : base(message, inner) - { - } - - protected ReadOnlyBufferException(SerializationInfo info, - StreamingContext context) - : base(info, context) - { - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/peer/IRobotStaticsN.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/peer/IRobotStaticsN.cs deleted file mode 100644 index b84b044..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/peer/IRobotStaticsN.cs +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace net.sf.robocode.peer -{ -#pragma warning disable 1591 - - /// - public interface IRobotStaticsN - { - bool IsInteractiveRobot(); - - bool IsPaintRobot(); - - bool IsAdvancedRobot(); - - bool IsTeamRobot(); - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/HiddenAccessN.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/HiddenAccessN.cs deleted file mode 100644 index 9dd414e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/HiddenAccessN.cs +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Security.Permissions; -using net.sf.robocode.io; -using net.sf.robocode.peer; -using Robocode; -using Robocode.RobotInterfaces; - -namespace net.sf.robocode.security -{ -#pragma warning disable 1591 - /// - [RobocodeInternalPermission(SecurityAction.LinkDemand)] - public class HiddenAccessN - { - private static IHiddenEventHelper eventHelper; - private static IHiddenBulletHelper bulletHelper; - private static IHiddenStatusHelper statusHelper; - private static IHiddenRulesHelper rulesHelper; - private static bool initialized; - public static IHiddenRandomHelper randomHelper; - - public static void init() - { - if (initialized) - { - return; - } - MethodInfo method; - - try - { - method = typeof (Event).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic); - eventHelper = (IHiddenEventHelper) method.Invoke(null, null); - - method = typeof (Bullet).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic); - bulletHelper = (IHiddenBulletHelper) method.Invoke(null, null); - - method = typeof (RobotStatus).GetMethod("createHiddenSerializer", - BindingFlags.Static | BindingFlags.NonPublic); - statusHelper = (IHiddenStatusHelper) method.Invoke(null, null); - - method = typeof (BattleRules).GetMethod("createHiddenHelper", - BindingFlags.Static | BindingFlags.NonPublic); - rulesHelper = (IHiddenRulesHelper) method.Invoke(null, null); - - initialized = true; - } - catch (Exception e) - { - LoggerN.logError(e); - Environment.Exit(-1); - } - } - - public static bool IsCriticalEvent(Event e) - { - return eventHelper.IsCriticalEvent(e); - } - - public static void SetEventTime(Event e, long newTime) - { - eventHelper.SetTime(e, newTime); - } - - public static void SetEventPriority(Event e, int newPriority) - { - eventHelper.SetPriority(e, newPriority); - } - - public static void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - eventHelper.Dispatch(evnt, robot, statics, graphics); - } - - public static void SetDefaultPriority(Event e) - { - eventHelper.SetDefaultPriority(e); - } - - public static byte GetSerializationType(Event e) - { - return eventHelper.GetSerializationType(e); - } - - // Needed for .NET version - public static void UpdateBullets(Event e, Dictionary bullets) - { - eventHelper.UpdateBullets(e, bullets); - } - - public static void Update(Bullet bullet, double x, double y, string victimName, bool isActive) - { - bulletHelper.update(bullet, x, y, victimName, isActive); - } - - public static RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading, - double radarHeading, double velocity, double bodyTurnRemaining, - double radarTurnRemaining, double gunTurnRemaining, - double distanceRemaining, double gunHeat, int others, int numSentries, - int roundNum, int numRounds, long time) - { - return statusHelper.createStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, - bodyTurnRemaining, radarTurnRemaining, gunTurnRemaining, distanceRemaining, - gunHeat, others, numSentries, roundNum, numRounds, time); - } - - public static BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime, - bool hideEnemyNames, int borderSentryRobotAttackRange) - { - return rulesHelper.createRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, borderSentryRobotAttackRange); - } - - public static string GetRobotName() - { - string name = (string)AppDomain.CurrentDomain.GetData("robotName"); - return name ?? ""; - } - } -#pragma warning restore 1591 -} - -//happy diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenBulletHelper.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenBulletHelper.cs deleted file mode 100644 index d1eb3cf..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenBulletHelper.cs +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace net.sf.robocode.security -{ -#pragma warning disable 1591 - /// - public interface IHiddenBulletHelper - { - void update(Bullet bullet, double x, double y, string victimName, bool isActive); - } -} - -//happy \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenEventHelper.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenEventHelper.cs deleted file mode 100644 index b485e5b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenEventHelper.cs +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Collections.Generic; -using net.sf.robocode.peer; -using Robocode; -using Robocode.RobotInterfaces; - -namespace net.sf.robocode.security -{ -#pragma warning disable 1591 - /// - public interface IHiddenEventHelper - { - void SetDefaultPriority(Event evnt); - void SetPriority(Event evnt, int newPriority); - void SetTime(Event evnt, long newTime); - bool IsCriticalEvent(Event evnt); - void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics); - byte GetSerializationType(Event evnt); - void UpdateBullets(Event evnt, Dictionary bullets); // Needed for .NET version - } -} - -//happy diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenRandomHelper.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenRandomHelper.cs deleted file mode 100644 index 27e8963..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenRandomHelper.cs +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; - -namespace net.sf.robocode.security -{ -#pragma warning disable 1591 - /// - public interface IHiddenRandomHelper - { - Random GetRandom(); - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenRulesHelper.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenRulesHelper.cs deleted file mode 100644 index 447d1db..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenRulesHelper.cs +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace net.sf.robocode.security -{ -#pragma warning disable 1591 - /// - public interface IHiddenRulesHelper - { - BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime, - bool hideEnemyNames, int borderSentryRobotAttackRange); - } -} - -//happy \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenStatusHelper.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenStatusHelper.cs deleted file mode 100644 index db401f3..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/IHiddenStatusHelper.cs +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace net.sf.robocode.security -{ -#pragma warning disable 1591 - /// - public interface IHiddenStatusHelper - { - RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading, - double radarHeading, - double velocity, double bodyTurnRemaining, double radarTurnRemaining, - double gunTurnRemaining, - double distanceRemaining, double gunHeat, int others, int numSentries, - int roundNum, int numRounds, long time); - } -} - -//happy \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/RobocodeInternalPermission.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/RobocodeInternalPermission.cs deleted file mode 100644 index 94a8e50..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/security/RobocodeInternalPermission.cs +++ /dev/null @@ -1,151 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Security; -using System.Security.Permissions; -using System.Text; - -namespace net.sf.robocode.security -{ -#pragma warning disable 1591 - /// - [Serializable] - public sealed class RobocodeInternalPermission : CodeAccessPermission, IUnrestrictedPermission - { - private bool unrestricted; - - public RobocodeInternalPermission(PermissionState state) - { - unrestricted = state == PermissionState.Unrestricted; - } - - #region IUnrestrictedPermission Members - - public bool IsUnrestricted() - { - return unrestricted; - } - - #endregion - - public override IPermission Copy() - { - //Create a new instance of RobocodeInternalPermission with the current - //value of unrestricted. - var copy = new RobocodeInternalPermission(PermissionState.None); - - copy.unrestricted = IsUnrestricted(); - //Return the copy. - return copy; - } - - public override IPermission Intersect(IPermission target) - { - //If nothing was passed, return null. - if (null == target) - { - return null; - } - try - { - //Create a new instance of RobocodeInternalPermission from the passed object. - var PassedPermission = (RobocodeInternalPermission) target; - - //If one class has an unrestricted value of false, then the - //intersection will have an unrestricted value of false. - //Return the passed class with the unrestricted value of false. - if (!PassedPermission.unrestricted) - { - return target; - } - //Return a copy of the current class if the passed one has - //an unrestricted value of true. - return Copy(); - } - //Catch an InvalidCastException. - //Throw ArgumentException to notify the user. - catch (InvalidCastException) - { - throw new ArgumentException("Argument_WrongType", GetType().FullName); - } - } - - public override bool IsSubsetOf(IPermission target) - { - //If nothing was passed and unrestricted is false, - //then return true. - if (null == target) - { - return !unrestricted; - } - try - { - //Create a new instance of RobocodeInternalPermission from the passed object. - var passedpermission = (RobocodeInternalPermission) target; - - //If unrestricted has the same value in both objects, then - //one is the subset of the other. - return unrestricted == passedpermission.unrestricted; - } - //Catch an InvalidCastException. - //Throw ArgumentException to notify the user. - catch (InvalidCastException) - { - throw new ArgumentException("Argument_WrongType", GetType().FullName); - } - } - - public override void FromXml(SecurityElement PassedElement) - { - //Get the unrestricted value from the XML and initialize - //the current instance of unrestricted to that value. - string element = PassedElement.Attribute("Unrestricted"); - - if (null != element) - { - unrestricted = Convert.ToBoolean(element); - } - } - - public override SecurityElement ToXml() - { - //Encode the current permission to XML using the - //SecurityElement class. - var element = new SecurityElement("IPermission"); - Type type = GetType(); - var AssemblyName = new StringBuilder(type.Assembly.ToString()); - AssemblyName.Replace('\"', '\''); - element.AddAttribute("class", type.FullName + ", " + AssemblyName); - element.AddAttribute("version", "1"); - element.AddAttribute("Unrestricted", unrestricted.ToString()); - return element; - } - } - - - /// - [AttributeUsageAttribute(AttributeTargets.All, AllowMultiple = true)] - public class RobocodeInternalPermissionAttribute : CodeAccessSecurityAttribute - { - public RobocodeInternalPermissionAttribute(SecurityAction action) - : base(action) - { - Unrestricted = false; - } - - public override IPermission CreatePermission() - { - return Unrestricted - ? new RobocodeInternalPermission(PermissionState.Unrestricted) - : new RobocodeInternalPermission(PermissionState.None); - } - } -#pragma warning restore 1591 -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/serialization/ISerializableHelperN.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/serialization/ISerializableHelperN.cs deleted file mode 100644 index 139d0e9..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/serialization/ISerializableHelperN.cs +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using net.sf.robocode.nio; - -namespace net.sf.robocode.serialization -{ -#pragma warning disable 1591 - /// - public interface ISerializableHelperN - { - int sizeOf(RbSerializerN serializer, object obj); - void serialize(RbSerializerN serializer, ByteBuffer buffer, object obj); - object deserialize(RbSerializerN serializer, ByteBuffer buffer); - } -} - -//happy \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/serialization/RbSerializerN.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/serialization/RbSerializerN.cs deleted file mode 100644 index 28226d1..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/net/sf/robocode/serialization/RbSerializerN.cs +++ /dev/null @@ -1,524 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using System.Security.Permissions; -using System.Text; -using net.sf.robocode.io; -using net.sf.robocode.nio; -using net.sf.robocode.security; -using Robocode; - -namespace net.sf.robocode.serialization -{ -#pragma warning disable 1591 - /// - [RobocodeInternalPermission(SecurityAction.LinkDemand)] - public sealed class RbSerializerN - { - private const int byteOrder = -1059135839; //0xC0DEDEA1 - public static readonly int SIZEOF_TYPEINFO = 1; - public static readonly int SIZEOF_BYTE = 1; - public static readonly int SIZEOF_BOOL = 1; - public static readonly int SIZEOF_CHAR = 2; - public static readonly int SIZEOF_INT = 4; - public static readonly int SIZEOF_LONG = 8; - public static readonly int SIZEOF_DOUBLE = 8; - - public static readonly byte TERMINATOR_TYPE = 0xff; - public static readonly byte ExecCommands_TYPE = 1; - public static readonly byte BulletCommand_TYPE = 2; - public static readonly byte TeamMessage_TYPE = 3; - public static readonly byte DebugProperty_TYPE = 4; - public static readonly byte ExecResults_TYPE = 5; - public static readonly byte RobotStatus_TYPE = 6; - public static readonly byte BulletStatus_TYPE = 7; - public static readonly byte BattleResults_TYPE = 8; - public static readonly byte Bullet_TYPE = 9; - public static readonly byte RobotStatics_TYPE = 10; - - public static readonly byte BattleEndedEvent_TYPE = 32; - public static readonly byte BulletHitBulletEvent_TYPE = 33; - public static readonly byte BulletHitEvent_TYPE = 34; - public static readonly byte BulletMissedEvent_TYPE = 35; - public static readonly byte DeathEvent_TYPE = 36; - public static readonly byte WinEvent_TYPE = 37; - public static readonly byte HitWallEvent_TYPE = 38; - public static readonly byte RobotDeathEvent_TYPE = 39; - public static readonly byte SkippedTurnEvent_TYPE = 40; - public static readonly byte ScannedRobotEvent_TYPE = 41; - public static readonly byte HitByBulletEvent_TYPE = 42; - public static readonly byte HitRobotEvent_TYPE = 43; - public static readonly byte KeyPressedEvent_TYPE = 44; - public static readonly byte KeyReleasedEvent_TYPE = 45; - public static readonly byte KeyTypedEvent_TYPE = 46; - public static readonly byte MouseClickedEvent_TYPE = 47; - public static readonly byte MouseDraggedEvent_TYPE = 48; - public static readonly byte MouseEnteredEvent_TYPE = 49; - public static readonly byte MouseExitedEvent_TYPE = 50; - public static readonly byte MouseMovedEvent_TYPE = 51; - public static readonly byte MousePressedEvent_TYPE = 52; - public static readonly byte MouseReleasedEvent_TYPE = 53; - public static readonly byte MouseWheelMovedEvent_TYPE = 54; - public static readonly byte RoundEndedEvent_TYPE = 55; - - private static readonly ISerializableHelperN[] typeToHelper = new ISerializableHelperN[256]; - private static readonly Dictionary classToType = new Dictionary(); - private static readonly Encoding charset; - - private static int currentVersion; - - static RbSerializerN() - { - charset = Encoding.UTF8; // we will use it as UCS-2 - register(null, TERMINATOR_TYPE); // reserved for end of (list) element - } - - public static void Init(int version) - { - if (currentVersion == 0) - { - currentVersion = version; - } - } - - public ByteBuffer serialize(byte type, object obj) - { - int length = sizeOf(type, obj); - - // header - ByteBuffer buffer = ByteBuffer.allocate(SIZEOF_INT + SIZEOF_INT + SIZEOF_INT + length); - - buffer.putInt(byteOrder); - buffer.putInt(currentVersion); - buffer.putInt(length); - - // body - serialize(buffer, type, obj); - if (buffer.remaining() != 0) - { - throw new IOException("Serialization failed: bad size"); - } - return buffer; - } - - public ByteBuffer serializeToBuffer(ByteBuffer buffer, byte type, object obj) - { - int length = sizeOf(type, obj); - buffer.limit(SIZEOF_INT + SIZEOF_INT + SIZEOF_INT + length); - - buffer.putInt(byteOrder); - buffer.putInt(currentVersion); - buffer.putInt(length); - - // body - serialize(buffer, type, obj); - if (buffer.remaining() != 0) - { - throw new IOException("Serialization failed: bad size"); - } - return buffer; - } - - public Object deserialize(ByteBuffer buffer) - { - int bo = buffer.getInt(); - - if (bo != byteOrder) - { - throw new IOException("Different byte order is not supported"); - } - - int version = buffer.getInt(); - - if (version != currentVersion) - { - throw new IOException("Version of data is not supported. We support only strong match"); - } - int length = buffer.getInt(); - - if (length != buffer.remaining()) - { - throw new IOException("Wrong buffer size, " + length + "expected but got " + buffer.remaining()); - } - - // body - Object res = deserializeAny(buffer); - - if (buffer.remaining() != 0) - { - throw new IOException("Serialization failed"); - } - return res; - } - - public void serialize(ByteBuffer buffer, byte type, object obj) - { - ISerializableHelperN helper = getHelper(type); - - // FOR-DEBUG int expect = sizeOf(type, object) + buffer.position(); - - if (obj != null) - { - buffer.put(type); - helper.serialize(this, buffer, obj); - } - else - { - buffer.put(TERMINATOR_TYPE); - } - // FOR-DEBUG if (expect != buffer.position()) { - // FOR-DEBUG throw new Exception("Bad size"); - // FOR-DEBUG } - } - - public void serialize(ByteBuffer buffer, string data) - { - if (data == null) - { - buffer.putInt(-1); - } - else - { - int bytes = charset.GetBytes(data, 0, data.Length, buffer.array(), buffer.position() + 4); - buffer.putInt(bytes); - buffer.position(buffer.position() + bytes); - } - } - - public void serialize(ByteBuffer buffer, byte[] data) - { - if (data == null) - { - buffer.putInt(-1); - } - else - { - buffer.putInt(data.Length); - buffer.put(data); - } - } - - public void serialize(ByteBuffer buffer, int[] data) - { - if (data == null) - { - buffer.putInt(-1); - } - else - { - buffer.putInt(data.Length); - foreach (int aData in data) - { - buffer.putInt(aData); - } - } - } - - public void serialize(ByteBuffer buffer, char[] data) - { - if (data == null) - { - buffer.putInt(-1); - } - else - { - buffer.putInt(data.Length); - foreach (char aData in data) - { - buffer.putChar(aData); - } - } - } - - public void serialize(ByteBuffer buffer, double[] data) - { - if (data == null) - { - buffer.putInt(-1); - } - else - { - buffer.putInt(data.Length); - foreach (double aData in data) - { - buffer.putDouble(aData); - } - } - } - - public void serialize(ByteBuffer buffer, float[] data) - { - if (data == null) - { - buffer.putInt(-1); - } - else - { - buffer.putInt(data.Length); - foreach (float aData in data) - { - buffer.putFloat(aData); - } - } - } - - public void serialize(ByteBuffer buffer, bool value) - { - buffer.put((byte) (value ? 1 : 0)); - } - - public void serialize(ByteBuffer buffer, double value) - { - buffer.putDouble(value); - } - - public void serialize(ByteBuffer buffer, char value) - { - buffer.putChar(value); - } - - public void serialize(ByteBuffer buffer, long value) - { - buffer.putLong(value); - } - - public void serialize(ByteBuffer buffer, int value) - { - buffer.putInt(value); - } - - public void serialize(ByteBuffer buffer, Event evnt) - { - byte type = HiddenAccessN.GetSerializationType(evnt); - - serialize(buffer, type, evnt); - } - - public Object deserializeAny(ByteBuffer buffer) - { - byte type = buffer.get(); - - if (type == TERMINATOR_TYPE) - { - return null; - } - return getHelper(type).deserialize(this, buffer); - } - - public string deserializeString(ByteBuffer buffer) - { - int bytes = buffer.getInt(); - - if (bytes == -1) - { - return null; - } - ByteBuffer slice = buffer.slice(); - - slice.limit(bytes); - string res; - - try - { - byte[] array = buffer.array(); - char[] chars = charset.GetChars(array, buffer.position(), bytes); - res = new string(chars); - } - catch (Exception e) - { - throw new Exception("Bad character", e); - } - buffer.position(buffer.position() + bytes); - return res; - } - - public byte[] deserializeBytes(ByteBuffer buffer) - { - int len = buffer.getInt(); - - if (len == -1) - { - return null; - } - var res = new byte[len]; - - buffer.get(res); - return res; - } - - public int[] deserializeints(ByteBuffer buffer) - { - int len = buffer.getInt(); - - if (len == -1) - { - return null; - } - var res = new int[len]; - - for (int i = 0; i < len; i++) - { - res[i] = buffer.getInt(); - } - return res; - } - - public float[] deserializeFloats(ByteBuffer buffer) - { - int len = buffer.getInt(); - - if (len == -1) - { - return null; - } - var res = new float[len]; - - for (int i = 0; i < len; i++) - { - res[i] = buffer.getFloat(); - } - return res; - } - - public char[] deserializeChars(ByteBuffer buffer) - { - int len = buffer.getInt(); - - if (len == -1) - { - return null; - } - var res = new char[len]; - - for (int i = 0; i < len; i++) - { - res[i] = buffer.getChar(); - } - return res; - } - - public double[] deserializeDoubles(ByteBuffer buffer) - { - int len = buffer.getInt(); - - if (len == -1) - { - return null; - } - var res = new double[len]; - - for (int i = 0; i < len; i++) - { - res[i] = buffer.getDouble(); - } - return res; - } - - public bool deserializeBoolean(ByteBuffer buffer) - { - return buffer.get() != 0; - } - - public char deserializeChar(ByteBuffer buffer) - { - return buffer.getChar(); - } - - public int deserializeInt(ByteBuffer buffer) - { - return buffer.getInt(); - } - - public long deserializeLong(ByteBuffer buffer) - { - return buffer.getLong(); - } - - public float deserializeFloat(ByteBuffer buffer) - { - return buffer.getFloat(); - } - - public double deserializeDouble(ByteBuffer buffer) - { - return buffer.getDouble(); - } - - public int sizeOf(string data) - { - return (data == null) ? SIZEOF_INT : SIZEOF_INT + charset.GetByteCount(data); - } - - public int sizeOf(byte[] data) - { - return (data == null) ? SIZEOF_INT : SIZEOF_INT + data.Length; - } - - public int sizeOf(byte type, object obj) - { - return getHelper(type).sizeOf(this, obj); - } - - public int sizeOf(Event evnt) - { - return sizeOf(HiddenAccessN.GetSerializationType(evnt), evnt); - } - - private static ISerializableHelperN getHelper(byte type) - { - ISerializableHelperN helper = typeToHelper[type]; - - if (helper == null) - { - throw new Exception("Unknownd or unsupported data type"); - } - return helper; - } - - public static void register(Type realClass, byte type) - { - try - { - if (realClass != null) - { - MethodInfo method = realClass.GetMethod("createHiddenSerializer", - BindingFlags.NonPublic | BindingFlags.Static); - var helper = (ISerializableHelperN) method.Invoke(null, null); - - typeToHelper[type] = helper; - classToType.Add(realClass, type); - } - } - catch (Exception e) - { - LoggerN.logError(e); - } - } - - public static ByteBuffer serializeToBuffer(Object src) - { - var rbs = new RbSerializerN(); - Byte type = classToType[src.GetType()]; - - return rbs.serialize(type, src); - } - - public static T deserializeFromBuffer(ByteBuffer buffer) - { - var rbs = new RbSerializerN(); - Object res = rbs.deserialize(buffer); - - return (T) res; - } - } -} - -//happy diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode.dotnet.api.csproj b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode.dotnet.api.csproj deleted file mode 100644 index c23f971..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode.dotnet.api.csproj +++ /dev/null @@ -1,164 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {7E0900D3-6E8F-48EB-86DB-AA767AA90B84} - Library - Properties - robocode - robocode - v3.5 - 512 - true - ..\..\tools\keys\robocode.snk - - - 3.5 - - - - true - full - false - ..\target\ - ..\target\obj\ - DEBUG;TRACE - prompt - 4 - ..\target\robocode.xml - - - pdbonly - true - ..\target\ - ..\target\obj\ - TRACE - prompt - 4 - - - - - - - - - - - - - - AssemblyInfo.cs - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - Code - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - copy "$(TargetPath)" "$(SolutionDir)\robocode.dotnet.host\target" - if not exist $(OutDir)\build-sources\generated-sources\META-INF mkdir $(OutDir)\build-sources\generated-sources\META-INF\ -echo [assembly: System.Reflection.AssemblyVersion("1.9.2.4")] > $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/AdvancedRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/AdvancedRobot.cs deleted file mode 100644 index b92ce97..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/AdvancedRobot.cs +++ /dev/null @@ -1,2226 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using System.IO; -using Robocode.RobotInterfaces; -using Robocode.RobotInterfaces.Peer; -using Robocode.Util; - -namespace Robocode -{ - /// - /// A more advanced type of robot than Robot that allows non-blocking calls, - /// custom events, and writes to the filesystem. - ///

- /// If you have not already, you should create a first. - ///
- ///
- /// Building your first robot - /// - /// - /// - /// - /// - /// - /// - ///

- public abstract class AdvancedRobot : Robot, IAdvancedRobot, IAdvancedEvents - { - /// - /// Returns the distance remaining in the robot's current move measured in - /// pixels. - ///

- /// This call returns both positive and negative values. Positive values - /// means that the robot is currently moving forwards. Negative values means - /// that the robot is currently moving backwards. If the returned value is 0, - /// the robot currently stands still. - /// - /// - /// - /// - /// - /// - ///

- public double DistanceRemaining - { - get - { - if (peer != null) - { - return peer.GetDistanceRemaining(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the angle remaining in the robots's turn, in degrees. - ///

- /// This call returns both positive and negative values. - /// Positive values means that the robot is currently turning to the right. - /// Negative values means that the robot is currently turning to the left. - /// If the returned value is 0, the robot is currently not turning. - /// - /// - /// - /// - /// - /// - ///

- public double TurnRemaining - { - get - { - if (peer != null) - { - return Utils.ToDegrees(peer.GetBodyTurnRemaining()); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the angle remaining in the gun's turn, in degrees. - ///

- /// This call returns both positive and negative values. - /// Positive values means that the gun is currently turning to the right. - /// Negative values means that the gun is currently turning to the left. - /// If the returned value is 0, the gun is currently not turning. - /// - /// - /// - /// - /// - /// - ///

- public double GunTurnRemaining - { - get - { - if (peer != null) - { - return Utils.ToDegrees(peer.GetGunTurnRemaining()); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the angle remaining in the radar's turn, in degrees. - ///

- /// This call returns both positive and negative values. - /// Positive values means that the radar is currently turning to the right. - /// Negative values means that the radar is currently turning to the left. - /// If the returned value is 0, the radar is currently not turning. - /// - /// - /// - /// - /// - /// - ///

- public double RadarTurnRemaining - { - get - { - if (peer != null) - { - return Utils.ToDegrees(peer.GetRadarTurnRemaining()); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Sets the robot to move ahead (forward) by distance measured in - /// pixels when the next execution takes place. - ///

- /// This call returns immediately, and will not execute until you - /// call or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where positive values means that the robot is set to move ahead, and negative - /// values means that the robot is set to move back. If 0 is given as input, the - /// robot will stop its movement, but will have to decelerate till it stands still, - /// and will thus not be able to stop its movement immediately, but eventually. - ///

- /// - /// The distance to move measured in pixels. - /// If distance > 0 the robot is set to move ahead. - /// If distance < 0 the robot is set to move back. - /// If distance = 0 the robot is set to stop its movement. - /// - /// - /// - /// // Set the robot to move 50 pixels ahead - /// SetAhead(50); - /// - /// // Set the robot to move 100 pixels back - /// // (overrides the previous order) - /// SetAhead(-100); - /// - /// ... - /// // Executes the last SetAhead() - /// Execute(); - /// - /// - /// - /// - /// - public void SetAhead(double distance) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetMove(distance); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot to move back by distance measured in pixels when the next - /// execution takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, where - /// positive values means that the robot is set to move back, and negative - /// values means that the robot is set to move ahead. If 0 is given as input, - /// the robot will stop its movement, but will have to decelerate - /// till it stands still, and will thus not be able to stop its movement - /// immediately, but eventually. - ///

- /// - /// - /// // Set the robot to move 50 pixels back - /// SetBack(50); - /// - /// // Set the robot to move 100 pixels ahead - /// // (overrides the previous order) - /// SetBack(-100); - /// - /// ... - /// // Executes the last SetBack() - /// Execute(); - /// - /// - /// - /// - /// - ///

- /// - /// The distance to move measured in pixels. - /// If distance > 0 the robot is set to move back. - /// If distance < 0 the robot is set to move ahead. - /// If distance = 0 the robot is set to stop its movement. - /// - public void SetBack(double distance) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetMove(-distance); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot's body to turn left by degrees when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's body is set to turn right - /// instead of left. - ///

- /// - /// - /// // Set the robot to turn 180 degrees to the left - /// SetTurnLeft(180); - /// - /// // Set the robot to turn 90 degrees to the right instead of left - /// // (overrides the previous order) - /// SetTurnLeft(-90); - /// - /// ... - /// // Executes the last SetTurnLeft() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's body to the left. - /// If degrees > 0 the robot is set to turn left. - /// If degrees < 0 the robot is set to turn right. - /// If degrees = 0 the robot is set to stop turning. - /// - public void SetTurnLeft(double degrees) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnBody(-Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot's body to turn right by degrees when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's body is set to turn left - /// instead of right. - ///

- /// - /// - /// // Set the robot to turn 180 degrees to the right - /// SetTurnRight(180); - /// - /// // Set the robot to turn 90 degrees to the left instead of right - /// // (overrides the previous order) - /// SetTurnRight(-90); - /// - /// ... - /// // Executes the last SetTurnRight() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's body to the right. - /// If degrees > 0 the robot is set to turn right. - /// If degrees < 0 the robot is set to turn left. - /// If degrees = 0 the robot is set to stop turning. - /// - public void SetTurnRight(double degrees) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnBody(Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the gun to Fire a bullet when the next execution takes place. - /// The bullet will travel in the direction the gun is pointing. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// The specified bullet power is an amount of energy that will be taken from - /// the robot's energy. Hence, the more power you want to spend on the - /// bullet, the more energy is taken from your robot. - ///

- /// The bullet will do (4 * power) damage if it hits another robot. If power - /// is greater than 1, it will do an additional 2 * (power - 1) damage. - /// You will get (3 * power) back if you hit the other robot. You can call - /// Rules.GetBulletDamage(double)} for getting the damage that a - /// bullet with a specific bullet power will do. - ///

- /// The specified bullet power should be between - /// and . - ///

- /// Note that the gun cannot Fire if the gun is overheated, meaning that - /// returns a value > 0. - ///

- /// An event is generated when the bullet hits a robot, wall, or another - /// bullet. - ///

- /// - /// - /// // Fire a bullet with maximum power if the gun is ready - /// if (GunGeat == 0) - /// { - /// SetFire(Rules.MAX_BULLET_POWER); - /// } - /// ... - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of energy given to the bullet, and subtracted from the robot's energy. - /// - public void SetFire(double power) - { - if (peer != null) - { - peer.SetFire(power); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the gun to Fire a bullet when the next execution takes place. - /// The bullet will travel in the direction the gun is pointing. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// The specified bullet power is an amount of energy that will be taken from - /// the robot's energy. Hence, the more power you want to spend on the - /// bullet, the more energy is taken from your robot. - ///

- /// The bullet will do (4 * power) damage if it hits another robot. If power - /// is greater than 1, it will do an additional 2 * (power - 1) damage. - /// You will get (3 * power) back if you hit the other robot. You can call - /// for getting the damage that a - /// bullet with a specific bullet power will do. - ///

- /// The specified bullet power should be between - /// and . - ///

- /// Note that the gun cannot Fire if the gun is overheated, meaning that - /// returns a value > 0. - ///

- /// An event is generated when the bullet hits a robot - /// (), wall (), or another - /// bullet (). - ///

- /// - /// - /// Bullet bullet = null; - /// - /// // Fire a bullet with maximum power if the gun is ready - /// if (GunHeat == 0) - /// { - /// bullet = SetFireBullet(Rules.MAX_BULLET_POWER); - /// } - /// ... - /// Execute(); - /// ... - /// // Get the velocity of the bullet - /// if (bullet != null) - /// { - /// double bulletVelocity = bullet.Velocity; - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of energy given to the bullet, and subtracted from the robot's - /// energy. - /// - /// Returns a that contains information about the bullet if it - /// was actually fired, which can be used for tracking the bullet after it - /// has been fired. If the bullet was not fired, null is returned. - public Bullet SetFireBullet(double power) - { - if (peer != null) - { - return peer.SetFire(power); - } - UninitializedException(); - return null; - } - - /// - /// Registers a custom event to be called when a condition is met. - /// When you are finished with your condition or just want to remove it you - /// must call . - ///

- /// - /// - /// // Create the condition for our custom event - /// Condition triggerHitCondition = new Condition("triggerhit") - /// { - /// public bool Test() - /// { - /// return (Energy <= trigger); - /// } - /// } - /// - /// // Add our custom event based on our condition - /// AddCustomEvent(triggerHitCondition); - /// - /// - /// - /// - ///

- /// - /// The condition that must be met. - /// Throws ArgumentException if the condition parameter has been set to null. - /// - public void AddCustomEvent(Condition condition) - { - if (condition == null) - { - throw new ArgumentException("the condition cannot be null"); - } - if (peer != null) - { - ((IAdvancedRobotPeer) peer).AddCustomEvent(condition); - } - else - { - UninitializedException(); - } - } - - /// - /// Same as , but alows to define condition as anonymous method. - /// - public void AddCustomEvent(string name, int priority, ConditionTest test) - { - AddCustomEvent(new Condition(name, priority, test)); - } - - /// - /// Removes a custom event that was previously added by calling - /// . - ///

- /// - /// - /// // Create the condition for our custom event - /// Condition triggerHitCondition = new Condition("triggerhit") - /// { - /// public bool Test() - /// { - /// return (Energy <= trigger); - /// } - /// } - /// - /// // Add our custom event based on our condition - /// AddCustomEvent(triggerHitCondition); - /// ... - /// // do something with your robot - /// ... - /// // Remove the custom event based on our condition - /// RemoveCustomEvent(triggerHitCondition); - /// - /// - /// - /// - ///

- /// - /// The condition that was previous added and that must be removed now. - /// - public void RemoveCustomEvent(Condition condition) - { - if (condition == null) - { - throw new ArgumentException("the condition cannot be null"); - } - if (peer != null) - { - ((IAdvancedRobotPeer) peer).RemoveCustomEvent(condition); - } - else - { - UninitializedException(); - } - } - - /// - /// Clears Out any pending events in the robot's event queue immediately. - /// - /// - /// - public void ClearAllEvents() - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).clearAllEvents(); - } - else - { - UninitializedException(); - } - } - - /// - /// Executes any pending actions, or continues executing actions that are - /// in process. This call returns after the actions have been started. - ///

- /// Note that advanced robots must call this function in order to - /// Execute pending set* calls like e.g. , - /// , etc. - /// Otherwise, these calls will never get executed. - ///

- /// In this example the robot will move while turning: - /// - /// - /// SetTurnRight(90); - /// SetAhead(100); - /// Execute(); - /// - /// while (DistanceRemaining > 0 && TurnRemaining > 0) - /// { - /// Execute(); - /// } - /// - /// - ///

- public virtual void Execute() - { - if (peer != null) - { - peer.Execute(); - } - else - { - UninitializedException(); - } - } - - /// - /// Returns a list containing all events currently in the robot's queue. - /// You might, for example, call this while processing another event. - ///

- /// - /// - /// for (Event evnt : GetAllEvents()) { - /// if (evnt is HitRobotEvent) { - /// // do something with the event - /// } else if (evnt is HitByBulletEvent) { - /// // do something with the event - /// } - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public IList GetAllEvents() - { - if (peer != null) - { - return new List(((IAdvancedRobotPeer) peer).GetAllEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns a list containing all BulletHitBulletEvents currently in the - /// robot's queue. You might, for example, call this while processing another - /// event. - ///

- /// - /// - /// for (BulletHitBulletEvent evnt : GetBulletHitBulletEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- public IList GetBulletHitBulletEvents() - { - if (peer != null) - { - return new List(((IAdvancedRobotPeer) peer).GetBulletHitBulletEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns a list containing all BulletHitEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// for (BulletHitEvent event: GetBulletHitEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- public IList GetBulletHitEvents() - { - if (peer != null) - { - return new List(((IAdvancedRobotPeer) peer).GetBulletHitEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns a list containing all BulletMissedEvents currently in the - /// robot's queue. You might, for example, call this while processing another - /// event. - ///

- /// - /// - /// for (BulletMissedEvent evnt : GetBulletMissedEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- public IList GetBulletMissedEvents() - { - if (peer != null) - { - return new List(((IAdvancedRobotPeer) peer).GetBulletMissedEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns a file representing a data directory for the robot. - ///

- /// The system will automatically create the directory for you, so you do not - /// need to create it by yourself. - /// - ///

- public string GetDataDirectory() - { - if (peer != null) - { - return ((IAdvancedRobotPeer) peer).GetDataDirectory(); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns a file in your data directory that you can write to. - ///

- /// The system will automatically create the directory for you, so you do not - /// need to create it by yourself. - ///

- /// Please notice that the max. size of your data file is set to 200000 bytes - /// (~195 KB). - ///

- /// See the Sample.SittingDuck to see an example of how to use this - /// method. - /// - ///

- /// - /// The file name of the data file for your robot - /// - public Stream GetDataFile(string filename) - { - if (peer != null) - { - return ((IAdvancedRobotPeer) peer).GetDataFile(filename); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns the data quota available in your data directory, i.e. the amount - /// of bytes left in the data directory for the robot. - /// - /// - /// - public long DataQuotaAvailable - { - get - { - if (peer != null) - { - return ((IAdvancedRobotPeer) peer).GetDataQuotaAvailable(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the current priority of a class of events. - /// An event priority is a value from 0 - 99. The higher value, the higher priority. - ///

- /// - /// - /// int myHitRobotPriority = GetEventPriority("HitRobotEvent"); - /// - /// - ///

- /// The default priorities are, from highest to lowest: - ///

    :     100 (reserved)
-        ///    :             100 (reserved)
-        ///    :     100 (reserved)
-        ///    :           99
-        ///    Key and mouse events:  98
-        ///    :           80 (default value)
-        ///    :          75
-        ///    :       70
-        ///    :     60
-        ///    :  55
-        ///    :        50
-        ///    :      40
-        ///    :          30
-        ///    :         20
-        ///    :     10
-        ///    :             5
-        ///    :            -1 (reserved)
-        ///  
- /// - ///
- /// - /// the name of the event class (string) - /// - public int GetEventPriority(string eventClass) - { - if (peer != null) - { - return ((IAdvancedRobotPeer) peer).GetEventPriority(eventClass); - } - UninitializedException(); - return 0; // never called - } - - /// - /// Returns a list containing all HitByBulletEvents currently in the - /// robot's queue. You might, for example, call this while processing - /// another event. - ///

- /// - /// - /// for (HitByBulletEvent evnt : GetHitByBulletEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- public IList GetHitByBulletEvents() - { - if (peer != null) - { - return new List(((IAdvancedRobotPeer) peer).GetHitByBulletEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns a list containing all HitRobotEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// for (HitRobotEvent evnt : GetHitRobotEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- public IList GetHitRobotEvents() - { - if (peer != null) - { - return new List(((IAdvancedRobotPeer) peer).GetHitRobotEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns a list containing all HitWallEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// for (HitWallEvent evnt : GetHitWallEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- public IList GetHitWallEvents() - { - if (peer != null) - { - return new List(((IAdvancedRobotPeer) peer).GetHitWallEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns a list containing all RobotDeathEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// for (RobotDeathEvent evnt : GetRobotDeathEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- public IList GetRobotDeathEvents() - { - if (peer != null) - { - return new List(((IAdvancedRobotPeer) peer).GetRobotDeathEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns a list containing all ScannedRobotEvents currently in the robot's queue. - /// You might, for example, call this while processing another event. - ///

- /// - /// - /// for (ScannedRobotEvent evnt : GetScannedRobotEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- public IList GetScannedRobotEvents() - { - if (peer != null) - { - return new List(((IAdvancedRobotPeer) peer).GetScannedRobotEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - /// Returns a list containing all StatusEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// for (StatusEvent evnt : GetStatusEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- public IList GetStatusEvents() - { - if (peer != null) - { - return new List(((IAdvancedRobotPeer) peer).GetStatusEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - public virtual void OnCustomEvent(CustomEvent evnt) - { - } - - /// - /// Sets the priority of a class of events. - ///

- /// Events are sent to the onXXX handlers in order of priority. - /// Higher priority events can interrupt lower priority events. - /// For events with the same priority, newer events are always sent first. - /// Valid priorities are 0 - 99, where 100 is reserved and 80 is the default - /// priority. - ///

- /// - /// - /// SetEventPriority("RobotDeathEvent", 15); - /// - /// - ///

- /// The default priorities are, from highest to lowest: - ///

    :             100 (reserved)
-        ///    :     100 (reserved)
-        ///    :           99
-        ///    :           80
-        ///    :          75
-        ///    :       70
-        ///    :     60
-        ///    :  55
-        ///    :        50
-        ///    :      40
-        ///    :          30
-        ///    :         20
-        ///    :     10
-        ///    :             5
-        ///    :            -1 (reserved)
-        ///  
- ///

- /// Note that you cannot change the priority for events with the special - /// priority value -1 or 100 (reserved) as these events are system events. - /// Also note that you cannot change the priority of CustomEvent. - /// Instead you must change the priority of the condition(s) for your custom - /// event(s). - /// - ///

- /// - /// The name of the event class (string) to set the priority for - /// - /// - /// The new priority for that event class - /// - public void SetEventPriority(string eventClass, int priority) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetEventPriority(eventClass, priority); - } - else - { - UninitializedException(); - } - } - - /// - /// Call this during an event handler to allow new events of the same - /// priority to restart the event handler. - ///

- /// - /// - /// public override void OnScannedRobot(ScannedRobotEvent e) - /// { - /// Fire(1); - /// IsInterruptible = true; - /// Ahead(100); // If you see a robot while moving ahead, - /// // this handler will start from the top - /// // Without IsInterruptible (true), we wouldn't - /// // receive scan events at all! - /// // We'll only get here if we don't see a robot during the move. - /// Out.WriteLine("Ok, I can't see anyone"); - /// } - /// - /// - /// - /// - ///

- public bool IsInterruptible - { - set - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetInterruptible(value); - } - else - { - UninitializedException(); - } - } - } - - /// - /// Sets the maximum turn rate of the robot measured in degrees if the robot - /// should turn slower than (10 degress/turn). - /// - /// - /// - /// - /// - /// - public double MaxTurnRate - { - set - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetMaxTurnRate(Utils.ToRadians(value)); - } - else - { - UninitializedException(); - } - } - } - - /// - /// Sets the maximum velocity of the robot measured in pixels/turn if the - /// robot should move slower than (8 pixels/turn). - /// - /// - /// - /// - /// - /// - public double MaxVelocity - { - set - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetMaxVelocity(value); - } - else - { - UninitializedException(); - } - } - } - - /// - /// Sets the robot to resume the movement stopped by - /// or , if any. - ///

- /// This call returns immediately, and will not execute until you call - /// or take an action that executes. - /// - /// - /// - /// - /// - /// - /// - ///

- public void SetResume() - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetResume(); - } - else - { - UninitializedException(); - } - } - - /// - /// This call is identical to , but returns immediately, and - /// will not execute until you call or take an action that - /// executes. - ///

- /// If there is already movement saved from a previous stop, this will have - /// no effect. - ///

- /// This call is equivalent to calling SetStop(false); - /// - /// - /// - /// - /// - /// - /// - ///

- public void SetStop() - { - SetStop(false); - } - - /// - /// This call is identical to , but - /// returns immediately, and will not execute until you call - /// or take an action that executes. - ///

- /// If there is already movement saved from a previous stop, you can - /// overwrite it by calling SetStop(true). - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// true if the movement saved from a previous stop - /// should be overwritten; false otherwise. - /// - public void SetStop(bool overwrite) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetStop(overwrite); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot's gun to turn left by degrees when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's gun is set to turn right - /// instead of left. - ///

- /// - /// - /// // Set the gun to turn 180 degrees to the left - /// SetTurnGunLeft(180); - /// - /// // Set the gun to turn 90 degrees to the right instead of left - /// // (overrides the previous order) - /// SetTurnGunLeft(-90); - /// - /// ... - /// // Executes the last SetTurnGunLeft() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's gun to the left. - /// If degrees > 0 the robot's gun is set to turn left. - /// If degrees < 0 the robot's gun is set to turn right. - /// If degrees = 0 the robot's gun is set to stop turning. - /// - public void SetTurnGunLeft(double degrees) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnGun(-Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot's gun to turn right by degrees when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's gun is set to turn left - /// instead of right. - ///

- /// - /// - /// // Set the gun to turn 180 degrees to the right - /// SetTurnGunRight(180); - /// - /// // Set the gun to turn 90 degrees to the left instead of right - /// // (overrides the previous order) - /// SetTurnGunRight(-90); - /// - /// ... - /// // Executes the last SetTurnGunRight() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// - /// The amount of degrees to turn the robot's gun to the right. - /// If degrees > 0 the robot's gun is set to turn right. - /// If degrees < 0 the robot's gun is set to turn left. - /// If degrees = 0 the robot's gun is set to stop turning. - /// - public void SetTurnGunRight(double degrees) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnGun(Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot's radar to turn left by degrees when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's radar is set to turn right - /// instead of left. - ///

- /// - /// - /// // Set the radar to turn 180 degrees to the left - /// SetTurnRadarLeft(180); - /// - /// // Set the radar to turn 90 degrees to the right instead of left - /// // (overrides the previous order) - /// SetTurnRadarLeft(-90); - /// - /// ... - /// // Executes the last SetTurnRadarLeft() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's radar to the left. - /// If degrees > 0 the robot's radar is set to turn left. - /// If degrees < 0 the robot's radar is set to turn right. - /// If degrees = 0 the robot's radar is set to stop turning. - /// - public void SetTurnRadarLeft(double degrees) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnRadar(-Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot's radar to turn right by degrees when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's radar is set to turn left - /// instead of right. - ///

- /// - /// - /// // Set the radar to turn 180 degrees to the right - /// SetTurnRadarRight(180); - /// - /// // Set the radar to turn 90 degrees to the right instead of right - /// // (overrides the previous order) - /// SetTurnRadarRight(-90); - /// - /// ... - /// // Executes the last SetTurnRadarRight() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's radar to the rright. - /// If degrees > 0 the robot's radar is set to turn right. - /// If degrees < 0 the robot's radar is set to turn left. - /// If degrees = 0 the robot's radar is set to stop turning. - /// - public void SetTurnRadarRight(double degrees) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnRadar(Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Does not return until a condition is met, i.e. when a - /// returns true. - ///

- /// This call executes immediately. - ///

- /// See the Sample.Crazy robot for how this method can be used. - /// - /// - ///

- /// - /// the condition that must be met before this call returns - /// - public void WaitFor(Condition condition) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).WaitFor(condition); - } - else - { - UninitializedException(); - } - } - - /// - /// This method is called if your robot dies. - ///

- /// You should override it in your robot if you want to be informed of this - /// event. Actions will have no effect if called from this section. The - /// intent is to allow you to perform calculations or print something out - /// when the robot is killed. - /// - /// - ///

- /// the death event set by the game - public override void OnDeath(DeathEvent evnt) - { - } - - /// - public virtual void OnSkippedTurn(SkippedTurnEvent evnt) - { - } - - /// - /// Returns the direction that the robot's body is facing, in radians. - /// The value returned will be between 0 and 2 * PI (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// PI / 2 means East, PI means South, and 3 * PI / 2 means West. - /// - /// - /// - ///

- public double HeadingRadians - { - get - { - if (peer != null) - { - return peer.GetBodyHeading(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Sets the robot's body to turn left by radians when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's body is set to turn right - /// instead of left. - ///

- /// - /// - /// // Set the robot to turn 180 degrees to the left - /// SetTurnLeftRadians(Math.PI); - /// - /// // Set the robot to turn 90 degrees to the right instead of left - /// // (overrides the previous order) - /// SetTurnLeftRadians(-Math.PI / 2); - /// - /// ... - /// // Executes the last SetTurnLeftRadians() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's body to the left. - /// If radians > 0 the robot is set to turn left. - /// If radians < 0 the robot is set to turn right. - /// If radians = 0 the robot is set to stop turning. - public void SetTurnLeftRadians(double radians) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnBody(-radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot's body to turn right by radians when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's body is set to turn left - /// instead of right. - ///

- /// - /// - /// // Set the robot to turn 180 degrees to the right - /// SetTurnRightRadians(Math.PI); - /// - /// // Set the robot to turn 90 degrees to the left instead of right - /// // (overrides the previous order) - /// SetTurnRightRadians(-Math.PI / 2); - /// - /// ... - /// // Executes the last SetTurnRightRadians() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's body to the right. - /// If radians > 0 the robot is set to turn right. - /// If radians < 0 the robot is set to turn left. - /// If radians = 0 the robot is set to stop turning. - public void SetTurnRightRadians(double radians) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnBody(radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Immediately turns the robot's body to the left by radians. - ///

- /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the robot's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's body is set to turn right - /// instead of left. - ///

- /// - /// - /// // Turn the robot 180 degrees to the left - /// TurnLeftRadians(Math.PI); - /// - /// // Afterwards, turn the robot 90 degrees to the right - /// TurnLeftRadians(-Math.PI / 2); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's body to the left. - /// If radians > 0 the robot will turn right. - /// If radians < 0 the robot will turn left. - /// If radians = 0 the robot will not turn, but execute. - public void TurnLeftRadians(double radians) - { - if (peer != null) - { - peer.TurnBody(-radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Immediately turns the robot's body to the right by radians. - /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the robot's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's body is set to turn left - /// instead of right. - ///

- /// - /// - /// // Turn the robot 180 degrees to the right - /// TurnRightRadians(Math.PI); - /// - /// // Afterwards, turn the robot 90 degrees to the left - /// TurnRightRadians(-Math.PI / 2); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's body to the right. - /// If radians > 0 the robot will turn right. - /// If radians < 0 the robot will turn left. - /// If radians = 0 the robot will not turn, but execute. - public void TurnRightRadians(double radians) - { - if (peer != null) - { - peer.TurnBody(radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Returns the direction that the robot's gun is facing, in radians. - /// The value returned will be between 0 and 2 * PI (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// PI / 2 means East, PI means South, and 3 * PI / 2 means West. - /// - /// - /// - ///

- public double GunHeadingRadians - { - get - { - if (peer != null) - { - return peer.GetGunHeading(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the direction that the robot's radar is facing, in radians. - /// The value returned will be between 0 and 2 * PI (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// PI / 2 means East, PI means South, and 3 * PI / 2 means West. - /// - /// - /// - ///

- public double RadarHeadingRadians - { - get - { - if (peer != null) - { - return peer.GetRadarHeading(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Sets the robot's gun to turn left by radians when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's gun is set to turn right - /// instead of left. - ///

- /// - /// - /// // Set the gun to turn 180 degrees to the left - /// SetTurnGunLeftRadians(Math.PI); - /// - /// // Set the gun to turn 90 degrees to the right instead of left - /// // (overrides the previous order) - /// SetTurnGunLeftRadians(-Math.PI / 2); - /// - /// ... - /// // Executes the last SetTurnGunLeftRadians() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's gun to the left. - /// If radians > 0 the robot's gun is set to turn left. - /// If radians < 0 the robot's gun is set to turn right. - /// If radians = 0 the robot's gun is set to stop turning. - public void SetTurnGunLeftRadians(double radians) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnGun(-radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot's gun to turn right by radians when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's gun is set to turn left - /// instead of right. - ///

- /// - /// - /// // Set the gun to turn 180 degrees to the right - /// SetTurnGunRightRadians(Math.PI); - /// - /// // Set the gun to turn 90 degrees to the left instead of right - /// // (overrides the previous order) - /// SetTurnGunRightRadians(-Math.PI / 2); - /// - /// ... - /// // Executes the last SetTurnGunRightRadians() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's gun to the right. - /// If radians > 0 the robot's gun is set to turn left. - /// If radians < 0 the robot's gun is set to turn right. - /// If radians = 0 the robot's gun is set to stop turning. - public void SetTurnGunRightRadians(double radians) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnGun(radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot's radar to turn left by radians when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's radar is set to turn right - /// instead of left. - ///

- /// - /// - /// // Set the radar to turn 180 degrees to the left - /// SetTurnRadarLeftRadians(Math.PI); - /// - /// // Set the radar to turn 90 degrees to the right instead of left - /// // (overrides the previous order) - /// SetTurnRadarLeftRadians(-Math.PI / 2); - /// - /// ... - /// // Executes the last SetTurnRadarLeftRadians() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's radar to the left. - /// If radians > 0 the robot's radar is set to turn left. - /// If radians < 0 the robot's radar is set to turn right. - /// If radians = 0 the robot's radar is set to stop turning. - public void SetTurnRadarLeftRadians(double radians) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnRadar(-radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the robot's radar to turn right by radians when the next execution - /// takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's radar is set to turn left - /// instead of right. - ///

- /// - /// - /// // Set the radar to turn 180 degrees to the right - /// SetTurnRadarRightRadians(Math.PI); - /// - /// // Set the radar to turn 90 degrees to the right instead of right - /// // (overrides the previous order) - /// SetTurnRadarRightRadians(-Math.PI / 2); - /// - /// ... - /// // Executes the last SetTurnRadarRightRadians() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's radar to the right. - /// If radians > 0 the robot's radar is set to turn left. - /// If radians < 0 the robot's radar is set to turn right. - /// If radians = 0 the robot's radar is set to stop turning. - public void SetTurnRadarRightRadians(double radians) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).SetTurnRadar(radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Immediately turns the robot's gun to the left by radians. - ///

- /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the gun's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's gun is set to turn right - /// instead of left. - ///

- /// - /// - /// // Turn the robot's gun 180 degrees to the left - /// TurnGunLeftRadians(Math.PI); - /// - /// // Afterwards, turn the robot's gun 90 degrees to the right - /// TurnGunLeftRadians(-Math.PI / 2); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's gun to the left. - /// If radians > 0 the robot's gun will turn left. - /// If radians < 0 the robot's gun will turn right. - /// If radians = 0 the robot's gun will not turn, but execute. - public void TurnGunLeftRadians(double radians) - { - if (peer != null) - { - peer.TurnGun(-radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Immediately turns the robot's gun to the right by radians. - /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the gun's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's gun is set to turn left - /// instead of right. - ///

- /// - /// - /// // Turn the robot's gun 180 degrees to the right - /// TurnGunRightRadians(Math.PI); - /// - /// // Afterwards, turn the robot's gun 90 degrees to the left - /// TurnGunRightRadians(-Math.PI / 2); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's gun to the right. - /// If radians > 0 the robot's gun will turn right. - /// If radians < 0 the robot's gun will turn left. - /// If radians = 0 the robot's gun will not turn, but execute. - public void TurnGunRightRadians(double radians) - { - if (peer != null) - { - peer.TurnGun(radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Immediately turns the robot's radar to the left by radians. - ///

- /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the radar's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's radar is set to turn right - /// instead of left. - ///

- /// - /// - /// // Turn the robot's radar 180 degrees to the left - /// TurnRadarLeftRadians(Math.PI); - /// - /// // Afterwards, turn the robot's radar 90 degrees to the right - /// TurnRadarLeftRadians(-Math.PI / 2); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's radar to the left. - /// If radians > 0 the robot's radar will turn left. - /// If radians < 0 the robot's radar will turn right. - /// If radians = 0 the robot's radar will not turn, but execute. - public void TurnRadarLeftRadians(double radians) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).TurnRadar(-radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Immediately turns the robot's radar to the right by radians. - /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the radar's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's radar is set to turn left - /// instead of right. - ///

- /// - /// - /// // Turn the robot's radar 180 degrees to the right - /// TurnRadarRightRadians(Math.PI); - /// - /// // Afterwards, turn the robot's radar 90 degrees to the left - /// TurnRadarRightRadians(-Math.PI / 2); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// the amount of radians to turn the robot's radar to the right. - /// If radians > 0 the robot's radar will turn right. - /// If radians < 0 the robot's radar will turn left. - /// If radians = 0 the robot's radar will not turn, but execute. - public void TurnRadarRightRadians(double radians) - { - if (peer != null) - { - ((IAdvancedRobotPeer) peer).TurnRadar(radians); - } - else - { - UninitializedException(); - } - } - - /// - /// Returns the angle remaining in the gun's turn, in radians. - ///

- /// This call returns both positive and negative values. Positive values - /// means that the gun is currently turning to the right. Negative values - /// means that the gun is currently turning to the left. - /// - /// - /// - /// - /// - ///

- public double GunTurnRemainingRadians - { - get - { - if (peer != null) - { - return peer.GetGunTurnRemaining(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the angle remaining in the radar's turn, in radians. - ///

- /// This call returns both positive and negative values. Positive values - /// means that the radar is currently turning to the right. Negative values - /// means that the radar is currently turning to the left. - /// - /// - /// - /// - /// - ///

- public double RadarTurnRemainingRadians - { - get - { - if (peer != null) - { - return peer.GetRadarTurnRemaining(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the angle remaining in the robot's turn, in radians. - ///

- /// This call returns both positive and negative values. Positive values - /// means that the robot is currently turning to the right. Negative values - /// means that the robot is currently turning to the left. - /// - /// - /// - /// - /// - ///

- public double TurnRemainingRadians - { - get - { - if (peer != null) - { - return peer.GetBodyTurnRemaining(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - IAdvancedEvents IAdvancedRobot.GetAdvancedEventListener() - { - return this; // this robot is listening - } - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BattleEndedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BattleEndedEvent.cs deleted file mode 100644 index 7c877c1..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BattleEndedEvent.cs +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A BattleEndedEvent is sent to - /// when the battle is ended. - /// You can use the information contained in this event to determine if the - /// battle was aborted and also get the results of the battle. - /// - /// - /// - [Serializable] - public sealed class BattleEndedEvent : Event - { - private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!; - - private readonly bool aborted; - private readonly BattleResults results; - - /// - /// - /// Called by the game to create a new BattleEndedEvent. - /// - public BattleEndedEvent(bool aborted, BattleResults results) - { - this.aborted = aborted; - this.results = results; - } - - /// - /// Checks if this battle was aborted. - /// Returns true if the battle was aborted - /// - public bool IsAborted - { - get { return aborted; } - } - - /// - /// Returns the battle results. - /// - public BattleResults Results - { - get { return results; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - /// - public override int Priority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (robot != null) - { - var listener = robot.GetBasicEventListener() as IBasicEvents2; - if (listener != null) - { - listener.OnBattleEnded(this); - } - } - } - - internal override bool IsCriticalEvent - { - get { return true; } - } - - internal override byte SerializationType - { - get { return RbSerializerN.BattleEndedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - var obj = (BattleEndedEvent) objec; - - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_BOOL - + serializer.sizeOf(RbSerializerN.BattleResults_TYPE, obj.results); - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (BattleEndedEvent) objec; - - serializer.serialize(buffer, obj.aborted); - serializer.serialize(buffer, RbSerializerN.BattleResults_TYPE, obj.results); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - bool aborted = serializer.deserializeBoolean(buffer); - var results = (BattleResults) serializer.deserializeAny(buffer); - - return new BattleEndedEvent(aborted, results); - } - } - } -} - -//docl \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BattleResults.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BattleResults.cs deleted file mode 100644 index 8975462..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BattleResults.cs +++ /dev/null @@ -1,225 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.serialization; - -namespace Robocode -{ - /// - /// Contains the battle results returned by - /// when a battle has ended. - /// - /// - /// - [Serializable] - public class BattleResults : IComparable - { - internal string teamLeaderName; - internal int rank; - internal double score; - internal double survival; - internal double lastSurvivorBonus; - internal double bulletDamage; - internal double bulletDamageBonus; - internal double ramDamage; - internal double ramDamageBonus; - internal int firsts; - internal int seconds; - internal int thirds; - - /// - /// Constructs this BattleResults object. - /// - public BattleResults( - string teamLeaderName, - int rank, - double score, - double survival, - double lastSurvivorBonus, - double bulletDamage, - double bulletDamageBonus, - double ramDamage, - double ramDamageBonus, - int firsts, - int seconds, - int thirds - ) - { - this.teamLeaderName = teamLeaderName; - this.rank = rank; - this.score = score; - this.survival = survival; - this.lastSurvivorBonus = lastSurvivorBonus; - this.bulletDamage = bulletDamage; - this.bulletDamageBonus = bulletDamageBonus; - this.ramDamage = ramDamage; - this.ramDamageBonus = ramDamageBonus; - this.firsts = firsts; - this.seconds = seconds; - this.thirds = thirds; - } - - /// - /// Returns the name of the team leader in the team or the name of the - /// robot if the robot is not participating in a team. - /// - public string TeamLeaderName - { - get { return teamLeaderName; } - } - - /// - /// Returns the rank of this robot in the battle results. - /// - public int Rank - { - get { return rank; } - } - - /// - /// Returns the total score of this robot in the battle. - /// - public int Score - { - get { return (int) (score + 0.5); } - } - - /// - /// Returns the survival score of this robot in the battle. - /// - public int Survival - { - get { return (int) (survival + 0.5); } - } - - /// - /// Returns the last survivor score of this robot in the battle. - /// - public int LastSurvivorBonus - { - get { return (int) (lastSurvivorBonus + 0.5); } - } - - /// - /// Returns the bullet damage score of this robot in the battle. - /// - public int BulletDamage - { - get { return (int) (bulletDamage + 0.5); } - } - - /// - /// Returns the bullet damage bonus of this robot in the battle. - /// - public int BulletDamageBonus - { - get { return (int) (bulletDamageBonus + 0.5); } - } - - /// - /// Returns the ram damage score of this robot in the battle. - /// - public int RamDamage - { - get { return (int) (ramDamage + 0.5); } - } - - /// - /// Returns the ram damage bonus of this robot in the battle. - /// - public int RamDamageBonus - { - get { return (int) (ramDamageBonus + 0.5); } - } - - /// - /// Returns the number of rounds this robot placed first in the battle. - /// - public int Firsts - { - get { return firsts; } - } - - /// - /// Returns the number of rounds this robot placed second in the battle. - /// - public int Seconds - { - get { return seconds; } - } - - /// - /// Returns the number of rounds this robot placed third in the battle. - /// - public int Thirds - { - get { return thirds; } - } - - public int CompareTo(BattleResults o) - { - return score.CompareTo(o.score); - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - var obj = (BattleResults) objec; - - return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.teamLeaderName) + - 4*RbSerializerN.SIZEOF_INT - + 7*RbSerializerN.SIZEOF_DOUBLE; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (BattleResults) objec; - - serializer.serialize(buffer, obj.teamLeaderName); - serializer.serialize(buffer, obj.rank); - serializer.serialize(buffer, obj.score); - serializer.serialize(buffer, obj.survival); - serializer.serialize(buffer, obj.lastSurvivorBonus); - serializer.serialize(buffer, obj.bulletDamage); - serializer.serialize(buffer, obj.bulletDamageBonus); - serializer.serialize(buffer, obj.ramDamage); - serializer.serialize(buffer, obj.ramDamageBonus); - serializer.serialize(buffer, obj.firsts); - serializer.serialize(buffer, obj.seconds); - serializer.serialize(buffer, obj.thirds); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - string teamLeaderName = serializer.deserializeString(buffer); - int rank = buffer.getInt(); - double score = buffer.getDouble(); - double survival = buffer.getDouble(); - double lastSurvivorBonus = buffer.getDouble(); - double bulletDamage = buffer.getDouble(); - double bulletDamageBonus = buffer.getDouble(); - double ramDamage = buffer.getDouble(); - double ramDamageBonus = buffer.getDouble(); - int firsts = buffer.getInt(); - int seconds = buffer.getInt(); - int thirds = buffer.getInt(); - - return new BattleResults(teamLeaderName, rank, score, survival, lastSurvivorBonus, bulletDamage, - bulletDamageBonus, ramDamage, ramDamageBonus, firsts, seconds, thirds); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BattleRules.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BattleRules.cs deleted file mode 100644 index 461d0f1..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BattleRules.cs +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.security; - -namespace Robocode -{ - /// - /// Contains the battle rules returned by BattleStartedEvent.BattleRules - /// when a battle is started and BattleCompletedEvent.BattleRules - /// when a battle is completed. - /// - /// BattleStartedEvent - /// BattleCompletedEvent - [Serializable] - public sealed class BattleRules - { - private readonly int battlefieldWidth; - private readonly int battlefieldHeight; - private readonly int numRounds; - private readonly double gunCoolingRate; - private readonly long inactivityTime; - private readonly bool hideEnemyNames; - private readonly int sentryBorderSize; - - /// - /// Returns the battlefield width. - /// - public int BattlefieldWidth - { - get { return battlefieldWidth; } - } - - /// - /// Returns the battlefield height. - /// - public int BattlefieldHeight - { - get { return battlefieldHeight; } - } - - /// - /// Returns the number of rounds. - /// - public int NumRounds - { - get { return numRounds; } - } - - /// - /// Returns the rate at which the gun will cool down, i.e. the amount of heat the gun heat will drop per turn. - ///

- /// The gun cooling rate is default 0.1 per turn, but can be changed by the battle setup. - /// So don't count on the cooling rate being 0.1! - /// - /// - /// - ///

- public double GunCoolingRate - { - get { return gunCoolingRate; } - } - - /// - /// Returns the allowed inactivity time, where the robot is not taking any action, before will begin to be zapped. - /// The inactivity time is measured in turns, and is the allowed time that a robot is allowed to omit taking - /// action before being punished by the game by zapping. - ///

- /// When a robot is zapped by the game, it will loose 0.1 energy points per turn. Eventually the robot will be - /// killed by zapping until the robot takes action. When the robot takes action, the inactivity time counter is - /// reset. - ///

- /// The allowed inactivity time is per default 450 turns, but can be changed by the battle setup. - /// So don't count on the inactivity time being 450 turns! - /// - /// - ///

- public long InactivityTime - { - get { return inactivityTime; } - } - - /// - /// Returns true if the enemy names are hidden, i.e. anonymous; false otherwise. - /// - public bool HideEnemyNames - { - get { return hideEnemyNames; } - } - - /// - /// Returns the sentry border size for a BorderSentry that defines the how - /// far a BorderSentry is allowed to move from the border edges measured in units.
- /// Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that - /// BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the - /// distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this - /// border area. - ///
- public int SentryBorderSize - { - get { return sentryBorderSize; } - } - - private BattleRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime, - bool hideEnemyNames, int sentryBorderSize) - { - this.battlefieldWidth = battlefieldWidth; - this.battlefieldHeight = battlefieldHeight; - this.numRounds = numRounds; - this.gunCoolingRate = gunCoolingRate; - this.inactivityTime = inactivityTime; - this.hideEnemyNames = hideEnemyNames; - this.sentryBorderSize = sentryBorderSize; - } - - private static IHiddenRulesHelper createHiddenHelper() - { - return new HiddenHelper(); - } - - private class HiddenHelper : IHiddenRulesHelper - { - public BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime, - bool hideEnemyNames, int borderSentryRobotAttackRange) - { - return new BattleRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, borderSentryRobotAttackRange); - } - } - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Bullet.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Bullet.cs deleted file mode 100644 index 2a4ddef..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Bullet.cs +++ /dev/null @@ -1,217 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.security; -using net.sf.robocode.serialization; -using Robocode.Util; - -namespace Robocode -{ - /// - /// - /// Represents a bullet. This is returned from - /// and , and all the bullet-related - /// events. - /// - /// - /// - /// - /// - /// - [Serializable] - public class Bullet - { - private readonly double headingRadians; - private double x; - private double y; - private readonly double power; - private readonly string ownerName; - private string victimName; - private bool _isActive; - private readonly int bulletId; - - /// - /// Called by the game to create a new Bullet object - /// - public Bullet(double heading, double x, double y, double power, string ownerName, string victimName, - bool isActive, int bulletId) - { - headingRadians = heading; - this.x = x; - this.y = y; - this.power = power; - this.ownerName = ownerName; - this.victimName = victimName; - _isActive = isActive; - this.bulletId = bulletId; - } - - public override bool Equals(Object obj) - { - if (obj is Bullet) - { - Bullet bullet = (Bullet)obj; - return bullet.bulletId == bulletId; - } - return Equals(obj); - } - - /// - /// Returns the direction the bullet is/was heading, in degrees - /// (0 <= getHeading() < 360). This is not relative to the direction you are facing. - /// - public double Heading - { - get { return Utils.ToDegrees(headingRadians); } - } - - /// - /// Returns the direction the bullet is/was heading, in radians - /// (0 <= getHeadingRadians() < 2 * Math.PI). This is not relative to the direction you are facing. - /// - public double HeadingRadians - { - get { return headingRadians; } - } - - /// - /// Returns the name of the robot that fired this bullet. - /// - public string Name - { - get { return ownerName; } - } - - /// - /// Returns the power of this bullet. - ///

- /// The bullet will do (4 * power) damage if it hits another robot. - /// If power is greater than 1, it will do an additional 2 * (power - 1) - /// damage. You will get (3 * power) back if you hit the other robot. - ///

- public double Power - { - get { return power; } - } - - /// - /// Returns the velocity of this bullet. The velocity of the bullet is - /// constant once it has been fired. - /// - public double Velocity - { - get { return Rules.GetBulletSpeed(power); } - } - - /// - /// Returns the name of the robot that this bullet hit, or null if - /// the bullet has not hit a robot. - /// - public string Victim - { - get { return victimName; } - } - - /// - /// Returns the X position of the bullet. - /// - public double X - { - get { return x; } - } - - /// - /// Returns the Y position of the bullet. - /// - public double Y - { - get { return y; } - } - - /// - /// Checks if this bullet is still active on the battlefield. - /// - public bool IsActive - { - get { return _isActive; } - } - - /// - /// Updates this bullet based on the specified bullet status. - /// - // this method is invisible on RobotAPI - private void update(double x, double y, string victimName, bool isActive) - { - this.x = x; - this.y = y; - this.victimName = victimName; - _isActive = isActive; - } - - internal int getBulletId() - { - return bulletId; - } - - private static IHiddenBulletHelper createHiddenHelper() - { - return new HiddenBulletHelper(); - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new HiddenBulletHelper(); - } - - private class HiddenBulletHelper : IHiddenBulletHelper, ISerializableHelperN - { - public void update(Bullet bullet, double x, double y, string victimName, bool isActive) - { - bullet.update(x, y, victimName, isActive); - } - - public int sizeOf(RbSerializerN serializer, object objec) - { - var obj = (Bullet)objec; - - return RbSerializerN.SIZEOF_TYPEINFO + 4 * RbSerializerN.SIZEOF_DOUBLE + serializer.sizeOf(obj.ownerName) - + serializer.sizeOf(obj.victimName) + RbSerializerN.SIZEOF_BOOL + RbSerializerN.SIZEOF_INT; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (Bullet)objec; - - serializer.serialize(buffer, obj.headingRadians); - serializer.serialize(buffer, obj.x); - serializer.serialize(buffer, obj.y); - serializer.serialize(buffer, obj.power); - serializer.serialize(buffer, obj.ownerName); - serializer.serialize(buffer, obj.victimName); - serializer.serialize(buffer, obj._isActive); - serializer.serialize(buffer, obj.bulletId); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - double headingRadians = buffer.getDouble(); - double x = buffer.getDouble(); - double y = buffer.getDouble(); - double power = buffer.getDouble(); - string ownerName = serializer.deserializeString(buffer); - string victimName = serializer.deserializeString(buffer); - bool isActive = serializer.deserializeBoolean(buffer); - int bulletId = serializer.deserializeInt(buffer); - - return new Bullet(headingRadians, x, y, power, ownerName, victimName, isActive, bulletId); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BulletHitBulletEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BulletHitBulletEvent.cs deleted file mode 100644 index 6723d1b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BulletHitBulletEvent.cs +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// This event is sent to - /// when one of your bullets has hit another bullet. - /// - [Serializable] - public sealed class BulletHitBulletEvent : Event - { - private const int DEFAULT_PRIORITY = 55; - - private Bullet bullet; - private readonly Bullet hitBullet; - - /// - /// Called by the game to create a new BulletHitEvent. - /// - public BulletHitBulletEvent(Bullet bullet, Bullet hitBullet) - { - this.bullet = bullet; - this.hitBullet = hitBullet; - } - - /// - /// Returns your bullet that hit another bullet. - /// - public Bullet Bullet - { - get { return bullet; } - } - - /// - /// Returns the bullet that was hit by your bullet. - /// - public Bullet HitBullet - { - get { return hitBullet; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnBulletHitBullet(this); - } - } - - // Needed for .NET version - internal override void UpdateBullets(Dictionary bullets) - { - // we need to pass same instance - bullet = bullets[bullet.getBulletId()]; - } - - internal override byte SerializationType - { - get { return RbSerializerN.BulletHitBulletEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - var obj = (BulletHitBulletEvent) objec; - - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT - + serializer.sizeOf(RbSerializerN.Bullet_TYPE, obj.hitBullet); - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (BulletHitBulletEvent) objec; - - // no need to transmit whole bullet, rest of it is already known to proxy side - serializer.serialize(buffer, obj.bullet.getBulletId()); - serializer.serialize(buffer, RbSerializerN.Bullet_TYPE, obj.hitBullet); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt()); - var hitBullet = (Bullet) serializer.deserializeAny(buffer); - - return new BulletHitBulletEvent(bullet, hitBullet); - } - } - } -} - -//doc diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BulletHitEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BulletHitEvent.cs deleted file mode 100644 index bc35644..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BulletHitEvent.cs +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// This event is sent to - /// when one of your bullets has hit another robot. - /// - [Serializable] - public sealed class BulletHitEvent : Event - { - private const int DEFAULT_PRIORITY = 50; - - private readonly string name; - private readonly double energy; - private Bullet bullet; - - /// - /// Called by the game to create a new BulletHitEvent. - /// - public BulletHitEvent(string name, double energy, Bullet bullet) - { - this.name = name; - this.energy = energy; - this.bullet = bullet; - } - - /// - /// Returns the bullet of yours that hit the robot. - /// - public Bullet Bullet - { - get { return bullet; } - } - - /// - /// Returns the remaining energy of the robot your bullet has hit (after the - /// damage done by your bullet). - /// - public double VictimEnergy - { - get { return energy; } - } - - /// - /// Returns the name of the robot your bullet hit. - /// - public string VictimName - { - get { return name; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnBulletHit(this); - } - } - - // Needed for .NET version - internal override void UpdateBullets(Dictionary bullets) - { - // we need to pass same instance - bullet = bullets[bullet.getBulletId()]; - } - - internal override byte SerializationType - { - get { return RbSerializerN.BulletHitEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - var obj = (BulletHitEvent) objec; - - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT + serializer.sizeOf(obj.name) - + RbSerializerN.SIZEOF_DOUBLE; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (BulletHitEvent) objec; - - serializer.serialize(buffer, obj.bullet.getBulletId()); - serializer.serialize(buffer, obj.name); - serializer.serialize(buffer, obj.energy); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt()); - string name = serializer.deserializeString(buffer); - double energy = buffer.getDouble(); - - return new BulletHitEvent(name, energy, bullet); - } - } - } -} - -//doc diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BulletMissedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BulletMissedEvent.cs deleted file mode 100644 index 19294d6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/BulletMissedEvent.cs +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// This event is sent to - /// when one of your bullets has missed, i.e. when the bullet has - /// reached the border of the battlefield. - /// - [Serializable] - public sealed class BulletMissedEvent : Event - { - private const int DEFAULT_PRIORITY = 60; - - private Bullet bullet; - - /// - /// - /// Called by the game to create a new BulletMissedEvent. - /// - public BulletMissedEvent(Bullet bullet) - { - this.bullet = bullet; - } - - /// - /// - /// Returns the bullet that missed. - /// - public Bullet Bullet - { - get { return bullet; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnBulletMissed(this); - } - } - - // Needed for .NET version - internal override void UpdateBullets(Dictionary bullets) - { - // we need to pass same instance - bullet = bullets[bullet.getBulletId()]; - } - - internal override byte SerializationType - { - get { return RbSerializerN.BulletMissedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (BulletMissedEvent) objec; - - serializer.serialize(buffer, obj.bullet.getBulletId()); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt()); - - return new BulletMissedEvent(bullet); - } - } - } -} -//doc diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Condition.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Condition.cs deleted file mode 100644 index 974fcea..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Condition.cs +++ /dev/null @@ -1,155 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.io; - -namespace Robocode -{ - /// - /// Condition is used to define custom - /// and custom events for an AdvancedRobot. The code below is taken from the sample robot - /// named samplecs.Target. See the samplecs/Target.cs for details. - /// - /// - /// AddCustomEvent( - /// new Condition("triggerhit", (c) => - /// { - /// return Energy <= trigger; - /// })); - /// - /// - /// - /// - /// - /// - /// - public class Condition - { - private readonly ConditionTest test; - - /// - /// The priority of this condition. Defaults to 80. - /// - public int priority = 80; - - /// - /// The name of this condition. - /// - public string name; - - /// - /// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method. - /// - public Condition(string name, int priority, ConditionTest test) - : this(name, priority) - { - this.test = test; - } - - /// - /// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method. - /// - public Condition(string name, ConditionTest test) - : this(name) - { - this.test = test; - } - - /// - /// Convinience constructor, allows to pass delegate to method, instead of overriding Test() method. - /// - public Condition(ConditionTest test) - { - this.test = test; - } - - /// - /// Creates a new, unnamed Condition with the default priority, which is 80. - /// - protected Condition() - { - } - - /// - /// Creates a new Condition with the specified name, and default priority, which is 80. - /// - /// The name for the new Condition - protected Condition(string name) - { - this.name = name; - } - - /// - /// Creates a new Condition with the specified name and priority. - /// A condition priority is a value from 0 - 99. The higher value, the - /// higher priority. The default priority is 80. - /// - /// The name for the new condition - /// The priority of the new condition - protected Condition(string name, int priority) - { - this.name = name; - if (priority < 0) - { - LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99."); - LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for condition " + name + " will be 0."); - priority = 0; - } - else if (priority > 99) - { - LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99."); - LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for condition " + name + " will be 99."); - priority = 99; - } - this.priority = priority; - } - - /// - /// Returns the name of this condition. - /// - public string Name - { - get { return name ?? GetType().Name; } - set { name = value; } - } - - /// - /// Returns the priority of this condition. - /// A condition priority is a value from 0 - 99. The higher value, the - /// higher priority. The default priority is 80. - /// - public int Priority - { - get { return priority; } - set { priority=value; } - } - - /// - /// Overriding the Test() method is the point of a Condition. - /// The game will call your Test() function, and take action if it returns true. - /// This is valid for both and - /// - ///

- /// You may not take any actions inside of Test(). - ///

- public virtual bool Test() - { - if (test != null) - { - return test(this); - } - throw new NotImplementedException("You should inherit from Condition class and override Test() method or pass delegate into constructor"); - } - } - - /// - /// Method signature for Test method of - /// - public delegate bool ConditionTest(Condition condition); -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/CustomEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/CustomEvent.cs deleted file mode 100644 index 7a3ec36..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/CustomEvent.cs +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.peer; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// This event is sent to - /// when a custom condition is met. Be sure to reset or remove the custom condition to avoid - /// having it recurring repeatedly (see the example for the method. - /// - /// - [Serializable] - public class CustomEvent : Event - { - private const int DEFAULT_PRIORITY = 80; - - private readonly Condition condition; - - /// - /// Called by the game to create a new CustomEvent when a condition is met. - /// - public CustomEvent(Condition condition) - { - this.condition = condition; - if (condition != null) - { - Priority = condition.Priority; - } - } - - /// - /// Called by the game to create a new CustomEvent when a condition is met. - /// The event will have the given priority. - /// An event priority is a value from 0 - 99. The higher value, the higher - /// priority. The default priority is 80. - ///

- /// This is equivalent to calling on the - /// Condition. - ///

- /// The condition that must be met - /// The priority of the condition - public CustomEvent(Condition condition, int priority) - { - this.condition = condition; - Priority = priority; - if (condition != null) - { - condition.Priority = priority; - } - } - - /// - /// Returns the condition that fired, causing this event to be generated. - /// Use this to determine which condition fired, and to remove the custom event. - /// - /// - /// public void OnCustomEvent(CustomEvent evnt) - /// { - /// if (event.Condition.Name == "mycondition") - /// { - /// RemoveCustomEvent(event.Condition); - /// // do something else - /// } - /// } - /// - /// - /// - public Condition Condition - { - get { return condition; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsAdvancedRobot()) - { - IAdvancedEvents listener = ((IAdvancedRobot) robot).GetAdvancedEventListener(); - - if (listener != null) - { - listener.OnCustomEvent(this); - } - } - } - - // sealed to disable overrides - public override sealed int CompareTo(Event evnt) - { - return base.CompareTo(evnt); - } - - // sealed to disable overrides - internal override bool IsCriticalEvent - { - get { return false; } - } - - // sealed to disable overrides - public sealed override int Priority - { - get { return base.Priority; } - } - - internal override byte SerializationType - { - get { throw new System.Exception("Serialization not supported on this event type"); } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/DeathEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/DeathEvent.cs deleted file mode 100644 index 7c02457..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/DeathEvent.cs +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// This event is sent to when your robot dies. - /// - [Serializable] - public sealed class DeathEvent : Event - { - private const int DEFAULT_PRIORITY = -1; // System event -> cannot be changed!; - - /// - public override int Priority - { - get { return DEFAULT_PRIORITY; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnDeath(this); - } - } - - internal override bool IsCriticalEvent - { - get { return true; } - } - - internal override byte SerializationType - { - get { return RbSerializerN.DeathEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - return new DeathEvent(); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Event.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Event.cs deleted file mode 100644 index b09b84b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Event.cs +++ /dev/null @@ -1,279 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using net.sf.robocode.io; -using net.sf.robocode.peer; -using net.sf.robocode.security; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// The superclass of all Robocode events. - /// - [Serializable] - public abstract class Event : IComparable - { - private const int DEFAULT_PRIORITY = 80; - - private long time; - private int priority; - - // time is valid only after adding to event manager on proxy side, we do not update it on battle side - private volatile bool addedToQueue; - - /// - /// Compares this event to another event regarding precedence. - /// - /// The event precedence is first and foremost determined by the event time, - /// secondly the event priority, and lastly specific event information. - /// - /// This method will first compare the time of each event. If the event time - /// is the same for both events, then this method compared the priority of - /// each event. If the event priorities are equals, then this method will - /// compare the two events based on specific event information. - /// - /// This method is called by the game in order to sort the event queue of a - /// robot to make sure the events are listed in chronological order. - /// - /// - /// the event to compare to this event. - /// - /// Returns a negative value if this event has higher precedence, i.e. must - /// be listed before the specified event. A positive value if this event - /// has a lower precedence, i.e. must be listed after the specified event. - /// 0 means that the precedence of the two events are equal. - /// - public virtual int CompareTo(Event evnt) - { - // Compare the time difference which has precedence over priority. - var timeDiff = (int) (time - evnt.time); - - if (timeDiff != 0) - { - return timeDiff; // Time differ - } - - // Same time -> Compare the difference in priority - int priorityDiff = evnt.Priority - Priority; - - if (priorityDiff != 0) - { - return priorityDiff; // Priority differ - } - - // Same time and priority -> Compare specific event types - // look at overrides in ScannedRobotEvent and HitRobotEvent - - // No difference found - return 0; - } - - /// - /// The time when this event occurred. - /// - /// - /// Note that the time is equal to the turn of a battle round. - /// - /// This method is intended for letting robot developers create their own event types. - /// It is not possible to change the time of an event after it has been added to the event - /// queue of the robot. - /// - public long Time - { - get { return time; } - set - { - if (addedToQueue) - { - LoggerN.WriteLineToRobotsConsole("SYSTEM: The time of an event cannot be changed after it has been added the event queue."); - } - else - { - time = value; - } - } - } - - /// - /// The priority of this event. - /// - /// An event priority is a value from 0 - 99. The higher value, the higher priority. - /// - /// The default priority is 80, but varies depending on the type of event. - /// - /// - /// This method is intended for letting robot developers create their own event types. - /// - /// It is not possible to change the priority of an event after it has been added to the event - /// queue of the robot. - /// - /// - public virtual int Priority - { - get { return priority; } - set - { - if (addedToQueue) - { - LoggerN.WriteLineToRobotsConsole("SYSTEM: The priority of an event cannot be changed after it has been added the event queue."); - } - else - { - SetPriorityHidden(value); - } - } - } - - /// - /// Hidden method for setting the exact time when this event occurred. - /// - /// - /// This method is called by the game engine only. - /// - /// the time when this event occurred. - // This method must be invisible on Robot API - private void SetTimeHidden(long time) - { - // we do not replace time which is set by robot to the future - if (this.time < time) - { - this.time = time; - } - // when this flag is set, robots are not allowed to change the time or priority of the event anymore - addedToQueue = true; - } - - /// - /// Hidden method for setting the priority from the game engine without checking for the 'addedToQueue' flag. - /// - /// - /// This method is called by the game engine only. - /// - /// the new priority of this event. - // This method must be invisible on Robot API - private void SetPriorityHidden(int newPriority) - { - if (newPriority < 0) - { - LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99"); - LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for " + GetType().Name + " will be 0"); - newPriority = 0; - } - else if (newPriority > 99) - { - LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority must be between 0 and 99"); - LoggerN.WriteLineToRobotsConsole("SYSTEM: Priority for " + GetType().Name + " will be 99"); - newPriority = 99; - } - priority = newPriority; - } - - /// - /// Dispatch this event for a robot, it's statistics, and graphics context. - /// - /// the robot to dispatch to. - /// the robot to statistics to. - /// the robot to graphics to. - // This method must be invisible on Robot API - internal virtual void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - } - - /// - /// The default priority of this event class. - /// - // This method must be invisible on Robot API - internal virtual int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - /// - /// Checks if this event must be delivered even after timeout. - /// - /// - /// true when this event must be delivered even after timeout; - /// false otherwise. - /// - // This method must be invisible on Robot API - internal virtual bool IsCriticalEvent - { - get { return false; } - } - - // This method must be invisible on Robot API - internal virtual byte SerializationType - { - get { throw new System.Exception("Serialization not supported on this event type"); } - } - - // Needed for .NET version - // This method must be invisible on Robot API - internal virtual void UpdateBullets(Dictionary bullets) - { - } - - /// - /// Returns a hidden event helper for accessing hidden methods on this object. - /// - // This method must be invisible on Robot API - private static IHiddenEventHelper createHiddenHelper() - { - return new HiddenEventHelper(); - } - - /// - /// Hidden event helper implementation for accessing the internal methods of an event. - /// - /// - /// This class is used internally by the game engine. - /// - // This method must be invisible on Robot API - private class HiddenEventHelper : IHiddenEventHelper - { - public void SetTime(Event evnt, long newTime) - { - evnt.SetTimeHidden(newTime); - } - - public void SetDefaultPriority(Event evnt) - { - evnt.Priority = evnt.DefaultPriority; - } - - public void SetPriority(Event evnt, int newPriority) - { - evnt.SetPriorityHidden(newPriority); - } - - public bool IsCriticalEvent(Event evnt) - { - return evnt.IsCriticalEvent; - } - - public void Dispatch(Event evnt, IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - evnt.Dispatch(robot, statics, graphics); - } - - public byte GetSerializationType(Event evnt) - { - return evnt.SerializationType; - } - - // Needed for .NET version - public void UpdateBullets(Event evnt, Dictionary bullets) - { - evnt.UpdateBullets(bullets); - } - } - } -} -//doc diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/GunTurnCompleteCondition.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/GunTurnCompleteCondition.cs deleted file mode 100644 index e6f7fe0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/GunTurnCompleteCondition.cs +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode -{ - /// - /// A prebuilt condition you can use that indicates your gun has finished turning. - /// - /// - public class GunTurnCompleteCondition : Condition - { - private readonly AdvancedRobot robot; - - /// - /// Creates a new GunTurnCompleteCondition with default priority. - /// The default priority is 80. - /// - /// Your robot, which must be an - public GunTurnCompleteCondition(AdvancedRobot robot) - { - this.robot = robot; - } - - /// - /// Creates a new GunTurnCompleteCondition with a specific priority. - /// A condition priority is a value from 0 - 99. The higher value, the - /// higher priority. The default priority is 80. - /// - /// - /// Your robot, which must be an - /// The priority of this condition - public GunTurnCompleteCondition(AdvancedRobot robot, int priority) - { - this.robot = robot; - this.priority = priority; - } - - /// - /// Tests if the gun has stopped turning. - /// Returns true if the gun has stopped turning - /// - public override bool Test() - { - return (robot.GunTurnRemaining == 0); - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/HitByBulletEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/HitByBulletEvent.cs deleted file mode 100644 index 394eff0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/HitByBulletEvent.cs +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A HitByBulletEvent is sent to - /// when your robot has been hit by a bullet. - /// You can use the information contained in this event to determine what to do. - /// - [Serializable] - public sealed class HitByBulletEvent : Event - { - private const int DEFAULT_PRIORITY = 20; - - private readonly double bearing; - private readonly Bullet bullet; - - /// - /// Called by the game to create a new HitByBulletEvent. - /// - public HitByBulletEvent(double bearing, Bullet bullet) - { - this.bearing = bearing; - this.bullet = bullet; - } - - /// - /// Returns the bearing to the bullet, relative to your robot's heading, - /// in degrees (-180 < getBearing() <= 180). - ///

- /// If you were to TurnRight(event.Bearing), you would be facing the - /// direction the bullet came from. The calculation used here is: - /// (bullet's heading in degrees + 180) - (your heading in degrees) - ///

- public double Bearing - { - get { return bearing*180.0/Math.PI; } - } - - /// - /// Returns the bearing to the bullet, relative to your robot's heading, - /// in radians (-Math.PI < getBearingRadians() <= Math.PI). - ///

- /// If you were to TurnRightRadians(event.BearingRadians), you would be - /// facing the direction the bullet came from. The calculation used here is: - /// (bullet's heading in radians + Math.PI) - (your heading in radians) - ///

- public double BearingRadians - { - get { return bearing; } - } - - /// - /// Returns the bullet that hit your robot. - /// - public Bullet Bullet - { - get { return bullet; } - } - - /// - /// Returns the heading of the bullet when it hit you, in degrees - /// (0 <= getHeading() < 360). - ///

- /// Note: This is not relative to the direction you are facing. The robot - /// that fired the bullet was in the opposite direction of getHeading() when - /// it fired the bullet. - ///

- public double Heading - { - get { return bullet.Heading; } - } - - /// - /// Returns the heading of the bullet when it hit you, in radians - /// (0 <= getHeadingRadians() < 2 * PI). - ///

- /// Note: This is not relative to the direction you are facing. The robot - /// that fired the bullet was in the opposite direction of - /// getHeadingRadians() when it fired the bullet. - ///

- public double HeadingRadians - { - get { return bullet.HeadingRadians; } - } - - /// - /// Returns the name of the robot that fired the bullet. - /// - public string Name - { - get { return bullet.Name; } - } - - /// - /// Returns the power of this bullet. The damage you take (in fact, already - /// took) is 4 * power, plus 2 * (power-1) if power > 1. The robot that fired - /// the bullet receives 3 * power back. - /// - public double Power - { - get { return bullet.Power; } - } - - /// - /// Returns the velocity of this bullet. - /// - public double Velocity - { - get { return bullet.Velocity; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnHitByBullet(this); - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.HitByBulletEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - var obj = (HitByBulletEvent) objec; - - return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(RbSerializerN.Bullet_TYPE, obj.bullet) - + RbSerializerN.SIZEOF_DOUBLE; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (HitByBulletEvent) objec; - - serializer.serialize(buffer, RbSerializerN.Bullet_TYPE, obj.bullet); - serializer.serialize(buffer, obj.bearing); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - var bullet = (Bullet) serializer.deserializeAny(buffer); - double bearing = buffer.getDouble(); - - return new HitByBulletEvent(bearing, bullet); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/HitRobotEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/HitRobotEvent.cs deleted file mode 100644 index 675b933..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/HitRobotEvent.cs +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A HitRobotEvent is sent to - /// when your robot collides with another robot. - /// You can use the information contained in this event to determine what to do. - /// - [Serializable] - public sealed class HitRobotEvent : Event - { - private const int DEFAULT_PRIORITY = 40; - - private readonly string name; - private readonly double bearing; - private readonly double energy; - private readonly bool atFault; - - /// - /// Called by the game to create a new HitRobotEvent. - /// - public HitRobotEvent(string name, double bearing, double energy, bool atFault) - { - this.name = name; - this.bearing = bearing; - this.energy = energy; - this.atFault = atFault; - } - - /// - /// Returns the bearing to the robot you hit, relative to your robot's - /// heading, in degrees (-180 <= getBearing() < 180) - /// - public double Bearing - { - get { return bearing*180.0/Math.PI; } - } - - /// - /// Returns the bearing to the robot you hit, relative to your robot's - /// heading, in radians (-PI <= getBearingRadians() < PI) - /// - public double BearingRadians - { - get { return bearing; } - } - - /// - /// Returns the amount of energy of the robot you hit. - /// - public double Energy - { - get { return energy; } - } - - /// - /// Returns the name of the robot you hit. - /// - public string Name - { - get { return name; } - } - - /// - /// Checks if your robot was moving towards the robot that was hit. - ///

- /// If returns true then your robot's movement (including - /// turning) will have stopped and been marked complete. - ///

- /// Note: If two robots are moving toward each other and collide, they will - /// each receive two HitRobotEvents. The first will be the one if isMyFault() - /// returns true. - ///

- public bool IsMyFault - { - get { return atFault; } - } - - /// - public override int CompareTo(Event evnt) - { - int res = base.CompareTo(evnt); - - if (res != 0) - { - return res; - } - - // Compare the IsMyFault, if the events are HitRobotEvents - // The isMyFault has higher priority when it is set compared to when it is not set - if (evnt is HitRobotEvent) - { - int compare1 = (this).IsMyFault ? -1 : 0; - int compare2 = ((HitRobotEvent) evnt).IsMyFault ? -1 : 0; - - return compare1 - compare2; - } - - // No difference found - return 0; - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnHitRobot(this); - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.HitRobotEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - var obj = (HitRobotEvent) objec; - - return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.name) + 2*RbSerializerN.SIZEOF_DOUBLE - + RbSerializerN.SIZEOF_BOOL; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (HitRobotEvent) objec; - - serializer.serialize(buffer, obj.name); - serializer.serialize(buffer, obj.bearing); - serializer.serialize(buffer, obj.energy); - serializer.serialize(buffer, obj.atFault); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - string robotName = serializer.deserializeString(buffer); - double bearing = buffer.getDouble(); - double energy = buffer.getDouble(); - bool atFault = serializer.deserializeBoolean(buffer); - - return new HitRobotEvent(robotName, bearing, energy, atFault); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/HitWallEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/HitWallEvent.cs deleted file mode 100644 index 1b73982..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/HitWallEvent.cs +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A HitWallEvent is sent to - /// when you collide a wall. - /// You can use the information contained in this event to determine what to do. - /// - [Serializable] - public sealed class HitWallEvent : Event - { - private const int DEFAULT_PRIORITY = 30; - - private readonly double bearing; - - /// - /// Called by the game to create a new HitWallEvent. - /// - public HitWallEvent(double bearing) - { - this.bearing = bearing; - } - - /// - /// Returns the bearing to the wall you hit, relative to your robot's - /// heading, in degrees (-180 <= getBearing() < 180) - /// - public double Bearing - { - get { return bearing*180.0/Math.PI; } - } - - - /// - /// Returns the bearing to the wall you hit, relative to your robot's - /// heading, in radians (-PI <= getBearingRadians() < PI) - /// - public double BearingRadians - { - get { return bearing; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnHitWall(this); - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.HitWallEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_DOUBLE; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (HitWallEvent) objec; - - serializer.serialize(buffer, obj.bearing); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - double bearing = buffer.getDouble(); - - return new HitWallEvent(bearing); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/IBorderSentry.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/IBorderSentry.cs deleted file mode 100644 index ea60f9c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/IBorderSentry.cs +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode -{ - /// - /// A robot that implement IBorderSentry is a robot type used for keeping other robots away from the borders, - /// i.e. guarding the borders in order to prevent "wall crawlers".
- /// Robots that implement IBorderSentry have 400 extra life/energy (500 in total), but is placed at the border - /// of the battlefield when the game is started.
- /// Border sentry robots cannot move away from the border area, and they can only make damage to robots that - /// are moving into the border area. The size of the border area is determined by the - /// battle rules.
- /// This type of robot is intended for use in battles where robots should be forced away from the borders in - /// order to prevent "wall crawlers".
- /// Border sentry robots does not get scores, and will not occur in the battle results or rankings. - ///
- /// - /// - /// - /// - /// - /// - /// - public interface IBorderSentry - { - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/IDroid.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/IDroid.cs deleted file mode 100644 index 4c682b3..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/IDroid.cs +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode -{ - /// - /// Robots that implement IDroid have no scanner, but an extra 20 life/energy. - /// This class is intended for use in teams. - /// - /// - /// - /// - /// - /// - /// - public interface IDroid - { - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/IGraphics.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/IGraphics.cs deleted file mode 100644 index e92c808..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/IGraphics.cs +++ /dev/null @@ -1,160 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Drawing; - -namespace Robocode -{ - /// - /// - /// - public interface IGraphics - { -#pragma warning disable 1591 - //TODO xml doc - void DrawLine(Pen pen, float x1, float y1, float x2, float y2); - void DrawLine(Pen pen, PointF pt1, PointF pt2); - void DrawLine(Pen pen, int x1, int y1, int x2, int y2); - void DrawLine(Pen pen, Point pt1, Point pt2); - void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle); - void DrawArc(Pen pen, RectangleF rect, float startAngle, float sweepAngle); - void DrawArc(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle); - void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle); - void DrawRectangle(Pen pen, RectangleF rect); - void DrawRectangle(Pen pen, Rectangle rect); - void DrawRectangle(Pen pen, float x, float y, float width, float height); - void DrawRectangle(Pen pen, int x, int y, int width, int height); - void DrawEllipse(Pen pen, RectangleF rect); - void DrawEllipse(Pen pen, float x, float y, float width, float height); - void DrawEllipse(Pen pen, Rectangle rect); - void DrawEllipse(Pen pen, int x, int y, int width, int height); - void DrawPie(Pen pen, RectangleF rect, float startAngle, float sweepAngle); - void DrawPie(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle); - void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle); - void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle); - void DrawPolygon(Pen pen, PointF[] points); - void DrawPolygon(Pen pen, Point[] points); - void FillRectangle(Brush brush, RectangleF rect); - void FillRectangle(Brush brush, float x, float y, float width, float height); - void FillRectangle(Brush brush, Rectangle rect); - void FillRectangle(Brush brush, int x, int y, int width, int height); - void FillPolygon(Brush brush, PointF[] points); - void FillPolygon(Brush brush, Point[] points); - void FillEllipse(Brush brush, RectangleF rect); - void FillEllipse(Brush brush, float x, float y, float width, float height); - void FillEllipse(Brush brush, Rectangle rect); - void FillEllipse(Brush brush, int x, int y, int width, int height); - void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle); - void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle); - void FillPie(Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle); - void DrawString(string s, Font font, Brush brush, int x, int y); - void DrawString(string s, Font font, Brush brush, float x, float y); - void DrawString(string s, Font font, Brush brush, PointF point); - void DrawString(string s, Font font, Brush brush, Point point); - - /* - void DrawLines(Pen pen, PointF[] points); - void DrawLines(Pen pen, Point[] points); - void DrawRectangles(Pen pen, RectangleF[] rects); - void DrawRectangles(Pen pen, Rectangle[] rects); - void DrawPath(Pen pen, GraphicsPath path); - void DrawCurve(Pen pen, PointF[] points); - void DrawCurve(Pen pen, PointF[] points, float tension); - void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments); - void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension); - void DrawCurve(Pen pen, Point[] points); - void DrawCurve(Pen pen, Point[] points, float tension); - void DrawCurve(Pen pen, Point[] points, int offset, int numberOfSegments, float tension); - void DrawClosedCurve(Pen pen, PointF[] points); - void DrawClosedCurve(Pen pen, PointF[] points, float tension, FillMode fillmode); - void DrawClosedCurve(Pen pen, Point[] points); - void DrawClosedCurve(Pen pen, Point[] points, float tension, FillMode fillmode); - void FillPolygon(Brush brush, PointF[] points, FillMode fillMode); - void FillPolygon(Brush brush, Point[] points, FillMode fillMode); - void FillRectangles(Brush brush, RectangleF[] rects); - void FillRectangles(Brush brush, Rectangle[] rects); - void FillClosedCurve(Brush brush, PointF[] points); - void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode); - void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode, float tension); - void FillClosedCurve(Brush brush, Point[] points); - void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode); - void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode, float tension); - void FillRegion(Brush brush, Region region); - void FillPath(Brush brush, GraphicsPath path); - void DrawString(string s, Font font, Brush brush, float x, float y, StringFormat format); - void DrawString(string s, Font font, Brush brush, PointF point, StringFormat format); - void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle); - void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format); - - SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat, - out int charactersFitted, out int linesFilled); - - SizeF MeasureString(string text, Font font, PointF origin, StringFormat stringFormat); - SizeF MeasureString(string text, Font font, SizeF layoutArea); - SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat); - SizeF MeasureString(string text, Font font); - SizeF MeasureString(string text, Font font, int width); - SizeF MeasureString(string text, Font font, int width, StringFormat format); - Region[] MeasureCharacterRanges(string text, Font font, RectangleF layoutRect, StringFormat stringFormat); - - void ResetTransform(); - void MultiplyTransform(Matrix matrix); - void MultiplyTransform(Matrix matrix, MatrixOrder order); - void TranslateTransform(float dx, float dy); - void TranslateTransform(float dx, float dy, MatrixOrder order); - void ScaleTransform(float sx, float sy); - void ScaleTransform(float sx, float sy, MatrixOrder order); - void RotateTransform(float angle); - void RotateTransform(float angle, MatrixOrder order); - void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF[] pts); - void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, Point[] pts); - void SetClip(Graphics g); - void SetClip(Graphics g, CombineMode combineMode); - void SetClip(Rectangle rect); - void SetClip(Rectangle rect, CombineMode combineMode); - void SetClip(RectangleF rect); - void SetClip(RectangleF rect, CombineMode combineMode); - void SetClip(GraphicsPath path); - void SetClip(GraphicsPath path, CombineMode combineMode); - void SetClip(Region region, CombineMode combineMode); - void IntersectClip(Rectangle rect); - void IntersectClip(RectangleF rect); - void IntersectClip(Region region); - void ExcludeClip(Rectangle rect); - void ExcludeClip(Region region); - void ResetClip(); - void TranslateClip(float dx, float dy); - void TranslateClip(int dx, int dy); - bool IsVisible(int x, int y); - bool IsVisible(Point point); - bool IsVisible(float x, float y); - bool IsVisible(PointF point); - bool IsVisible(int x, int y, int width, int height); - bool IsVisible(Rectangle rect); - bool IsVisible(float x, float y, float width, float height); - bool IsVisible(RectangleF rect); - CompositingMode CompositingMode { get; set; } - Point RenderingOrigin { get; set; } - CompositingQuality CompositingQuality { get; set; } - TextRenderingHint TextRenderingHint { get; set; } - int TextContrast { get; set; } - SmoothingMode SmoothingMode { get; set; } - PixelOffsetMode PixelOffsetMode { get; set; } - InterpolationMode InterpolationMode { get; set; } - Matrix Transform { get; set; } - GraphicsUnit PageUnit { get; set; } - float PageScale { get; set; } - float DpiX { get; } - float DpiY { get; } - Region Clip { get; set; } - RectangleF ClipBounds { get; } - bool IsClipEmpty { get; } - RectangleF VisibleClipBounds { get; } - bool IsVisibleClipEmpty { get; } - */ - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/JuniorRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/JuniorRobot.cs deleted file mode 100644 index 0ea5d59..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/JuniorRobot.cs +++ /dev/null @@ -1,1324 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using System.IO; -using Robocode.Exception; -using Robocode.RobotInterfaces; -using Robocode.RobotInterfaces.Peer; -using Robocode.Util; - -namespace Robocode -{ - /// - /// This is the simplest robot type, which is simpler than the and - /// classes. The JuniorRobot has a simplified model, in - /// purpose of teaching programming skills to inexperienced in programming - /// students. The simplified robot model will keep player from overwhelming of - /// Robocode's rules, programming syntax and programming concept. - ///

- /// Instead of using getters and setters, public fields are provided for - /// receiving information like the last scanned robot, the coordinate of the - /// robot etc. - ///

- /// All methods on this class are blocking calls, i.e. they do not return before - /// their action has been completed and will at least take one turn to execute. - /// However, setting colors is executed immediately and does not cost a turn to - /// perform. - /// - /// - /// - /// - ///

- public abstract class JuniorRobot : IJuniorRobot - { - internal IBasicRobotPeer peer; - internal TextWriter _output; - - /// - /// The color black (0x000000) - /// - public const int BLACK=0; - - /// - /// The color white (0xFFFFFF) - /// - public const int WHITE = 0xFFFFFF; - - /// - /// The color red (0xFF0000) - /// - public const int RED = 0xFF0000; - - /// - /// The color orange (0xFFA500) - /// - public const int ORANGE = 0xFFA500; - - /// - /// The color yellow (0xFFFF00) - /// - public const int YELLOW = 0xFFFF00; - - /// - /// The color green (0x008000) - /// - public const int GREEN = 0x008000; - - /// - /// The color blue (0x0000FF) - /// - public const int BLUE = 0x0000FF; - - /// - /// The color purple (0x800080) - /// - public const int PURPLE = 0x800080; - - /// - /// The color brown (0x8B4513) - /// - public const int BROWN = 0x8B4513; - - /// - /// The color gray (0x808080) - /// - public const int GRAY = 0x808080; - - /// - /// Contains the width of the battlefield. - /// - /// - /// - private int fieldWidth; - - /// - /// Contains the height of the battlefield. - /// - /// - /// - private int fieldHeight; - - /// - /// Current number of other robots on the battle field. - /// - private int others; - - /// - /// Current energy of this robot, where 100 means full energy and 0 means no energy (dead). - /// - private int energy; - - /// - /// Current horizontal location of this robot (in pixels). - /// - /// - /// - private int robotX; - - /// - /// Current vertical location of this robot (in pixels). - /// - /// - /// - private int robotY; - - /// - /// Current heading angle of this robot (in degrees). - /// - /// - /// - /// - /// - /// - /// - /// - /// - private int heading; - - /// - /// Current gun heading angle of this robot (in degrees). - /// - /// - /// - /// - /// - /// - /// - private int gunHeading; - - /// - /// Current gun heading angle of this robot compared to its body (in degrees). - /// - /// - /// - /// - /// - /// - /// - private int gunBearing; - - /// - /// Flag specifying if the gun is ready to Fire, i.e. gun heat <= 0. - /// true means that the gun is able to Fire; false - /// means that the gun cannot Fire yet as it still needs to cool down. - /// - /// - /// - /// - private bool gunReady; - - /// - /// Current distance to the scanned nearest other robot (in pixels). - /// If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - /// - private int scannedDistance = -1; - - /// - /// Current angle to the scanned nearest other robot (in degrees). - /// If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - /// - private int scannedAngle = -1; - - /// - /// Current angle to the scanned nearest other robot (in degrees) compared to - /// the body of this robot. - /// If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - /// - private int scannedBearing = -1; - - /// - /// Current velocity of the scanned nearest other robot. - /// If there is no robot in the radar's sight, this field will be -99. - /// Note that a positive value means that the robot moves forward, a negative - /// value means that the robot moved backward, and 0 means that the robot is - /// not moving at all. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - /// - private int scannedVelocity = -99; - - /// - /// Current heading of the scanned nearest other robot (in degrees). - /// If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - /// - private int scannedHeading = -1; - - /// - /// Current energy of scanned nearest other robot. - /// If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - private int scannedEnergy = -1; - - /// - /// Latest angle from where this robot was hit by a bullet (in degrees). - /// If the robot has never been hit, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - private int hitByBulletAngle = -1; - - /// - /// Latest angle from where this robot was hit by a bullet (in degrees) - /// compared to the body of this robot. - /// If the robot has never been hit, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - private int hitByBulletBearing = -1; - - /// - /// Latest angle where this robot has hit another robot (in degrees). - /// If this robot has never hit another robot, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - private int hitRobotAngle = -1; - - /// - /// Latest angle where this robot has hit another robot (in degrees) - /// compared to the body of this robot. - /// If this robot has never hit another robot, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - private int hitRobotBearing = -1; - - /// - /// Latest angle where this robot has hit a wall (in degrees). - /// If this robot has never hit a wall, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - private int hitWallAngle = -1; - - /// - /// Latest angle where this robot has hit a wall (in degrees) - /// compared to the body of this robot. - /// If this robot has never hit a wall, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - private int hitWallBearing = -1; - - /// - /// The robot event handler for this robot. - /// - private InnerEventHandler innerEventHandler; - - - /// - /// The Out stream your robot should use to print. - ///

- /// You can view the print-outs by clicking the button for your robot in the - /// right side of the battle window. - ///

- /// - /// - /// // Print Out a line each time my robot hits another robot - /// public void OnHitRobot(HitRobotEvent e) - /// { - /// Out.WriteLine("I hit a robot! My energy: " + Energy + " his energy: " + e.Energy); - /// } - /// - /// - ///

- public TextWriter Out - { - get { return _output; } - } - - /// - /// Contains the width of the battlefield. - /// - /// - /// - public int FieldWidth - { - get { return fieldWidth; } - } - - /// - /// Contains the height of the battlefield. - /// - /// - /// - public int FieldHeight - { - get { return fieldHeight; } - } - - /// - /// Current number of other robots on the battle field. - /// - public int Others - { - get { return others; } - } - - /// - /// Current energy of this robot, where 100 means full energy and 0 means no energy (dead). - /// - public int Energy - { - get { return energy; } - } - - /// - /// Current horizontal location of this robot (in pixels). - /// - /// - /// - public int RobotX - { - get { return robotX; } - } - - /// - /// Current vertical location of this robot (in pixels). - /// - /// - /// - public int RobotY - { - get { return robotY; } - } - - /// - /// Current heading angle of this robot (in degrees). - /// - /// - /// - /// - /// - /// - /// - /// - /// - public int Heading - { - get { return heading; } - } - - /// - /// Current gun heading angle of this robot (in degrees). - /// - /// - /// - /// - /// - /// - /// - public int GunHeading - { - get { return gunHeading; } - } - - /// - /// Current gun heading angle of this robot compared to its body (in degrees). - /// - /// - /// - /// - /// - /// - /// - public int GunBearing - { - get { return gunBearing; } - } - - /// - /// Flag specifying if the gun is ready to Fire, i.e. gun heat <= 0. - /// true means that the gun is able to Fire; false - /// means that the gun cannot Fire yet as it still needs to cool down. - /// - /// - /// - /// - public bool IsGunReady - { - get { return gunReady; } - } - - /// - /// Current distance to the scanned nearest other robot (in pixels). - /// If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - /// - public int ScannedDistance - { - get { return scannedDistance; } - } - - /// - /// Current angle to the scanned nearest other robot (in degrees). - /// If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - /// - public int ScannedAngle - { - get { return scannedAngle; } - } - - /// - /// Current angle to the scanned nearest other robot (in degrees) compared to - /// the body of this robot. - /// If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - /// - public int ScannedBearing - { - get { return scannedBearing; } - } - - /// - /// Current velocity of the scanned nearest other robot. - /// If there is no robot in the radar's sight, this field will be -99. - /// Note that a positive value means that the robot moves forward, a negative - /// value means that the robot moved backward, and 0 means that the robot is - /// not moving at all. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - /// - public int ScannedVelocity - { - get { return scannedVelocity; } - } - - /// - /// Current heading of the scanned nearest other robot (in degrees). - /// If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - /// - public int ScannedHeading - { - get { return scannedHeading; } - } - - /// - /// Current energy of scanned nearest other robot. - /// If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - /// - /// - /// - public int ScannedEnergy - { - get { return scannedEnergy; } - } - - /// - /// Latest angle from where this robot was hit by a bullet (in degrees). - /// If the robot has never been hit, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - public int HitByBulletAngle - { - get { return hitByBulletAngle; } - } - - /// - /// Latest angle from where this robot was hit by a bullet (in degrees) - /// compared to the body of this robot. - /// If the robot has never been hit, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - public int HitByBulletBearing - { - get { return hitByBulletBearing; } - } - - /// - /// Latest angle where this robot has hit another robot (in degrees). - /// If this robot has never hit another robot, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - public int HitRobotAngle - { - get { return hitRobotAngle; } - } - - /// - /// Latest angle where this robot has hit another robot (in degrees) - /// compared to the body of this robot. - /// If this robot has never hit another robot, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - public int HitRobotBearing - { - get { return hitRobotBearing; } - } - - /// - /// Latest angle where this robot has hit a wall (in degrees). - /// If this robot has never hit a wall, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - public int HitWallAngle - { - get { return hitWallAngle; } - } - - /// - /// Latest angle where this robot has hit a wall (in degrees) - /// compared to the body of this robot. - /// If this robot has never hit a wall, this field will be less than 0, i.e. -1. - /// This field will not be updated while event is active. - /// - /// - /// - /// - public int HitWallBearing - { - get { return hitWallBearing; } - } - - /// - void IBasicRobot.SetOut(TextWriter outpt) - { - _output = outpt; - } - - /// - void IBasicRobot.SetPeer(IBasicRobotPeer per) - { - peer = per; - } - - /// - /// Throws a RobotException. This method should be called when the robot's peer - /// is uninitialized. - /// - internal static void UninitializedException() - { - throw new RobotException( - "You cannot call the methods before your Run() method is called, or you are using a Robot object that the game doesn't know about."); - } - - /// - IRunnable IBasicRobot.GetRobotRunnable() - { - return getEventHandler(); - } - - /// - IBasicEvents IBasicRobot.GetBasicEventListener() - { - return getEventHandler(); - } - - - /// - /// Moves this robot forward by pixels. - /// - /// - /// - /// - /// The amount of pixels to move forward - public void Ahead(int distance) - { - if (peer != null) - { - peer.Move(distance); - } - else - { - UninitializedException(); - } - } - - /// - /// Moves this robot backward by pixels. - /// - /// - /// - /// - /// - /// the amount of pixels to move backward - public void Back(int distance) - { - Ahead(-distance); - } - - /// - /// Turns the gun to the specified angle (in degrees) relative to body of this robot. - /// The gun will turn to the side with the shortest delta angle to the specified angle. - /// - /// - /// - /// - /// - /// - /// the angle to turn the gun to relative to the body of this robot - public void BearGunTo(int angle) - { - if (peer != null) - { - peer.TurnGun( - Utils.NormalRelativeAngle(peer.GetBodyHeading() + Utils.ToRadians(angle) - peer.GetGunHeading())); - } - else - { - UninitializedException(); - } - } - - /// - /// Skips a turn. - /// - /// - public void DoNothing() - { - if (peer != null) - { - peer.Execute(); - } - else - { - UninitializedException(); - } - } - - /// - /// Skips the specified number of turns. - /// - /// - /// The number of turns to skip - public void DoNothing(int turns) - { - if (turns <= 0) - { - return; - } - if (peer != null) - { - for (int i = 0; i < turns; i++) - { - peer.Execute(); - } - } - else - { - UninitializedException(); - } - } - - /// - /// Fires a bullet with the default power of 1. - /// If the gun heat is more than 0 and hence cannot Fire, this method will - /// suspend until the gun is ready to Fire, and then Fire a bullet. - /// - /// - /// - public void Fire() - { - Fire(1); - } - - /// - /// Fires a bullet with the specified bullet power, which is between 0.1 and 3 - /// where 3 is the maximum bullet power. - /// If the gun heat is more than 0 and hence cannot Fire, this method will - /// suspend until the gun is ready to Fire, and then Fire a bullet. - /// - /// - /// Between 0.1 and 3 - public void Fire(double power) - { - if (peer != null) - { - getEventHandler().juniorFirePower = power; - peer.Execute(); - } - else - { - UninitializedException(); - } - } - - /// - /// This event method is called from the game when this robot has been hit - /// by another robot's bullet. When this event occurs the - /// and fields values - /// are automatically updated. - /// - /// - /// - /// - public virtual void OnHitByBullet() - { - } - - /// - /// This event method is called from the game when a bullet from this robot - /// has hit another robot. When this event occurs the - /// and fields values are automatically updated. - /// - /// - /// - /// - public virtual void OnHitRobot() - { - } - - /// - /// This event method is called from the game when this robot has hit a wall. - /// When this event occurs the and - /// fields values are automatically updated. - /// - /// - /// - /// - public virtual void OnHitWall() - { - } - - /// - /// This event method is called from the game when the radar detects another - /// robot. When this event occurs the , - /// , , and - /// field values are automatically updated. - /// - /// - /// - /// - /// - public virtual void OnScannedRobot() - { - } - - /// - /// The main method in every robot. You must override this to set up your - /// robot's basic behavior. - ///

- /// - /// - /// // A basic robot that moves around in a square - /// public void Run() - /// { - /// Ahead(100); - /// TurnRight(90); - /// } - /// - /// - /// This method is automatically re-called when it has returned. - ///

- public virtual void Run() - { - } - - /// - /// Sets the colors of the robot. The color values are RGB values. - /// You can use the colors that are already defined for this class. - /// - /// - /// The RGB color value for the body - /// The RGB color value for the gun - /// The RGB color value for the radar - public void SetColors(int bodyColor, int gunColor, int radarColor) - { - if (peer != null) - { - peer.SetBodyColor(Color.FromArgb(bodyColor)); - peer.SetGunColor(Color.FromArgb(gunColor)); - peer.SetRadarColor(Color.FromArgb(radarColor)); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the colors of the robot. The color values are RGB values. - /// You can use the colors that are already defined for this class. - /// - /// - /// The RGB color value for the body - /// The RGB color value for the gun - /// The RGB color value for the radar - /// The RGB color value for the bullets - /// The RGB color value for the scan arc - public void SetColors(int bodyColor, int gunColor, int radarColor, int bulletColor, int scanArcColor) - { - if (peer != null) - { - peer.SetBodyColor(Color.FromArgb(bodyColor)); - peer.SetGunColor(Color.FromArgb(gunColor)); - peer.SetRadarColor(Color.FromArgb(radarColor)); - peer.SetBulletColor(Color.FromArgb(bulletColor)); - peer.SetScanColor(Color.FromArgb(scanArcColor)); - } - else - { - UninitializedException(); - } - } - - /// - /// Moves this robot forward by pixels and turns this robot left by degrees - /// at the same time. The robot will move in a curve that follows a perfect - /// circle, and the moving and turning will end at the same time. - ///

- /// Note that the max. velocity and max. turn rate is automatically adjusted, - /// which means that the robot will move slower the sharper the turn is - /// compared to the distance. - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// The amount of pixels to move forward - /// The amount of degrees to turn to the left - public void TurnAheadLeft(int distance, int degrees) - { - TurnAheadRight(distance, -degrees); - } - - /// - /// Moves this robot forward by pixels and turns this robot right by degrees - /// at the same time. The robot will move in a curve that follows a perfect - /// circle, and the moving and turning will end at the same time. - ///

- /// Note that the max. velocity and max. turn rate is automatically adjusted, - /// which means that the robot will move slower the sharper the turn is - /// compared to the distance. - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// The amount of pixels to move forward - /// The amount of degrees to turn to the right - public void TurnAheadRight(int distance, int degrees) - { - if (peer != null) - { - ((IJuniorRobotPeer) peer).TurnAndMove(distance, Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Moves this robot backward by pixels and turns this robot left by degrees - /// at the same time. The robot will move in a curve that follows a perfect - /// circle, and the moving and turning will end at the same time. - ///

- /// Note that the max. velocity and max. turn rate is automatically adjusted, - /// which means that the robot will move slower the sharper the turn is - /// compared to the distance. - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// The amount of pixels to move backward - /// The amount of degrees to turn to the left - public void TurnBackLeft(int distance, int degrees) - { - TurnAheadRight(-distance, degrees); - } - - /// - /// Moves this robot backward by pixels and turns this robot right by degrees - /// at the same time. The robot will move in a curve that follows a perfect - /// circle, and the moving and turning will end at the same time. - ///

- /// Note that the max. velocity and max. turn rate is automatically adjusted, - /// which means that the robot will move slower the sharper the turn is - /// compared to the distance. - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// The amount of pixels to move backward - /// The amount of degrees to turn to the right - public void TurnBackRight(int distance, int degrees) - { - TurnAheadRight(-distance, -degrees); - } - - /// - /// Turns the gun left by degrees. - /// - /// - /// - /// - /// - /// - /// The amount of degrees to turn the gun to the left - public void TurnGunLeft(int degrees) - { - TurnGunRight(-degrees); - } - - /// - /// Turns the gun right by degrees. - /// - /// - /// - /// - /// - /// - /// The amount of degrees to turn the gun to the right - public void TurnGunRight(int degrees) - { - if (peer != null) - { - peer.TurnGun(Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Turns the gun to the specified angle (in degrees). - /// The gun will turn to the side with the shortest delta angle to the - /// specified angle. - /// - /// - /// - /// - /// - /// - /// The angle to turn the gun to - public void TurnGunTo(int angle) - { - if (peer != null) - { - peer.TurnGun(Utils.NormalRelativeAngle(Utils.ToRadians(angle) - peer.GetGunHeading())); - } - else - { - UninitializedException(); - } - } - - /// - /// Turns this robot left by degrees. - /// - /// - /// - /// - /// - /// - /// - /// - /// The amount of degrees to turn to the left - public void TurnLeft(int degrees) - { - TurnRight(-degrees); - } - - /// - /// Turns this robot right by degrees. - /// - /// - /// - /// - /// - /// - /// - /// - /// The amount of degrees to turn to the right - public void TurnRight(int degrees) - { - if (peer != null) - { - peer.TurnBody(Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Turns this robot to the specified angle (in degrees). - /// The robot will turn to the side with the shortest delta angle to the - /// specified angle. - /// - /// - /// - /// - /// - /// - /// - /// - /// The angle to turn this robot to - public void TurnTo(int angle) - { - if (peer != null) - { - peer.TurnBody(Utils.NormalRelativeAngle(Utils.ToRadians(angle) - peer.GetBodyHeading())); - } - else - { - UninitializedException(); - } - } - - /// - /// Returns the event handler of this robot. - /// - private InnerEventHandler getEventHandler() - { - if (innerEventHandler == null) - { - innerEventHandler = new InnerEventHandler(this); - } - return innerEventHandler; - } - - /// - /// The JuniorRobot event handler, which extends the basic robot events, - /// IBasicEvents, and IRunnable. - /// - private sealed class InnerEventHandler : IBasicEvents, IRunnable - { - public InnerEventHandler(JuniorRobot robot) - { - this.robot = robot; - } - - private readonly JuniorRobot robot; - internal double juniorFirePower; - private long currentTurn; - - public void OnBulletHit(BulletHitEvent evnt) - { - } - - public void OnBulletHitBullet(BulletHitBulletEvent evnt) - { - } - - public void OnBulletMissed(BulletMissedEvent evnt) - { - } - - public void OnDeath(DeathEvent evnt) - { - } - - public void OnHitByBullet(HitByBulletEvent evnt) - { - double angle = robot.peer.GetBodyHeading() + evnt.BearingRadians; - - robot.hitByBulletAngle = (int) (Utils.ToDegrees(Utils.NormalAbsoluteAngle(angle)) + 0.5); - robot.hitByBulletBearing = (int) (evnt.Bearing + 0.5); - robot.OnHitByBullet(); - } - - public void OnHitRobot(HitRobotEvent evnt) - { - double angle = robot.peer.GetBodyHeading() + evnt.BearingRadians; - - robot.hitRobotAngle = (int) (Utils.ToDegrees(Utils.NormalAbsoluteAngle(angle)) + 0.5); - robot.hitRobotBearing = (int) (evnt.Bearing + 0.5); - robot.OnHitRobot(); - } - - public void OnHitWall(HitWallEvent evnt) - { - double angle = robot.peer.GetBodyHeading() + evnt.BearingRadians; - - robot.hitWallAngle = (int) (Utils.ToDegrees(Utils.NormalAbsoluteAngle(angle)) + 0.5); - robot.hitWallBearing = (int) (evnt.Bearing + 0.5); - robot.OnHitWall(); - } - - public void OnRobotDeath(RobotDeathEvent evnt) - { - robot.others = robot.peer.GetOthers(); - } - - public void OnScannedRobot(ScannedRobotEvent evnt) - { - robot.scannedDistance = (int) (evnt.Distance + 0.5); - robot.scannedEnergy = Math.Max(1, (int) (evnt.Energy + 0.5)); - robot.scannedAngle = (int) (Utils.ToDegrees( - Utils.NormalAbsoluteAngle(robot.peer.GetBodyHeading() + - evnt.BearingRadians)) - + 0.5); - robot.scannedBearing = (int) (evnt.Bearing + 0.5); - robot.scannedHeading = (int) (evnt.Heading + 0.5); - robot.scannedVelocity = (int) (evnt.Velocity + 0.5); - - robot.OnScannedRobot(); - } - - public void OnStatus(StatusEvent e) - { - RobotStatus s = e.Status; - - robot.others = robot.peer.GetOthers(); - robot.energy = Math.Max(1, (int) (s.Energy + 0.5)); - robot.robotX = (int) (s.X + 0.5); - robot.robotY = (int) (s.Y + 0.5); - robot.heading = (int) (Utils.ToDegrees(s.Heading) + 0.5); - robot.gunHeading = (int) (Utils.ToDegrees(s.GunHeading) + 0.5); - robot.gunBearing = - (int) (Utils.ToDegrees(Utils.NormalRelativeAngle(s.GunHeading - s.Heading)) + 0.5); - robot.gunReady = (s.GunHeat <= 0); - - currentTurn = e.Time; - - // Auto Fire - if (juniorFirePower > 0 && robot.gunReady && (robot.peer.GetGunTurnRemaining() == 0)) - { - if (robot.peer.SetFire(juniorFirePower) != null) - { - robot.gunReady = false; - juniorFirePower = 0; - } - } - - // Reset event data - robot.scannedDistance = -1; - robot.scannedAngle = -1; - robot.scannedBearing = -1; - robot.scannedVelocity = -99; - robot.scannedHeading = -1; - robot.scannedEnergy = -1; - robot.hitByBulletAngle = -1; - robot.hitByBulletBearing = -1; - robot.hitRobotAngle = -1; - robot.hitRobotBearing = -1; - robot.hitWallAngle = -1; - robot.hitWallBearing = -1; - } - - public void OnWin(WinEvent evnt) - { - } - - // ReSharper disable FunctionNeverReturns - public void Run() - { - robot.fieldWidth = (int) (robot.peer.GetBattleFieldWidth() + 0.5); - robot.fieldHeight = (int) (robot.peer.GetBattleFieldHeight() + 0.5); - - // noinspection InfiniteLoopStatement - while (true) - { - long lastTurn = currentTurn; // Used for the Rescan check - - robot.Run(); // Run the code in the JuniorRobot - - // Make sure that we Rescan if the robot did not execute anything this turn. - // When the robot executes the currentTurn will automatically be increased by 1, - // So when the turn stays the same, the robot did not take any action this turn. - if (lastTurn == currentTurn) - { - robot.peer.Rescan(); // Spend a turn on rescanning - } - } - } - } - // ReSharper restore FunctionNeverReturns - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyEvent.cs deleted file mode 100644 index 1bb3bdd..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyEvent.cs +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; - -namespace Robocode -{ - /// - /// Super class of all events that originates from the keyboard. - /// - [Serializable] - public abstract class KeyEvent : Event - { - private readonly char keyChar; - private readonly int keyCode; - private readonly int keyLocation; - private readonly int id; - private readonly int modifiersEx; - private readonly long when; - - /// - /// Called by game - /// - protected KeyEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when) - { - this.keyChar = keyChar; - this.keyCode = keyCode; - this.keyLocation = keyLocation; - this.id = id; - this.modifiersEx = modifiersEx; - this.when = when; - } - - /// - /// Char of they key pressed - /// - public char KeyChar - { - get { return keyChar; } - } - - /// - /// - /// - public int KeyCode - { - get { return keyCode; } - } - - internal int KeyLocation - { - get { return keyLocation; } - } - - internal int ID - { - get { return id; } - } - - internal int ModifiersEx - { - get { return modifiersEx; } - } - - /// - /// Age of the event - /// - public long When - { - get { return when; } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyPressedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyPressedEvent.cs deleted file mode 100644 index 0ec1caa..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyPressedEvent.cs +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A KeyPressedEvent is sent to - /// when a key has been pressed on the keyboard. - /// - /// - /// - [Serializable] - public sealed class KeyPressedEvent : KeyEvent - { - private const int DEFAULT_PRIORITY = 98; - - /// - /// Called by the game to create a new KeyPressedEvent. - /// - public KeyPressedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when) - : base(keyChar, keyCode, keyLocation, id, modifiersEx, when) - { - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnKeyPressed(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.KeyPressedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT - + RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT + - RbSerializerN.SIZEOF_INT; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (KeyPressedEvent) objec; - serializer.serialize(buffer, obj.KeyChar); - serializer.serialize(buffer, obj.KeyCode); - serializer.serialize(buffer, obj.KeyLocation); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - char keyChar = buffer.getChar(); - int keyCode = buffer.getInt(); - int keyLocation = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - return new KeyPressedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyReleasedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyReleasedEvent.cs deleted file mode 100644 index 30add3e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyReleasedEvent.cs +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A KeyReleasedEvent is sent to - /// when a key has been released on the keyboard. - /// - /// - /// - [Serializable] - public sealed class KeyReleasedEvent : KeyEvent - { - private const int DEFAULT_PRIORITY = 98; - - /// - /// Called by the game to create a new KeyReleasedEvent. - /// - public KeyReleasedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when) - : base(keyChar, keyCode, keyLocation, id, modifiersEx, when) - { - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnKeyReleased(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.KeyReleasedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT - + RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT + - RbSerializerN.SIZEOF_INT; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (KeyReleasedEvent) objec; - - serializer.serialize(buffer, obj.KeyChar); - serializer.serialize(buffer, obj.KeyCode); - serializer.serialize(buffer, obj.KeyLocation); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - char keyChar = buffer.getChar(); - int keyCode = buffer.getInt(); - int keyLocation = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new KeyReleasedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyTypedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyTypedEvent.cs deleted file mode 100644 index b59b4fa..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/KeyTypedEvent.cs +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A KeyTypedEvent is sent to - /// when a key has been typed (pressed and released) on the keyboard. - /// - /// - /// - [Serializable] - public sealed class KeyTypedEvent : KeyEvent - { - private const int DEFAULT_PRIORITY = 98; - - /// - /// Called by the game to create a new KeyTypedEvent. - /// - public KeyTypedEvent(char keyChar, int keyCode, int keyLocation, int id, int modifiersEx, long when) - : base(keyChar, keyCode, keyLocation, id, modifiersEx, when) - { - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnKeyTyped(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.KeyTypedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_CHAR + RbSerializerN.SIZEOF_INT - + RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG + RbSerializerN.SIZEOF_INT + - RbSerializerN.SIZEOF_INT; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (KeyTypedEvent) objec; - - serializer.serialize(buffer, obj.KeyChar); - serializer.serialize(buffer, obj.KeyCode); - serializer.serialize(buffer, obj.KeyLocation); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - char keyChar = buffer.getChar(); - int keyCode = buffer.getInt(); - int keyLocation = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new KeyTypedEvent(keyChar, keyCode, keyLocation, id, modifiersEx, when); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Keys.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Keys.cs deleted file mode 100644 index fd834ca..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Keys.cs +++ /dev/null @@ -1,292 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// This class is based on the source code from Sun's Java 1.5.0 API for java.awt.event.KeyEvent, but -// rewritten for C# and .NET with the purpose to bridge the .NET and Java internals of Robocode. - -namespace Robocode -{ -#pragma warning disable 1591 - /// - public static class Keys - { - public const int KEY_FIRST = 400; - - public const int KEY_LAST = 402; - - public const int KEY_TYPED = KEY_FIRST; - - public const int KEY_PRESSED = 1 + KEY_FIRST; - - public const int KEY_RELEASED = 2 + KEY_FIRST; - - public const int VK_ENTER = 0x0A; - public const int VK_BACK_SPACE = 0x20; - public const int VK_TAB = 0x08; - public const int VK_CANCEL = 0x03; - public const int VK_CLEAR = 0x0C; - public const int VK_SHIFT = 0x10; - public const int VK_CONTROL = 0x11; - public const int VK_ALT = 0x12; - public const int VK_PAUSE = 0x13; - public const int VK_CAPS_LOCK = 0x14; - public const int VK_ESCAPE = 0x1B; - public const int VK_SPACE = 0x20; - public const int VK_PAGE_UP = 0x21; - public const int VK_PAGE_DOWN = 0x22; - public const int VK_END = 0x23; - public const int VK_HOME = 0x24; - - public const int VK_LEFT = 0x25; - - public const int VK_UP = 0x26; - - public const int VK_RIGHT = 0x27; - - public const int VK_DOWN = 0x28; - - public const int VK_COMMA = 0x2C; - - public const int VK_MINUS = 0x2D; - - public const int VK_PERIOD = 0x2E; - - public const int VK_SLASH = 0x2F; - - public const int VK_0 = 0x30; - public const int VK_1 = 0x31; - public const int VK_2 = 0x32; - public const int VK_3 = 0x33; - public const int VK_4 = 0x34; - public const int VK_5 = 0x35; - public const int VK_6 = 0x36; - public const int VK_7 = 0x37; - public const int VK_8 = 0x38; - public const int VK_9 = 0x39; - - public const int VK_SEMICOLON = 0x3B; - - public const int VK_EQUALS = 0x3D; - - public const int VK_A = 0x41; - public const int VK_B = 0x42; - public const int VK_C = 0x43; - public const int VK_D = 0x44; - public const int VK_E = 0x45; - public const int VK_F = 0x46; - public const int VK_G = 0x47; - public const int VK_H = 0x48; - public const int VK_I = 0x49; - public const int VK_J = 0x4A; - public const int VK_K = 0x4B; - public const int VK_L = 0x4C; - public const int VK_M = 0x4D; - public const int VK_N = 0x4E; - public const int VK_O = 0x4F; - public const int VK_P = 0x50; - public const int VK_Q = 0x51; - public const int VK_R = 0x52; - public const int VK_S = 0x53; - public const int VK_T = 0x54; - public const int VK_U = 0x55; - public const int VK_V = 0x56; - public const int VK_W = 0x57; - public const int VK_X = 0x58; - public const int VK_Y = 0x59; - public const int VK_Z = 0x5A; - - public const int VK_OPEN_BRACKET = 0x5B; - - public const int VK_BACK_SLASH = 0x5C; - - public const int VK_CLOSE_BRACKET = 0x5D; - - public const int VK_NUMPAD0 = 0x60; - public const int VK_NUMPAD1 = 0x61; - public const int VK_NUMPAD2 = 0x62; - public const int VK_NUMPAD3 = 0x63; - public const int VK_NUMPAD4 = 0x64; - public const int VK_NUMPAD5 = 0x65; - public const int VK_NUMPAD6 = 0x66; - public const int VK_NUMPAD7 = 0x67; - public const int VK_NUMPAD8 = 0x68; - public const int VK_NUMPAD9 = 0x69; - public const int VK_MULTIPLY = 0x6A; - public const int VK_ADD = 0x6B; - - public const int VK_SEPARATER = 0x6C; - - public const int VK_SEPARATOR = VK_SEPARATER; - - public const int VK_SUBTRACT = 0x6D; - public const int VK_DECIMAL = 0x6E; - public const int VK_DIVIDE = 0x6F; - public const int VK_DELETE = 0x7F; - public const int VK_NUM_LOCK = 0x90; - public const int VK_SCROLL_LOCK = 0x91; - - public const int VK_F1 = 0x70; - - public const int VK_F2 = 0x71; - - public const int VK_F3 = 0x72; - - public const int VK_F4 = 0x73; - - public const int VK_F5 = 0x74; - - public const int VK_F6 = 0x75; - - public const int VK_F7 = 0x76; - - public const int VK_F8 = 0x77; - - public const int VK_F9 = 0x78; - - public const int VK_F10 = 0x79; - - public const int VK_F11 = 0x7A; - - public const int VK_F12 = 0x7B; - - public const int VK_F13 = 0xF000; - - public const int VK_F14 = 0xF001; - - public const int VK_F15 = 0xF002; - - public const int VK_F16 = 0xF003; - - public const int VK_F17 = 0xF004; - - public const int VK_F18 = 0xF005; - - public const int VK_F19 = 0xF006; - - public const int VK_F20 = 0xF007; - - public const int VK_F21 = 0xF008; - - public const int VK_F22 = 0xF009; - - public const int VK_F23 = 0xF00A; - - public const int VK_F24 = 0xF00B; - - public const int VK_PRINTSCREEN = 0x9A; - public const int VK_INSERT = 0x9B; - public const int VK_HELP = 0x9C; - public const int VK_META = 0x9D; - - public const int VK_BACK_QUOTE = 0xC0; - public const int VK_QUOTE = 0xDE; - - public const int VK_KP_UP = 0xE0; - - public const int VK_KP_DOWN = 0xE1; - - public const int VK_KP_LEFT = 0xE2; - - public const int VK_KP_RIGHT = 0xE3; - - public const int VK_DEAD_GRAVE = 0x80; - public const int VK_DEAD_ACUTE = 0x81; - public const int VK_DEAD_CIRCUMFLEX = 0x82; - public const int VK_DEAD_TILDE = 0x83; - public const int VK_DEAD_MACRON = 0x84; - public const int VK_DEAD_BREVE = 0x85; - public const int VK_DEAD_ABOVEDOT = 0x86; - public const int VK_DEAD_DIAERESIS = 0x87; - public const int VK_DEAD_ABOVERING = 0x88; - public const int VK_DEAD_DOUBLEACUTE = 0x89; - public const int VK_DEAD_CARON = 0x8a; - public const int VK_DEAD_CEDILLA = 0x8b; - public const int VK_DEAD_OGONEK = 0x8c; - public const int VK_DEAD_IOTA = 0x8d; - public const int VK_DEAD_VOICED_SOUND = 0x8e; - public const int VK_DEAD_SEMIVOICED_SOUND = 0x8f; - - public const int VK_AMPERSAND = 0x96; - public const int VK_ASTERISK = 0x97; - public const int VK_QUOTEDBL = 0x98; - public const int VK_LESS = 0x99; - public const int VK_GREATER = 0xa0; - public const int VK_BRACELEFT = 0xa1; - public const int VK_BRACERIGHT = 0xa2; - - public const int VK_AT = 0x0200; - public const int VK_COLON = 0x0201; - public const int VK_CIRCUMFLEX = 0x0202; - public const int VK_DOLLAR = 0x0203; - public const int VK_EURO_SIGN = 0x0204; - - public const int VK_EXCLAMATION_MARK = 0x0205; - public const int VK_INVERTED_EXCLAMATION_MARK = 0x0206; - public const int VK_LEFT_PARENTHESIS = 0x0207; - public const int VK_NUMBER_SIGN = 0x0208; - public const int VK_PLUS = 0x0209; - public const int VK_RIGHT_PARENTHESIS = 0x020A; - public const int VK_UNDERSCORE = 0x020B; - public const int VK_WINDOWS = 0x020C; - public const int VK_CONTEXT_MENU = 0x020D; - public const int VK_const = 0x0018; - public const int VK_CONVERT = 0x001C; - public const int VK_NONCONVERT = 0x001D; - public const int VK_ACCEPT = 0x001E; - public const int VK_MODECHANGE = 0x001F; - public const int VK_KANA = 0x0015; - public const int VK_KANJI = 0x0019; - public const int VK_ALPHANUMERIC = 0x00F0; - public const int VK_KATAKANA = 0x00F1; - public const int VK_HIRAGANA = 0x00F2; - public const int VK_FULL_WIDTH = 0x00F3; - public const int VK_HALF_WIDTH = 0x00F4; - public const int VK_ROMAN_CHARACTERS = 0x00F5; - public const int VK_ALL_CANDIDATES = 0x0100; - public const int VK_PREVIOUS_CANDIDATE = 0x0101; - public const int VK_CODE_INPUT = 0x0102; - public const int VK_JAPANESE_KATAKANA = 0x0103; - public const int VK_JAPANESE_HIRAGANA = 0x0104; - public const int VK_JAPANESE_ROMAN = 0x0105; - public const int VK_KANA_LOCK = 0x0106; - public const int VK_INPUT_METHOD_ON_OFF = 0x0107; - public const int VK_CUT = 0xFFD1; - public const int VK_COPY = 0xFFCD; - public const int VK_PASTE = 0xFFCF; - public const int VK_UNDO = 0xFFCB; - public const int VK_AGAIN = 0xFFC9; - public const int VK_FIND = 0xFFD0; - public const int VK_PROPS = 0xFFCA; - public const int VK_STOP = 0xFFC8; - public const int VK_COMPOSE = 0xFF20; - public const int VK_ALT_GRAPH = 0xFF7E; - public const int VK_BEGIN = 0xFF58; - public const int VK_UNDEFINED = 0x0; - public const int KEY_LOCATION_UNKNOWN = 0; - public const int KEY_LOCATION_STANDARD = 1; - public const int KEY_LOCATION_LEFT = 2; - public const int KEY_LOCATION_RIGHT = 3; - public const int KEY_LOCATION_NUMPAD = 4; - public static readonly char CHAR_UNDEFINED = (char) 0xFFFF; - public const int MOUSE_FIRST = 500; - public const int MOUSE_LAST = 507; - public const int MOUSE_CLICKED = MOUSE_FIRST; - public const int MOUSE_PRESSED = 1 + MOUSE_FIRST; //Event.MOUSE_DOWN - public const int MOUSE_RELEASED = 2 + MOUSE_FIRST; //Event.MOUSE_UP - public const int MOUSE_MOVED = 3 + MOUSE_FIRST; //Event.MOUSE_MOVE - public const int MOUSE_ENTERED = 4 + MOUSE_FIRST; //Event.MOUSE_ENTER - public const int MOUSE_EXITED = 5 + MOUSE_FIRST; //Event.MOUSE_EXIT - public const int MOUSE_DRAGGED = 6 + MOUSE_FIRST; //Event.MOUSE_DRAG - public const int MOUSE_WHEEL = 7 + MOUSE_FIRST; - public const int NOBUTTON = 0; - public const int BUTTON1 = 1; - public const int BUTTON2 = 2; - public const int BUTTON3 = 3; - - } -#pragma warning restore 1591 -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MessageEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MessageEvent.cs deleted file mode 100644 index 8e01625..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MessageEvent.cs +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.peer; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A MessageEvent is sent to - /// when a teammate sends a message to your robot. - /// You can use the information contained in this event to determine what to do. - /// - [Serializable] - public sealed class MessageEvent : Event - { - private const int DEFAULT_PRIORITY = 75; - - private readonly string sender; - [NonSerialized] - private readonly object message; - - /// - /// Called by the game to create a new MessageEvent. - /// - public MessageEvent(string sender, object message) - { - this.sender = sender; - this.message = message; - } - - /// - /// Returns the name of the sending robot. - /// - public string Sender - { - get { return sender; } - } - - /// - /// Returns the message itself. - /// - public object Message - { - get { return message; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsTeamRobot()) - { - ITeamEvents listener = ((ITeamRobot) robot).GetTeamEventListener(); - - if (listener != null) - { - listener.OnMessageReceived(this); - } - } - } - - internal override byte SerializationType - { - get { throw new System.Exception("Serialization of event type not supported"); } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseClickedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseClickedEvent.cs deleted file mode 100644 index bfeba0b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseClickedEvent.cs +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A MouseClickedEvent is sent to - /// when the mouse is clicked inside the battle view. - /// - /// - /// - /// - /// - /// - /// - /// - [Serializable] - public sealed class MouseClickedEvent : MouseEvent - { - private const int DEFAULT_PRIORITY = 98; - - /// - /// Called by the game to create a new MouseClickedEvent. - /// - public MouseClickedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when) - : base(button, clickCount, x, y, id, modifiersEx, when) - { - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnMouseClicked(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.MouseClickedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (MouseClickedEvent) objec; - - serializer.serialize(buffer, obj.Button); - serializer.serialize(buffer, obj.ClickCount); - serializer.serialize(buffer, obj.X); - serializer.serialize(buffer, obj.Y); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseClickedEvent(button, clickCount, x, y, id, modifiersEx, when); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseDraggedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseDraggedEvent.cs deleted file mode 100644 index 013a1e3..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseDraggedEvent.cs +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A MouseDraggedEvent is sent to - /// when the mouse is dragged inside the battle view. - /// - /// - /// - /// - /// - /// - /// - /// - [Serializable] - public sealed class MouseDraggedEvent : MouseEvent - { - private const int DEFAULT_PRIORITY = 98; - - /// - /// Called by the game to create a new MouseDraggedEvent. - /// - public MouseDraggedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when) - : base(button, clickCount, x, y, id, modifiersEx, when) - { - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnMouseDragged(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.MouseDraggedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (MouseDraggedEvent) objec; - - serializer.serialize(buffer, obj.Button); - serializer.serialize(buffer, obj.ClickCount); - serializer.serialize(buffer, obj.X); - serializer.serialize(buffer, obj.Y); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseDraggedEvent(button, clickCount, x, y, id, modifiersEx, when); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseEnteredEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseEnteredEvent.cs deleted file mode 100644 index b0ce310..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseEnteredEvent.cs +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A MouseEnteredEvent is sent to - /// when the mouse has entered the battle view. - /// - /// - /// - /// - /// - /// - /// - /// - [Serializable] - public sealed class MouseEnteredEvent : MouseEvent - { - private const int DEFAULT_PRIORITY = 98; - - /// - /// Called by the game to create a new MouseDraggedEvent. - /// - public MouseEnteredEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when) - : base(button, clickCount, x, y, id, modifiersEx, when) - { - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnMouseEntered(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.MouseEnteredEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (MouseEnteredEvent)objec; - - serializer.serialize(buffer, obj.Button); - serializer.serialize(buffer, obj.ClickCount); - serializer.serialize(buffer, obj.X); - serializer.serialize(buffer, obj.Y); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseEnteredEvent(button, clickCount, x, y, id, modifiersEx, when); - } - } - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseEvent.cs deleted file mode 100644 index 2f87e17..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseEvent.cs +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; - -namespace Robocode -{ - /// - /// Super class of all events that originates from the mouse. - /// - [Serializable] - public abstract class MouseEvent : Event - { - private readonly int button; - private readonly int clickCount; - private readonly int x; - private readonly int y; - private readonly int id; - private readonly int modifiersEx; - private readonly long when; - - /// - /// Called by the game to create a new MouseEvent. - /// - protected MouseEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when) - { - this.button = button; - this.clickCount = clickCount; - this.x = x; - this.y = y; - this.id = id; - this.modifiersEx = modifiersEx; - this.when = when; - } - - /// - /// Number of the button - /// - public int Button - { - get { return button; } - } - - /// - /// Click count - /// - public int ClickCount - { - get { return clickCount; } - } - - /// - /// Cursor coordinates - /// - public int X - { - get { return x; } - } - - /// - /// Cursor coordinates - /// - public int Y - { - get { return y; } - } - - internal int ID - { - get { return id; } - } - - internal int ModifiersEx - { - get { return modifiersEx; } - } - - /// - /// Age of the event - /// - public long When - { - get { return when; } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseExitedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseExitedEvent.cs deleted file mode 100644 index 7a39cc7..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseExitedEvent.cs +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A MouseExitedEvent is sent to - /// when the mouse has exited the battle view. - /// - /// - /// - /// - /// - /// - /// - /// - [Serializable] - public sealed class MouseExitedEvent : MouseEvent - { - private const int DEFAULT_PRIORITY = 98; - - /// - /// Called by the game to create a new MouseDraggedEvent. - /// - public MouseExitedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when) - : base(button, clickCount, x, y, id, modifiersEx, when) - { - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnMouseExited(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.MouseExitedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (MouseExitedEvent)objec; - - serializer.serialize(buffer, obj.Button); - serializer.serialize(buffer, obj.ClickCount); - serializer.serialize(buffer, obj.X); - serializer.serialize(buffer, obj.Y); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseExitedEvent(button, clickCount, x, y, id, modifiersEx, when); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseMovedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseMovedEvent.cs deleted file mode 100644 index 6b4b640..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseMovedEvent.cs +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A MouseMovedEvent is sent to - /// when the mouse has moved inside the battle view. - /// - /// - /// - /// - /// - /// - /// - /// - [Serializable] - public sealed class MouseMovedEvent : MouseEvent - { - private const int DEFAULT_PRIORITY = 98; - - /// - /// Called by the game to create a new MouseDraggedEvent. - /// - public MouseMovedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when) - : base(button, clickCount, x, y, id, modifiersEx, when) - { - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnMouseMoved(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.MouseMovedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (MouseMovedEvent)objec; - - serializer.serialize(buffer, obj.Button); - serializer.serialize(buffer, obj.ClickCount); - serializer.serialize(buffer, obj.X); - serializer.serialize(buffer, obj.Y); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseMovedEvent(button, clickCount, x, y, id, modifiersEx, when); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MousePressedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MousePressedEvent.cs deleted file mode 100644 index 35b7470..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MousePressedEvent.cs +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A MousePressedEvent is sent to - /// when the mouse is pressed inside the battle view. - /// - /// - /// - /// - /// - /// - /// - /// - [Serializable] - public sealed class MousePressedEvent : MouseEvent - { - private const int DEFAULT_PRIORITY = 98; - - /// - /// Called by the game to create a new MouseDraggedEvent. - /// - public MousePressedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when) - : base(button, clickCount, x, y, id, modifiersEx, when) - { - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnMousePressed(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.MousePressedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (MousePressedEvent)objec; - - serializer.serialize(buffer, obj.Button); - serializer.serialize(buffer, obj.ClickCount); - serializer.serialize(buffer, obj.X); - serializer.serialize(buffer, obj.Y); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MousePressedEvent(button, clickCount, x, y, id, modifiersEx, when); - } - } - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseReleasedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseReleasedEvent.cs deleted file mode 100644 index f3c6e75..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseReleasedEvent.cs +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A MouseReleasedEvent is sent to - /// when the mouse is released inside the battle view. - /// - /// - /// - /// - /// - /// - /// - /// - [Serializable] - public sealed class MouseReleasedEvent : MouseEvent - { - private const int DEFAULT_PRIORITY = 98; - - /// - /// Called by the game to create a new MouseDraggedEvent. - /// - public MouseReleasedEvent(int button, int clickCount, int x, int y, int id, int modifiersEx, long when) - : base(button, clickCount, x, y, id, modifiersEx, when) - { - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnMouseReleased(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.MouseReleasedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + 6*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (MouseReleasedEvent)objec; - - serializer.serialize(buffer, obj.Button); - serializer.serialize(buffer, obj.ClickCount); - serializer.serialize(buffer, obj.X); - serializer.serialize(buffer, obj.Y); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseReleasedEvent(button, clickCount, x, y, id, modifiersEx, when); - } - } - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseWheelMovedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseWheelMovedEvent.cs deleted file mode 100644 index 986507d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MouseWheelMovedEvent.cs +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A MouseWheelMovedEvent is sent to - /// when the mouse wheel is rotated inside the battle view. - /// - /// - /// - /// - /// - /// - /// - /// - [Serializable] - public sealed class MouseWheelMovedEvent : MouseEvent - { - private const int DEFAULT_PRIORITY = 98; - private readonly int scrollType; - private readonly int scrollAmount; - private readonly int wheelRotation; - - /// - /// Called by the game to create a new MouseWheelMovedEvent. - /// - public MouseWheelMovedEvent(int clickCount, int x, int y, int scrollType, int scrollAmount, int wheelRotation, - int id, int modifiersEx, long when) - : base(-1, clickCount, x, y, id, modifiersEx, when) - { - this.scrollType = scrollType; - this.scrollAmount = scrollAmount; - this.wheelRotation = wheelRotation; - } - - internal int ScrollType - { - get { return scrollType; } - } - - internal int ScrollAmount - { - get { return scrollAmount; } - } - - /// - /// Indicates how far the mouse wheel was rotated. - /// - public int WheelRotation - { - get { return wheelRotation; } - } - - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsInteractiveRobot()) - { - IInteractiveEvents listener = ((IInteractiveRobot) robot).GetInteractiveEventListener(); - - if (listener != null) - { - listener.OnMouseWheelMoved(this); - } - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.MouseWheelMovedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + 8*RbSerializerN.SIZEOF_INT + RbSerializerN.SIZEOF_LONG; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (MouseWheelMovedEvent) objec; - - serializer.serialize(buffer, obj.ClickCount); - serializer.serialize(buffer, obj.X); - serializer.serialize(buffer, obj.Y); - serializer.serialize(buffer, obj.ScrollType); - serializer.serialize(buffer, obj.ScrollAmount); - serializer.serialize(buffer, obj.WheelRotation); - serializer.serialize(buffer, obj.ID); - serializer.serialize(buffer, obj.ModifiersEx); - serializer.serialize(buffer, obj.When); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int scrollType = buffer.getInt(); - int scrollAmount = buffer.getInt(); - int wheelRotation = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseWheelMovedEvent(clickCount, x, y, scrollType, scrollAmount, wheelRotation, id, - modifiersEx, when); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MoveCompleteCondition.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MoveCompleteCondition.cs deleted file mode 100644 index dde6a0b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/MoveCompleteCondition.cs +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode -{ - /// - /// A prebuilt condition you can use that indicates your robot has finished moving. - /// - /// - public class MoveCompleteCondition : Condition - { - private readonly AdvancedRobot robot; - - /// - /// Creates a new MoveCompleteCondition with default priority. - /// The default priority is 80. - /// - /// Your robot, which must be a - public MoveCompleteCondition(AdvancedRobot robot) - { - this.robot = robot; - } - - /// - /// Creates a new MoveCompleteCondition with the specified priority. - /// A condition priority is a value from 0 - 99. The higher value, the - /// higher priority. The default priority is 80. - /// - /// - /// Your robot, which must be a - /// The priority of this condition - public MoveCompleteCondition(AdvancedRobot robot, int priority) - { - this.robot = robot; - this.priority = priority; - } - - /// - /// Tests if the robot has stopped moving. - /// Returns true if the robot has stopped moving - /// - public override bool Test() - { - return (robot.DistanceRemaining == 0); - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/PaintEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/PaintEvent.cs deleted file mode 100644 index 6848122..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/PaintEvent.cs +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.peer; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// This event occurs when your robot should paint, where the - /// is called on your robot. - ///

- /// You can use this event for setting the event priority by calling - /// - ///

- [Serializable] - public sealed class PaintEvent : Event - { - private const int DEFAULT_PRIORITY = 5; - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsPaintRobot()) - { - IPaintEvents listener = ((IPaintRobot) robot).GetPaintEventListener(); - - if (listener != null) - { - listener.OnPaint(graphics); - } - } - } - - internal override byte SerializationType - { - get { throw new System.Exception("Serialization of this type is not supported"); } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RadarTurnCompleteCondition.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RadarTurnCompleteCondition.cs deleted file mode 100644 index a46092a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RadarTurnCompleteCondition.cs +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode -{ - /// - /// A prebuilt condition you can use that indicates your radar has finished turning. - /// - /// - public class RadarTurnCompleteCondition : Condition - { - private readonly AdvancedRobot robot; - - /// - /// Creates a new RadarTurnCompleteCondition with default priority. - /// The default priority is 80. - /// - /// Your robot, which must be a - public RadarTurnCompleteCondition(AdvancedRobot robot) - { - this.robot = robot; - } - - /// - /// Creates a new RadarTurnCompleteCondition with the specified priority. - /// A condition priority is a value from 0 - 99. The higher value, the - /// higher priority. The default priority is 80. - /// - /// - /// Your robot, which must be a - /// The priority of this condition - public RadarTurnCompleteCondition(AdvancedRobot robot, int priority) - { - this.robot = robot; - this.priority = priority; - } - - /// - /// Tests if the radar has stopped turning. - /// Returns true if the radar has stopped turning; false otherwise - /// - public override bool Test() - { - return (robot.RadarTurnRemaining == 0); - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RateControlRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RateControlRobot.cs deleted file mode 100644 index 2521bcd..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RateControlRobot.cs +++ /dev/null @@ -1,364 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using Robocode.Util; - -namespace Robocode -{ - /// - /// This advanced robot type allows you to set a rate for each of the robot's movements. - ///

- /// You can set the rate for: - ///

    - ///
  • velocity - pixels per turn
  • - ///
  • robot turn - radians per turn
  • - ///
  • gun rotation - radians per turn
  • - ///
  • radar rotation - radians per turn
  • - ///
- /// When you set a rate for one of the above movements, the movement will continue the move by - /// specified rate for ever, until the rate is changed. In order to move ahead or right, the - /// rate must be set to a positive value. If a negative value is used instead, the movement - /// will go back or to the left. In order to stop the movement, the rate must be - /// set to 0. - /// - /// Note: When calling , , - /// , and variants, - /// any previous calls to "movement" functions outside of , - /// such as , - /// , - /// and similar will be - /// overridden when calling the on this robot class. - ///

- /// Look into the source code for the samplecs.VelociRobot in order to see how to use this - /// robot type. - /// - /// - /// - /// - /// - /// - ///

- public abstract class RateControlRobot : TeamRobot - { - private double velocityRate; // Pixels per turn - private double turnRate; // Radians per turn - private double gunRotationRate; // Radians per turn - private double radarRotationRate; // Radians per turn - - /// - /// - /// The speed the robot will move (forward), in pixels per turn. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot will move backwards - ///

- /// - /// - /// // Set the robot to move forward 2 pixels per turn - /// VelocityRate = 2; - /// - /// // Set the robot to move backwards 8 pixels per turn - /// // (overrides the previous order) - /// VelocityRate = -8; - /// - /// ... - /// // Executes the last VelocityRate - /// Execute(); - /// - /// - /// Note: This method overrules and - /// - /// - /// - /// - /// - /// - /// - ///

- public double VelocityRate - { - get { return velocityRate; } - set { velocityRate = value; } - } - - /// - /// - /// The robot's clockwise (right) rotation per turn, in degrees. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot turns counterclockwise (left) - ///

- /// - /// - /// // Set the robot to turn right 10 degrees per turn - /// TurnRate = 10; - /// - /// // Set the robot to turn left 4 degrees per turn - /// // (overrides the previous order) - /// TurnRate = -5; - /// - /// ... - /// // Executes the last TurnRate - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public double TurnRate - { - get { return Utils.ToRadians(turnRate); } - set { turnRate = Utils.ToRadians(value); } - } - - /// - /// The robot's clockwise (right) rotation per turn, in radians. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot turns counterclockwise (left) - ///

- /// - /// - /// // Set the robot to turn right pi / 32 radians per turn - /// TurnRateRadians = Math.PI / 32; - /// - /// // Set the robot to turn left pi / 20 radians per turn - /// // (overrides the previous order) - /// TurnRateRadians = -Math.PI / 20; - /// - /// ... - /// // Executes the last TurnRateRadians - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public double TurnRateRadians - { - get { return turnRate; } - set { turnRate = value; } - } - - /// - /// The gun's clockwise (right) rotation per turn, in degrees. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the gun turns counterclockwise (left) - ///

- /// - /// - /// // Set the gun to turn right 15 degrees per turn - /// GunRotationRate = 15; - /// - /// // Set the gun to turn left 9 degrees per turn - /// // (overrides the previous order) - /// GunRotationRate = -9; - /// - /// ... - /// // Executes the last GunRotationRate() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public double GunRotationRate - { - get { return Utils.ToDegrees(gunRotationRate); } - set { gunRotationRate = Utils.ToRadians(value); } - } - - /// - /// The gun's clockwise (right) rotation per turn, in radians. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the gun turns counterclockwise (left) - ///

- /// - /// - /// // Set the gun to turn right pi / 16 radians per turn - /// GunRotationRateRadians = Math.PI / 16; - /// - /// // Set the gun to turn left pi / 12 radians per turn - /// // (overrides the previous order) - /// GunRotationRateRadians = -Math.PI / 12; - /// - /// ... - /// // Executes the last GunRotationRateRadians - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public double GunRotationRateRadians - { - get { return gunRotationRate; } - set { gunRotationRate = value; } - } - - /// - /// The radar's clockwise (right) rotation per turn, in degrees. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the radar turns counterclockwise (left) - ///

- /// - /// - /// // Set the radar to turn right 45 degrees per turn - /// RadarRotationRate = 45; - /// - /// // Set the radar to turn left 15 degrees per turn - /// // (overrides the previous order) - /// RadarRotationRate = -15; - /// - /// ... - /// // Executes the last RadarRotationRate - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public double RadarRotationRate - { - get { return Utils.ToDegrees(radarRotationRate); } - set { radarRotationRate = Utils.ToRadians(value); } - } - - /// - /// The radar's clockwise (right) rotation per turn, in radians. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the radar turns counterclockwise (left) - ///

- /// - /// - /// // Set the radar to turn right pi / 4 radians per turn - /// RadarRotationRateRadians = Math.PI / 4; - /// - /// // Set the radar to turn left pi / 8 radians per turn - /// // (overrides the previous order) - /// RadarRotationRateRadians = -Math.PI / 8; - /// - /// ... - /// // Executes the last RadarRotationRateRadians - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public double RadarRotationRateRadians - { - get { return radarRotationRate; } - set { radarRotationRate = value; } - } - - /// - /// Executes any pending actions, or continues executing actions that are - /// in process. This call returns after the actions have been started. - ///

- /// Note that advanced robots must call this function in order to - /// Execute pending set* calls like e.g. , - /// , - /// etc. Otherwise, these calls will never get executed. - ///

- /// Any previous calls to "movement" functions outside of - /// , such as - /// , - /// , - /// - /// etc. will be overridden when this method is called on this robot class. - ///

- /// - /// In this example the robot will move while turning: - /// - /// VelocityRate = 6; - /// TurnRate = 7; - /// - /// while (true) - /// { - /// Execute(); - /// } - /// - /// - ///

- public override void Execute() - { - MaxVelocity = velocityRate; - if (velocityRate > 0) - { - SetAhead(Double.PositiveInfinity); - } - else if (velocityRate < 0) - { - SetBack(Double.PositiveInfinity); - } - else - { - SetAhead(0); - } - - SetTurnGunRightRadians(gunRotationRate); - SetTurnRadarRightRadians(radarRotationRate); - SetTurnRightRadians(turnRate); - - base.Execute(); - } - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Robot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Robot.cs deleted file mode 100644 index 4d65225..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Robot.cs +++ /dev/null @@ -1,1927 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using System.IO; -using System.Security.Permissions; -using net.sf.robocode.security; -using Robocode.Exception; -using Robocode.RobotInterfaces; -using Robocode.RobotInterfaces.Peer; -using Robocode.Util; - -namespace Robocode -{ - /// - /// - /// The basic robot class that you will extend to create your own robots. - ///

- /// Please note the following standards will be used: - ///

- /// heading - absolute angle in degrees with 0 facing up the screen, - /// positive clockwise. 0 <= heading < 360. - ///

- /// bearing - relative angle to some obj from your robot's heading, - /// positive clockwise. -180 < bearing <= 180 - ///

- /// All coordinates are expressed as (x,y). - /// All coordinates are positive. - ///

- /// The origin (0,0) is at the bottom left of the screen. - ///

- /// Positive X is right. - /// Positive Y is up. - ///
- ///
- /// Building your first robot - /// - /// - /// - /// - /// - /// - /// - ///

- public abstract class Robot : IInteractiveRobot, IPaintRobot, IBasicEvents3, IInteractiveEvents, IPaintEvents, IRunnable - { - private const int - WIDTH = 36, - HEIGHT = 36; - - internal IBasicRobotPeer peer; - internal TextWriter _output; - - /// - /// The Out stream your robot should use to print. - ///

- /// You can view the print-outs by clicking the button for your robot in the - /// right side of the battle window. - ///

- /// - /// - /// // Print Out a line each time my robot hits another robot - /// public void OnHitRobot(HitRobotEvent e) - /// { - /// Out.WriteLine("I hit a robot! My energy: " + Energy + " his energy: " + e.Energy); - /// } - /// - /// - ///

- public TextWriter Out - { - get { return _output; } - } - - [RobocodeInternalPermission(SecurityAction.LinkDemand)] - void IBasicRobot.SetOut(TextWriter outpt) - { - _output = outpt; - } - - [RobocodeInternalPermission(SecurityAction.LinkDemand)] - void IBasicRobot.SetPeer(IBasicRobotPeer per) - { - peer = per; - } - - /// - /// Throws a RobotException. - /// This method should be called when the robot's peer is uninitialized. - /// - internal static void UninitializedException() - { - throw new RobotException( - "You cannot call the methods before your Run() method is called, or you are using a Robot object that the game doesn't know about."); - } - - /// - IRunnable IBasicRobot.GetRobotRunnable() - { - return this; - } - - /// - IBasicEvents IBasicRobot.GetBasicEventListener() - { - return this; - } - - /// - IInteractiveEvents IInteractiveRobot.GetInteractiveEventListener() - { - return this; - } - - /// - IPaintEvents IPaintRobot.GetPaintEventListener() - { - return this; - } - - /// - /// Immediately moves your robot ahead (forward) by distance measured in - /// pixels. - ///

- /// This call executes immediately, and does not return until it is complete, - /// i.e. when the remaining distance to move is 0. - ///

- /// If the robot collides with a wall, the move is complete, meaning that the - /// robot will not move any further. If the robot collides with another - /// robot, the move is complete if you are heading toward the other robot. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot is set to move backward - /// instead of forward. - ///

- /// - /// - /// // Move the robot 100 pixels forward - /// Ahead(100); - /// - /// // Afterwards, move the robot 50 pixels backward - /// Ahead(-50); - /// - /// - ///

- /// - /// The distance to move ahead measured in pixels. - /// If this value is negative, the robot will move back instead of ahead. - /// - /// - /// - /// - public void Ahead(double distance) - { - if (peer != null) - { - peer.Move(distance); - } - else - { - UninitializedException(); - } - } - - /// - /// Immediately moves your robot backward by distance measured in pixels. - ///

- /// This call executes immediately, and does not return until it is complete, - /// i.e. when the remaining distance to move is 0. - ///

- /// If the robot collides with a wall, the move is complete, meaning that the - /// robot will not move any further. If the robot collides with another - /// robot, the move is complete if you are heading toward the other robot. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot is set to move forward instead - /// of backward. - ///

- /// - /// - /// // Move the robot 100 pixels backward - /// Back(100); - /// - /// // Afterwards, move the robot 50 pixels forward - /// Back(-50); - /// - /// - /// - /// - /// - ///

- /// - /// The distance to move back measured in pixels. - /// If this value is negative, the robot will move ahead instead of back. - /// - public void Back(double distance) - { - if (peer != null) - { - peer.Move(-distance); - } - else - { - UninitializedException(); - } - } - - /// - /// Returns the width of the current battlefield measured in pixels. - /// - public double BattleFieldWidth - { - get - { - if (peer != null) - { - return peer.GetBattleFieldWidth(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the height of the current battlefield measured in pixels. - /// - public double BattleFieldHeight - { - get - { - if (peer != null) - { - return peer.GetBattleFieldHeight(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the direction that the robot's body is facing, in degrees. - /// The value returned will be between 0 and 360 (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// 90 means East, 180 means South, and 270 means West. - /// - /// - ///

- public double Heading - { - get - { - if (peer != null) - { - double rv = 180.0*peer.GetBodyHeading()/Math.PI; - - while (rv < 0) - { - rv += 360; - } - while (rv >= 360) - { - rv -= 360; - } - return rv; - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the height of the robot measured in pixels. - /// - /// - public double Height - { - get - { - if (peer == null) - { - UninitializedException(); - } - return HEIGHT; - } - } - - /// - /// Returns the width of the robot measured in pixels. - /// - /// - public double Width - { - get - { - if (peer == null) - { - UninitializedException(); - } - return WIDTH; - } - } - - /// - /// Returns the robot's name. - /// - public string Name - { - get - { - if (peer != null) - { - return peer.GetName(); - } - UninitializedException(); - return null; // never called - } - } - - /// - /// Returns the X position of the robot. (0,0) is at the bottom left of the battlefield. - /// - /// - public double X - { - get - { - if (peer != null) - { - return peer.GetX(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the Y position of the robot. (0,0) is at the bottom left of the battlefield. - /// - /// - public double Y - { - get - { - if (peer != null) - { - return peer.GetY(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// The main method in every robot. You must override this to set up your - /// robot's basic behavior. - ///

- /// - /// - /// // A basic robot that moves around in a square - /// public void Run() - /// { - /// while (true) - /// { - /// Ahead(100); - /// TurnRight(90); - /// } - /// } - /// - /// - ///

- public virtual void Run() - { - } - - /// - /// Immediately turns the robot's body to the left by degrees. - ///

- /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the robot's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's body is set to turn right - /// instead of left. - ///

- /// - /// - /// // Turn the robot 180 degrees to the left - /// TurnLeft(180); - /// - /// // Afterwards, turn the robot 90 degrees to the right - /// TurnLeft(-90); - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's body to the left. - /// If degrees > 0 the robot will turn left. - /// If degrees < 0 the robot will turn right. - /// If degrees = 0 the robot will not turn, but execute. - /// - public void TurnLeft(double degrees) - { - if (peer != null) - { - peer.TurnBody(-Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// - /// Immediately turns the robot's body to the right by degrees. - /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the robot's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's body is set to turn left - /// instead of right. - ///

- /// - /// - /// // Turn the robot 180 degrees to the right - /// TurnRight(180); - /// - /// // Afterwards, turn the robot 90 degrees to the left - /// TurnRight(-90); - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's body to the right. - /// If degrees > 0 the robot will turn right. - /// If degrees < 0 the robot will turn left. - /// If degrees = 0 the robot will not turn, but execute. - /// - public void TurnRight(double degrees) - { - if (peer != null) - { - peer.TurnBody(Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Do nothing this turn, meaning that the robot will skip it's turn. - ///

- /// This call executes immediately, and does not return until the turn is over. - ///

- public void DoNothing() - { - if (peer != null) - { - peer.Execute(); - } - else - { - UninitializedException(); - } - } - - /// - /// Immediately fires a bullet. The bullet will travel in the direction the - /// gun is pointing. - ///

- /// The specified bullet power is an amount of energy that will be taken from - /// the robot's energy. Hence, the more power you want to spend on the - /// bullet, the more energy is taken from your robot. - ///

- /// The bullet will do (4 * power) damage if it hits another robot. If power - /// is greater than 1, it will do an additional 2 * (power - 1) damage. - /// You will get (3 * power) back if you hit the other robot. You can call - /// - /// for getting the damage that a - /// bullet with a specific bullet power will do. - ///

- /// The specified bullet power should be between - /// and . - ///

- /// Note that the gun cannot Fire if the gun is overheated, meaning that - /// - /// returns a value > 0. - ///

- /// A event is generated when the bullet hits a robot (), - /// wall (), or another bullet - /// (). - ///

- /// - /// - /// // Fire a bullet with maximum power if the gun is ready - /// if (GetGunHeat() == 0) - /// { - /// Fire(Rules.MAX_BULLET_POWER); - /// } - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of energy given to the bullet, and subtracted from the robot's energy. - /// - public void Fire(double power) - { - if (peer != null) - { - peer.SetFire(power); - peer.Execute(); - } - else - { - UninitializedException(); - } - } - - /// - /// - /// Immediately fires a bullet. The bullet will travel in the direction the - /// gun is pointing. - ///

- /// The specified bullet power is an amount of energy that will be taken from - /// the robot's energy. Hence, the more power you want to spend on the - /// bullet, the more energy is taken from your robot. - ///

- /// The bullet will do (4 * power) damage if it hits another robot. If power - /// is greater than 1, it will do an additional 2 * (power - 1) damage. - /// You will get (3 * power) back if you hit the other robot. You can call - /// - /// for getting the damage that a - /// bullet with a specific bullet power will do. - ///

- /// The specified bullet power should be between - /// and . - ///

- /// Note that the gun cannot Fire if the gun is overheated, meaning that - /// returns a value > 0. - ///

- /// A event is generated when the bullet hits a robot (), - /// wall (), or another bullet - /// (). - ///

- /// - /// - /// // Fire a bullet with maximum power if the gun is ready - /// if (GetGunHeat() == 0) - /// { - /// Bullet bullet = FireBullet(Rules.MAX_BULLET_POWER); - /// - /// // Get the velocity of the bullet - /// if (bullet != null) - /// { - /// double bulletVelocity = bullet.Velocity; - /// } - /// } - /// - /// - /// Returns a - /// - /// That contains information about the bullet if it was actually fired, - /// which can be used for tracking the bullet after it has been fired. - /// If the bullet was not fired, null is returned. - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// power the amount of energy given to the bullet, and subtracted from the robot's energy. - /// - public Bullet FireBullet(double power) - { - if (peer != null) - { - return peer.Fire(power); - } - UninitializedException(); - return null; - } - - /// - /// Returns the rate at which the gun will cool down, i.e. the amount of heat - /// the gun heat will drop per turn. - ///

- /// The gun cooling rate is default 0.1 / turn, but can be changed by the - /// battle setup. So don't count on the cooling rate being 0.1! - /// - /// - /// - ///

- public double GunCoolingRate - { - get - { - if (peer != null) - { - return peer.GetGunCoolingRate(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the direction that the robot's gun is facing, in degrees. - /// The value returned will be between 0 and 360 (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// 90 means East, 180 means South, and 270 means West. - /// - /// - ///

- public double GunHeading - { - get - { - if (peer != null) - { - return peer.GetGunHeading()*180.0/Math.PI; - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the current heat of the gun. The gun cannot Fire unless this is - /// 0. (Calls to Fire will succeed, but will not actually Fire unless - /// GetGunHeat() == 0). - ///

- /// The amount of gun heat generated when the gun is fired is 1 + (firePower / 5). - /// Each turn the gun heat drops by the amount returned by , - /// which is a battle setup. - ///

- /// Note that all guns are "hot" at the start of each round, where the gun heat is 3. - /// - /// - /// - ///

- public double GunHeat - { - get - { - if (peer != null) - { - return peer.GetGunHeat(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the number of rounds in the current battle. - /// - /// - public int NumRounds - { - get - { - if (peer != null) - { - return peer.GetNumRounds(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the sentry border size for a BorderSentry that defines the how - /// far a BorderSentry is allowed to move from the border edges measured in units.
- /// Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that - /// BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the - /// distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this - /// border area. - ///
- public int SentryBorderSize - { - get { - if (peer != null) - { - return peer.GetSentryBorderSize(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns how many opponents that are left in the current round. - /// - public int Others - { - get - { - if (peer != null) - { - return peer.GetOthers(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns how many sentry robots that are left in the current round. - /// - public int NumSentries - { - get - { - if (peer != null) - { - return peer.GetNumSentries(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the direction that the robot's radar is facing, in degrees. - /// The value returned will be between 0 and 360 (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// 90 means East, 180 means South, and 270 means West. - /// - /// - ///

- public double RadarHeading - { - get - { - if (peer != null) - { - return peer.GetRadarHeading()*180.0/Math.PI; - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the current round number (0 to - 1) of the battle. - /// - /// - public int RoundNum - { - get - { - if (peer != null) - { - return peer.GetRoundNum(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the game time of the current round, where the time is equal to - /// the current turn in the round. - ///

- /// A battle consists of multiple rounds. - ///

- /// Time is reset to 0 at the beginning of every round. - ///

- public long Time - { - get - { - if (peer != null) - { - return peer.GetTime(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns the velocity of the robot measured in pixels/turn. - ///

- /// The maximum velocity of a robot is defined by - /// (8 pixels / turn). - /// - ///

- public double Velocity - { - get - { - if (peer != null) - { - return peer.GetVelocity(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - public virtual void OnBulletHit(BulletHitEvent evnt) - { - } - - /// - public virtual void OnBulletHitBullet(BulletHitBulletEvent evnt) - { - } - - /// - public virtual void OnBulletMissed(BulletMissedEvent evnt) - { - } - - /// - public virtual void OnDeath(DeathEvent evnt) - { - } - - /// - public virtual void OnHitByBullet(HitByBulletEvent evnt) - { - } - - /// - public virtual void OnHitRobot(HitRobotEvent evnt) - { - } - - /// - public virtual void OnHitWall(HitWallEvent evnt) - { - } - - /// - public virtual void OnRobotDeath(RobotDeathEvent evnt) - { - } - - /// - public virtual void OnScannedRobot(ScannedRobotEvent evnt) - { - } - - /// - public virtual void OnWin(WinEvent evnt) - { - } - - /// - public virtual void OnRoundEnded(RoundEndedEvent evnt) - { - } - - /// - public virtual void OnBattleEnded(BattleEndedEvent evnt) - { - } - - /// - /// - /// Scans for other robots. This method is called automatically by the game, - /// as long as the robot is moving, turning its body, turning its gun, or - /// turning its radar. - ///

- /// Scan will cause - /// to be called if you see a robot. - ///

- /// There are 2 reasons to call manually: - ///

    - ///
  1. - /// You want to scan after you stop moving. - ///
  2. - ///
  3. - /// You want to interrupt the - /// event. This is more likely. If you are in - /// and call - /// , and you still see a robot, then the system will interrupt your - /// event immediately and start it - /// from the top. - ///
  4. - ///
- ///

- /// This call executes immediately. - /// - /// - ///

- public void Scan() - { - if (peer != null) - { - peer.Rescan(); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the gun to turn independent from the robot's turn. - ///

- /// Ok, so this needs some explanation: The gun is mounted on the robot's - /// body. So, normally, if the robot turns 90 degrees to the right, then the - /// gun will turn with it as it is mounted on top of the robot's body. To - /// compensate for this, you can call - /// . - /// When this is set, the gun will turn independent from the robot's turn, - /// i.e. the gun will compensate for the robot's body turn. - ///

- /// Note: This method is additive until you reach the maximum the gun can - /// turn. The "adjust" is added to the amount you set for turning the robot, - /// then capped by the physics of the game. If you turn infinite, then the - /// adjust is ignored (and hence overridden). - ///

- /// - /// Assuming both the robot and gun start Out facing up (0 degrees): - /// - /// // Set gun to turn with the robot's turn - /// SetAdjustGunForRobotTurn(false); // This is the default - /// TurnRight(90); - /// // At this point, both the robot and gun are facing right (90 degrees) - /// TurnLeft(90); - /// // Both are back to 0 degrees - /// - /// -- or -- - /// - /// // Set gun to turn independent from the robot's turn - /// SetAdjustGunForRobotTurn(true); - /// TurnRight(90); - /// // At this point, the robot is facing right (90 degrees), but the gun is still facing up. - /// TurnLeft(90); - /// // Both are back to 0 degrees. - /// - /// - ///

- /// Note: The gun compensating this way does count as "turning the gun". - /// - ///

- public virtual bool IsAdjustGunForRobotTurn - { - get - { - if (peer != null) - { - return ((IStandardRobotPeer) peer).IsAdjustGunForBodyTurn(); - } - UninitializedException(); - return false; - } - set - { - if (peer != null) - { - ((IStandardRobotPeer) peer).SetAdjustGunForBodyTurn(value); - } - else - { - UninitializedException(); - } - } - } - - /// - /// Sets the radar to turn independent from the robot's turn. - ///

- /// Ok, so this needs some explanation: The radar is mounted on the gun, and - /// the gun is mounted on the robot's body. So, normally, if the robot turns - /// 90 degrees to the right, the gun turns, as does the radar. Hence, if the - /// robot turns 90 degrees to the right, then the gun and radar will turn - /// with it as the radar is mounted on top of the gun. To compensate for - /// this, you can call = true. - /// When this is set, the radar will turn independent from the robot's turn, - /// i.e. the radar will compensate for the robot's turn. - ///

- /// Note: This method is additive until you reach the maximum the radar can - /// turn. The "adjust" is added to the amount you set for turning the robot, - /// then capped by the physics of the game. If you turn infinite, then the - /// adjust is ignored (and hence overridden). - ///

- /// - /// Assuming the robot, gun, and radar all start Out facing up (0 - /// degrees): - /// - /// // Set radar to turn with the robots's turn - /// SetAdjustRadarForRobotTurn(false); // This is the default - /// TurnRight(90); - /// // At this point, the body, gun, and radar are all facing right (90 degrees); - /// - /// -- or -- - /// - /// // Set radar to turn independent from the robot's turn - /// SetAdjustRadarForRobotTurn(true); - /// TurnRight(90); - /// // At this point, the robot and gun are facing right (90 degrees), but the radar is still facing up. - /// - /// - /// - /// - ///

- public bool IsAdjustRadarForRobotTurn - { - get - { - if (peer != null) - { - return ((IStandardRobotPeer) peer).IsAdjustRadarForBodyTurn(); - } - UninitializedException(); - return false; - } - set - { - if (peer != null) - { - ((IStandardRobotPeer) peer).SetAdjustRadarForBodyTurn(value); - } - else - { - UninitializedException(); - } - } - } - - /// - /// Sets the radar to turn independent from the gun's turn. - ///

- /// Ok, so this needs some explanation: The radar is mounted on the robot's - /// gun. So, normally, if the gun turns 90 degrees to the right, then the - /// radar will turn with it as it is mounted on top of the gun. To compensate - /// for this, you can call = (true). - /// When this is set, the radar will turn independent from the robot's turn, - /// i.e. the radar will compensate for the gun's turn. - ///

- /// Note: This method is additive until you reach the maximum the radar can - /// turn. The "adjust" is added to the amount you set for turning the gun, - /// then capped by the physics of the game. If you turn infinite, then the - /// adjust is ignored (and hence overridden). - ///

- /// - /// Assuming both the gun and radar start Out facing up (0 degrees): - /// - /// // Set radar to turn with the gun's turn - /// SetAdjustRadarForGunTurn(false); // This is the default - /// TurnGunRight(90); - /// // At this point, both the radar and gun are facing right (90 degrees); - /// - /// -- or -- - /// - /// // Set radar to turn independent from the gun's turn - /// SetAdjustRadarForGunTurn(true); - /// TurnGunRight(90); - /// // At this point, the gun is facing right (90 degrees), but the radar is still facing up. - /// - /// - /// Note: Calling will automatically call - /// with the same value, unless you have - /// already called it earlier. This behavior is primarily for backward compatibility - /// with older Robocode robots. - /// - /// - ///

- public bool IsAdjustRadarForGunTurn - { - get - { - if (peer != null) - { - return ((IStandardRobotPeer) peer).IsAdjustRadarForGunTurn(); - } - UninitializedException(); - return false; - } - set - { - if (peer != null) - { - ((IStandardRobotPeer) peer).SetAdjustRadarForGunTurn(value); - } - else - { - UninitializedException(); - } - } - } - - /// - /// Sets the color of the robot's body, gun, and radar in the same time. - ///

- /// You may only call this method one time per battle. A null - /// indicates the default (blue) color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetColors(null, Color.Red, Color.fromArgb(150, 0, 150)); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// The new body color - /// The new gun color - /// The new radar color - public void SetColors(Color bodyColor, Color gunColor, Color radarColor) - { - if (peer != null) - { - peer.SetBodyColor(bodyColor); - peer.SetGunColor(gunColor); - peer.SetRadarColor(radarColor); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the color of the robot's body, gun, radar, bullet, and scan arc in - /// the same time. - ///

- /// You may only call this method one time per battle. A null - /// indicates the default (blue) color for the body, gun, radar, and scan - /// arc, but white for the bullet color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetColors(null, Color.Red, Color.Greeen, null, Color.fromArgb(150, 0, 150)); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// The new body color - /// The new gun color - /// The new radar color - /// The new bullet color - /// The new scan arc color - public void SetColors(Color bodyColor, Color gunColor, Color radarColor, Color bulletColor, Color scanArcColor) - { - if (peer != null) - { - peer.SetBodyColor(bodyColor); - peer.SetGunColor(gunColor); - peer.SetRadarColor(radarColor); - peer.SetBulletColor(bulletColor); - peer.SetScanColor(scanArcColor); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets all the robot's color to the same color in the same time, i.e. the - /// color of the body, gun, radar, bullet, and scan arc. - ///

- /// You may only call this method one time per battle. A null - /// indicates the default (blue) color for the body, gun, radar, and scan - /// arc, but white for the bullet color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetAllColors(Color.Red); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// The new color for all the colors of the robot - public void SetAllColors(Color color) - { - if (peer != null) - { - peer.SetBodyColor(color); - peer.SetGunColor(color); - peer.SetRadarColor(color); - peer.SetBulletColor(color); - peer.SetScanColor(color); - } - else - { - UninitializedException(); - } - } - - /// - /// Sets the color of the robot's body. - ///

- /// A null indicates the default (blue) color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetBodyColor(Color.Black); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public Color BodyColor - { - set - { - if (peer != null) - { - peer.SetBodyColor(value); - } - else - { - UninitializedException(); - } - } - get - { - if (peer != null) - { - return peer.GetBodyColor(); - } - UninitializedException(); - return default(Color); - } - } - - /// - /// - /// Sets the color of the robot's gun. - ///

- /// A null indicates the default (blue) color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetGunColor(Color.Red); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public Color GunColor - { - set - { - if (peer != null) - { - peer.SetGunColor(value); - } - else - { - UninitializedException(); - } - } - get - { - if (peer != null) - { - return peer.GetGunColor(); - } - UninitializedException(); - return default(Color); - } - } - - /// - /// - /// Sets the color of the robot's radar. - ///

- /// A null indicates the default (blue) color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetRadarColor(Color.Yellow); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public Color RadarColor - { - set - { - if (peer != null) - { - peer.SetRadarColor(value); - } - else - { - UninitializedException(); - } - } - get - { - if (peer != null) - { - return peer.GetRadarColor(); - } - UninitializedException(); - return default(Color); - } - } - - /// - /// - /// Sets the color of the robot's bullets. - ///

- /// A null indicates the default white color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetBulletColor(Color.Green); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public Color BulletColor - { - set - { - if (peer != null) - { - peer.SetBulletColor(value); - } - else - { - UninitializedException(); - } - } - get - { - if (peer != null) - { - return peer.GetBulletColor(); - } - UninitializedException(); - return default(Color); - } - } - - /// - /// - /// Sets the color of the robot's scan arc. - ///

- /// A null indicates the default (blue) color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetScanColor(Color.White); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- public Color ScanColor - { - set - { - if (peer != null) - { - peer.SetScanColor(value); - } - else - { - UninitializedException(); - } - } - get - { - if (peer != null) - { - return peer.GetScanColor(); - } - UninitializedException(); - return default(Color); - } - } - - /// - /// - /// Immediately stops all movement, and saves it for a call to . - /// If there is already movement saved from a previous stop, this will have no effect. - ///

- /// This method is equivalent to Stop(false). - /// - /// - ///

- public void Stop() - { - Stop(false); - } - - /// - /// Immediately stops all movement, and saves it for a call to . - /// If there is already movement saved from a previous stop, you can overwrite it by - /// calling Stop(true). - /// - /// - /// - /// - /// If there is already movement saved from a previous stop, you can overwrite it by - /// calling Stop(true). - /// - public void Stop(bool overwrite) - { - if (peer != null) - { - ((IStandardRobotPeer) peer).Stop(overwrite); - } - else - { - UninitializedException(); - } - } - - /// - /// Immediately resumes the movement you stopped by , if any. - ///

- /// This call executes immediately, and does not return until it is complete. - /// - /// - ///

- public void Resume() - { - if (peer != null) - { - ((IStandardRobotPeer) peer).Resume(); - } - else - { - UninitializedException(); - } - } - - /// - /// - /// Immediately turns the robot's gun to the left by degrees. - ///

- /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the gun's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's gun is set to turn right - /// instead of left. - ///

- /// - /// - /// // Turn the robot's gun 180 degrees to the left - /// TurnGunLeft(180); - /// - /// // Afterwards, turn the robot's gun 90 degrees to the right - /// TurnGunLeft(-90); - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's gun to the left. - /// If degrees > 0 the robot's gun will turn left. - /// If degrees < 0 the robot's gun will turn right. - /// If degrees = 0 the robot's gun will not turn, but execute. - /// - public void TurnGunLeft(double degrees) - { - if (peer != null) - { - peer.TurnGun(-Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// - /// Immediately turns the robot's gun to the right by degrees. - /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the gun's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's gun is set to turn left - /// instead of right. - ///

- /// - /// - /// // Turn the robot's gun 180 degrees to the right - /// TurnGunRight(180); - /// - /// // Afterwards, turn the robot's gun 90 degrees to the left - /// TurnGunRight(-90); - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's gun to the right. - /// If degrees > 0 the robot's gun will turn right. - /// If degrees < 0 the robot's gun will turn left. - /// If degrees = 0 the robot's gun will not turn, but execute. - /// - public void TurnGunRight(double degrees) - { - if (peer != null) - { - peer.TurnGun(Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Immediately turns the robot's radar to the left by degrees. - ///

- /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the radar's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's radar is set to turn right - /// instead of left. - ///

- /// - /// - /// // Turn the robot's radar 180 degrees to the left - /// TurnRadarLeft(180); - /// - /// // Afterwards, turn the robot's radar 90 degrees to the right - /// TurnRadarLeft(-90); - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's radar to the left. - /// If degrees > 0 the robot's radar will turn left. - /// If degrees < 0 the robot's radar will turn right. - /// If degrees = 0 the robot's radar will not turn, but execute. - /// - public void TurnRadarLeft(double degrees) - { - if (peer != null) - { - ((IStandardRobotPeer) peer).TurnRadar(-Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// - /// Immediately turns the robot's radar to the right by degrees. - /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the radar's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, - /// where negative values means that the robot's radar is set to turn left - /// instead of right. - ///

- /// - /// - /// // Turn the robot's radar 180 degrees to the right - /// TurnRadarRight(180); - /// - /// // Afterwards, turn the robot's radar 90 degrees to the left - /// TurnRadarRight(-90); - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of degrees to turn the robot's radar to the right. - /// If degrees > 0 the robot's radar will turn right. - /// If degrees < 0 the robot's radar will turn left. - /// If degrees = 0 the robot's radar will not turn, but execute. - /// - public void TurnRadarRight(double degrees) - { - if (peer != null) - { - ((IStandardRobotPeer) peer).TurnRadar(Utils.ToRadians(degrees)); - } - else - { - UninitializedException(); - } - } - - /// - /// Returns the robot's current energy. - /// - public double Energy - { - get - { - if (peer != null) - { - return peer.GetEnergy(); - } - UninitializedException(); - return 0; // never called - } - } - - /// - /// Returns a graphics context used for painting graphical items for the robot. - ///

- /// This method is very useful for debugging your robot. - ///

- /// Note that the robot will only be painted if the "Paint" is enabled on the - /// robot's console window; otherwise the robot will never get painted (the - /// reason being that all robots might have graphical items that must be - /// painted, and then you might not be able to tell what graphical items that - /// have been painted for your robot). - ///

- /// Also note that the coordinate system for the graphical context where you - /// paint items fits for the Robocode coordinate system where (0, 0) is at - /// the bottom left corner of the battlefield, where X is towards right and Y - /// is upwards. - /// - ///

- public IGraphics Graphics - { - get - { - if (peer != null) - { - return peer.GetGraphics(); - } - UninitializedException(); - return null; // never called - } - } - - /// - /// Sets the debug property with the specified key to the specified value. - ///

- /// This method is very useful when debugging or reviewing your robot as you - /// will be able to see this property displayed in the robot console for your - /// robots under the Debug Properties tab page. - ///

- public DebugPropertyH DebugProperty - { - get - { - if (peer != null) - { - if (debugProperty == null) - { - debugProperty = new DebugPropertyH(peer); - } - return debugProperty; - } - UninitializedException(); - return null; - } - } - - private DebugPropertyH debugProperty; - - /// - /// Container class for debug properties - /// - public class DebugPropertyH - { - private readonly IBasicRobotPeer peer; - - internal DebugPropertyH(IBasicRobotPeer peer) - { - this.peer = peer; - } - - /// - /// Set the new value of the debug property, where null or - /// the empty string is used for removing this debug property. - /// - /// - /// The name/key of the debug property - /// - /// - public string this[string key] - { - set { peer.SetDebugProperty(key, value); } - } - } - - - /// - public virtual void OnPaint(IGraphics graphics) - { - } - - /// - public virtual void OnKeyPressed(KeyEvent e) - { - } - - /// - public virtual void OnKeyReleased(KeyEvent e) - { - } - - /// - public virtual void OnKeyTyped(KeyEvent e) - { - } - - /// - public virtual void OnMouseClicked(MouseEvent e) - { - } - - /// - public virtual void OnMouseEntered(MouseEvent e) - { - } - - /// - public virtual void OnMouseExited(MouseEvent e) - { - } - - /// - public virtual void OnMousePressed(MouseEvent e) - { - } - - /// - public virtual void OnMouseReleased(MouseEvent e) - { - } - - /// - public virtual void OnMouseMoved(MouseEvent e) - { - } - - /// - public virtual void OnMouseDragged(MouseEvent e) - { - } - - /// - public virtual void OnMouseWheelMoved(MouseWheelMovedEvent e) - { - } - - /// - public virtual void OnStatus(StatusEvent e) - { - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RobotDeathEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RobotDeathEvent.cs deleted file mode 100644 index e93c3cf..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RobotDeathEvent.cs +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// This event is sent to - /// when another robot (not your robot) dies. - /// - [Serializable] - public sealed class RobotDeathEvent : Event - { - private const int DEFAULT_PRIORITY = 70; - - private readonly string robotName; - - /// - /// Called by the game to create a new RobotDeathEvent. - /// - /// the name of the robot that died - public RobotDeathEvent(string robotName) - { - this.robotName = robotName; - } - - /// - /// Returns the name of the robot that died. - /// - public string Name - { - get { return robotName; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnRobotDeath(this); - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.RobotDeathEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - var obj = (RobotDeathEvent) objec; - - return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.robotName); - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (RobotDeathEvent) objec; - - serializer.serialize(buffer, obj.robotName); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - string name = serializer.deserializeString(buffer); - - return new RobotDeathEvent(name); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RobotStatus.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RobotStatus.cs deleted file mode 100644 index 0d6be6e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RobotStatus.cs +++ /dev/null @@ -1,401 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.security; -using net.sf.robocode.serialization; -using Robocode.Util; - -namespace Robocode -{ - /// - /// Contains the status of a robot for a specific time/turn returned by - /// . - /// - [Serializable] - public sealed class RobotStatus - { - private readonly double energy; - private readonly double x; - private readonly double y; - private readonly double bodyHeading; - private readonly double gunHeading; - private readonly double radarHeading; - private readonly double velocity; - private readonly double bodyTurnRemaining; - private readonly double radarTurnRemaining; - private readonly double gunTurnRemaining; - private readonly double distanceRemaining; - private readonly double gunHeat; - private readonly int others; - private readonly int numSentries; - private readonly int roundNum; - private readonly int numRounds; - private readonly long time; - - /// - /// Returns the robot's current energy. - /// - public double Energy - { - get { return energy; } - } - - /// - /// Returns the X position of the robot. (0,0) is at the bottom left of the - /// battlefield. - /// - /// - public double X - { - get { return x; } - } - - /// - /// Returns the Y position of the robot. (0,0) is at the bottom left of the - /// battlefield. - /// - /// - public double Y - { - get { return y; } - } - - /// - /// Returns the direction that the robot's body is facing, in radians. - /// The value returned will be between 0 and 2 * PI (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// PI / 2 means East, PI means South, and 3 * PI / 2 means West. - ///

- public double HeadingRadians - { - get { return bodyHeading; } - } - - /// - /// Returns the direction that the robot's body is facing, in degrees. - /// The value returned will be between 0 and 360 (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// 90 means East, 180 means South, and 270 means West. - ///

- public double Heading - { - get { return Utils.ToDegrees(bodyHeading); } - } - - /// - /// Returns the direction that the robot's gun is facing, in radians. - /// The value returned will be between 0 and 2 * PI (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// PI / 2 means East, PI means South, and 3 * PI / 2 means West. - ///

- public double GunHeadingRadians - { - get { return gunHeading; } - } - - /// - /// Returns the direction that the robot's gun is facing, in degrees. - /// The value returned will be between 0 and 360 (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// 90 means East, 180 means South, and 270 means West. - ///

- public double GunHeading - { - get { return Utils.ToDegrees(gunHeading); } - } - - /// - /// Returns the direction that the robot's radar is facing, in radians. - /// The value returned will be between 0 and 2 * PI (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// PI / 2 means East, PI means South, and 3 * PI / 2 means West. - ///

- public double RadarHeadingRadians - { - get { return radarHeading; } - } - - /// - /// Returns the direction that the robot's radar is facing, in degrees. - /// The value returned will be between 0 and 360 (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// 90 means East, 180 means South, and 270 means West. - ///

- public double RadarHeading - { - get { return Utils.ToDegrees(radarHeading); } - } - - /// - /// Returns the velocity of the robot measured in pixels/turn. - ///

- /// The maximum velocity of a robot is defined by - /// (8 pixels / turn). - /// - ///

- public double Velocity - { - get { return velocity; } - } - - /// - /// Returns the angle remaining in the robots's turn, in radians. - ///

- /// This call returns both positive and negative values. - /// Positive values means that the robot is currently turning to the right. - /// Negative values means that the robot is currently turning to the left. - ///

- public double TurnRemainingRadians - { - get { return bodyTurnRemaining; } - } - - /// - /// Returns the angle remaining in the robots's turn, in degrees. - ///

- /// This call returns both positive and negative values. - /// Positive values means that the robot is currently turning to the right. - /// Negative values means that the robot is currently turning to the left. - ///

- public double TurnRemaining - { - get { return Utils.ToDegrees(bodyTurnRemaining); } - } - - /// - /// Returns the angle remaining in the radar's turn, in radians. - ///

- /// This call returns both positive and negative values. - /// Positive values means that the radar is currently turning to the right. - /// Negative values means that the radar is currently turning to the left. - ///

- public double RadarTurnRemainingRadians - { - get { return radarTurnRemaining; } - } - - /// - /// Returns the angle remaining in the radar's turn, in degrees. - ///

- /// This call returns both positive and negative values. - /// Positive values means that the radar is currently turning to the right. - /// Negative values means that the radar is currently turning to the left. - ///

- public double RadarTurnRemaining - { - get { return Utils.ToDegrees(radarTurnRemaining); } - } - - /// - /// Returns the angle remaining in the gun's turn, in radians. - ///

- /// This call returns both positive and negative values. - /// Positive values means that the gun is currently turning to the right. - /// Negative values means that the gun is currently turning to the left. - ///

- public double GunTurnRemainingRadians - { - get { return gunTurnRemaining; } - } - - /// - /// Returns the angle remaining in the gun's turn, in degrees. - ///

- /// This call returns both positive and negative values. - /// Positive values means that the gun is currently turning to the right. - /// Negative values means that the gun is currently turning to the left. - ///

- public double GunTurnRemaining - { - get { return Utils.ToDegrees(gunTurnRemaining); } - } - - /// - /// Returns the distance remaining in the robot's current move measured in - /// pixels. - ///

- /// This call returns both positive and negative values. - /// Positive values means that the robot is currently moving forwards. - /// Negative values means that the robot is currently moving backwards. - ///

- public double DistanceRemaining - { - get { return distanceRemaining; } - } - - /// - /// Returns the current heat of the gun. The gun cannot Fire unless this is - /// 0. (Calls to Fire will succeed, but will not actually Fire unless - /// GetGunHeat() == 0). - ///

- /// The amount of gun heat generated when the gun is fired is - /// 1 + (firePower / 5). Each turn the gun heat drops by the amount returned - /// by , which is a battle setup. - ///

- /// Note that all guns are "hot" at the start of each round, where the gun - /// heat is 3. - ///

- /// - /// - /// - public double GunHeat - { - get { return gunHeat; } - } - - /// - /// Returns how many opponents that are left in the current round. - /// - public int Others - { - get { return others; } - } - - /// - /// Returns how many sentry robots that are left in the current round. - /// - public int NumSentries - { - get { return numSentries; } - } - - /// - /// Returns the number of rounds in the current battle. - /// - /// - public int NumRounds - { - get { return numRounds; } - } - - /// - /// Returns the current round number (0 to - 1) of - /// the battle. - /// - /// - public int RoundNum - { - get { return roundNum; } - } - - /// - /// Returns the game time of the round, where the time is equal to the current turn in the round. - /// - public long Time - { - get { return time; } - } - - private RobotStatus(double energy, double x, double y, double bodyHeading, double gunHeading, - double radarHeading, - double velocity, double bodyTurnRemaining, double radarTurnRemaining, - double gunTurnRemaining, - double distanceRemaining, double gunHeat, - int others, int numSentries, - int roundNum, int numRounds, long time) - { - this.energy = energy; - this.x = x; - this.y = y; - this.bodyHeading = bodyHeading; - this.gunHeading = gunHeading; - this.radarHeading = radarHeading; - this.bodyTurnRemaining = bodyTurnRemaining; - this.velocity = velocity; - this.radarTurnRemaining = radarTurnRemaining; - this.gunTurnRemaining = gunTurnRemaining; - this.distanceRemaining = distanceRemaining; - this.gunHeat = gunHeat; - this.others = others; - this.numSentries = numSentries; - this.roundNum = roundNum; - this.numRounds = numRounds; - this.time = time; - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN, IHiddenStatusHelper - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + 12*RbSerializerN.SIZEOF_DOUBLE + 4*RbSerializerN.SIZEOF_INT - + RbSerializerN.SIZEOF_LONG; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (RobotStatus) objec; - - serializer.serialize(buffer, obj.energy); - serializer.serialize(buffer, obj.x); - serializer.serialize(buffer, obj.y); - serializer.serialize(buffer, obj.bodyHeading); - serializer.serialize(buffer, obj.gunHeading); - serializer.serialize(buffer, obj.radarHeading); - serializer.serialize(buffer, obj.velocity); - serializer.serialize(buffer, obj.bodyTurnRemaining); - serializer.serialize(buffer, obj.radarTurnRemaining); - serializer.serialize(buffer, obj.gunTurnRemaining); - serializer.serialize(buffer, obj.distanceRemaining); - serializer.serialize(buffer, obj.gunHeat); - serializer.serialize(buffer, obj.others); - serializer.serialize(buffer, obj.numSentries); - serializer.serialize(buffer, obj.roundNum); - serializer.serialize(buffer, obj.numRounds); - serializer.serialize(buffer, obj.time); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - double energy = buffer.getDouble(); - double x = buffer.getDouble(); - double y = buffer.getDouble(); - double bodyHeading = buffer.getDouble(); - double gunHeading = buffer.getDouble(); - double radarHeading = buffer.getDouble(); - double velocity = buffer.getDouble(); - double bodyTurnRemaining = buffer.getDouble(); - double radarTurnRemaining = buffer.getDouble(); - double gunTurnRemaining = buffer.getDouble(); - double distanceRemaining = buffer.getDouble(); - double gunHeat = buffer.getDouble(); - int others = buffer.getInt(); - int numSentries = buffer.getInt(); - int roundNum = buffer.getInt(); - int numRounds = buffer.getInt(); - long time = buffer.getLong(); - - return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining, - radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries, - roundNum, numRounds, time); - } - - public RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading, - double radarHeading, double velocity, double bodyTurnRemaining, - double radarTurnRemaining, double gunTurnRemaining, double distanceRemaining, - double gunHeat, int others, int numSentries, int roundNum, int numRounds, long time) - { - return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining, - radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries, - roundNum, numRounds, time); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RoundEndedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RoundEndedEvent.cs deleted file mode 100644 index 5554c77..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/RoundEndedEvent.cs +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A RoundEndedEvent is sent to when a round has ended. - /// You can use the information contained in this event to determine which round that has ended. - /// - /// - public class RoundEndedEvent : Event - { - private const int DEFAULT_PRIORITY = 110; // System event -> cannot be changed! - - private readonly int round; - private readonly int turns; - private readonly int totalTurns; - - - /// - /// Called by the game to create a new RoundEndedEvent. - /// - /// The round that has ended (zero-indexed) - /// The number of turns that this round reached - /// The total number of turns reached in the battle when this round ended - public RoundEndedEvent(int round, int turns, int totalTurns) - { - this.round = round; - this.turns = turns; - this.totalTurns = totalTurns; - } - - /// - /// The round that ended (zero-indexed). - /// - public int Round - { - get { return round; } - } - - /// - /// The number of turns that this round reached. - /// - public int Turns - { - get { return turns; } - } - - /// - /// The total number of turns reached in the battle when this round ended. - /// - public int TotalTurns - { - get { return totalTurns; } - } - - internal override sealed int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - /// - public override sealed int Priority - { - get { return DEFAULT_PRIORITY; } - } - - internal override sealed void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (robot != null) - { - IBasicEvents3 listener = robot.GetBasicEventListener() as IBasicEvents3; - - - if (listener != null) - { - listener.OnRoundEnded(this); - } - } - } - - internal override sealed bool IsCriticalEvent - { - get { return true; } - } - - internal override byte SerializationType - { - get { return RbSerializerN.RoundEndedEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, Object obje) - { - return RbSerializerN.SIZEOF_TYPEINFO + 3*RbSerializerN.SIZEOF_INT; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje) - { - RoundEndedEvent evnt = (RoundEndedEvent) obje; - - serializer.serialize(buffer, evnt.round); - serializer.serialize(buffer, evnt.turns); - serializer.serialize(buffer, evnt.totalTurns); - } - - public Object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - int round = serializer.deserializeInt(buffer); - int turns = serializer.deserializeInt(buffer); - int totalTurns = serializer.deserializeInt(buffer); - - return new RoundEndedEvent(round, turns, totalTurns); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Rules.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Rules.cs deleted file mode 100644 index 50af6b4..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Rules.cs +++ /dev/null @@ -1,214 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using Robocode.Util; - -namespace Robocode -{ - /// - /// Constants and methods that defines the rules of Robocode. - /// Constants are used for rules that will not change. - /// Methods are provided for rules that can be changed between battles or which depends - /// on some other factor. - /// - public static class Rules - { - // Hide the constructor in the docs as it should not be used - - /// - /// The acceleration of a robot, i.e. the increase of velocity when the - /// robot moves forward, which is 1 pixel/turn. - /// - public static readonly double ACCELERATION = 1; - - /// - /// The deceleration of a robot, i.e. the decrease of velocity when the - /// robot moves backwards (or brakes), which is 2 pixels/turn. - /// - public static readonly double DECELERATION = 2; - - /// - /// The maximum velocity of a robot, which is 8 pixels/turn. - /// - public static readonly double MAX_VELOCITY = 8; - - /// - /// The radar scan radius, which is 1200 pixels. - /// Robots which is more than 1200 pixels away cannot be seen on the radar. - /// - public static readonly double RADAR_SCAN_RADIUS = 1200; - - /// - /// The minimum bullet power, i.e the amount of energy required for firing a - /// bullet, which is 0.1 energy points. - /// - public static readonly double MIN_BULLET_POWER = 0.1; - - /// - /// The maximum bullet power, i.e. the maximum amount of energy that can be - /// transferred to a bullet when it is fired, which is 3 energy points. - /// - public static readonly double MAX_BULLET_POWER = 3; - - /// - /// The maximum turning rate of the robot, in degrees, which is - /// 10 degress/turn. - /// Note, that the turn rate of the robot depends on it's velocity. - /// - /// - /// - /// - public static readonly double MAX_TURN_RATE = 10; - - /// - /// The maximum turning rate of the robot measured in radians instead of - /// degrees. - /// - /// - /// - /// - /// - public static readonly double MAX_TURN_RATE_RADIANS = Utils.ToRadians(MAX_TURN_RATE); - - /// - /// The turning rate of the gun measured in degrees, which is 20 degrees/turn. - /// Note, that if AdjustGunForRobotTurn = true has been set, the gun turn is - /// independent of the robot turn. In this case the gun moves relatively to the screen. - ///

- /// If AdjustGunForRobotTurn = false has been set or AdjustGunForRobotTurn has not - /// been called at all (this is the default), then the gun turn is dependent on - /// the robot turn, and in this case the gun moves relatively to the robot body. - /// - /// - /// - ///

- public static readonly double GUN_TURN_RATE = 20; - - /// - /// The turning rate of the gun measured in radians instead of degrees. - /// - /// - /// - public static readonly double GUN_TURN_RATE_RADIANS = Utils.ToRadians(GUN_TURN_RATE); - - /// - /// The turning rate of the radar measured in degrees, which is 45 degrees/turn. - /// Note, that if AdjustRadarForRobotTurn = true and/or - /// AdjustRadarForGunTurn = true has been set, the radar turn is independent of - /// the robot and/or gun turn. If both properties hava been set to true, the radar - /// moves relatively to the screen. - ///

- /// If AdjustRadarForRobotTurn = false and/or AdjustRadarForGunTurn = false - /// have been set or not set at all (this is the default), then the radar turn is - /// dependent on the robot and/or gun turn, and in this case the radar moves - /// relatively to the gun and/or robot body. - /// - /// - /// - /// - ///

- public static readonly double RADAR_TURN_RATE = 45; - - /// - /// The turning rate of the radar measured in radians instead of degrees. - /// - /// - /// - public static readonly double RADAR_TURN_RATE_RADIANS = Utils.ToRadians(RADAR_TURN_RATE); - - /// - /// The amount of damage taken when a robot hits or is hit by another robot, - /// which is 0.6 energy points. - /// - public static readonly double ROBOT_HIT_DAMAGE = 0.6; - - /// - /// The amount of bonus given when a robot moving forward hits an opponent - /// robot (ramming), which is 1.2 energy points. - /// - public static readonly double ROBOT_HIT_BONUS = 1.2; - - /// - /// Returns the turn rate of a robot given a specific velocity measured in - /// degrees/turn. - /// - /// - /// The velocity of the robot. - public static double GetTurnRate(double velocity) - { - return MAX_TURN_RATE - 0.75*velocity; - } - - /// - /// Returns the turn rate of a robot given a specific velocity measured in - /// radians/turn. - /// - /// - /// the velocity of the robot. - public static double GetTurnRateRadians(double velocity) - { - return Utils.ToRadians(GetTurnRate(velocity)); - } - - /// - /// Returns the amount of damage taken when robot hits a wall with a - /// specific velocity. - /// - /// the velocity of the robot. - public static double GetWallHitDamage(double velocity) - { - return Math.Max(Math.Abs(velocity)/2 - 1, 0); - } - - /// - /// Returns the amount of damage of a bullet given a specific bullet power. - /// - /// the energy power of the bullet. - public static double GetBulletDamage(double bulletPower) - { - double damage = 4*bulletPower; - - if (bulletPower > 1) - { - damage += 2*(bulletPower - 1); - } - return damage; - } - - /// - /// Returns the amount of bonus given when a robot's bullet hits an opponent - /// robot given a specific bullet power. - /// - /// the energy power of the bullet - public static double GetBulletHitBonus(double bulletPower) - { - return 3*bulletPower; - } - - /// - /// Returns the speed of a bullet given a specific bullet power measured in - /// pixels/turn. - /// - /// the energy power of the bullet. - public static double GetBulletSpeed(double bulletPower) - { - bulletPower = Math.Min(Math.Max(bulletPower, MIN_BULLET_POWER), MAX_BULLET_POWER); - return 20 - 3 * bulletPower; - } - - /// - /// Returns the heat produced by firing the gun given a specific bullet power. - /// - /// the energy power of the bullet - public static double GetGunHeat(double bulletPower) - { - return 1 + (bulletPower/5); - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/ScannedRobotEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/ScannedRobotEvent.cs deleted file mode 100644 index c76ff49..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/ScannedRobotEvent.cs +++ /dev/null @@ -1,238 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A ScannedRobotEvent is sent to - /// OnScannedRobot()} when you scan a robot. - /// You can use the information contained in this event to determine what to do. - ///

- /// Note: You should not inherit from this class in your own event class! - /// The internal logic of this event class might change. Hence, your robot might - /// not work in future Robocode versions, if you choose to inherit from this class. - ///

- public class ScannedRobotEvent : Event - { - private const int DEFAULT_PRIORITY = 10; - - private readonly string name; - private readonly double energy; - private readonly double heading; - private readonly double bearing; - private readonly double distance; - private readonly double velocity; - private readonly bool isSentryRobot; - - [Obsolete("ScannedRobotEvent() is obsolete.\n" + - "Please use ScannedRobotEvent(string, double, double, double, double, double, bool) instead.")] - internal ScannedRobotEvent() - : this(null, 0, 0, 0, 0, 0, false) - { - } - - /// - /// Called by the game to create a new ScannedRobotEvent. - /// - /// The name of the scanned robot - /// The energy of the scanned robot - /// The bearing of the scanned robot, in radians - /// The distance from your robot to the scanned robot - /// The heading of the scanned robot - /// The velocity of the scanned robot - [Obsolete("ScannedRobotEvent(string, double, double, double, double, double) is obsolete.\n" + - "Please use ScannedRobotEvent(string, double, double, double, double, double, bool) instead.")] - public ScannedRobotEvent(string name, double energy, double bearing, double distance, double heading, double velocity) : - this(name, energy, bearing, distance, heading, velocity, false) - { - } - - /// - /// Called by the game to create a new ScannedRobotEvent. - /// - /// The name of the scanned robot - /// The energy of the scanned robot - /// The bearing of the scanned robot, in radians - /// The distance from your robot to the scanned robot - /// The heading of the scanned robot - /// The velocity of the scanned robot - /// Flag specifying if the scanned robot is a sentry robot - public ScannedRobotEvent(string name, double energy, double bearing, double distance, double heading, double velocity, bool isSentryRobot) - { - this.name = name; - this.energy = energy; - this.bearing = bearing; - this.distance = distance; - this.heading = heading; - this.velocity = velocity; - this.isSentryRobot = isSentryRobot; - } - - /// - /// Returns the bearing to the robot you scanned, relative to your robot's - /// heading, in degrees (-180 <= getBearing() < 180) - /// - public double Bearing - { - get { return bearing*180.0/Math.PI; } - } - - /// - /// Returns the bearing to the robot you scanned, relative to your robot's - /// heading, in radians (-PI <= getBearingRadians() < PI) - /// - public double BearingRadians - { - get { return bearing; } - } - - /// - /// Returns the distance to the robot (your center to his center). - /// - public double Distance - { - get { return distance; } - } - - /// - /// Returns the energy of the robot. - /// - public double Energy - { - get { return energy; } - } - - /// - /// Returns the heading of the robot, in degrees (0 <= getHeading() < 360) - /// - public double Heading - { - get { return heading*180.0/Math.PI; } - } - - /// - /// Returns the heading of the robot, in radians (0 <= getHeading() < 2 * PI) - /// - public double HeadingRadians - { - get { return heading; } - } - - - /// - /// Returns the name of the robot. - /// - public string Name - { - get { return name; } - } - - - /// - /// Returns the velocity of the robot. - /// - public double Velocity - { - get { return velocity; } - } - - /// - /// true if the scanned robot is a sentry robot; false otherwise. - /// - public bool IsSentryRobot - { - get { return isSentryRobot; } - } - - /// - public override sealed int CompareTo(Event evnt) - { - int res = base.CompareTo(evnt); - - if (res != 0) - { - return res; - } - // Compare the distance, if the events are ScannedRobotEvents - // The shorter distance to the robot, the higher priority - if (evnt is ScannedRobotEvent) - { - return (int) (Distance - ((ScannedRobotEvent) evnt).Distance); - } - // No difference found - return 0; - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnScannedRobot(this); - } - } - - internal override byte SerializationType - { - get { return RbSerializerN.ScannedRobotEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - var obj = (ScannedRobotEvent) objec; - - return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.name) + 5 * RbSerializerN.SIZEOF_DOUBLE + RbSerializerN.SIZEOF_BOOL; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (ScannedRobotEvent) objec; - - serializer.serialize(buffer, obj.name); - serializer.serialize(buffer, obj.energy); - serializer.serialize(buffer, obj.heading); - serializer.serialize(buffer, obj.bearing); - serializer.serialize(buffer, obj.distance); - serializer.serialize(buffer, obj.velocity); - serializer.serialize(buffer, obj.isSentryRobot); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - string name = serializer.deserializeString(buffer); - double energy = buffer.getDouble(); - double heading = buffer.getDouble(); - double bearing = buffer.getDouble(); - double distance = buffer.getDouble(); - double velocity = buffer.getDouble(); - bool isSentryRobot = serializer.deserializeBoolean(buffer); - - return new ScannedRobotEvent(name, energy, bearing, distance, heading, velocity, isSentryRobot); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/SkippedTurnEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/SkippedTurnEvent.cs deleted file mode 100644 index a0aaef0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/SkippedTurnEvent.cs +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// A SkippedTurnEvent is sent to - /// OnSkippedTurn()} when your robot is forced to skipping a turn. - /// You must take an action every turn in order to participate in the game. - /// - /// - /// Thread.Sleep(1000); - /// - /// will cause many SkippedTurnEvents, because you are not responding to the game. - /// If you receive 30 SkippedTurnEvents, you will be removed from the round. - ///

- /// Instead, you should do something such as: - /// - /// for (int i = 0; i < 30; i++) - /// { - /// DoNothing(); // or perhaps Scan(); - /// } - /// - /// - ///

- /// This event may also be generated if you are simply doing too much processing - /// between actions, that is using too much processing power for the calculations - /// etc. in your robot. - /// - /// - ///

- public sealed class SkippedTurnEvent : Event - { - private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!; - - private readonly long skippedTurn; - - /// - /// Called by the game to create a new SkippedTurnEvent. - /// - public SkippedTurnEvent(long skippedTurn) - { - this.skippedTurn = skippedTurn; - } - - /// - /// Returns the turn that was skipped. - /// - public long SkippedTurn - { - get { return skippedTurn; } - } - - /// - public override int Priority - { - get { return DEFAULT_PRIORITY; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - if (statics.IsAdvancedRobot()) - { - IAdvancedEvents listener = ((IAdvancedRobot) robot).GetAdvancedEventListener(); - - if (listener != null) - { - listener.OnSkippedTurn(this); - } - } - } - - internal override bool IsCriticalEvent - { - get { return true; } - } - - internal override byte SerializationType - { - get { return RbSerializerN.SkippedTurnEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_LONG; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - var obj = (SkippedTurnEvent)objec; - - serializer.serialize(buffer, obj.skippedTurn); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - long skippedTurn = buffer.getLong(); - - return new SkippedTurnEvent(skippedTurn); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/StatusEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/StatusEvent.cs deleted file mode 100644 index 84bac6a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/StatusEvent.cs +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.peer; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// This event is sent to every - /// turn in a battle to provide the status of the robot. - /// - [Serializable] - public sealed class StatusEvent : Event - { - private const int DEFAULT_PRIORITY = 99; - - private readonly RobotStatus status; - - /// - /// This constructor is called internally from the game in order to create - /// a new . - /// - /// - /// the current states - public StatusEvent(RobotStatus status) - { - this.status = status; - } - - /// - /// Returns the at the time defined by . - /// - /// - public RobotStatus Status - { - get { return status; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnStatus(this); - } - } - - internal override byte SerializationType - { - get { throw new System.Exception("Serialization of this type is not supported"); } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/TeamRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/TeamRobot.cs deleted file mode 100644 index bfa6eda..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/TeamRobot.cs +++ /dev/null @@ -1,193 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Collections.Generic; -using Robocode.RobotInterfaces; -using Robocode.RobotInterfaces.Peer; - -namespace Robocode -{ - /// - /// An advanced type of robot that supports sending messages between team - /// mates in a robot team. - ///

- /// If you have not done already, you should create a or - /// first. - /// - /// - /// - /// - /// - /// - ///

- public abstract class TeamRobot : AdvancedRobot, ITeamRobot, ITeamEvents - { - - /// - /// Broadcasts a message to all teammates. - ///

- /// - /// - /// public void Run() - /// { - /// BroadcastMessage("I'm here!"); - /// } - /// - /// - ///

- /// The message to broadcast to all teammates - /// if the message could not be broadcasted to the teammates. - /// - /// - /// - /// - public void BroadcastMessage(object message) - { - if (peer != null) - { - ((ITeamRobotPeer) peer).BroadcastMessage(message); - } - else - { - UninitializedException(); - } - } - - /// - /// Returns a list containing all MessageEvents currently in the robot's queue. - /// You might, for example, call this while processing another event. - ///

- /// - /// - /// foreach (MessageEvent e in GetMessageEvents()) - /// { - /// // do something with e - /// } - /// - /// - /// - /// - ///

- public IList GetMessageEvents() - { - if (peer != null) - { - return new List(((ITeamRobotPeer) peer).GetMessageEvents()); - } - UninitializedException(); - return null; // never called - } - - /// - ITeamEvents ITeamRobot.GetTeamEventListener() - { - return this; // this robot is listening - } - - /// - /// Returns the names of all teammates, or null there is no teammates. - /// The length of the string array is equal to the number of teammates. - ///

- /// - /// - /// public void Run() - /// { - /// // Prints Out all teammates - /// string[] teammates = GetTeammates(); - /// if (teammates != null) - /// { - /// foreach (string member in teammates) - /// { - /// Out.WriteLine(member); - /// } - /// } - /// } - /// - /// - /// - /// - /// - ///

- public string[] Teammates - { - get - { - if (peer != null) - { - return ((ITeamRobotPeer) peer).GetTeammates(); - } - UninitializedException(); - return null; - } - } - - /// - /// Checks if a given robot name is the name of one of your teammates. - ///

- /// - /// - /// public void OnScannedRobot(ScannedRobotEvent e) - /// { - /// if (IsTeammate(e.Name) - /// { - /// return; - /// } - /// Fire(1); - /// } - /// - /// - /// - /// - /// - ///

- /// The robot name to check - public bool IsTeammate(string name) - { - if (peer != null) - { - return ((ITeamRobotPeer) peer).IsTeammate(name); - } - UninitializedException(); - return false; - } - - /// - public virtual void OnMessageReceived(MessageEvent evnt) - { - } - - /// - /// Sends a message to one (or more) teammates. - ///

- /// - /// - /// public void Run() - /// { - /// SendMessage("Sample.DroidBot", "I'm here!"); - /// } - /// - /// - /// - /// - /// - ///

- /// The name of the intended recipient of the message - /// The message to send - public void SendMessage(string name, object message) - { - if (peer != null) - { - ((ITeamRobotPeer) peer).SendMessage(name, message); - } - else - { - UninitializedException(); - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Thread.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Thread.cs deleted file mode 100644 index 3bcdfdd..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/Thread.cs +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Threading; -using net.sf.robocode.io; -using net.sf.robocode.security; - -namespace Robocode -{ - /// - /// Wrapper for .NET Thread, secured according to robocode rules. - /// - public class Thread - { - private static readonly object syncRoot=new object(); - private static int runningCounter; - - private readonly System.Threading.Thread thread; - private readonly ParameterizedThreadStart real1; - private readonly ThreadStart real2; - - /// - /// Initializes a new instance of the Thread class - /// - /// A ThreadStart delegate that represents the methods to be invoked when this thread begins executing. - public Thread(ParameterizedThreadStart start) - { - if (start == null) - { - throw new ArgumentException("start"); - } - int id = CheckCount(); - real1 = start; - thread = new System.Threading.Thread(main); - string name = (string) AppDomain.CurrentDomain.GetData("robotName"); - if (!string.IsNullOrEmpty(name)) - { - thread.Name = name + " [" + id + "]"; - } - } - - /// - /// Initializes a new instance of the Thread class - /// - /// A ThreadStart delegate that represents the methods to be invoked when this thread begins executing. - public Thread(ThreadStart start) - { - if (start==null) - { - throw new ArgumentException("start"); - } - int id = CheckCount(); - real2 = start; - thread = new System.Threading.Thread(main); - string name = (string)AppDomain.CurrentDomain.GetData("robotName"); - if (!string.IsNullOrEmpty(name)) - { - thread.Name = name + " [" + id + "]"; - } - } - - private static int CheckCount() - { - lock (syncRoot) - { - if (runningCounter > 5) - { - string message = "Preventing " + HiddenAccessN.GetRobotName() + "from thread creation. You may only create 5 threads at same time."; - LoggerN.logError(message); - LoggerN.WriteLineToRobotsConsole(message); - throw new AccessViolationException(message); - } - runningCounter++; - return runningCounter; - } - } - - /// - /// Blocks the current thread for the specified number of milliseconds. - /// - public static void Sleep(int millisecondsTimeout) - { - System.Threading.Thread.Sleep(millisecondsTimeout); - } - - /// - /// Causes a thread to be scheduled for execution. - /// - public void Start(object param) - { - thread.Start(param); - } - - /// - /// Causes a thread to be scheduled for execution. - /// - public void Start() - { - thread.Start(null); - } - - private void main(object param) - { - try - { - if (real1!=null) - { - real1.Invoke(param); - } - real2.Invoke(); - } - catch (System.Exception ex) - { - Console.WriteLine("Undandled exception on thread " + thread.Name); - Console.WriteLine(ex); - } - finally - { - lock (syncRoot) - { - runningCounter--; - } - } - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/TurnCompleteCondition.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/TurnCompleteCondition.cs deleted file mode 100644 index 4a5af67..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/TurnCompleteCondition.cs +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode -{ - /// - /// A prebuilt condition you can use that indicates your robot has finished turning. - /// - /// - public class TurnCompleteCondition : Condition - { - private readonly AdvancedRobot robot; - - /// - /// Creates a new TurnCompleteCondition with default priority. - /// The default priority is 80. - /// - /// Your robot, which must be an - public TurnCompleteCondition(AdvancedRobot robot) - { - this.robot = robot; - } - - /// - /// Creates a new TurnCompleteCondition with the specified priority. - /// A condition priority is a value from 0 - 99. The higher value, the - /// higher priority. The default priority is 80. - /// - /// Your robot, which must be an - /// The priority of this condition - /// - public TurnCompleteCondition(AdvancedRobot robot, int priority) - { - this.robot = robot; - this.priority = priority; - } - - /// - /// Tests if the robot has finished turning. - /// Returns true if the robot has stopped turning; false otherwise - /// - public override bool Test() - { - return (robot.TurnRemaining == 0); - } - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/WinEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/WinEvent.cs deleted file mode 100644 index 2cd83be..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/WinEvent.cs +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.serialization; -using Robocode.RobotInterfaces; - -namespace Robocode -{ - /// - /// This event is sent to when your robot - /// wins the round in a battle. - /// - [Serializable] - public sealed class WinEvent : Event - { - private const int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!; - - /// - public override int Priority - { - get { return DEFAULT_PRIORITY; } - } - - internal override int DefaultPriority - { - get { return DEFAULT_PRIORITY; } - } - - internal override void Dispatch(IBasicRobot robot, IRobotStaticsN statics, IGraphics graphics) - { - IBasicEvents listener = robot.GetBasicEventListener(); - - if (listener != null) - { - listener.OnWin(this); - } - } - - internal override bool IsCriticalEvent - { - get { return true; } - } - - internal override byte SerializationType - { - get { return RbSerializerN.WinEvent_TYPE; } - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - private class SerializableHelper : ISerializableHelperN - { - public int sizeOf(RbSerializerN serializer, object objec) - { - return RbSerializerN.SIZEOF_TYPEINFO; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object objec) - { - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - return new WinEvent(); - } - } - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/exception/EventInterruptedException.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/exception/EventInterruptedException.cs deleted file mode 100644 index b7891db..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/exception/EventInterruptedException.cs +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Runtime.Serialization; - -namespace Robocode.Exception -{ - /// - [Serializable] - public class EventInterruptedException : System.Exception - { - private readonly int priority = int.MinValue; - - /// - /// Used by game - /// - public EventInterruptedException(int priority) - { - this.priority = priority; - } - - /// - /// Last top priority - /// - public int Priority - { - get - { - return priority; - } - } - - /// - /// Serialization constructor - /// - protected EventInterruptedException(SerializationInfo info, StreamingContext context) : - base(info, context) - { - } - - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/exception/RobotException.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/exception/RobotException.cs deleted file mode 100644 index 4d37cf6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/exception/RobotException.cs +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Runtime.Serialization; - -namespace Robocode.Exception -{ - /// - /// Throw this exception to stop robot - /// - /// - [Serializable] - public class RobotException : System.Exception - { - /// - /// Default constructor - /// - public RobotException() - { - } - - /// - /// Constructor with message - /// - public RobotException(string s) - : base(s) - { - } - - /// - /// Deserialization constructor - /// - protected RobotException(SerializationInfo info, StreamingContext context) : - base(info, context) - { - } - - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IAdvancedEvents.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IAdvancedEvents.cs deleted file mode 100644 index e7579e1..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IAdvancedEvents.cs +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace Robocode.RobotInterfaces -{ - /// - /// An event interface for receiving advanced robot events with an - /// - /// - /// - public interface IAdvancedEvents - { - /// - /// This method is called if the robot is using too much time between - /// actions. When this event occur, the robot's turn is skipped, meaning that - /// it cannot take action anymore in this turn. - ///

- /// If you receive 30 skipped turn event, your robot will be removed from the - /// round and loose the round. - ///

- /// You will only receive this event after taking an action. So a robot in an - /// infinite loop will not receive any events, and will simply be stopped. - ///

- /// No correctly working, reasonable robot should ever receive this event - /// unless it is using too many CPU cycles. - /// - /// - ///

- /// The skipped turn event set by the game - void OnSkippedTurn(SkippedTurnEvent evnt); - - /// - /// This method is called when a custom condition is met. - ///

- /// See the sample robots for examples of use, e.g. the Sample.Target - /// robot. - /// - /// - /// - ///

- /// The custom event that occurred - void OnCustomEvent(CustomEvent evnt); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IAdvancedRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IAdvancedRobot.cs deleted file mode 100644 index 392ab8d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IAdvancedRobot.cs +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode.RobotInterfaces -{ - /// - /// A robot interface for creating a more advanced type of robot like - /// that is able to handle advanced robot events. - /// An advanced robot allows non-blocking calls, custom events, get notifications - /// about skipped turns, and also allow writes to the file system. - /// - /// - /// - /// - /// - /// - public interface IAdvancedRobot : IBasicRobot - { - /// - /// This method is called by the game to notify this robot about advanced - /// robot event. Hence, this method must be implemented so it returns your - /// listener. - /// - IAdvancedEvents GetAdvancedEventListener(); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicEvents.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicEvents.cs deleted file mode 100644 index 2d15b9c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicEvents.cs +++ /dev/null @@ -1,270 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace Robocode.RobotInterfaces -{ - /// - /// An event interface for receiving basic robot events with an - /// . - /// - /// - public interface IBasicEvents - { - /// - /// This method is called every turn in a battle round in order to provide - /// the robot status as a complete snapshot of the robot's current state at - /// that specific time. - ///

- /// The main benefit of this method is that you'll automatically receive all - /// current data values of the robot like e.g. the x and y coordinate, - /// heading, gun heat etc., which are grouped into the exact same time/turn. - ///

- /// This is the only way to map the robots data values to a specific time. - /// For example, it is not possible to determine the exact time of the - /// robot's heading by calling first calling and then - /// afterwards, as the time might change - /// after between the and - /// call. - /// - /// - ///

- void OnStatus(StatusEvent evnt); - - /// - /// This method is called when one of your bullets hits another robot. - /// You should override it in your robot if you want to be informed of this - /// event. - ///

- /// - /// - /// public void OnBulletHit(BulletHitEvent evnt) - /// { - /// Out.WriteLine("I hit " + evnt.Name + "!"); - /// } - /// - /// - /// - /// - ///

- void OnBulletHit(BulletHitEvent evnt); - - /// - /// This method is called when one of your bullets hits another bullet. - /// You should override it in your robot if you want to be informed of this - /// event. - ///

- /// - /// - /// public void OnBulletHitBullet(BulletHitBulletEvent evnt) - /// { - /// Out.WriteLine("I hit a bullet fired by " + evnt.Bullet.Name + "!"); - /// } - /// - /// - /// - /// - ///

- void OnBulletHitBullet(BulletHitBulletEvent evnt); - - /// - /// This method is called when one of your bullets misses, i.e. hits a wall. - /// You should override it in your robot if you want to be informed of this - /// event. - ///

- /// - /// - /// public void OnBulletMissed(BulletMissedEvent evnt) - /// { - /// Out.WriteLine("Drat, I missed."); - /// } - /// - /// - /// - /// - ///

- void OnBulletMissed(BulletMissedEvent evnt); - - /// - /// This method is called if your robot dies. - ///

- /// You should override it in your robot if you want to be informed of this - /// event. Actions will have no effect if called from this section. The - /// intent is to allow you to perform calculations or print something out - /// when the robot is killed. - /// - /// - /// - /// - ///

- void OnDeath(DeathEvent evnt); - - /// - /// This method is called when your robot is hit by a bullet. - /// You should override it in your robot if you want to be informed of this - /// event. - ///

- /// - /// - /// void OnHitByBullet(HitByBulletEvent evnt) - /// { - /// Out.WriteLine(event.RobotName + " hit me!"); - /// } - /// - /// - /// - /// - ///

- void OnHitByBullet(HitByBulletEvent evnt); - - /// - /// This method is called when your robot collides with another robot. - /// You should override it in your robot if you want to be informed of this - /// event. - ///

- /// - /// - /// void OnHitRobot(HitRobotEvent evnt) - /// { - /// if (event.Bearing > -90 && evnt.Bearing <= 90) - /// { - /// Back(100); - /// } - /// else - /// { - /// Ahead(100); - /// } - /// } - /// - /// -- or perhaps, for a more advanced robot -- - /// - /// public void OnHitRobot(HitRobotEvent evnt) - /// { - /// if (event.Bearing > -90 && evnt.Bearing <= 90) - /// { - /// SetBack(100); - /// } - /// else - /// { - /// SetAhead(100); - /// } - /// } - /// - /// - ///

- /// The angle is relative to your robot's facing. So 0 is straight ahead of - /// you. - ///

- /// This event can be generated if another robot hits you, in which case - /// will return false. - /// In this case, you will not be automatically stopped by the game -- - /// but if you continue moving toward the robot you will hit it (and - /// generate another event). If you are moving away, then you won't hit it. - /// - /// - ///

- void OnHitRobot(HitRobotEvent evnt); - - /// - /// This method is called when your robot collides with a wall. - /// You should override it in your robot if you want to be informed of this - /// event. - ///

- /// The wall at the top of the screen is 0 degrees, right is 90 degrees, - /// bottom is 180 degrees, left is 270 degrees. But this event is relative to - /// your heading, so: The bearing is such that - /// will point you perpendicular to the wall. - ///

- /// - /// - /// void OnHitWall(HitWallEvent evnt) - /// { - /// Out.WriteLine("Ouch, I hit a wall bearing " + evnt.Bearing + " degrees."); - /// } - /// - /// - /// - /// - ///

- void OnHitWall(HitWallEvent evnt); - - /// - /// This method is called when your robot sees another robot, i.e. when the - /// robot's radar scan "hits" another robot. - /// You should override it in your robot if you want to be informed of this - /// event. (Almost all robots should override this!) - ///

- /// This event is automatically called if there is a robot in range of your - /// radar. - ///

- /// Note that the robot's radar can only see robot within the range defined - /// by (1200 pixels). - ///

- /// Also not that the bearing of the scanned robot is relative to your - /// robot's heading. - ///

- /// - /// - /// void OnScannedRobot(ScannedRobotEvent evnt) - /// { - /// // Assuming radar and gun are aligned... - /// if (event.Distance < 100) - /// { - /// Fire(3); - /// } - /// else - /// { - /// Fire(1); - /// } - /// } - /// - /// - ///

- /// Note:
- /// The game assists Robots in firing, as follows: - ///

    - ///
  • If the gun and radar are aligned (and were aligned last turn),
  • - ///
  • and the event is current,
  • - ///
  • and you call Fire() before taking any other actions, Robot.Fire(double) will Fire directly at the robot.
  • - ///
- ///

- /// In essence, this means that if you can see a robot, and it doesn't move, - /// then Fire will hit it. - ///

- /// AdvancedRobots will NOT be assisted in this manner, and are expected to - /// examine the event to determine if would - /// hit. (i.e. you are spinning your gun around, but by the time you get the - /// event, your gun is 5 degrees past the robot). - /// - /// - /// - ///

- void OnScannedRobot(ScannedRobotEvent evnt); - - /// - /// This method is called when another robot dies. - /// You should override it in your robot if you want to be informed of this - /// event. - /// - /// - /// - void OnRobotDeath(RobotDeathEvent evnt); - - /// - /// This method is called if your robot wins a battle. - ///

- /// Your robot could perform a victory dance here! :-) - /// - /// - /// - ///

- void OnWin(WinEvent evnt); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicEvents2.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicEvents2.cs deleted file mode 100644 index e08397c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicEvents2.cs +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace Robocode.RobotInterfaces -{ - /// - /// First extended version of the interface. - /// - public interface IBasicEvents2 : IBasicEvents - { - /// - /// This method is called after end of the battle, even when the battle is aborted. - /// You should override it in your robot if you want to be informed of this event. - ///

- /// - /// - /// public void OnBattleEnded(BattleEndedEvent evnt) - /// { - /// Out.WriteLine("The battle has ended"); - /// } - /// - /// - /// - /// - /// - /// - ///

- void OnBattleEnded(BattleEndedEvent evnt); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicEvents3.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicEvents3.cs deleted file mode 100644 index 1352a47..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicEvents3.cs +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using Robocode; - -namespace Robocode.RobotInterfaces -{ - /// - /// Second extended version of the interface. - /// - public interface IBasicEvents3 : IBasicEvents2 - { - /// - /// This method is called after the end of a round. - /// You should override it in your robot if you want to be informed of this event. - ///

- /// - /// - /// public void OnRoundEnded(RoundEndedEvent event) - /// { - /// Out.WriteLine("The round has ended"); - /// } - /// - /// - /// - /// - /// - /// - /// - ///

- /// - void OnRoundEnded(RoundEndedEvent evnt); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicRobot.cs deleted file mode 100644 index ef3dfad..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IBasicRobot.cs +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.IO; -using Robocode.RobotInterfaces.Peer; - -namespace Robocode.RobotInterfaces -{ - /// - /// A robot interface for creating a basic type of robot like - /// that is able to receive common robot events, but not interactive events as - /// with the class. - /// A basic robot allows blocking calls only and cannot handle custom events nor - /// writes to the file system like an advanced robot. - /// - /// - /// - /// - /// - /// - public interface IBasicRobot - { - /// - /// This method is called by the game to invoke the - /// method of your robot, where the program of your robot is implemented. - /// - IRunnable GetRobotRunnable(); - - /// - /// This method is called by the game to notify this robot about basic - /// robot event. Hence, this method must be implemented so it returns your - /// listener. - /// - IBasicEvents GetBasicEventListener(); - - /// - /// Do not call this method! Your robot will simply stop interacting with - /// the game. - ///

- /// This method is called by the game. A robot peer is the object that deals - /// with game mechanics and rules, and makes sure your robot abides by them. - ///

- void SetPeer(IBasicRobotPeer peer); - - /// - /// Do not call this method! - ///

- /// This method is called by the game when setting the Out stream for your - /// robot. - ///

- void SetOut(TextWriter output); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IInteractiveEvents.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IInteractiveEvents.cs deleted file mode 100644 index b49ec7e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IInteractiveEvents.cs +++ /dev/null @@ -1,183 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace Robocode.RobotInterfaces -{ - /// - /// An event interface for receiving interactive events with an . - /// - /// - public interface IInteractiveEvents - { - /// - /// This method is called when a key has been pressed. - ///

- /// See the Sample.Interactive robot for an example of how to use - /// key events. - /// - /// - ///

- /// Holds details about current event - void OnKeyPressed(KeyEvent evnt); - - /// - /// This method is called when a key has been released. - ///

- /// See the Sample.Interactive robot for an example of how to use - /// key events. - /// - /// - ///

- /// Holds details about current event - void OnKeyReleased(KeyEvent evnt); - - /// - /// This method is called when a key has been typed (pressed and released). - ///

- /// See the Sample.Interactive robot for an example of how to use - /// key events. - /// - /// - ///

- /// Holds details about current event - void OnKeyTyped(KeyEvent evnt); - - /// - /// This method is called when a mouse button has been clicked (pressed and - /// released). - ///

- /// See the Sample.Interactive robot for an example of how to use - /// mouse events. - /// - /// - /// - /// - /// - /// - /// - ///

- /// Holds details about current event - void OnMouseClicked(MouseEvent evnt); - - /// - /// This method is called when the mouse has entered the battle view. - ///

- /// See the Sample.Interactive robot for an example of how to use - /// mouse events. - /// - /// - /// - /// - /// - /// - /// - ///

- /// Holds details about current event - void OnMouseEntered(MouseEvent evnt); - - /// - /// This method is called when the mouse has exited the battle view. - ///

- /// See the Sample.Interactive robot for an example of how to use - /// mouse events. - /// - /// - /// - /// - /// - /// - /// - ///

- /// Holds details about current event - void OnMouseExited(MouseEvent evnt); - - /// - /// This method is called when a mouse button has been pressed. - ///

- /// See the Sample.Interactive robot for an example of how to use - /// mouse events. - /// - /// - /// - /// - /// - /// - /// - ///

- /// Holds details about current event - void OnMousePressed(MouseEvent evnt); - - /// - /// This method is called when a mouse button has been released. - ///

- /// See the Sample.Interactive robot for an example of how to use - /// mouse events. - /// - /// - /// - /// - /// - /// - /// - ///

- /// Holds details about current event - void OnMouseReleased(MouseEvent evnt); - - /// - /// This method is called when the mouse has been moved. - ///

- /// See the Sample.Interactive robot for an example of how to use - /// mouse events. - /// - /// - /// - /// - /// - /// - /// - ///

- /// Holds details about current event - void OnMouseMoved(MouseEvent evnt); - - /// - /// This method is called when a mouse button has been pressed and then - /// dragged. - ///

- /// See the Sample.Interactive robot for an example of how to use - /// mouse events. - /// - /// - /// - /// - /// - /// - /// - ///

- /// Holds details about current event - void OnMouseDragged(MouseEvent evnt); - - /// - /// This method is called when the mouse wheel has been rotated. - ///

- /// See the Sample.Interactive robot for an example of how to use - /// mouse events. - /// - /// - /// - /// - /// - /// - /// - ///

- /// Holds details about current event - void OnMouseWheelMoved(MouseWheelMovedEvent evnt); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IInteractiveRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IInteractiveRobot.cs deleted file mode 100644 index d2d0ad9..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IInteractiveRobot.cs +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode.RobotInterfaces -{ - /// - /// A robot interface for creating an interactive type of robot like - /// and that is able to - /// receive interactive events from the keyboard or mouse. - /// If a robot is directly inherited from this class it will behave as similar to - /// a . If you need it to behave similar to an - /// or , you should inherit from these - /// interfaces instead, as these are inherited from this interface. - /// - /// - /// - /// - /// - /// - /// - public interface IInteractiveRobot : IBasicRobot - { - /// - /// This method is called by the game to notify this robot about interactive - /// events, i.e. keyboard and mouse events. Hence, this method must be - /// implemented so it returns your listener. - /// - IInteractiveEvents GetInteractiveEventListener(); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IJuniorRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IJuniorRobot.cs deleted file mode 100644 index 127970e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IJuniorRobot.cs +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode.RobotInterfaces -{ - /// - /// A robot interface for creating the most primitive robot type, which is a - /// . A junior robot is simpler than the - /// class. - ///

- /// A junior robot has a simplified model, in purpose of teaching programming - /// skills to inexperienced in programming students. - /// The simplified robot model will keep player from overwhelming of Robocode's - /// rules, programming syntax and programming concept. - ///

- /// Instead of using getters and setters, public fields are provided for - /// receiving information like the last scanned robot, the coordinate of the - /// robot etc. - ///

- /// All methods on a junior robot are blocking calls, i.e. they do not return - /// before their action has been completed and will at least take one turn to - /// Execute. - /// - /// - /// - /// - /// - ///

- public interface IJuniorRobot : IBasicRobot - { - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IPaintEvents.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IPaintEvents.cs deleted file mode 100644 index c423597..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IPaintEvents.cs +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace Robocode.RobotInterfaces -{ - /// - /// An event interface for receiving paint events with an . - /// - /// - public interface IPaintEvents - { - /// - /// This method is called every time the robot is painted. You should - /// override this method if you want to draw items for your robot on the - /// battle field, e.g. targets, virtual bullets etc. - ///

- /// This method is very useful for debugging your robot. - ///

- /// Note that the robot will only be painted if the "Paint" is enabled on the - /// robot's console window; otherwise the robot will never get painted (the - /// reason being that all robots might have graphical items that must be - /// painted, and then you might not be able to tell what graphical items that - /// have been painted for your robot). - ///

- /// Also note that the coordinate system for the graphical context where you - /// paint items fits for the Robocode coordinate system where (0, 0) is at - /// the bottom left corner of the battlefield, where X is towards right and Y - /// is upwards. - /// - ///

- /// The graphics context to use for painting graphical items for the robot - void OnPaint(IGraphics graphics); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IPaintRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IPaintRobot.cs deleted file mode 100644 index f23f9fc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IPaintRobot.cs +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode.RobotInterfaces -{ - /// - /// A robot interface that makes it possible for a robot to receive paint events. - /// - public interface IPaintRobot : IBasicRobot - { - /// - /// This method is called by the game to notify this robot about painting - /// events. Hence, this method must be implemented so it returns your - /// listener. - /// - IPaintEvents GetPaintEventListener(); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IRunnable.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IRunnable.cs deleted file mode 100644 index a389814..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/IRunnable.cs +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode.RobotInterfaces -{ - /// - /// Interface to anything what could run - /// - public interface IRunnable - { - /// - /// Robot main loop or anything what could run. - /// - void Run(); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/ITeamEvents.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/ITeamEvents.cs deleted file mode 100644 index 16723c4..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/ITeamEvents.cs +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace Robocode.RobotInterfaces -{ - /// - /// An event interface for receiving robot team events with an . - /// - /// - public interface ITeamEvents - { - /// - /// This method is called when your robot receives a message from a teammate. - /// You should override it in your robot if you want to be informed of this - /// event. - ///

- /// - /// - /// public void OnMessageReceived(MessageEvent evnt) - /// { - /// Out.WriteLine(event.Sender + " sent me: " + evnt.Message); - /// } - /// - /// - /// - /// - ///

- /// The message event sent by the game - void OnMessageReceived(MessageEvent evnt); - } -} -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/ITeamRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/ITeamRobot.cs deleted file mode 100644 index e0b3ceb..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/ITeamRobot.cs +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode.RobotInterfaces -{ - /// - /// A robot interface for creating a team robot like - /// that is able to receive team events. - /// A team robot is an advanced type of robot that supports sending messages - /// between teammates that participates in a team. - /// - /// - /// - /// - /// - /// - /// - public interface ITeamRobot : IAdvancedRobot - { - /// - /// This method is called by the game to notify this robot about team events. - /// Hence, this method must be implemented so it returns your - /// listener. - /// - ITeamEvents GetTeamEventListener(); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IAdvancedRobotPeer.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IAdvancedRobotPeer.cs deleted file mode 100644 index e84346e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IAdvancedRobotPeer.cs +++ /dev/null @@ -1,659 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Collections.Generic; -using System.IO; - -namespace Robocode.RobotInterfaces.Peer -{ - /// - /// The advanced robot peer for advanced robot types like - /// and . - ///

- /// A robot peer is the object that deals with game mechanics and rules, and - /// makes sure your robot abides by them. - /// - /// - /// - /// - ///

- public interface IAdvancedRobotPeer : IStandardRobotPeer - { - /// - /// This call is identical to , - /// but returns immediately, and will not execute until you - /// call or take an action that executes. - ///

- /// If there is already movement saved from a previous stop, you can - /// overwrite it by calling SetStop(true). - /// - /// - /// - /// - ///

- /// true if the movement saved from a previous stop - /// should be overwritten; false otherwise. - void SetStop(bool overwrite); - - /// - /// Sets the robot to Resume the movement stopped by - /// or , if any. - ///

- /// This call returns immediately, and will not execute until you call - /// or take an action that executes. - /// - /// - /// - /// - /// - ///

- void SetResume(); - - /// - /// Sets the robot to move forward or backward by distance measured in pixels - /// when the next execution takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// or take an action that executes. - ///

- /// Note that both positive and negative values can be given as input, where - /// positive values means that the robot is set to move forward, and negative - /// values means that the robot is set to move backward. If 0 is given as - /// input, the robot will stop its movement, but will have to decelerate - /// till it stands still, and will thus not be able to stop its movement - /// immediately, but eventually. - ///

- /// - /// - /// // Set the robot to move 50 pixels forward - /// SetMove(50); - /// - /// // Set the robot to move 100 pixels backward - /// // (overrides the previous order) - /// SetMove(-100); - /// - /// ... - /// // Executes the last SetMove() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The distance to move measured in pixels. - /// If distance > 0 the robot is set to move forward. - /// If distance < 0 the robot is set to move backward. - /// If distance = 0 the robot is set to stop its movement. - /// - void SetMove(double distance); - - /// - /// Sets the robot's body to turn right or left by radians when the next - /// execution takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// or take an action that - /// executes. - ///

- /// Note that both positive and negative values can be given as input, where - /// positive values means that the robot's body is set to turn right, and - /// negative values means that the robot's body is set to turn left. - /// If 0 is given as input, the robot's body will stop turning. - ///

- /// - /// - /// // Set the robot's body to turn 180 degrees to the right - /// SetTurnBody(Math.PI); - /// - /// // Set the robot's body to turn 90 degrees to the left instead of right - /// // (overrides the previous order) - /// SetTurnBody(-Math.PI / 2); - /// - /// ... - /// // Executes the last SetTurnBody() - /// Execute(); - /// - /// - /// - /// - /// - /// - /// - ///

- /// T - /// The amount of radians to turn the robot's body. - /// If radians > 0 the robot's body is set to turn right. - /// If radians < 0 the robot's body is set to turn left. - /// If radians = 0 the robot's body is set to stop turning. - /// - void SetTurnBody(double radians); - - /// - /// Sets the robot's gun to turn right or left by radians when the next - /// execution takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// or take an action that - /// executes. - ///

- /// Note that both positive and negative values can be given as input, where - /// positive values means that the robot's gun is set to turn right, and - /// negative values means that the robot's gun is set to turn left. - /// If 0 is given as input, the robot's gun will stop turning. - ///

- /// - /// - /// // Set the robot's gun to turn 180 degrees to the right - /// SetTurnGun(Math.PI); - /// - /// // Set the robot's gun to turn 90 degrees to the left instead of right - /// // (overrides the previous order) - /// SetTurnGun(-Math.PI / 2); - /// - /// ... - /// // Executes the last setTurnFun() - /// Execute(); - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of radians to turn the robot's gun. - /// If radians > 0 the robot's gun is set to turn right. - /// If radians < 0 the robot's gun is set to turn left. - /// If radians = 0 the robot's gun is set to stop turning. - /// - void SetTurnGun(double radians); - - /// - /// Sets the robot's radar to turn right or left by radians when the next - /// execution takes place. - ///

- /// This call returns immediately, and will not execute until you call - /// or take an action that - /// executes. - ///

- /// Note that both positive and negative values can be given as input, where - /// positive values means that the robot's radar is set to turn right, and - /// negative values means that the robot's radar is set to turn left. - /// If 0 is given as input, the robot's radar will stop turning. - ///

- /// - /// - /// // Set the robot's radar to turn 180 degrees to the right - /// SetTurnRadar(Math.PI); - /// - /// // Set the robot's radar to turn 90 degrees to the left instead of right - /// // (overrides the previous order) - /// SetTurnRadar(-Math.PI / 2); - /// - /// ... - /// // Executes the last SetTurnRadar() - /// Execute(); - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of radians to turn the robot's radar. - /// If radians > 0 the robot's radar is set to turn right. - /// If radians < 0 the robot's radar is set to turn left. - /// If radians = 0 the robot's radar is set to stop turning. - /// - void SetTurnRadar(double radians); - - /// - /// Sets the maximum turn rate of the robot measured in degrees if the robot - /// should turn slower than (10 degress/turn). - /// - /// - /// - /// - /// - /// The new maximum turn rate of the robot measured in degrees. - /// Valid values are 0 - - /// - void SetMaxTurnRate(double newMaxTurnRate); - - /// - /// Sets the maximum velocity of the robot measured in pixels/turn if the - /// robot should move slower than (8 pixels/turn). - /// - /// - /// - /// - /// - /// The new maximum turn rate of the robot measured in pixels/turn. - /// Valid values are 0 - - /// - void SetMaxVelocity(double newMaxVelocity); - - /// - /// Does not return until a condition is met, i.e. when a returns true. - ///

- /// This call executes immediately. - ///

- /// See the Sample.Crazy robot for how this method can be used. - /// - /// - ///

- /// The condition that must be met before this call returns - void WaitFor(Condition condition); - - /// - /// Call this during an event handler to allow new events of the same - /// priority to restart the event handler. - ///

- /// - /// - /// public void OnScannedRobot(ScannedRobotEvent e) - /// { - /// Fire(1); - /// SetInterruptible(true); - /// Move(100); // If you see a robot while moving ahead, - /// // this handler will start from the top - /// // Without SetInterruptible(true), we wouldn't - /// // receive scan events at all! - /// // We'll only get here if we don't see a robot during the move. - /// Out().WriteLine("Ok, I can't see anyone"); - /// } - /// - /// - /// - /// - ///

- /// - /// true if the event handler should be interrupted if new events of - /// the same priority occurs; false otherwise - /// - void SetInterruptible(bool interruptible); - - /// - /// Sets the priority of a class of events. - ///

- /// Events are sent to the onXXX handlers in order of priority. - /// Higher priority events can interrupt lower priority events. - /// For events with the same priority, newer events are always sent first. - /// Valid priorities are 0 - 99, where 100 is reserved and 80 is the default - /// priority. - ///

- /// - /// - /// SetEventPriority("RobotDeathEvent", 15); - /// - ///

- /// - /// The default priorities are, from highest to lowest: - /// - /// : 100 (reserved) - /// : 100 (reserved) - /// : 100 (reserved) - /// : 99 - /// Key and mouse events: 98 - /// : 80 (default value) - /// : 75 - /// : 70 - /// : 60 - /// : 55 - /// : 50 - /// : 40 - /// : 30 - /// : 20 - /// : 10 - /// : 5 - /// : -1 (reserved) - /// - ///

- /// Note that you cannot change the priority for events with the special - /// priority value -1 or 100 (reserved) as these event are system events. - /// Also note that you cannot change the priority of CustomEvent. - /// Instead you must change the priority of the condition(s) for your custom - /// event(s). - /// - /// - ///

- /// The name of the event class (string) to set the priority for - /// The new priority for that event class - void SetEventPriority(string eventClass, int priority); - - /// - /// Returns the current priority of a class of events. - /// An event priority is a value from 0 - 99. The higher value, the higher - /// priority. - ///

- /// - /// - /// int myHitRobotPriority = GetEventPriority("HitRobotEvent"); - /// - ///

- /// - /// The default priorities are, from highest to lowest: - /// - /// : 100 (reserved) - /// : 100 (reserved) - /// : 100 (reserved) - /// : 99 - /// Key and mouse events: 98 - /// : 80 (default value) - /// : 75 - /// : 70 - /// : 60 - /// : 55 - /// : 50 - /// : 40 - /// : 30 - /// : 20 - /// : 10 - /// : 5 - /// : -1 (reserved) - /// - /// - ///

- /// The name of the event class (string) - int GetEventPriority(string eventClass); - - /// - /// Registers a custom event to be called when a condition is met. - /// When you are finished with your condition or just want to remove it you - /// must call . - ///

- /// - /// - /// AddCustomEvent( - /// new Condition("triggerhit", (c) => - /// { - /// return Energy <= trigger; - /// })); - /// - /// // Add our custom event based on our condition - /// AddCustomEvent(triggerHitCondition); - /// - /// - /// - /// - ///

- /// The condition that must be met. - void AddCustomEvent(Condition condition); - - /// - /// Removes a custom event that was previously added by calling . - ///

- /// - /// - /// AddCustomEvent( - /// new Condition("triggerhit", (c) => - /// { - /// return Energy <= trigger; - /// })); - /// - /// // Add our custom event based on our condition - /// AddCustomEvent(triggerHitCondition); - /// ... - /// // do something with your robot - /// ... - /// // Remove the custom event based on our condition - /// RemoveCustomEvent(triggerHitCondition); - /// - /// - /// - /// - ///

- /// - /// The condition that was previous added and that must be removed now. - /// - void RemoveCustomEvent(Condition condition); - - /// - /// Clears Out any pending events in the robot's event queue immediately. - /// - /// - /// - void clearAllEvents(); - - /// - /// Returns a list containing all events currently in the robot's queue. - /// You might, for example, call this while processing another event. - ///

- /// - /// - /// foreach (Event evnt in GetAllEvents()) - /// { - /// if (event is HitRobotEvent) - /// { - /// // do something with the event - /// } - /// else if (event is HitByBulletEvent) - /// { - /// // do something with the event - /// } - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- IList GetAllEvents(); - - /// - /// Returns a list containing all StatusEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// foreach (StatusEvent evnt inGetStatusEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- IList GetStatusEvents(); - - /// - /// Returns a list containing all BulletMissedEvents currently in the - /// robot's queue. You might, for example, call this while processing another - /// event. - ///

- /// - /// - /// foreach (BulletMissedEvent evnt inGetBulletMissedEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- IList GetBulletMissedEvents(); - - /// - /// Returns a list containing all BulletHitBulletEvents currently in the - /// robot's queue. You might, for example, call this while processing another - /// event. - ///

- /// - /// - /// foreach (BulletHitBulletEvent evnt inGetBulletHitBulletEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- IList GetBulletHitBulletEvents(); - - /// - /// Returns a list containing all BulletHitEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// foreach (BulletHitEvent event: GetBulletHitEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- IList GetBulletHitEvents(); - - /// - /// Returns a list containing all HitByBulletEvents currently in the - /// robot's queue. You might, for example, call this while processing - /// another event. - ///

- /// - /// - /// foreach (HitByBulletEvent evnt inGetHitByBulletEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- IList GetHitByBulletEvents(); - - /// - /// Returns a list containing all HitRobotEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// foreach (HitRobotEvent evnt inGetHitRobotEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- IList GetHitRobotEvents(); - - /// - /// Returns a list containing all HitWallEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// foreach (HitWallEvent evnt inGetHitWallEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- IList GetHitWallEvents(); - - /// - /// Returns a list containing all RobotDeathEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// foreach (RobotDeathEvent evnt inGetRobotDeathEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- IList GetRobotDeathEvents(); - - /// - /// Returns a list containing all ScannedRobotEvents currently in the - /// robot's queue. You might, for example, call this while processing another - /// event. - ///

- /// - /// - /// foreach (ScannedRobotEvent evnt inGetScannedRobotEvents()) - /// { - /// // do something with the event - /// } - /// - /// - /// - /// - /// - ///

- IList GetScannedRobotEvents(); - - /// - /// Returns a file representing a data directory for the robot, which can be - /// written to. - ///

- /// The system will automatically create the directory for you, so you do not - /// need to create it by yourself. - /// - ///

- string GetDataDirectory(); - - /// - /// Returns a file in your data directory that you can write to. - ///

- /// The system will automatically create the directory for you, so you do not - /// need to create it by yourself. - ///

- /// Please notice that the max. size of your data file is set to 200000 - /// (~195 KB). - ///

- /// See the Sample.SittingDuck to see an example of how to use this - /// method. - /// - ///

- /// The file name of the data file for your robot - Stream GetDataFile(string filename); - - /// - /// Returns the data quota available in your data directory, i.e. the amount - /// of bytes left in the data directory for the robot. - /// - /// - /// - long GetDataQuotaAvailable(); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IBasicRobotPeer.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IBasicRobotPeer.cs deleted file mode 100644 index f5b5822..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IBasicRobotPeer.cs +++ /dev/null @@ -1,698 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Drawing; -using Robocode; -using Robocode.RobotInterfaces; - -namespace Robocode.RobotInterfaces.Peer -{ - /// - /// The basic robot peer for all robot types. - ///

- /// A robot peer is the obj that deals with game mechanics and rules, and - /// makes sure your robot abides by them. - /// - /// - /// - /// - ///

- public interface IBasicRobotPeer - { - /// - /// Returns the robot's name. - /// - string GetName(); - - /// - /// Returns the game time of the current round, where the time is equal to - /// the current turn in the round. - ///

- /// A battle consists of multiple rounds. - ///

- /// Time is reset to 0 at the beginning of every round. - ///

- long GetTime(); - - /// - /// Returns the robot's current energy. - /// - double GetEnergy(); - - /// - /// Returns the X position of the robot. (0,0) is at the bottom left of the - /// battlefield. - /// - /// - double GetX(); - - /// - /// Returns the Y position of the robot. (0,0) is at the bottom left of the - /// battlefield. - /// - /// - double GetY(); - - /// - /// Returns the velocity of the robot measured in pixels/turn. - ///

- /// The maximum velocity of a robot is defined by - /// (8 pixels / turn). - /// - ///

- double GetVelocity(); - - /// - /// Returns the direction that the robot's body is facing, in radians. - /// The value returned will be between 0 and 2 * PI (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// PI / 2 means East, PI means South, and 3 * PI / 2 means West. - /// - /// - ///

- double GetBodyHeading(); - - /// - /// Returns the direction that the robot's gun is facing, in radians. - /// The value returned will be between 0 and 2 * PI (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// PI / 2 means East, PI means South, and 3 * PI / 2 means West. - /// - /// - ///

- double GetGunHeading(); - - /// - /// Returns the direction that the robot's radar is facing, in radians. - /// The value returned will be between 0 and 2 * PI (is excluded). - ///

- /// Note that the heading in Robocode is like a compass, where 0 means North, - /// PI / 2 means East, PI means South, and 3 * PI / 2 means West. - /// - /// - ///

- double GetRadarHeading(); - - /// - /// Returns the current heat of the gun. The gun cannot Fire unless this is - /// 0. (Calls to Fire will succeed, but will not actually Fire unless - /// GetGunHeat() == 0). - ///

- /// The amount of gun heat generated when the gun is fired is - /// 1 + (firePower / 5). Each turn the gun heat drops by the amount returned - /// by , which is a battle setup. - ///

- /// Note that all guns are "hot" at the start of each round, where the gun - /// heat is 3. - /// - /// - ///

- double GetGunHeat(); - - /// - /// Returns the width of the current battlefield measured in pixels. - /// - double GetBattleFieldWidth(); - - /// - /// Returns the height of the current battlefield measured in pixels. - /// - double GetBattleFieldHeight(); - - /// - /// Returns how many opponents that are left in the current round. - /// - int GetOthers(); - - /// - /// Returns how many sentry robots that are left in the current round. - /// - int GetNumSentries(); - - /// - /// Returns the number of rounds in the current battle. - /// - /// - int GetNumRounds(); - - /// - /// Returns the number of the current round (0 to - 1) - /// in the battle. - /// - /// - int GetRoundNum(); - - /// - /// Returns the sentry border size for a BorderSentry that defines the how - /// far a BorderSentry is allowed to move from the border edges measured in units.
- /// Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that - /// BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the - /// distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this - /// border area. - ///
- int GetSentryBorderSize(); - - /// - /// Returns the rate at which the gun will cool down, i.e. the amount of heat - /// the gun heat will drop per turn. - ///

- /// The gun cooling rate is default 0.1 / turn, but can be changed by the - /// battle setup. So don't count on the cooling rate being 0.1! - /// - /// - ///

- double GetGunCoolingRate(); - - /// - /// Returns the distance remaining in the robot's current move measured in - /// pixels. - ///

- /// This call returns both positive and negative values. Positive values - /// means that the robot is currently moving forwards. Negative values means - /// that the robot is currently moving backwards. If the returned value is 0, - /// the robot currently stands still. - /// - /// - /// - ///

- double GetDistanceRemaining(); - - /// - /// Returns the angle remaining in the robot's turn, in radians. - ///

- /// This call returns both positive and negative values. Positive values - /// means that the robot is currently turning to the right. Negative values - /// means that the robot is currently turning to the left. - /// - /// - /// - ///

- double GetBodyTurnRemaining(); - - /// - /// Returns the angle remaining in the gun's turn, in radians. - ///

- /// This call returns both positive and negative values. Positive values - /// means that the gun is currently turning to the right. Negative values - /// means that the gun is currently turning to the left. - /// - /// - /// - ///

- double GetGunTurnRemaining(); - - /// - /// Returns the angle remaining in the radar's turn, in radians. - ///

- /// This call returns both positive and negative values. Positive values - /// means that the radar is currently turning to the right. Negative values - /// means that the radar is currently turning to the left. - /// - /// - /// - ///

- double GetRadarTurnRemaining(); - - /// - /// Executes any pending actions, or continues executing actions that are - /// in process. This call returns after the actions have been started. - ///

- /// Note that advanced robots must call this function in order to - /// Execute pending set* calls like e.g. - /// , etc. - /// Otherwise, these calls will never get executed. - ///

- /// In this example the robot will move while turning: - /// - /// - /// SetTurnBody(90); - /// SetMove(100); - /// Execute(); - /// - /// while (GetDistanceRemaining() > 0 && GetTurnRemaining() > 0) - /// { - /// Execute(); - /// } - /// - /// - ///

- void Execute(); - - /// - /// Immediately moves your robot forward or backward by distance measured in - /// pixels. - ///

- /// This call executes immediately, and does not return until it is complete, - /// i.e. when the remaining distance to move is 0. - ///

- /// If the robot collides with a wall, the move is complete, meaning that the - /// robot will not move any further. If the robot collides with another - /// robot, the move is complete if you are heading toward the other robot. - ///

- /// Note that both positive and negative values can be given as input, where - /// positive values means that the robot is set to move forward, and negative - /// values means that the robot is set to move backward. - ///

- /// - /// - /// // Move the robot 100 pixels forward - /// Ahead(100); - /// - /// // Afterwards, move the robot 50 pixels backward - /// Ahead(-50); - /// - /// - /// - /// - ///

- /// - /// The distance to move measured in pixels. - /// If distance > 0 the robot is set to move forward. - /// If distance < 0 the robot is set to move backward. - /// If distance = 0 the robot will not move anywhere, but just finish its turn. - /// - void Move(double distance); - - /// - /// Immediately turns the robot's body to the right or left by radians. - /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the body's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, where - /// positive values means that the robot's body is set to turn right, and - /// negative values means that the robot's body is set to turn left. - /// If 0 is given as input, the robot's body will stop turning. - ///

- /// - /// - /// // Turn the robot's body 180 degrees to the right - /// TurnBody(Math.PI); - /// - /// // Afterwards, turn the robot's body 90 degrees to the left - /// TurnBody(-Math.PI / 2); - /// - /// - /// - /// - /// - ///

- /// - /// The amount of radians to turn the robot's body. - /// If radians > 0 the robot's body is set to turn right. - /// If radians < 0 the robot's body is set to turn left. - /// If radians = 0 the robot's body is set to stop turning. - /// - void TurnBody(double radians); - - /// - /// Immediately turns the robot's gun to the right or left by radians. - /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the gun's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, where - /// positive values means that the robot's gun is set to turn right, and - /// negative values means that the robot's gun is set to turn left. - /// If 0 is given as input, the robot's gun will stop turning. - ///

- /// - /// - /// // Turn the robot's gun 180 degrees to the right - /// TurnGun(Math.PI); - /// - /// // Afterwards, turn the robot's gun 90 degrees to the left - /// TurnGun(-Math.PI / 2); - /// - /// - /// - /// - /// - ///

- /// - /// The amount of radians to turn the robot's gun. - /// If radians > 0 the robot's gun is set to turn right. - /// If radians < 0 the robot's gun is set to turn left. - /// If radians = 0 the robot's gun is set to stop turning. - /// - void TurnGun(double radians); - - /// - /// Immediately fires a bullet. The bullet will travel in the direction the - /// gun is pointing. - ///

- /// The specified bullet power is an amount of energy that will be taken from - /// the robot's energy. Hence, the more power you want to spend on the - /// bullet, the more energy is taken from your robot. - ///

- /// The bullet will do (4 * power) damage if it hits another robot. If power - /// is greater than 1, it will do an additional 2 * (power - 1) damage. - /// You will get (3 * power) back if you hit the other robot. You can call - /// for getting the damage that a - /// bullet with a specific bullet power will do. - ///

- /// The specified bullet power should be between - /// and . - ///

- /// Note that the gun cannot Fire if the gun is overheated, meaning that - /// returns a value > 0. - ///

- /// An event is generated when the bullet hits a robot - /// ("/>, wall (), or another - /// bullet (). - ///

- /// - /// - /// // Fire a bullet with maximum power if the gun is ready - /// if (GetGunHeat() == 0) - /// { - /// Bullet bullet = Fire(Rules.MAX_BULLET_POWER); - /// - /// // Get the velocity of the bullet - /// if (bullet != null) - /// { - /// double bulletVelocity = bullet.Velocity; - /// } - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of energy given to the bullet, and subtracted from the robot's energy. - /// - Bullet Fire(double power); - - /// - /// Sets the gun to Fire a bullet when the next execution takes place. - /// The bullet will travel in the direction the gun is pointing. - ///

- /// This call returns immediately, and will not execute until you call - /// Execute() or take an action that executes. - ///

- /// The specified bullet power is an amount of energy that will be taken from - /// the robot's energy. Hence, the more power you want to spend on the - /// bullet, the more energy is taken from your robot. - ///

- /// The bullet will do (4 * power) damage if it hits another robot. If power - /// is greater than 1, it will do an additional 2 * (power - 1) damage. - /// You will get (3 * power) back if you hit the other robot. You can call - /// for getting the damage that a - /// bullet with a specific bullet power will do. - ///

- /// The specified bullet power should be between - /// and . - ///

- /// Note that the gun cannot Fire if the gun is overheated, meaning that - /// returns a value > 0. - ///

- /// An event is generated when the bullet hits a robot - /// (), wall (), or another - /// bullet (). - ///

- /// - /// - /// Bullet bullet = null; - /// - /// // Fire a bullet with maximum power if the gun is ready - /// if (GetGunHeat() == 0) - /// { - /// bullet = SetFireBullet(Rules.MAX_BULLET_POWER); - /// } - /// ... - /// Execute(); - /// ... - /// // Get the velocity of the bullet - /// if (bullet != null) - /// { - /// double bulletVelocity = bullet.Velocity; - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// - ///

- /// - /// The amount of energy given to the bullet, and subtracted from the robot's energy. - /// - Bullet SetFire(double power); - - /// - /// Sets the color of the robot's body. - ///

- /// A null indicates the default (blue) color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetBodyColor(Color.BLACK); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - /// - /// The new body color - ///

- void SetBodyColor(Color color); - - /// - /// Returns current color of body - /// - Color GetBodyColor(); - - /// - /// Sets the color of the robot's gun. - ///

- /// A null indicates the default (blue) color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetGunColor(Color.RED); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - ///

- /// The new gun color - void SetGunColor(Color color); - - /// - /// Returns current color of gun - /// - Color GetGunColor(); - - /// - /// Sets the color of the robot's radar. - ///

- /// A null indicates the default (blue) color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetRadarColor(Color.YELLOW); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - ///

- /// The new radar color - void SetRadarColor(Color color); - - /// - /// Returns current color of radar - /// - Color GetRadarColor(); - - /// - /// Sets the color of the robot's bullets. - ///

- /// A null indicates the default white color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetBulletColor(Color.GREEN); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - ///

- /// The new bullet color - void SetBulletColor(Color color); - - /// - /// Returns current color of bullet - /// - Color GetBulletColor(); - - /// - /// Sets the color of the robot's scan arc. - ///

- /// A null indicates the default (blue) color. - ///

- /// - /// - /// // Don't forget to using System.Drawing at the top... - /// using System.Drawing; - /// ... - /// - /// public void Run() - /// { - /// SetScanColor(Color.WHITE); - /// ... - /// } - /// - /// - /// - /// - /// - /// - /// - ///

- /// the new scan arc color - void SetScanColor(Color color); - - /// - /// Returns current color of scan beam - /// - Color GetScanColor(); - - /// - /// This call must be made from a robot call to inform the game - /// that the robot made a Get* call like e.g. or - /// . - ///

- /// This method is used by the game to determine if the robot is inactive or - /// not. Note: You should only make this call once in a Get* method! - /// - ///

- void GetCall(); - - /// - /// This call must be made from a robot call to inform the game - /// that the robot made a Set* call like e.g. - /// or . - ///

- /// This method is used by the game to determine if the robot is inactive or - /// not. Note: You should only make this call once in a Set* method! - /// - /// - ///

- void SetCall(); - - /// - /// Returns a graphics context used for painting graphical items for the robot. - ///

- /// This method is very useful for debugging your robot. - ///

- /// Note that the robot will only be painted if the "Paint" is enabled on the - /// robot's console window; otherwise the robot will never get painted (the - /// reason being that all robots might have graphical items that must be - /// painted, and then you might not be able to tell what graphical items that - /// have been painted for your robot). - ///

- /// Also note that the coordinate system for the graphical context where you - /// paint items fits for the Robocode coordinate system where (0, 0) is at - /// the bottom left corner of the battlefield, where X is towards right and Y - /// is upwards. - /// - ///

- IGraphics GetGraphics(); - - /// - /// Sets the debug property with the specified key to the specified value. - ///

- /// This method is very useful when debugging or reviewing your robot as you - /// will be able to see this property displayed in the robot console for your - /// robots under the Debug Properties tab page. - ///

- /// The name/key of the debug property. - /// - /// The new value of the debug property, where null or the empty string is used - /// for removing this debug property. - /// - void SetDebugProperty(string key, string value); - - /// - /// Rescan for other robots. This method is called automatically by the game, - /// as long as the robot is moving, turning its body, turning its gun, or - /// turning its radar. - ///

- /// Rescan will cause - /// to be called if you see a robot. - ///

- /// There are 2 reasons to call Rescan() manually: - ///

    - ///
  1. You want to scan after you stop moving.
  2. - ///
  3. You want to interrupt the OnScannedRobot event. This is more - /// likely. If you are in OnScannedRobot and call Scan(), - /// and you still see a robot, then the system will interrupt your - /// OnScannedRobot event immediately and start it from the top.
  4. - ///
- ///

- /// This call executes immediately. - /// - /// - /// - ///

- void Rescan(); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IJuniorRobotPeer.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IJuniorRobotPeer.cs deleted file mode 100644 index f07e86d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IJuniorRobotPeer.cs +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode.RobotInterfaces.Peer -{ - /// - /// The junior robot peer for junior robot types like . - ///

- /// A robot peer is the obj that deals with game mechanics and rules, and - /// makes sure your robot abides by them. - /// - /// - /// - /// - ///

- public interface IJuniorRobotPeer : IBasicRobotPeer - { - /// - /// Moves this robot forward or backwards by pixels and turns this robot - /// right or left by degrees at the same time. The robot will move in a curve - /// that follows a perfect circle, and the moving and turning will end at - /// exactly the same time. - ///

- /// Note that the max. velocity and max. turn rate is automatically adjusted, - /// which means that the robot will move slower the sharper the turn is - /// compared to the distance. - ///

- /// Note that both positive and negative values can be given as input: - ///

    - ///
  • If the distance parameter is set to a positive value, it - /// means that the robot is set to move forward, and a negative value means - /// that the robot is set to move backward. If set to 0, the robot will not - /// move, but will be able to turn.
  • - ///
  • If the radians parameter is set to a positive value, it means - /// that the robot is set to turn to the right, and a negative value means - /// that the robot is set to turn to the left. If set to 0, the robot will - /// not turn, but will be able to move.
  • - ///
- /// - /// - /// - /// - /// - ///
- /// - /// The distance to move measured in pixels. - /// If distance > 0 the robot is set to move forward. - /// If distance < 0 the robot is set to move backward. - /// If distance = 0 the robot will not move anywhere, but just finish its turn. - /// - /// - /// The amount of radians to turn the robot's body. - /// If radians > 0 the robot's body is set to turn right. - /// If radians < 0 the robot's body is set to turn left. - /// If radians = 0 the robot's body is set to stop turning. - /// - void TurnAndMove(double distance, double radians); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IStandardRobotPeer.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IStandardRobotPeer.cs deleted file mode 100644 index 5b785c5..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/IStandardRobotPeer.cs +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode.RobotInterfaces.Peer -{ - /// - /// The standard robot peer for standard robot types like , - /// , and . - ///

- /// A robot peer is the obj that deals with game mechanics and rules, and - /// makes sure your robot abides by them. - /// - /// - /// - /// - ///

- public interface IStandardRobotPeer : IBasicRobotPeer - { - /// - /// Immediately stops all movement, and saves it for a call to - /// . If there is already movement saved from a previous - /// stop, you can overwrite it by calling Stop(true). - /// - /// - /// - /// If there is already movement saved from a previous stop, - /// you can overwrite it by calling Stop(true). - /// - void Stop(bool overwrite); - - /// - /// Immediately resumes the movement you stopped by , if any. - ///

- /// This call executes immediately, and does not return until it is complete. - /// - /// - ///

- void Resume(); - - /// - /// Immediately turns the robot's radar to the right or left by radians. - /// This call executes immediately, and does not return until it is complete, - /// i.e. when the angle remaining in the radar's turn is 0. - ///

- /// Note that both positive and negative values can be given as input, where - /// positive values means that the robot's radar is set to turn right, and - /// negative values means that the robot's radar is set to turn left. - /// If 0 is given as input, the robot's radar will stop turning. - ///

- /// - /// - /// // Turn the robot's radar 180 degrees to the right - /// TurnRadar(Math.PI); - /// - /// // Afterwards, turn the robot's radar 90 degrees to the left - /// TurnRadar(-Math.PI / 2); - /// - /// - /// - /// - /// - ///

- /// - /// The amount of radians to turn the robot's radar. - /// If radians > 0 the robot's radar is set to turn right. - /// If radians < 0 the robot's radar is set to turn left. - /// If radians = 0 the robot's radar is set to stop turning. - /// - void TurnRadar(double radians); - - /// - /// Sets the gun to turn independent from the robot's turn. - ///

- /// Ok, so this needs some explanation: The gun is mounted on the robot's - /// body. So, normally, if the robot turns 90 degrees to the right, then the - /// gun will turn with it as it is mounted on top of the robot's body. To - /// compensate for this, you can call IsAdjustGunForBodyTurn(true). - /// When this is set, the gun will turn independent from the robot's turn, - /// i.e. the gun will compensate for the robot's body turn. - ///

- /// Note: This method is additive until you reach the maximum the gun can - /// turn. The "adjust" is added to the amount you set for turning the robot, - /// then capped by the physics of the game. If you turn infinite, then the - /// adjust is ignored (and hence overridden). - ///

- /// - /// Assuming both the robot and gun start Out facing up (0 degrees): - /// - /// // Set gun to turn with the robot's turn - /// SetAdjustGunForBodyTurn(false); // This is the default - /// TurnBodyRight(Math.PI / 2); - /// // At this point, both the robot and gun are facing right (90 degrees) - /// TurnBodyLeft(Math.PI / 2); - /// // Both are back to 0 degrees - /// - /// -- or -- - /// - /// // Set gun to turn independent from the robot's turn - /// SetAdjustGunForBodyTurn(true); - /// TurnBodyRight(Math.PI / 2); - /// // At this point, the robot is facing right (90 degrees), but the gun is still facing up. - /// TurnBodyLeft(Math.PI / 2); - /// // Both are back to 0 degrees. - /// - /// - ///

- /// Note: The gun compensating this way does count as "turning the gun". - /// See for details. - /// - ///

- /// - /// true if the gun must turn independent from the robot's turn; - /// false if the gun must turn with the robot's turn. - /// - void SetAdjustGunForBodyTurn(bool independent); - - /// - /// Sets the radar to turn independent from the gun's turn. - ///

- /// Ok, so this needs some explanation: The radar is mounted on the robot's - /// gun. So, normally, if the gun turns 90 degrees to the right, then the - /// radar will turn with it as it is mounted on top of the gun. To compensate - /// for this, you can call IsAdjustRadarForGunTurn(true). When this - /// is set, the radar will turn independent from the robot's turn, i.e. the - /// radar will compensate for the gun's turn. - ///

- /// Note: This method is additive until you reach the maximum the radar can - /// turn. The "adjust" is added to the amount you set for turning the robot, - /// then capped by the physics of the game. If you turn infinite, then the - /// adjust is ignored (and hence overridden). - ///

- /// - /// Assuming both the gun and radar start Out facing up (0 degrees): - /// - /// // Set radar to turn with the gun's turn - /// SetAdjustRadarForGunTurn(false); // This is the default - /// TurnGunRight(Math.PI / 2); - /// // At this point, both the radar and gun are facing right (90 degrees); - /// - /// -- or -- - /// - /// // Set radar to turn independent from the gun's turn - /// SetAdjustRadarForGunTurn(true); - /// TurnGunRight(Math.PI / 2); - /// // At this point, the gun is facing right (90 degrees), but the radar is still facing up. - /// - /// - /// Note: Calling IsAdjustRadarForGunTurn(bool) will - /// automatically call with the - /// same value, unless you have already called it earlier. This behavior is - /// primarily for backward compatibility with older Robocode robots. - /// - /// - ///

- /// - /// true if the radar must turn independent from the gun's turn; - /// false if the radar must turn with the gun's turn. - /// - void SetAdjustRadarForGunTurn(bool independent); - - /// - /// Sets the radar to turn independent from the robot's turn. - ///

- /// Ok, so this needs some explanation: The radar is mounted on the gun, and - /// the gun is mounted on the robot's body. So, normally, if the robot turns - /// 90 degrees to the right, the gun turns, as does the radar. Hence, if the - /// robot turns 90 degrees to the right, then the gun and radar will turn - /// with it as the radar is mounted on top of the gun. To compensate for - /// this, you can call IsAdjustRadarForBodyTurn(true). When this is - /// set, the radar will turn independent from the robot's turn, i.e. the - /// radar will compensate for the robot's turn. - ///

- /// Note: This method is additive until you reach the maximum the radar can - /// turn. The "adjust" is added to the amount you set for turning the gun, - /// then capped by the physics of the game. If you turn infinite, then the - /// adjust is ignored (and hence overridden). - ///

- /// - /// Assuming the robot, gun, and radar all start Out facing up (0 degrees): - /// - /// // Set radar to turn with the robots's turn - /// SetAdjustRadarForBodyTurn(false); // This is the default - /// TurnRight(Math.PI / 2); - /// // At this point, the body, gun, and radar are all facing right (90 degrees); - /// - /// -- or -- - /// - /// // Set radar to turn independent from the robot's turn - /// SetAdjustRadarForBodyTurn(true); - /// TurnRight(Math.PI / 2); - /// // At this point, the robot and gun are facing right (90 degrees), but the radar is still facing up. - /// - /// - /// - /// - ///

- /// - /// true if the radar must turn independent from the robots's turn; - /// false if the radar must turn with the robot's turn. - /// - void SetAdjustRadarForBodyTurn(bool independent); - - /// - /// Checks if the gun is set to adjust for the robot turning, i.e. to turn - /// independent from the robot's body turn. - ///

- /// This call returns true if the gun is set to turn independent of - /// the turn of the robot's body. Otherwise, false is returned, - /// meaning that the gun is set to turn with the robot's body turn. - /// - /// - /// - ///

- bool IsAdjustGunForBodyTurn(); - - /// - /// Checks if the radar is set to adjust for the robot turning, i.e. to turn - /// independent from the robot's body turn. - ///

- /// This call returns true if the radar is set to turn independent of - /// the turn of the robot. Otherwise, false is returned, meaning that - /// the radar is set to turn with the robot's turn. - /// - /// - /// - ///

- bool IsAdjustRadarForGunTurn(); - - /// - /// Checks if the radar is set to adjust for the gun turning, i.e. to turn - /// independent from the gun's turn. - ///

- /// This call returns true if the radar is set to turn independent of - /// the turn of the gun. Otherwise, false is returned, meaning that - /// the radar is set to turn with the gun's turn. - /// - /// - /// - ///

- bool IsAdjustRadarForBodyTurn(); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/ITeamRobotPeer.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/ITeamRobotPeer.cs deleted file mode 100644 index cdd4872..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/robotinterfaces/peer/ITeamRobotPeer.cs +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Collections.Generic; -using Robocode; - -namespace Robocode.RobotInterfaces.Peer -{ - /// - /// The team robot peer for team robots like . - ///

- /// A robot peer is the object that deals with game mechanics and rules, and - /// makes sure your robot abides by them. - /// - /// - /// - /// - ///

- public interface ITeamRobotPeer : IAdvancedRobotPeer - { - /// - /// Returns the names of all teammates, or null there is no teammates. - ///

- /// - /// - /// public void Run() - /// { - /// // Prints Out all teammates - /// string[] teammates = GetTeammates(); - /// if (teammates != null) - /// { - /// foreach (string member in teammates) - /// { - /// Out.WriteLine(member); - /// } - /// } - /// } - /// - /// - /// - /// - /// - ///

- string[] GetTeammates(); - - /// - /// Checks if a given robot name is the name of one of your teammates. - ///

- /// - /// - /// public void OnScannedRobot(ScannedRobotEvent e) - /// { - /// if (IsTeammate(e.Name) - /// { - /// return; - /// } - /// Fire(1); - /// } - /// - /// - /// - /// - /// - /// - ///

- /// The robot name to check - bool IsTeammate(string name); - - /// - /// Broadcasts a message to all teammates. - ///

- /// - /// - /// public void Run() - /// { - /// BroadcastMessage("I'm here!"); - /// } - /// - /// - /// - /// - /// - ///

- /// The message to broadcast to all teammates - void BroadcastMessage(object message); - - /// - /// Sends a message to one (or more) teammates. - ///

- /// - /// - /// public void Run() - /// { - /// SendMessage("Sample.DroidBot", "I'm here!"); - /// } - /// - /// - /// - /// - /// - ///

- /// The name of the intended recipient of the message - /// The message to send - void SendMessage(string name, object message); - - /// - /// Returns a list containing all MessageEvents currently in the robot's - /// queue. You might, for example, call this while processing another event. - ///

- /// - /// - /// foreach (MessageEvent e in GetMessageEvents()) - /// { - /// // do something with e - /// } - /// - /// - /// - /// - ///

- IList GetMessageEvents(); - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/util/Utils.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/util/Utils.cs deleted file mode 100644 index fa1fdb5..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.api/src/robocode/util/Utils.cs +++ /dev/null @@ -1,206 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.security; - -namespace Robocode.Util -{ - /// - /// Utility class that provide methods for normalizing angles. - /// - public static class Utils - { - private const double TWO_PI = 2*Math.PI; - private const double THREE_PI_OVER_TWO = 3*Math.PI/2; - private const double PI_OVER_TWO = Math.PI/2; - private const double NEAR_DELTA = .00001; - - /// - /// Normalizes an angle to an absolute angle. - /// The normalized angle will be in the range from 0 to 2*PI, where 2*PI - /// itself is not included. - /// - /// the angle in radians to normalize - public static double NormalAbsoluteAngle(double angle) - { - return (angle %= TWO_PI) >= 0 ? angle : (angle + TWO_PI); - } - - /// - /// Normalizes an angle to an absolute angle. - /// The normalized angle will be in the range from 0 to 360, where 360 - /// itself is not included. - /// - /// the angle in degrees to normalize - public static double NormalAbsoluteAngleDegrees(double angle) - { - return (angle %= 360) >= 0 ? angle : (angle + 360); - } - - /// - /// Normalizes an angle to a relative angle. - /// The normalized angle will be in the range from -PI to PI, where PI - /// itself is not included. - /// - /// the angle in radinas to normalize - public static double NormalRelativeAngle(double angle) - { - return (angle %= TWO_PI) >= 0 - ? (angle < Math.PI) ? angle : angle - TWO_PI - : (angle >= -Math.PI) ? angle : angle + TWO_PI; - } - - /// - /// Normalizes an angle to a relative angle. - /// The normalized angle will be in the range from -180 to 180, where 180 - /// itself is not included. - /// - /// the angle to normalize - public static double NormalRelativeAngleDegrees(double angle) - { - return (angle %= 360) >= 0 ? (angle < 180) ? angle : angle - 360 : (angle >= -180) ? angle : angle + 360; - } - - /// - /// Normalizes an angle to be near an absolute angle. - /// The normalized angle will be in the range from 0 to 360, where 360 - /// itself is not included. - /// If the normalized angle is near to 0, 90, 180, 270 or 360, that - /// angle will be returned. The - /// method is used for defining when the angle is near one of angles listed - /// above. - /// - /// - /// - /// the angle to normalize - public static double NormalNearAbsoluteAngleDegrees(double angle) - { - angle = (angle %= 360) >= 0 ? angle : (angle + 360); - - if (IsNear(angle, 180)) - { - return 180; - } - if (angle < 180) - { - if (IsNear(angle, 0)) - { - return 0; - } - if (IsNear(angle, 90)) - { - return 90; - } - } - else - { - if (IsNear(angle, 270)) - { - return 270; - } - if (IsNear(angle, 360)) - { - return 0; - } - } - return angle; - } - - /// - /// Normalizes an angle to be near an absolute angle. - /// The normalized angle will be in the range from 0 to 2*PI, where 2*PI - /// itself is not included. - /// If the normalized angle is near to 0, PI/2, PI, 3*PI/2 or 2*PI, that - /// angle will be returned. The - /// method is used for defining when the angle is near one of angles listed - /// above. - /// - /// - /// - /// the angle to normalize - public static double NormalNearAbsoluteAngle(double angle) - { - angle = (angle %= TWO_PI) >= 0 ? angle : (angle + TWO_PI); - - if (IsNear(angle, Math.PI)) - { - return Math.PI; - } - if (angle < Math.PI) - { - if (IsNear(angle, 0)) - { - return 0; - } - if (IsNear(angle, PI_OVER_TWO)) - { - return PI_OVER_TWO; - } - } - else - { - if (IsNear(angle, THREE_PI_OVER_TWO)) - { - return THREE_PI_OVER_TWO; - } - if (IsNear(angle, TWO_PI)) - { - return 0; - } - } - return angle; - } - - /// - /// Tests if the two double values are near to each other. - /// It is recommended to use this method instead of testing if the two - /// doubles are equal using an this expression: value1 == value2. - /// The reason being, that this expression might never become - /// true due to the precision of double values. - /// Whether or not the specified doubles are near to each other is defined by - /// the following expression: - /// (Math.abs(value1 - value2) < .00001) - /// - /// the first double value - /// the second double value - public static bool IsNear(double value1, double value2) - { - return (Math.Abs(value1 - value2) < NEAR_DELTA); - } - - /// - /// Returns random number generator. It might be configured for repeatable behavior by setting -DRANDOMSEED option. - /// - public static Random GetRandom() - { - return HiddenAccessN.randomHelper.GetRandom(); - } - - /// - /// Conversion from degrees to radians - /// - /// in degrees - /// angle in radians - public static double ToRadians(double angle) - { - return Math.PI*angle/180.0; - } - - /// - /// Conversion from radians to degrees - /// - /// in radians - /// angle in degrees - public static double ToDegrees(double angle) - { - return angle*(180.0/Math.PI); - } - } -} - -//doc \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/.classpath b/workspace_robo/plugins/dotnet/robocode.dotnet.content/.classpath deleted file mode 100644 index 6750eaa..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.content/.project deleted file mode 100644 index 70b6969..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/.project +++ /dev/null @@ -1,19 +0,0 @@ - - - robocode.dotnet.content - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.dotnet.host - robocode.dotnet.nhost - robocode.dotnet.api - robocode.dotnet.control.api - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.content/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 764c3ab..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:34:11 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/test/java=8859_1 -encoding/src/main/resources=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.content/pom.xml deleted file mode 100644 index f67bbeb..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - 4.0.0 - robocode.dotnet.content - Robocode .NET Content - - net.sf.robocode - robocode.dotnet - ${robocode.dotnet.version} - - - - net.sf.robocode - robocode.dotnet.host - ${robocode.version} - - - net.sf.robocode - robocode.api - - - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/robocode.dotnet.content.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.content/robocode.dotnet.content.iml deleted file mode 100644 index 98715be..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/robocode.dotnet.content.iml +++ /dev/null @@ -1,147 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/.gitignore b/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/.gitignore deleted file mode 100644 index 4a3496d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -obj -Properties -BattleRunnnerSample.suo diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/BattleRunnnerSample.csproj b/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/BattleRunnnerSample.csproj deleted file mode 100644 index b5fb8dd..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/BattleRunnnerSample.csproj +++ /dev/null @@ -1,69 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {9826B19C-0C68-4D4A-B6CE-6F2A80B4B114} - Exe - Properties - BattleRunnner - BattleRunnner - v3.5 - 512 - - - - - 3.5 - - - true - full - false - ..\ - DEBUG;TRACE - prompt - 4 - - - pdbonly - true - bin\Release\ - TRACE - prompt - 4 - - - - False - C:\robocode\libs\jni4net.n-0.8.7.0.dll - - - False - C:\robocode\libs\robocode.dll - - - False - C:\robocode\libs\robocode.control.dll - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/BattleRunnnerSample.sln b/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/BattleRunnnerSample.sln deleted file mode 100644 index 67b675a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/BattleRunnnerSample.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C# Express 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "BattleRunnnerSample", "BattleRunnnerSample.csproj", "{9826B19C-0C68-4D4A-B6CE-6F2A80B4B114}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {9826B19C-0C68-4D4A-B6CE-6F2A80B4B114}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {9826B19C-0C68-4D4A-B6CE-6F2A80B4B114}.Debug|Any CPU.Build.0 = Debug|Any CPU - {9826B19C-0C68-4D4A-B6CE-6F2A80B4B114}.Release|Any CPU.ActiveCfg = Release|Any CPU - {9826B19C-0C68-4D4A-B6CE-6F2A80B4B114}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/Program.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/Program.cs deleted file mode 100644 index e757cab..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/libs/control/Program.cs +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -// Application that demonstrates how to run two sample robots in Robocode with the RobocodeEngine using the -// Robocode.Control package. -// -// NOTE: this application assumes that Robocode and the .NET plugin has been installed at C:\robocode, and that this -// application is run from the file path C:\robocode\libs\control. If this is not the case, the references for this -// solution must be changed to point at [your robocode dir]\libs directory where these references are located. -// Also note that the application will need some time to start up and initialize Robocode before the battle can begin. -// -// Author: Flemming N. Larsen - -using System; -using Robocode; -using Robocode.Control; -using Robocode.Control.Events; - -class BattleRunner -{ - static void Main(string[] args) - { - // Create the RobocodeEngine - RobocodeEngine engine = new RobocodeEngine("C:\\robocode"); // Run from C:\Robocode - - // Add battle event handlers - engine.BattleCompleted += new BattleCompletedEventHandler(BattleCompleted); - engine.BattleMessage += new BattleMessageEventHandler(BattleMessage); - engine.BattleError += new BattleErrorEventHandler(BattleError); - - // Show the Robocode battle view - engine.Visible = true; - - // Disable log messages from Robocode - RobocodeEngine.LogMessagesEnabled = false; - - // Setup the battle specification - - int numberOfRounds = 5; - BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600); // 800x600 - RobotSpecification[] selectedRobots = engine.GetLocalRepository("sample.RamFire,sample.Corners"); - - BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield, selectedRobots); - - // Run our specified battle and let it run till it is over - engine.RunBattle(battleSpec, true /* wait till the battle is over */); - - // Cleanup our RobocodeEngine - engine.Close(); - } - - // Called when the battle is completed successfully with battle results - private static void BattleCompleted(BattleCompletedEvent e) - { - Console.WriteLine("-- Battle has completed --"); - - // Print out the sorted results with the robot names - Console.WriteLine("Battle results:"); - foreach (BattleResults result in e.SortedResults) - { - Console.WriteLine(" " + result.TeamLeaderName + ": " + result.Score); - } - } - - // Called when the game sends out an information message during the battle - private static void BattleMessage(BattleMessageEvent e) - { - Console.WriteLine("Msg> " + e.Message); - } - - // Called when the game sends out an error message during the battle - private static void BattleError(BattleErrorEvent e) - { - Console.WriteLine("Err> " + e.Error); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/robocode.bat b/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/robocode.bat deleted file mode 100644 index af55147..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/robocode.bat +++ /dev/null @@ -1,9 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -java -Xmx512M -cp libs/robocode.jar;libs/jni4net.j-0.8.7.0.jar robocode.Robocode %* diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/robots/SamplesCs.csproj b/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/robots/SamplesCs.csproj deleted file mode 100644 index 58786f6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.content/src/main/resources/robots/SamplesCs.csproj +++ /dev/null @@ -1,89 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {80857B97-6397-487B-A9F5-B07026DCB666} - Library - SampleCs - samplescs-1.9.2.4 - v2.0 - 512 - - - - - true - full - false - .\ - obj\ - DEBUG;TRACE - prompt - 4 - false - false - - - pdbonly - true - .\ - obj\ - - - prompt - 4 - true - - - - False - ..\libs\robocode.dll - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/.project deleted file mode 100644 index 41b449a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/.project +++ /dev/null @@ -1,10 +0,0 @@ - - - robocode.dotnet.control.api - .NET Control API for Robocode. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.dotnet.api - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 070758f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,10 +0,0 @@ -#Tue Nov 27 22:34:10 CET 2012 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 -encoding/src/main/resources=8859_1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/test/resources=8859_1 -encoding/src=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/Content Layout.content b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/Content Layout.content deleted file mode 100644 index 31aca23..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/Content Layout.content +++ /dev/null @@ -1,4 +0,0 @@ - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/Introduction.aml b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/Introduction.aml deleted file mode 100644 index 09788c4..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/Introduction.aml +++ /dev/null @@ -1,113 +0,0 @@ - - - - Introduction - - The Robocode Control API is used for controlling the Robocode - application from another external application. Basically, it is possible - to run battles between selected robots and retrieve the results. However, - it is also possible to get detailed information as snapshots during the - battles regarding e.g. the positions and headings of the individual robots - and bullets at a specific time during a battle. - - - The main entry class is the Robocode.Control.RobocodeEngine class, which - must be instantiated by the application controlling Robocode. With the - RobocodeEngine, a battle specification must be provided in order to run a - battle. The battle specification specify the size of the battlefield, and - which rules that must be used. In addition, the participant robots must be - selected, which must exist in the robot directory of Robocode in - advantage. - - -
- Example - - - Here is a simple sample application that runs a battle in Robocode for 5 - rounds on the default battlefield of 800x600 pixels. The robots selected - for the battle are sample.RamFire and sample.Corners. - - - A Visual Studio solution containing this BattleRunner can be found in - [your robocode dir]\lib\control if you have installed Robocode and the - .NET plugin for Robocode, where [your robocode dir] is your Robocode - installation directory, which could be C:\robocode like this example - assumes. - - -// Application that demonstrates how to run two sample robots in Robocode with the RobocodeEngine using the -// Robocode.Control package. -// -// NOTE: this application assumes that Robocode and the .NET plugin has been installed at C:\robocode, and that this -// application is run from the file path C:\robocode\libs\control. If this is not the case, the references for this -// solution must be changed to point at [your robocode dir]\libs directory where these references are located. -// Also note that the application will need some time to start up and initialize Robocode before the battle can begin. -// -// Author: Flemming N. Larsen - -using System; -using Robocode; -using Robocode.Control; -using Robocode.Control.Events; - -class BattleRunner -{ - static void Main(string[] args) - { - // Create the RobocodeEngine - RobocodeEngine engine = new RobocodeEngine("C:\\robocode"); // Run from C:\Robocode - - // Add battle event handlers - engine.BattleCompleted += new BattleCompletedEventHandler(BattleCompleted); - engine.BattleMessage += new BattleMessageEventHandler(BattleMessage); - engine.BattleError += new BattleErrorEventHandler(BattleError); - - // Show the Robocode battle view - engine.Visible = true; - - // Setup the battle specification - - int numberOfRounds = 5; - BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600); // 800x600 - RobotSpecification[] selectedRobots = engine.GetLocalRepository("sample.RamFire,sample.Corners"); - - BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield, selectedRobots); - - // Run our specified battle and let it run till it is over - engine.RunBattle(battleSpec, true /* wait till the battle is over */); - - // Cleanup our RobocodeEngine - engine.Close(); - } - - // Called when the battle is completed successfully with battle results - private static void BattleCompleted(BattleCompletedEvent e) - { - Console.WriteLine("-- Battle has completed --"); - - // Print out the sorted results with the robot names - Console.WriteLine("Battle results:"); - foreach (BattleResults result in e.SortedResults) - { - Console.WriteLine(" " + result.TeamLeaderName + ": " + result.Score); - } - } - - // Called when the game sends out an information message during the battle - private static void BattleMessage(BattleMessageEvent e) - { - Console.WriteLine("Msg> " + e.Message); - } - - // Called when the game sends out an error message during the battle - private static void BattleError(BattleErrorEvent e) - { - Console.WriteLine("Err> " + e.Error); - } -} - - -
-
-
\ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/controlAPI.shfbproj b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/controlAPI.shfbproj deleted file mode 100644 index 15f8d16..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/controlAPI.shfbproj +++ /dev/null @@ -1,81 +0,0 @@ - - - - - Debug - AnyCPU - 2.0 - {90f0d09b-f58d-4f2e-ac8a-164d89979ef1} - 1.9.5.0 - - Documentation - Documentation - Documentation - - .\target\Help\ - ControlAPI - - - - - AutoDocumentCtors, AutoDocumentDispose - Robocode Control API for .NET - .NET Framework 3.5 - HtmlHelp1, Website - - - - - - - InheritedMembers, Protected, SealedProtected - - Control API used for controlling Robocode from an external .NET application. - Control API used for controlling Robocode from an external .NET application. - Control API used for controlling Robocode from an external .NET application. - - Copyright %28c%29 2001-2016 Mathew A. Nelson and Robocode contributors - fnl%40users.sourceforge.net - administator and maintainer of Robocode - Robocode Control API for .NET - vs2010 - - - - - - - - - - - - - - - - - - - - - - - - - - - ..\tools\lib\jni4net.n-0.8.7.0.dll - - - ..\robocode.dotnet.api\target\robocode.dll - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/pom.xml deleted file mode 100644 index 81f54e7..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/pom.xml +++ /dev/null @@ -1,66 +0,0 @@ - - - 4.0.0 - robocode.dotnet.control.api - Robocode .NET Control API - .NET Control API for Robocode - dotnet:library - - robocode.dotnet - net.sf.robocode - ${robocode.dotnet.version} - - - - net.sf.jni4net - jni4net.n - 0.8.7.0 - dotnet:library - - - net.sf.robocode - robocode.dotnet.api - ${project.version} - dotnet:library - - - - robocode.control - src - - - org.sonatype.nmaven.plugins - maven-dotnet-compiler-plugin - - /unsafe /warn:0 /nowarn:1591 /keyfile:"${basedir}/../tools/keys/robocode.snk" - robocode.control.dll - - - - org.jvnet.maven-antrun-extended-plugin - maven-antrun-extended-plugin - - - process-classes - - - - - - - - - - - run - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/robocode.dotnet.control.api.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/robocode.dotnet.control.api.iml deleted file mode 100644 index 64ccd25..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/robocode.dotnet.control.api.iml +++ /dev/null @@ -1,74 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/.gitignore b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/.gitignore deleted file mode 100644 index dcb7ccb..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/obj -/robocode.dotnet.control.api.sln -/robocode.dotnet.control.api.suo diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/java/util/Random.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/java/util/Random.generated.cs deleted file mode 100644 index 6b73e37..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/java/util/Random.generated.cs +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace java.util { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class Random : global::java.lang.Object, global::java.io.Serializable { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_nextInt0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_nextInt1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_nextLong2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_nextDouble3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_nextBoolean4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_nextBytes5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_nextFloat6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_nextGaussian7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setSeed8; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRandom9; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRandom10; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(J)V")] - public Random(long par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::java.util.Random.staticClass, global::java.util.Random.j4n__ctorRandom9, this, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public Random() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::java.util.Random.staticClass, global::java.util.Random.j4n__ctorRandom10, this); - } - } - - protected Random(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::java.util.Random.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::java.util.Random.staticClass = @__class; - global::java.util.Random.j4n_nextInt0 = @__env.GetMethodID(global::java.util.Random.staticClass, "nextInt", "(I)I"); - global::java.util.Random.j4n_nextInt1 = @__env.GetMethodID(global::java.util.Random.staticClass, "nextInt", "()I"); - global::java.util.Random.j4n_nextLong2 = @__env.GetMethodID(global::java.util.Random.staticClass, "nextLong", "()J"); - global::java.util.Random.j4n_nextDouble3 = @__env.GetMethodID(global::java.util.Random.staticClass, "nextDouble", "()D"); - global::java.util.Random.j4n_nextBoolean4 = @__env.GetMethodID(global::java.util.Random.staticClass, "nextBoolean", "()Z"); - global::java.util.Random.j4n_nextBytes5 = @__env.GetMethodID(global::java.util.Random.staticClass, "nextBytes", "([B)V"); - global::java.util.Random.j4n_nextFloat6 = @__env.GetMethodID(global::java.util.Random.staticClass, "nextFloat", "()F"); - global::java.util.Random.j4n_nextGaussian7 = @__env.GetMethodID(global::java.util.Random.staticClass, "nextGaussian", "()D"); - global::java.util.Random.j4n_setSeed8 = @__env.GetMethodID(global::java.util.Random.staticClass, "setSeed", "(J)V"); - global::java.util.Random.j4n__ctorRandom9 = @__env.GetMethodID(global::java.util.Random.staticClass, "", "(J)V"); - global::java.util.Random.j4n__ctorRandom10 = @__env.GetMethodID(global::java.util.Random.staticClass, "", "()V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(I)I")] - public virtual int nextInt(int par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((int)(@__env.CallIntMethod(this, global::java.util.Random.j4n_nextInt0, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int nextInt() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::java.util.Random.j4n_nextInt1))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()J")] - public virtual long nextLong() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((long)(@__env.CallLongMethod(this, global::java.util.Random.j4n_nextLong2))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - public virtual double nextDouble() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::java.util.Random.j4n_nextDouble3))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool nextBoolean() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::java.util.Random.j4n_nextBoolean4))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("([B)V")] - public virtual void nextBytes(byte[] par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::java.util.Random.j4n_nextBytes5, global::net.sf.jni4net.utils.Convertor.ParArrayPrimC2J(@__env, par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()F")] - public virtual float nextFloat() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((float)(@__env.CallFloatMethod(this, global::java.util.Random.j4n_nextFloat6))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - public virtual double nextGaussian() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::java.util.Random.j4n_nextGaussian7))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(J)V")] - public virtual void setSeed(long par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::java.util.Random.j4n_setSeed8, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::java.util.Random(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/BattleSpecification.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/BattleSpecification.generated.cs deleted file mode 100644 index c714d62..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/BattleSpecification.generated.cs +++ /dev/null @@ -1,207 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BattleSpecification : global::java.lang.Object, global::java.io.Serializable { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getInactivityTime0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getGunCoolingRate1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getBattlefield2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getNumRounds3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getHideEnemyNames4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getSentryBorderSize5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobots6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getInitialSetups7; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleSpecification8; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleSpecification9; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleSpecification10; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleSpecification11; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleSpecification12; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(IJDLrobocode/control/BattlefieldSpecification;[Lrobocode/control/RobotSpecificat" + - "ion;)V")] - public BattleSpecification(int par0, long par1, double par2, global::robocode.control.BattlefieldSpecification par3, robocode.control.RobotSpecification[] par4) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 20)){ - @__env.NewObject(global::robocode.control.BattleSpecification.staticClass, global::robocode.control.BattleSpecification.j4n__ctorBattleSpecification8, this, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par3), global::net.sf.jni4net.utils.Convertor.ParArrayStrongCp2J(@__env, par4)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(IJDZLrobocode/control/BattlefieldSpecification;[Lrobocode/control/RobotSpecifica" + - "tion;)V")] - public BattleSpecification(int par0, long par1, double par2, bool par3, global::robocode.control.BattlefieldSpecification par4, robocode.control.RobotSpecification[] par5) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 22)){ - @__env.NewObject(global::robocode.control.BattleSpecification.staticClass, global::robocode.control.BattleSpecification.j4n__ctorBattleSpecification9, this, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par3), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par4), global::net.sf.jni4net.utils.Convertor.ParArrayStrongCp2J(@__env, par5)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/BattlefieldSpecification;IJDIZ[Lrobocode/control/RobotSpecific" + - "ation;)V")] - public BattleSpecification(global::robocode.control.BattlefieldSpecification par0, int par1, long par2, double par3, int par4, bool par5, robocode.control.RobotSpecification[] par6) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 24)){ - @__env.NewObject(global::robocode.control.BattleSpecification.staticClass, global::robocode.control.BattleSpecification.j4n__ctorBattleSpecification10, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par3), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par4), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par5), global::net.sf.jni4net.utils.Convertor.ParArrayStrongCp2J(@__env, par6)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/BattlefieldSpecification;IJDIZ[Lrobocode/control/RobotSpecific" + - "ation;[Lrobocode/control/RobotSetup;)V")] - public BattleSpecification(global::robocode.control.BattlefieldSpecification par0, int par1, long par2, double par3, int par4, bool par5, robocode.control.RobotSpecification[] par6, robocode.control.RobotSetup[] par7) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 26)){ - @__env.NewObject(global::robocode.control.BattleSpecification.staticClass, global::robocode.control.BattleSpecification.j4n__ctorBattleSpecification11, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par3), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par4), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par5), global::net.sf.jni4net.utils.Convertor.ParArrayStrongCp2J(@__env, par6), global::net.sf.jni4net.utils.Convertor.ParArrayStrongCp2J(@__env, par7)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(ILrobocode/control/BattlefieldSpecification;[Lrobocode/control/RobotSpecificatio" + - "n;)V")] - public BattleSpecification(int par0, global::robocode.control.BattlefieldSpecification par1, robocode.control.RobotSpecification[] par2) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - @__env.NewObject(global::robocode.control.BattleSpecification.staticClass, global::robocode.control.BattleSpecification.j4n__ctorBattleSpecification12, this, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1), global::net.sf.jni4net.utils.Convertor.ParArrayStrongCp2J(@__env, par2)); - } - } - - protected BattleSpecification(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.BattleSpecification.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.BattleSpecification.staticClass = @__class; - global::robocode.control.BattleSpecification.j4n_getInactivityTime0 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "getInactivityTime", "()J"); - global::robocode.control.BattleSpecification.j4n_getGunCoolingRate1 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "getGunCoolingRate", "()D"); - global::robocode.control.BattleSpecification.j4n_getBattlefield2 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "getBattlefield", "()Lrobocode/control/BattlefieldSpecification;"); - global::robocode.control.BattleSpecification.j4n_getNumRounds3 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "getNumRounds", "()I"); - global::robocode.control.BattleSpecification.j4n_getHideEnemyNames4 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "getHideEnemyNames", "()Z"); - global::robocode.control.BattleSpecification.j4n_getSentryBorderSize5 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "getSentryBorderSize", "()I"); - global::robocode.control.BattleSpecification.j4n_getRobots6 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "getRobots", "()[Lrobocode/control/RobotSpecification;"); - global::robocode.control.BattleSpecification.j4n_getInitialSetups7 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "getInitialSetups", "()[Lrobocode/control/RobotSetup;"); - global::robocode.control.BattleSpecification.j4n__ctorBattleSpecification8 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "", "(IJDLrobocode/control/BattlefieldSpecification;[Lrobocode/control/RobotSpecificat" + - "ion;)V"); - global::robocode.control.BattleSpecification.j4n__ctorBattleSpecification9 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "", "(IJDZLrobocode/control/BattlefieldSpecification;[Lrobocode/control/RobotSpecifica" + - "tion;)V"); - global::robocode.control.BattleSpecification.j4n__ctorBattleSpecification10 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "", "(Lrobocode/control/BattlefieldSpecification;IJDIZ[Lrobocode/control/RobotSpecific" + - "ation;)V"); - global::robocode.control.BattleSpecification.j4n__ctorBattleSpecification11 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "", "(Lrobocode/control/BattlefieldSpecification;IJDIZ[Lrobocode/control/RobotSpecific" + - "ation;[Lrobocode/control/RobotSetup;)V"); - global::robocode.control.BattleSpecification.j4n__ctorBattleSpecification12 = @__env.GetMethodID(global::robocode.control.BattleSpecification.staticClass, "", "(ILrobocode/control/BattlefieldSpecification;[Lrobocode/control/RobotSpecificatio" + - "n;)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()J")] - public virtual long getInactivityTime() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((long)(@__env.CallLongMethod(this, global::robocode.control.BattleSpecification.j4n_getInactivityTime0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - public virtual double getGunCoolingRate() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.BattleSpecification.j4n_getGunCoolingRate1))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Lrobocode/control/BattlefieldSpecification;")] - public virtual global::robocode.control.BattlefieldSpecification getBattlefield() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.BattleSpecification.j4n_getBattlefield2)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getNumRounds() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.BattleSpecification.j4n_getNumRounds3))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool getHideEnemyNames() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.BattleSpecification.j4n_getHideEnemyNames4))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getSentryBorderSize() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.BattleSpecification.j4n_getSentryBorderSize5))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/control/RobotSpecification;")] - public virtual robocode.control.RobotSpecification[] getRobots() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.BattleSpecification.j4n_getRobots6)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/control/RobotSetup;")] - public virtual robocode.control.RobotSetup[] getInitialSetups() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.BattleSpecification.j4n_getInitialSetups7)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.BattleSpecification(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/BattlefieldSpecification.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/BattlefieldSpecification.generated.cs deleted file mode 100644 index e7f0867..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/BattlefieldSpecification.generated.cs +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BattlefieldSpecification : global::java.lang.Object, global::java.io.Serializable { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getWidth0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getHeight1; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattlefieldSpecification2; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattlefieldSpecification3; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public BattlefieldSpecification() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::robocode.control.BattlefieldSpecification.staticClass, global::robocode.control.BattlefieldSpecification.j4n__ctorBattlefieldSpecification2, this); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(II)V")] - public BattlefieldSpecification(int par0, int par1) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.NewObject(global::robocode.control.BattlefieldSpecification.staticClass, global::robocode.control.BattlefieldSpecification.j4n__ctorBattlefieldSpecification3, this, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - protected BattlefieldSpecification(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.BattlefieldSpecification.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.BattlefieldSpecification.staticClass = @__class; - global::robocode.control.BattlefieldSpecification.j4n_getWidth0 = @__env.GetMethodID(global::robocode.control.BattlefieldSpecification.staticClass, "getWidth", "()I"); - global::robocode.control.BattlefieldSpecification.j4n_getHeight1 = @__env.GetMethodID(global::robocode.control.BattlefieldSpecification.staticClass, "getHeight", "()I"); - global::robocode.control.BattlefieldSpecification.j4n__ctorBattlefieldSpecification2 = @__env.GetMethodID(global::robocode.control.BattlefieldSpecification.staticClass, "", "()V"); - global::robocode.control.BattlefieldSpecification.j4n__ctorBattlefieldSpecification3 = @__env.GetMethodID(global::robocode.control.BattlefieldSpecification.staticClass, "", "(II)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getWidth() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.BattlefieldSpecification.j4n_getWidth0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getHeight() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.BattlefieldSpecification.j4n_getHeight1))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.BattlefieldSpecification(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RandomFactory.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RandomFactory.generated.cs deleted file mode 100644 index 0309397..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RandomFactory.generated.cs +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class RandomFactory : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isDeterministic0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRandom1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setRandom2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_resetDeterministic3; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRandomFactory4; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public RandomFactory() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::robocode.control.RandomFactory.staticClass, global::robocode.control.RandomFactory.j4n__ctorRandomFactory4, this); - } - } - - protected RandomFactory(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.RandomFactory.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.RandomFactory.staticClass = @__class; - global::robocode.control.RandomFactory.j4n_isDeterministic0 = @__env.GetMethodID(global::robocode.control.RandomFactory.staticClass, "isDeterministic", "()Z"); - global::robocode.control.RandomFactory.j4n_getRandom1 = @__env.GetStaticMethodID(global::robocode.control.RandomFactory.staticClass, "getRandom", "()Ljava/util/Random;"); - global::robocode.control.RandomFactory.j4n_setRandom2 = @__env.GetStaticMethodID(global::robocode.control.RandomFactory.staticClass, "setRandom", "(Ljava/util/Random;)V"); - global::robocode.control.RandomFactory.j4n_resetDeterministic3 = @__env.GetStaticMethodID(global::robocode.control.RandomFactory.staticClass, "resetDeterministic", "(J)V"); - global::robocode.control.RandomFactory.j4n__ctorRandomFactory4 = @__env.GetMethodID(global::robocode.control.RandomFactory.staticClass, "", "()V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isDeterministic() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.RandomFactory.j4n_isDeterministic0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/util/Random;")] - public static global::java.util.Random getRandom() { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::robocode.control.RandomFactory.staticClass, global::robocode.control.RandomFactory.j4n_getRandom1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/util/Random;)V")] - public static void setRandom(global::java.util.Random par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::robocode.control.RandomFactory.staticClass, global::robocode.control.RandomFactory.j4n_setRandom2, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(J)V")] - public static void resetDeterministic(long par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::robocode.control.RandomFactory.staticClass, global::robocode.control.RandomFactory.j4n_resetDeterministic3, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.RandomFactory(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobocodeEngine.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobocodeEngine.generated.cs deleted file mode 100644 index fe32567..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobocodeEngine.generated.cs +++ /dev/null @@ -1,296 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class RobocodeEngine : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_close0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getVersion1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_addBattleListener2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_removeBattleListener3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setVisible4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getLocalRepository5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getLocalRepository6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_runBattle7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_runBattle8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_runBattle9; - - internal static global::net.sf.jni4net.jni.MethodId j4n_waitTillBattleOver10; - - internal static global::net.sf.jni4net.jni.MethodId j4n_abortCurrentBattle11; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getCurrentWorkingDir12; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobotsDir13; - - internal static global::net.sf.jni4net.jni.MethodId j4n_printRunningThreads14; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setLogMessagesEnabled15; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setLogErrorsEnabled16; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRobocodeEngine17; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRobocodeEngine18; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRobocodeEngine19; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRobocodeEngine20; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRobocodeEngine21; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/io/File;)V")] - public RobocodeEngine(global::java.io.File par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.control.RobocodeEngine.staticClass, global::robocode.control.RobocodeEngine.j4n__ctorRobocodeEngine17, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/io/File;Lrobocode/control/RobocodeListener;)V")] - public RobocodeEngine(global::java.io.File par0, global::java.lang.Object par1) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.NewObject(global::robocode.control.RobocodeEngine.staticClass, global::robocode.control.RobocodeEngine.j4n__ctorRobocodeEngine18, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/RobocodeListener;)V")] - public RobocodeEngine(global::java.lang.Object par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.control.RobocodeEngine.staticClass, global::robocode.control.RobocodeEngine.j4n__ctorRobocodeEngine19, this, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/IBattleListener;)V")] - public RobocodeEngine(global::robocode.control.events.IBattleListener par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.control.RobocodeEngine.staticClass, global::robocode.control.RobocodeEngine.j4n__ctorRobocodeEngine20, this, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public RobocodeEngine() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::robocode.control.RobocodeEngine.staticClass, global::robocode.control.RobocodeEngine.j4n__ctorRobocodeEngine21, this); - } - } - - protected RobocodeEngine(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.RobocodeEngine.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.RobocodeEngine.staticClass = @__class; - global::robocode.control.RobocodeEngine.j4n_close0 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "close", "()V"); - global::robocode.control.RobocodeEngine.j4n_getVersion1 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "getVersion", "()Ljava/lang/String;"); - global::robocode.control.RobocodeEngine.j4n_addBattleListener2 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "addBattleListener", "(Lrobocode/control/events/IBattleListener;)V"); - global::robocode.control.RobocodeEngine.j4n_removeBattleListener3 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "removeBattleListener", "(Lrobocode/control/events/IBattleListener;)V"); - global::robocode.control.RobocodeEngine.j4n_setVisible4 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "setVisible", "(Z)V"); - global::robocode.control.RobocodeEngine.j4n_getLocalRepository5 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "getLocalRepository", "()[Lrobocode/control/RobotSpecification;"); - global::robocode.control.RobocodeEngine.j4n_getLocalRepository6 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "getLocalRepository", "(Ljava/lang/String;)[Lrobocode/control/RobotSpecification;"); - global::robocode.control.RobocodeEngine.j4n_runBattle7 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "runBattle", "(Lrobocode/control/BattleSpecification;Z)V"); - global::robocode.control.RobocodeEngine.j4n_runBattle8 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "runBattle", "(Lrobocode/control/BattleSpecification;Ljava/lang/String;Z)V"); - global::robocode.control.RobocodeEngine.j4n_runBattle9 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "runBattle", "(Lrobocode/control/BattleSpecification;)V"); - global::robocode.control.RobocodeEngine.j4n_waitTillBattleOver10 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "waitTillBattleOver", "()V"); - global::robocode.control.RobocodeEngine.j4n_abortCurrentBattle11 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "abortCurrentBattle", "()V"); - global::robocode.control.RobocodeEngine.j4n_getCurrentWorkingDir12 = @__env.GetStaticMethodID(global::robocode.control.RobocodeEngine.staticClass, "getCurrentWorkingDir", "()Ljava/io/File;"); - global::robocode.control.RobocodeEngine.j4n_getRobotsDir13 = @__env.GetStaticMethodID(global::robocode.control.RobocodeEngine.staticClass, "getRobotsDir", "()Ljava/io/File;"); - global::robocode.control.RobocodeEngine.j4n_printRunningThreads14 = @__env.GetStaticMethodID(global::robocode.control.RobocodeEngine.staticClass, "printRunningThreads", "()V"); - global::robocode.control.RobocodeEngine.j4n_setLogMessagesEnabled15 = @__env.GetStaticMethodID(global::robocode.control.RobocodeEngine.staticClass, "setLogMessagesEnabled", "(Z)V"); - global::robocode.control.RobocodeEngine.j4n_setLogErrorsEnabled16 = @__env.GetStaticMethodID(global::robocode.control.RobocodeEngine.staticClass, "setLogErrorsEnabled", "(Z)V"); - global::robocode.control.RobocodeEngine.j4n__ctorRobocodeEngine17 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "", "(Ljava/io/File;)V"); - global::robocode.control.RobocodeEngine.j4n__ctorRobocodeEngine18 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "", "(Ljava/io/File;Lrobocode/control/RobocodeListener;)V"); - global::robocode.control.RobocodeEngine.j4n__ctorRobocodeEngine19 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "", "(Lrobocode/control/RobocodeListener;)V"); - global::robocode.control.RobocodeEngine.j4n__ctorRobocodeEngine20 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "", "(Lrobocode/control/events/IBattleListener;)V"); - global::robocode.control.RobocodeEngine.j4n__ctorRobocodeEngine21 = @__env.GetMethodID(global::robocode.control.RobocodeEngine.staticClass, "", "()V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public virtual void close() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::robocode.control.RobocodeEngine.j4n_close0); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobocodeEngine.j4n_getVersion1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/IBattleListener;)V")] - public virtual void addBattleListener(global::robocode.control.events.IBattleListener par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.RobocodeEngine.j4n_addBattleListener2, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/IBattleListener;)V")] - public virtual void removeBattleListener(global::robocode.control.events.IBattleListener par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.RobocodeEngine.j4n_removeBattleListener3, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Z)V")] - public virtual void setVisible(bool par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.RobocodeEngine.j4n_setVisible4, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/control/RobotSpecification;")] - public virtual robocode.control.RobotSpecification[] getLocalRepository() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobocodeEngine.j4n_getLocalRepository5)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)[Lrobocode/control/RobotSpecification;")] - public virtual robocode.control.RobotSpecification[] getLocalRepository(global::java.lang.String par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobocodeEngine.j4n_getLocalRepository6, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/BattleSpecification;Z)V")] - public virtual void runBattle(global::robocode.control.BattleSpecification par0, bool par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::robocode.control.RobocodeEngine.j4n_runBattle7, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/BattleSpecification;Ljava/lang/String;Z)V")] - public virtual void runBattle(global::robocode.control.BattleSpecification par0, global::java.lang.String par1, bool par2) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - @__env.CallVoidMethod(this, global::robocode.control.RobocodeEngine.j4n_runBattle8, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/BattleSpecification;)V")] - public virtual void runBattle(global::robocode.control.BattleSpecification par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.RobocodeEngine.j4n_runBattle9, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public virtual void waitTillBattleOver() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::robocode.control.RobocodeEngine.j4n_waitTillBattleOver10); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public virtual void abortCurrentBattle() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::robocode.control.RobocodeEngine.j4n_abortCurrentBattle11); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/io/File;")] - public static global::java.io.File getCurrentWorkingDir() { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::robocode.control.RobocodeEngine.staticClass, global::robocode.control.RobocodeEngine.j4n_getCurrentWorkingDir12)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/io/File;")] - public static global::java.io.File getRobotsDir() { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::robocode.control.RobocodeEngine.staticClass, global::robocode.control.RobocodeEngine.j4n_getRobotsDir13)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public static void printRunningThreads() { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallStaticVoidMethod(global::robocode.control.RobocodeEngine.staticClass, global::robocode.control.RobocodeEngine.j4n_printRunningThreads14); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Z)V")] - public static void setLogMessagesEnabled(bool par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::robocode.control.RobocodeEngine.staticClass, global::robocode.control.RobocodeEngine.j4n_setLogMessagesEnabled15, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Z)V")] - public static void setLogErrorsEnabled(bool par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::robocode.control.RobocodeEngine.staticClass, global::robocode.control.RobocodeEngine.j4n_setLogErrorsEnabled16, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.RobocodeEngine(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobotResults.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobotResults.generated.cs deleted file mode 100644 index 7f246be..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobotResults.generated.cs +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class RobotResults : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobot0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_convertResults1; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRobotResults2; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRobotResults3; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/RobotSpecification;Ljava/lang/String;IDDDDDDDIII)V")] - public RobotResults(global::robocode.control.RobotSpecification par0, global::java.lang.String par1, int par2, double par3, double par4, double par5, double par6, double par7, double par8, double par9, int par10, int par11, int par12) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 36)){ - @__env.NewObject(global::robocode.control.RobotResults.staticClass, global::robocode.control.RobotResults.j4n__ctorRobotResults2, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par3), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par4), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par5), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par6), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par7), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par8), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par9), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par10), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par11), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par12)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/RobotSpecification;Lrobocode/BattleResults;)V")] - public RobotResults(global::robocode.control.RobotSpecification par0, global::java.lang.Object par1) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.NewObject(global::robocode.control.RobotResults.staticClass, global::robocode.control.RobotResults.j4n__ctorRobotResults3, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1)); - } - } - - protected RobotResults(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.RobotResults.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.RobotResults.staticClass = @__class; - global::robocode.control.RobotResults.j4n_getRobot0 = @__env.GetMethodID(global::robocode.control.RobotResults.staticClass, "getRobot", "()Lrobocode/control/RobotSpecification;"); - global::robocode.control.RobotResults.j4n_convertResults1 = @__env.GetStaticMethodID(global::robocode.control.RobotResults.staticClass, "convertResults", "([Lrobocode/BattleResults;)[Lrobocode/control/RobotResults;"); - global::robocode.control.RobotResults.j4n__ctorRobotResults2 = @__env.GetMethodID(global::robocode.control.RobotResults.staticClass, "", "(Lrobocode/control/RobotSpecification;Ljava/lang/String;IDDDDDDDIII)V"); - global::robocode.control.RobotResults.j4n__ctorRobotResults3 = @__env.GetMethodID(global::robocode.control.RobotResults.staticClass, "", "(Lrobocode/control/RobotSpecification;Lrobocode/BattleResults;)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Lrobocode/control/RobotSpecification;")] - public virtual global::robocode.control.RobotSpecification getRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotResults.j4n_getRobot0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("([Lrobocode/BattleResults;)[Lrobocode/control/RobotResults;")] - public static robocode.control.RobotResults[] convertResults(java.lang.Object[] par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::robocode.control.RobotResults.staticClass, global::robocode.control.RobotResults.j4n_convertResults1, global::net.sf.jni4net.utils.Convertor.ParArrayStrongCp2J(@__env, par0))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.RobotResults(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobotSetup.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobotSetup.generated.cs deleted file mode 100644 index 38ee1c2..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobotSetup.generated.cs +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class RobotSetup : global::java.lang.Object, global::java.io.Serializable { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getX0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getY1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getHeading2; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRobotSetup3; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/Double;Ljava/lang/Double;Ljava/lang/Double;)V")] - public RobotSetup(global::java.lang.Double par0, global::java.lang.Double par1, global::java.lang.Double par2) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - @__env.NewObject(global::robocode.control.RobotSetup.staticClass, global::robocode.control.RobotSetup.j4n__ctorRobotSetup3, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par2)); - } - } - - protected RobotSetup(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.RobotSetup.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.RobotSetup.staticClass = @__class; - global::robocode.control.RobotSetup.j4n_getX0 = @__env.GetMethodID(global::robocode.control.RobotSetup.staticClass, "getX", "()Ljava/lang/Double;"); - global::robocode.control.RobotSetup.j4n_getY1 = @__env.GetMethodID(global::robocode.control.RobotSetup.staticClass, "getY", "()Ljava/lang/Double;"); - global::robocode.control.RobotSetup.j4n_getHeading2 = @__env.GetMethodID(global::robocode.control.RobotSetup.staticClass, "getHeading", "()Ljava/lang/Double;"); - global::robocode.control.RobotSetup.j4n__ctorRobotSetup3 = @__env.GetMethodID(global::robocode.control.RobotSetup.staticClass, "", "(Ljava/lang/Double;Ljava/lang/Double;Ljava/lang/Double;)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/Double;")] - public virtual global::java.lang.Double getX() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSetup.j4n_getX0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/Double;")] - public virtual global::java.lang.Double getY() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSetup.j4n_getY1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/Double;")] - public virtual global::java.lang.Double getHeading() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSetup.j4n_getHeading2)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.RobotSetup(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobotSpecification.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobotSpecification.generated.cs deleted file mode 100644 index 6978fbc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/RobotSpecification.generated.cs +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class RobotSpecification : global::java.lang.Object, global::java.io.Serializable { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getName0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getClassName1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getJarFile2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getVersion3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getNameAndVersion4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getDescription5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobocodeVersion6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getWebpage7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getAuthorName8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTeamId9; - - protected RobotSpecification(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.RobotSpecification.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.RobotSpecification.staticClass = @__class; - global::robocode.control.RobotSpecification.j4n_getName0 = @__env.GetMethodID(global::robocode.control.RobotSpecification.staticClass, "getName", "()Ljava/lang/String;"); - global::robocode.control.RobotSpecification.j4n_getClassName1 = @__env.GetMethodID(global::robocode.control.RobotSpecification.staticClass, "getClassName", "()Ljava/lang/String;"); - global::robocode.control.RobotSpecification.j4n_getJarFile2 = @__env.GetMethodID(global::robocode.control.RobotSpecification.staticClass, "getJarFile", "()Ljava/io/File;"); - global::robocode.control.RobotSpecification.j4n_getVersion3 = @__env.GetMethodID(global::robocode.control.RobotSpecification.staticClass, "getVersion", "()Ljava/lang/String;"); - global::robocode.control.RobotSpecification.j4n_getNameAndVersion4 = @__env.GetMethodID(global::robocode.control.RobotSpecification.staticClass, "getNameAndVersion", "()Ljava/lang/String;"); - global::robocode.control.RobotSpecification.j4n_getDescription5 = @__env.GetMethodID(global::robocode.control.RobotSpecification.staticClass, "getDescription", "()Ljava/lang/String;"); - global::robocode.control.RobotSpecification.j4n_getRobocodeVersion6 = @__env.GetMethodID(global::robocode.control.RobotSpecification.staticClass, "getRobocodeVersion", "()Ljava/lang/String;"); - global::robocode.control.RobotSpecification.j4n_getWebpage7 = @__env.GetMethodID(global::robocode.control.RobotSpecification.staticClass, "getWebpage", "()Ljava/lang/String;"); - global::robocode.control.RobotSpecification.j4n_getAuthorName8 = @__env.GetMethodID(global::robocode.control.RobotSpecification.staticClass, "getAuthorName", "()Ljava/lang/String;"); - global::robocode.control.RobotSpecification.j4n_getTeamId9 = @__env.GetMethodID(global::robocode.control.RobotSpecification.staticClass, "getTeamId", "()Ljava/lang/String;"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSpecification.j4n_getName0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getClassName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSpecification.j4n_getClassName1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/io/File;")] - public virtual global::java.io.File getJarFile() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSpecification.j4n_getJarFile2)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSpecification.j4n_getVersion3)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getNameAndVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSpecification.j4n_getNameAndVersion4)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getDescription() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSpecification.j4n_getDescription5)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getRobocodeVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSpecification.j4n_getRobocodeVersion6)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getWebpage() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSpecification.j4n_getWebpage7)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getAuthorName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSpecification.j4n_getAuthorName8)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getTeamId() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.RobotSpecification.j4n_getTeamId9)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.RobotSpecification(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleCompletedEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleCompletedEvent.generated.cs deleted file mode 100644 index 025761f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleCompletedEvent.generated.cs +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BattleCompletedEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getBattleRules0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getSortedResults1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getIndexedResults2; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleCompletedEvent3; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/BattleRules;[Lrobocode/BattleResults;)V")] - public BattleCompletedEvent(global::java.lang.Object par0, java.lang.Object[] par1) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.NewObject(global::robocode.control.events.BattleCompletedEvent.staticClass, global::robocode.control.events.BattleCompletedEvent.j4n__ctorBattleCompletedEvent3, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParArrayStrongCp2J(@__env, par1)); - } - } - - protected BattleCompletedEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.BattleCompletedEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.BattleCompletedEvent.staticClass = @__class; - global::robocode.control.events.BattleCompletedEvent.j4n_getBattleRules0 = @__env.GetMethodID(global::robocode.control.events.BattleCompletedEvent.staticClass, "getBattleRules", "()Lrobocode/BattleRules;"); - global::robocode.control.events.BattleCompletedEvent.j4n_getSortedResults1 = @__env.GetMethodID(global::robocode.control.events.BattleCompletedEvent.staticClass, "getSortedResults", "()[Lrobocode/BattleResults;"); - global::robocode.control.events.BattleCompletedEvent.j4n_getIndexedResults2 = @__env.GetMethodID(global::robocode.control.events.BattleCompletedEvent.staticClass, "getIndexedResults", "()[Lrobocode/BattleResults;"); - global::robocode.control.events.BattleCompletedEvent.j4n__ctorBattleCompletedEvent3 = @__env.GetMethodID(global::robocode.control.events.BattleCompletedEvent.staticClass, "", "(Lrobocode/BattleRules;[Lrobocode/BattleResults;)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Lrobocode/BattleRules;")] - public virtual global::java.lang.Object getBattleRules() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.events.BattleCompletedEvent.j4n_getBattleRules0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/BattleResults;")] - public virtual java.lang.Object[] getSortedResults() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.events.BattleCompletedEvent.j4n_getSortedResults1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/BattleResults;")] - public virtual java.lang.Object[] getIndexedResults() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.events.BattleCompletedEvent.j4n_getIndexedResults2)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.BattleCompletedEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleErrorEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleErrorEvent.generated.cs deleted file mode 100644 index 0b4b42d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleErrorEvent.generated.cs +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BattleErrorEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getError0; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleErrorEvent1; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)V")] - public BattleErrorEvent(global::java.lang.String par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.control.events.BattleErrorEvent.staticClass, global::robocode.control.events.BattleErrorEvent.j4n__ctorBattleErrorEvent1, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - protected BattleErrorEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.BattleErrorEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.BattleErrorEvent.staticClass = @__class; - global::robocode.control.events.BattleErrorEvent.j4n_getError0 = @__env.GetMethodID(global::robocode.control.events.BattleErrorEvent.staticClass, "getError", "()Ljava/lang/String;"); - global::robocode.control.events.BattleErrorEvent.j4n__ctorBattleErrorEvent1 = @__env.GetMethodID(global::robocode.control.events.BattleErrorEvent.staticClass, "", "(Ljava/lang/String;)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getError() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.events.BattleErrorEvent.j4n_getError0)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.BattleErrorEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleEvent.generated.cs deleted file mode 100644 index 0698cd0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleEvent.generated.cs +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BattleEvent : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - protected BattleEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.BattleEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.BattleEvent.staticClass = @__class; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.BattleEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleFinishedEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleFinishedEvent.generated.cs deleted file mode 100644 index af8c2a8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleFinishedEvent.generated.cs +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BattleFinishedEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isAborted0; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleFinishedEvent1; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Z)V")] - public BattleFinishedEvent(bool par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.control.events.BattleFinishedEvent.staticClass, global::robocode.control.events.BattleFinishedEvent.j4n__ctorBattleFinishedEvent1, this, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - protected BattleFinishedEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.BattleFinishedEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.BattleFinishedEvent.staticClass = @__class; - global::robocode.control.events.BattleFinishedEvent.j4n_isAborted0 = @__env.GetMethodID(global::robocode.control.events.BattleFinishedEvent.staticClass, "isAborted", "()Z"); - global::robocode.control.events.BattleFinishedEvent.j4n__ctorBattleFinishedEvent1 = @__env.GetMethodID(global::robocode.control.events.BattleFinishedEvent.staticClass, "", "(Z)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isAborted() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.events.BattleFinishedEvent.j4n_isAborted0))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.BattleFinishedEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleMessageEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleMessageEvent.generated.cs deleted file mode 100644 index 27bf827..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleMessageEvent.generated.cs +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BattleMessageEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getMessage0; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleMessageEvent1; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)V")] - public BattleMessageEvent(global::java.lang.String par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.control.events.BattleMessageEvent.staticClass, global::robocode.control.events.BattleMessageEvent.j4n__ctorBattleMessageEvent1, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - protected BattleMessageEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.BattleMessageEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.BattleMessageEvent.staticClass = @__class; - global::robocode.control.events.BattleMessageEvent.j4n_getMessage0 = @__env.GetMethodID(global::robocode.control.events.BattleMessageEvent.staticClass, "getMessage", "()Ljava/lang/String;"); - global::robocode.control.events.BattleMessageEvent.j4n__ctorBattleMessageEvent1 = @__env.GetMethodID(global::robocode.control.events.BattleMessageEvent.staticClass, "", "(Ljava/lang/String;)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - public virtual global::java.lang.String getMessage() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.events.BattleMessageEvent.j4n_getMessage0)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.BattleMessageEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattlePausedEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattlePausedEvent.generated.cs deleted file mode 100644 index 4cb8dfd..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattlePausedEvent.generated.cs +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BattlePausedEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattlePausedEvent0; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public BattlePausedEvent() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::robocode.control.events.BattlePausedEvent.staticClass, global::robocode.control.events.BattlePausedEvent.j4n__ctorBattlePausedEvent0, this); - } - } - - protected BattlePausedEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.BattlePausedEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.BattlePausedEvent.staticClass = @__class; - global::robocode.control.events.BattlePausedEvent.j4n__ctorBattlePausedEvent0 = @__env.GetMethodID(global::robocode.control.events.BattlePausedEvent.staticClass, "", "()V"); - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.BattlePausedEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleResumedEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleResumedEvent.generated.cs deleted file mode 100644 index e3de918..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleResumedEvent.generated.cs +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BattleResumedEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleResumedEvent0; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public BattleResumedEvent() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::robocode.control.events.BattleResumedEvent.staticClass, global::robocode.control.events.BattleResumedEvent.j4n__ctorBattleResumedEvent0, this); - } - } - - protected BattleResumedEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.BattleResumedEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.BattleResumedEvent.staticClass = @__class; - global::robocode.control.events.BattleResumedEvent.j4n__ctorBattleResumedEvent0 = @__env.GetMethodID(global::robocode.control.events.BattleResumedEvent.staticClass, "", "()V"); - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.BattleResumedEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleStartedEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleStartedEvent.generated.cs deleted file mode 100644 index 5efc401..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/BattleStartedEvent.generated.cs +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BattleStartedEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getBattleRules0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isReplay1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobotsCount2; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorBattleStartedEvent3; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/BattleRules;IZ)V")] - public BattleStartedEvent(global::java.lang.Object par0, int par1, bool par2) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - @__env.NewObject(global::robocode.control.events.BattleStartedEvent.staticClass, global::robocode.control.events.BattleStartedEvent.j4n__ctorBattleStartedEvent3, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2)); - } - } - - protected BattleStartedEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.BattleStartedEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.BattleStartedEvent.staticClass = @__class; - global::robocode.control.events.BattleStartedEvent.j4n_getBattleRules0 = @__env.GetMethodID(global::robocode.control.events.BattleStartedEvent.staticClass, "getBattleRules", "()Lrobocode/BattleRules;"); - global::robocode.control.events.BattleStartedEvent.j4n_isReplay1 = @__env.GetMethodID(global::robocode.control.events.BattleStartedEvent.staticClass, "isReplay", "()Z"); - global::robocode.control.events.BattleStartedEvent.j4n_getRobotsCount2 = @__env.GetMethodID(global::robocode.control.events.BattleStartedEvent.staticClass, "getRobotsCount", "()I"); - global::robocode.control.events.BattleStartedEvent.j4n__ctorBattleStartedEvent3 = @__env.GetMethodID(global::robocode.control.events.BattleStartedEvent.staticClass, "", "(Lrobocode/BattleRules;IZ)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Lrobocode/BattleRules;")] - public virtual global::java.lang.Object getBattleRules() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.events.BattleStartedEvent.j4n_getBattleRules0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isReplay() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.events.BattleStartedEvent.j4n_isReplay1))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getRobotsCount() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.events.BattleStartedEvent.j4n_getRobotsCount2))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.BattleStartedEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/IBattleListener.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/IBattleListener.generated.cs deleted file mode 100644 index bc05339..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/IBattleListener.generated.cs +++ /dev/null @@ -1,331 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IBattleListener { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/BattleStartedEvent;)V")] - void onBattleStarted(global::robocode.control.events.BattleStartedEvent par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/BattleFinishedEvent;)V")] - void onBattleFinished(global::robocode.control.events.BattleFinishedEvent par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/BattleCompletedEvent;)V")] - void onBattleCompleted(global::robocode.control.events.BattleCompletedEvent par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/BattlePausedEvent;)V")] - void onBattlePaused(global::robocode.control.events.BattlePausedEvent par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/BattleResumedEvent;)V")] - void onBattleResumed(global::robocode.control.events.BattleResumedEvent par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/RoundStartedEvent;)V")] - void onRoundStarted(global::robocode.control.events.RoundStartedEvent par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/RoundEndedEvent;)V")] - void onRoundEnded(global::robocode.control.events.RoundEndedEvent par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/TurnStartedEvent;)V")] - void onTurnStarted(global::robocode.control.events.TurnStartedEvent par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/TurnEndedEvent;)V")] - void onTurnEnded(global::robocode.control.events.TurnEndedEvent par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/BattleMessageEvent;)V")] - void onBattleMessage(global::robocode.control.events.BattleMessageEvent par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/BattleErrorEvent;)V")] - void onBattleError(global::robocode.control.events.BattleErrorEvent par0); - } - #endregion - - #region Component Designer generated code - public partial class IBattleListener_ { - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.@__IBattleListener.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::robocode.control.events.IBattleListener), typeof(global::robocode.control.events.IBattleListener_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::robocode.control.events.IBattleListener), typeof(global::robocode.control.events.IBattleListener_))] - internal sealed partial class @__IBattleListener : global::java.lang.Object, global::robocode.control.events.IBattleListener { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onBattleStarted0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onBattleFinished1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onBattleCompleted2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onBattlePaused3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onBattleResumed4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onRoundStarted5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onRoundEnded6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onTurnStarted7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onTurnEnded8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onBattleMessage9; - - internal static global::net.sf.jni4net.jni.MethodId j4n_onBattleError10; - - private @__IBattleListener(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.@__IBattleListener.staticClass = @__class; - global::robocode.control.events.@__IBattleListener.j4n_onBattleStarted0 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onBattleStarted", "(Lrobocode/control/events/BattleStartedEvent;)V"); - global::robocode.control.events.@__IBattleListener.j4n_onBattleFinished1 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onBattleFinished", "(Lrobocode/control/events/BattleFinishedEvent;)V"); - global::robocode.control.events.@__IBattleListener.j4n_onBattleCompleted2 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onBattleCompleted", "(Lrobocode/control/events/BattleCompletedEvent;)V"); - global::robocode.control.events.@__IBattleListener.j4n_onBattlePaused3 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onBattlePaused", "(Lrobocode/control/events/BattlePausedEvent;)V"); - global::robocode.control.events.@__IBattleListener.j4n_onBattleResumed4 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onBattleResumed", "(Lrobocode/control/events/BattleResumedEvent;)V"); - global::robocode.control.events.@__IBattleListener.j4n_onRoundStarted5 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onRoundStarted", "(Lrobocode/control/events/RoundStartedEvent;)V"); - global::robocode.control.events.@__IBattleListener.j4n_onRoundEnded6 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onRoundEnded", "(Lrobocode/control/events/RoundEndedEvent;)V"); - global::robocode.control.events.@__IBattleListener.j4n_onTurnStarted7 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onTurnStarted", "(Lrobocode/control/events/TurnStartedEvent;)V"); - global::robocode.control.events.@__IBattleListener.j4n_onTurnEnded8 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onTurnEnded", "(Lrobocode/control/events/TurnEndedEvent;)V"); - global::robocode.control.events.@__IBattleListener.j4n_onBattleMessage9 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onBattleMessage", "(Lrobocode/control/events/BattleMessageEvent;)V"); - global::robocode.control.events.@__IBattleListener.j4n_onBattleError10 = @__env.GetMethodID(global::robocode.control.events.@__IBattleListener.staticClass, "onBattleError", "(Lrobocode/control/events/BattleErrorEvent;)V"); - } - - public void onBattleStarted(global::robocode.control.events.BattleStartedEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onBattleStarted0, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void onBattleFinished(global::robocode.control.events.BattleFinishedEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onBattleFinished1, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void onBattleCompleted(global::robocode.control.events.BattleCompletedEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onBattleCompleted2, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void onBattlePaused(global::robocode.control.events.BattlePausedEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onBattlePaused3, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void onBattleResumed(global::robocode.control.events.BattleResumedEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onBattleResumed4, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void onRoundStarted(global::robocode.control.events.RoundStartedEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onRoundStarted5, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void onRoundEnded(global::robocode.control.events.RoundEndedEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onRoundEnded6, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void onTurnStarted(global::robocode.control.events.TurnStartedEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onTurnStarted7, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void onTurnEnded(global::robocode.control.events.TurnEndedEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onTurnEnded8, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void onBattleMessage(global::robocode.control.events.BattleMessageEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onBattleMessage9, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void onBattleError(global::robocode.control.events.BattleErrorEvent par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::robocode.control.events.@__IBattleListener.j4n_onBattleError10, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IBattleListener); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onBattleStarted", "onBattleStarted0", "(Lrobocode/control/events/BattleStartedEvent;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onBattleFinished", "onBattleFinished1", "(Lrobocode/control/events/BattleFinishedEvent;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onBattleCompleted", "onBattleCompleted2", "(Lrobocode/control/events/BattleCompletedEvent;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onBattlePaused", "onBattlePaused3", "(Lrobocode/control/events/BattlePausedEvent;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onBattleResumed", "onBattleResumed4", "(Lrobocode/control/events/BattleResumedEvent;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onRoundStarted", "onRoundStarted5", "(Lrobocode/control/events/RoundStartedEvent;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onRoundEnded", "onRoundEnded6", "(Lrobocode/control/events/RoundEndedEvent;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onTurnStarted", "onTurnStarted7", "(Lrobocode/control/events/TurnStartedEvent;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onTurnEnded", "onTurnEnded8", "(Lrobocode/control/events/TurnEndedEvent;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onBattleMessage", "onBattleMessage9", "(Lrobocode/control/events/BattleMessageEvent;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "onBattleError", "onBattleError10", "(Lrobocode/control/events/BattleErrorEvent;)V")); - return methods; - } - - private static void onBattleStarted0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/BattleStartedEvent;)V - // (Lrobocode/control/events/BattleStartedEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onBattleStarted(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void onBattleFinished1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/BattleFinishedEvent;)V - // (Lrobocode/control/events/BattleFinishedEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onBattleFinished(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void onBattleCompleted2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/BattleCompletedEvent;)V - // (Lrobocode/control/events/BattleCompletedEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onBattleCompleted(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void onBattlePaused3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/BattlePausedEvent;)V - // (Lrobocode/control/events/BattlePausedEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onBattlePaused(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void onBattleResumed4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/BattleResumedEvent;)V - // (Lrobocode/control/events/BattleResumedEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onBattleResumed(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void onRoundStarted5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/RoundStartedEvent;)V - // (Lrobocode/control/events/RoundStartedEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onRoundStarted(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void onRoundEnded6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/RoundEndedEvent;)V - // (Lrobocode/control/events/RoundEndedEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onRoundEnded(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void onTurnStarted7(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/TurnStartedEvent;)V - // (Lrobocode/control/events/TurnStartedEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onTurnStarted(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void onTurnEnded8(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/TurnEndedEvent;)V - // (Lrobocode/control/events/TurnEndedEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onTurnEnded(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void onBattleMessage9(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/BattleMessageEvent;)V - // (Lrobocode/control/events/BattleMessageEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onBattleMessage(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void onBattleError10(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lrobocode/control/events/BattleErrorEvent;)V - // (Lrobocode/control/events/BattleErrorEvent;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::robocode.control.events.IBattleListener @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.onBattleError(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.@__IBattleListener(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/RoundEndedEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/RoundEndedEvent.generated.cs deleted file mode 100644 index 570931f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/RoundEndedEvent.generated.cs +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class RoundEndedEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRound0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTurns1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalTurns2; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRoundEndedEvent3; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(III)V")] - public RoundEndedEvent(int par0, int par1, int par2) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - @__env.NewObject(global::robocode.control.events.RoundEndedEvent.staticClass, global::robocode.control.events.RoundEndedEvent.j4n__ctorRoundEndedEvent3, this, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2)); - } - } - - protected RoundEndedEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.RoundEndedEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.RoundEndedEvent.staticClass = @__class; - global::robocode.control.events.RoundEndedEvent.j4n_getRound0 = @__env.GetMethodID(global::robocode.control.events.RoundEndedEvent.staticClass, "getRound", "()I"); - global::robocode.control.events.RoundEndedEvent.j4n_getTurns1 = @__env.GetMethodID(global::robocode.control.events.RoundEndedEvent.staticClass, "getTurns", "()I"); - global::robocode.control.events.RoundEndedEvent.j4n_getTotalTurns2 = @__env.GetMethodID(global::robocode.control.events.RoundEndedEvent.staticClass, "getTotalTurns", "()I"); - global::robocode.control.events.RoundEndedEvent.j4n__ctorRoundEndedEvent3 = @__env.GetMethodID(global::robocode.control.events.RoundEndedEvent.staticClass, "", "(III)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getRound() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.events.RoundEndedEvent.j4n_getRound0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getTurns() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.events.RoundEndedEvent.j4n_getTurns1))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getTotalTurns() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.events.RoundEndedEvent.j4n_getTotalTurns2))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.RoundEndedEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/RoundStartedEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/RoundStartedEvent.generated.cs deleted file mode 100644 index 0ffd0f6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/RoundStartedEvent.generated.cs +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class RoundStartedEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRound0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getStartSnapshot1; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRoundStartedEvent2; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/snapshot/ITurnSnapshot;I)V")] - public RoundStartedEvent(global::robocode.control.snapshot.ITurnSnapshot par0, int par1) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.NewObject(global::robocode.control.events.RoundStartedEvent.staticClass, global::robocode.control.events.RoundStartedEvent.j4n__ctorRoundStartedEvent2, this, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - protected RoundStartedEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.RoundStartedEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.RoundStartedEvent.staticClass = @__class; - global::robocode.control.events.RoundStartedEvent.j4n_getRound0 = @__env.GetMethodID(global::robocode.control.events.RoundStartedEvent.staticClass, "getRound", "()I"); - global::robocode.control.events.RoundStartedEvent.j4n_getStartSnapshot1 = @__env.GetMethodID(global::robocode.control.events.RoundStartedEvent.staticClass, "getStartSnapshot", "()Lrobocode/control/snapshot/ITurnSnapshot;"); - global::robocode.control.events.RoundStartedEvent.j4n__ctorRoundStartedEvent2 = @__env.GetMethodID(global::robocode.control.events.RoundStartedEvent.staticClass, "", "(Lrobocode/control/snapshot/ITurnSnapshot;I)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getRound() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.events.RoundStartedEvent.j4n_getRound0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Lrobocode/control/snapshot/ITurnSnapshot;")] - public virtual global::robocode.control.snapshot.ITurnSnapshot getStartSnapshot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.events.RoundStartedEvent.j4n_getStartSnapshot1)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.RoundStartedEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/TurnEndedEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/TurnEndedEvent.generated.cs deleted file mode 100644 index 032500a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/TurnEndedEvent.generated.cs +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class TurnEndedEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTurnSnapshot0; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorTurnEndedEvent1; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/snapshot/ITurnSnapshot;)V")] - public TurnEndedEvent(global::robocode.control.snapshot.ITurnSnapshot par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.control.events.TurnEndedEvent.staticClass, global::robocode.control.events.TurnEndedEvent.j4n__ctorTurnEndedEvent1, this, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0)); - } - } - - protected TurnEndedEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.TurnEndedEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.TurnEndedEvent.staticClass = @__class; - global::robocode.control.events.TurnEndedEvent.j4n_getTurnSnapshot0 = @__env.GetMethodID(global::robocode.control.events.TurnEndedEvent.staticClass, "getTurnSnapshot", "()Lrobocode/control/snapshot/ITurnSnapshot;"); - global::robocode.control.events.TurnEndedEvent.j4n__ctorTurnEndedEvent1 = @__env.GetMethodID(global::robocode.control.events.TurnEndedEvent.staticClass, "", "(Lrobocode/control/snapshot/ITurnSnapshot;)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Lrobocode/control/snapshot/ITurnSnapshot;")] - public virtual global::robocode.control.snapshot.ITurnSnapshot getTurnSnapshot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.events.TurnEndedEvent.j4n_getTurnSnapshot0)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.TurnEndedEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/TurnStartedEvent.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/TurnStartedEvent.generated.cs deleted file mode 100644 index 118276b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/events/TurnStartedEvent.generated.cs +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.events { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class TurnStartedEvent : global::robocode.control.events.BattleEvent { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorTurnStartedEvent0; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public TurnStartedEvent() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::robocode.control.events.TurnStartedEvent.staticClass, global::robocode.control.events.TurnStartedEvent.j4n__ctorTurnStartedEvent0, this); - } - } - - protected TurnStartedEvent(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.events.TurnStartedEvent.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.events.TurnStartedEvent.staticClass = @__class; - global::robocode.control.events.TurnStartedEvent.j4n__ctorTurnStartedEvent0 = @__env.GetMethodID(global::robocode.control.events.TurnStartedEvent.staticClass, "", "()V"); - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.events.TurnStartedEvent(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/BulletState.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/BulletState.generated.cs deleted file mode 100644 index 6b49adf..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/BulletState.generated.cs +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.snapshot { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BulletState : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_values0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_valueOf1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getValue2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_toState3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isActive4; - - internal static global::net.sf.jni4net.jni.FieldId j4n_FIRED5; - - internal static global::net.sf.jni4net.jni.FieldId j4n_MOVING6; - - internal static global::net.sf.jni4net.jni.FieldId j4n_HIT_VICTIM7; - - internal static global::net.sf.jni4net.jni.FieldId j4n_HIT_BULLET8; - - internal static global::net.sf.jni4net.jni.FieldId j4n_HIT_WALL9; - - internal static global::net.sf.jni4net.jni.FieldId j4n_EXPLODED10; - - internal static global::net.sf.jni4net.jni.FieldId j4n_INACTIVE11; - - protected BulletState(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.snapshot.BulletState.staticClass; - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/BulletState;")] - public static global::robocode.control.snapshot.BulletState FIRED { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.BulletState.staticClass, global::robocode.control.snapshot.BulletState.j4n_FIRED5)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/BulletState;")] - public static global::robocode.control.snapshot.BulletState MOVING { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.BulletState.staticClass, global::robocode.control.snapshot.BulletState.j4n_MOVING6)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/BulletState;")] - public static global::robocode.control.snapshot.BulletState HIT_VICTIM { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.BulletState.staticClass, global::robocode.control.snapshot.BulletState.j4n_HIT_VICTIM7)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/BulletState;")] - public static global::robocode.control.snapshot.BulletState HIT_BULLET { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.BulletState.staticClass, global::robocode.control.snapshot.BulletState.j4n_HIT_BULLET8)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/BulletState;")] - public static global::robocode.control.snapshot.BulletState HIT_WALL { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.BulletState.staticClass, global::robocode.control.snapshot.BulletState.j4n_HIT_WALL9)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/BulletState;")] - public static global::robocode.control.snapshot.BulletState EXPLODED { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.BulletState.staticClass, global::robocode.control.snapshot.BulletState.j4n_EXPLODED10)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/BulletState;")] - public static global::robocode.control.snapshot.BulletState INACTIVE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.BulletState.staticClass, global::robocode.control.snapshot.BulletState.j4n_INACTIVE11)); - } - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.snapshot.BulletState.staticClass = @__class; - global::robocode.control.snapshot.BulletState.j4n_values0 = @__env.GetStaticMethodID(global::robocode.control.snapshot.BulletState.staticClass, "values", "()[Lrobocode/control/snapshot/BulletState;"); - global::robocode.control.snapshot.BulletState.j4n_valueOf1 = @__env.GetStaticMethodID(global::robocode.control.snapshot.BulletState.staticClass, "valueOf", "(Ljava/lang/String;)Lrobocode/control/snapshot/BulletState;"); - global::robocode.control.snapshot.BulletState.j4n_getValue2 = @__env.GetMethodID(global::robocode.control.snapshot.BulletState.staticClass, "getValue", "()I"); - global::robocode.control.snapshot.BulletState.j4n_toState3 = @__env.GetStaticMethodID(global::robocode.control.snapshot.BulletState.staticClass, "toState", "(I)Lrobocode/control/snapshot/BulletState;"); - global::robocode.control.snapshot.BulletState.j4n_isActive4 = @__env.GetMethodID(global::robocode.control.snapshot.BulletState.staticClass, "isActive", "()Z"); - global::robocode.control.snapshot.BulletState.j4n_FIRED5 = @__env.GetStaticFieldID(global::robocode.control.snapshot.BulletState.staticClass, "FIRED", "Lrobocode/control/snapshot/BulletState;"); - global::robocode.control.snapshot.BulletState.j4n_MOVING6 = @__env.GetStaticFieldID(global::robocode.control.snapshot.BulletState.staticClass, "MOVING", "Lrobocode/control/snapshot/BulletState;"); - global::robocode.control.snapshot.BulletState.j4n_HIT_VICTIM7 = @__env.GetStaticFieldID(global::robocode.control.snapshot.BulletState.staticClass, "HIT_VICTIM", "Lrobocode/control/snapshot/BulletState;"); - global::robocode.control.snapshot.BulletState.j4n_HIT_BULLET8 = @__env.GetStaticFieldID(global::robocode.control.snapshot.BulletState.staticClass, "HIT_BULLET", "Lrobocode/control/snapshot/BulletState;"); - global::robocode.control.snapshot.BulletState.j4n_HIT_WALL9 = @__env.GetStaticFieldID(global::robocode.control.snapshot.BulletState.staticClass, "HIT_WALL", "Lrobocode/control/snapshot/BulletState;"); - global::robocode.control.snapshot.BulletState.j4n_EXPLODED10 = @__env.GetStaticFieldID(global::robocode.control.snapshot.BulletState.staticClass, "EXPLODED", "Lrobocode/control/snapshot/BulletState;"); - global::robocode.control.snapshot.BulletState.j4n_INACTIVE11 = @__env.GetStaticFieldID(global::robocode.control.snapshot.BulletState.staticClass, "INACTIVE", "Lrobocode/control/snapshot/BulletState;"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/control/snapshot/BulletState;")] - public static robocode.control.snapshot.BulletState[] values() { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::robocode.control.snapshot.BulletState.staticClass, global::robocode.control.snapshot.BulletState.j4n_values0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)Lrobocode/control/snapshot/BulletState;")] - public static global::robocode.control.snapshot.BulletState valueOf(global::java.lang.String par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::robocode.control.snapshot.BulletState.staticClass, global::robocode.control.snapshot.BulletState.j4n_valueOf1, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getValue() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.BulletState.j4n_getValue2))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(I)Lrobocode/control/snapshot/BulletState;")] - public static global::robocode.control.snapshot.BulletState toState(int par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::robocode.control.snapshot.BulletState.staticClass, global::robocode.control.snapshot.BulletState.j4n_toState3, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isActive() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.BulletState.j4n_isActive4))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.snapshot.BulletState(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IBulletSnapshot.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IBulletSnapshot.generated.cs deleted file mode 100644 index 6c857ec..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IBulletSnapshot.generated.cs +++ /dev/null @@ -1,431 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.snapshot { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IBulletSnapshot { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Lrobocode/control/snapshot/BulletState;")] - global::robocode.control.snapshot.BulletState getState(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getX(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getY(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getHeading(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getPower(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getPaintX(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getPaintY(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getColor(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getFrame(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isExplosion(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getExplosionImageIndex(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getBulletId(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getVictimIndex(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getOwnerIndex(); - } - #endregion - - #region Component Designer generated code - public partial class IBulletSnapshot_ { - - public static global::java.lang.Class _class { - get { - return global::robocode.control.snapshot.@__IBulletSnapshot.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::robocode.control.snapshot.IBulletSnapshot), typeof(global::robocode.control.snapshot.IBulletSnapshot_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::robocode.control.snapshot.IBulletSnapshot), typeof(global::robocode.control.snapshot.IBulletSnapshot_))] - internal sealed partial class @__IBulletSnapshot : global::java.lang.Object, global::robocode.control.snapshot.IBulletSnapshot { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getState0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getX1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getY2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getHeading3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getPower4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getPaintX5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getPaintY6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getColor7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getFrame8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isExplosion9; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getExplosionImageIndex10; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getBulletId11; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getVictimIndex12; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getOwnerIndex13; - - private @__IBulletSnapshot(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.snapshot.@__IBulletSnapshot.staticClass = @__class; - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getState0 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getState", "()Lrobocode/control/snapshot/BulletState;"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getX1 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getX", "()D"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getY2 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getY", "()D"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getHeading3 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getHeading", "()D"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getPower4 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getPower", "()D"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getPaintX5 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getPaintX", "()D"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getPaintY6 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getPaintY", "()D"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getColor7 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getColor", "()I"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getFrame8 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getFrame", "()I"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_isExplosion9 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "isExplosion", "()Z"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getExplosionImageIndex10 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getExplosionImageIndex", "()I"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getBulletId11 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getBulletId", "()I"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getVictimIndex12 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getVictimIndex", "()I"); - global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getOwnerIndex13 = @__env.GetMethodID(global::robocode.control.snapshot.@__IBulletSnapshot.staticClass, "getOwnerIndex", "()I"); - } - - public global::robocode.control.snapshot.BulletState getState() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getState0)); - } - } - - public double getX() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getX1))); - } - } - - public double getY() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getY2))); - } - } - - public double getHeading() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getHeading3))); - } - } - - public double getPower() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getPower4))); - } - } - - public double getPaintX() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getPaintX5))); - } - } - - public double getPaintY() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getPaintY6))); - } - } - - public int getColor() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getColor7))); - } - } - - public int getFrame() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getFrame8))); - } - } - - public bool isExplosion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_isExplosion9))); - } - } - - public int getExplosionImageIndex() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getExplosionImageIndex10))); - } - } - - public int getBulletId() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getBulletId11))); - } - } - - public int getVictimIndex() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getVictimIndex12))); - } - } - - public int getOwnerIndex() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IBulletSnapshot.j4n_getOwnerIndex13))); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IBulletSnapshot); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getState", "getState0", "()Lrobocode/control/snapshot/BulletState;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getX", "getX1", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getY", "getY2", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getHeading", "getHeading3", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getPower", "getPower4", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getPaintX", "getPaintX5", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getPaintY", "getPaintY6", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getColor", "getColor7", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getFrame", "getFrame8", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isExplosion", "isExplosion9", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getExplosionImageIndex", "getExplosionImageIndex10", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getBulletId", "getBulletId11", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getVictimIndex", "getVictimIndex12", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getOwnerIndex", "getOwnerIndex13", "()I")); - return methods; - } - - private static global::net.sf.jni4net.utils.JniHandle getState0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Lrobocode/control/snapshot/BulletState; - // ()Lrobocode/control/snapshot/BulletState; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getState()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getX1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getX())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getY2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getY())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getHeading3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getHeading())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getPower4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getPower())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getPaintX5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getPaintX())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getPaintY6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getPaintY())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getColor7(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getColor())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getFrame8(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getFrame())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isExplosion9(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isExplosion())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getExplosionImageIndex10(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getExplosionImageIndex())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getBulletId11(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getBulletId())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getVictimIndex12(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getVictimIndex())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getOwnerIndex13(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IBulletSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getOwnerIndex())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.snapshot.@__IBulletSnapshot(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IDebugProperty.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IDebugProperty.generated.cs deleted file mode 100644 index 9b34022..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IDebugProperty.generated.cs +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.snapshot { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IDebugProperty { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getValue(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getKey(); - } - #endregion - - #region Component Designer generated code - public partial class IDebugProperty_ { - - public static global::java.lang.Class _class { - get { - return global::robocode.control.snapshot.@__IDebugProperty.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::robocode.control.snapshot.IDebugProperty), typeof(global::robocode.control.snapshot.IDebugProperty_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::robocode.control.snapshot.IDebugProperty), typeof(global::robocode.control.snapshot.IDebugProperty_))] - internal sealed partial class @__IDebugProperty : global::java.lang.Object, global::robocode.control.snapshot.IDebugProperty { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getValue0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getKey1; - - private @__IDebugProperty(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.snapshot.@__IDebugProperty.staticClass = @__class; - global::robocode.control.snapshot.@__IDebugProperty.j4n_getValue0 = @__env.GetMethodID(global::robocode.control.snapshot.@__IDebugProperty.staticClass, "getValue", "()Ljava/lang/String;"); - global::robocode.control.snapshot.@__IDebugProperty.j4n_getKey1 = @__env.GetMethodID(global::robocode.control.snapshot.@__IDebugProperty.staticClass, "getKey", "()Ljava/lang/String;"); - } - - public global::java.lang.String getValue() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IDebugProperty.j4n_getValue0)); - } - } - - public global::java.lang.String getKey() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IDebugProperty.j4n_getKey1)); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IDebugProperty); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getValue", "getValue0", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getKey", "getKey1", "()Ljava/lang/String;")); - return methods; - } - - private static global::net.sf.jni4net.utils.JniHandle getValue0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IDebugProperty @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getValue()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getKey1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IDebugProperty @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getKey()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.snapshot.@__IDebugProperty(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IRobotSnapshot.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IRobotSnapshot.generated.cs deleted file mode 100644 index d73f872..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IRobotSnapshot.generated.cs +++ /dev/null @@ -1,795 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.snapshot { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IRobotSnapshot { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getName(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Lrobocode/control/snapshot/RobotState;")] - global::robocode.control.snapshot.RobotState getState(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getTeamName(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getX(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getY(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getShortName(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getVeryShortName(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getRobotIndex(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getTeamIndex(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getContestantIndex(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getEnergy(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getVelocity(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getBodyHeading(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getGunHeading(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getRadarHeading(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getGunHeat(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getBodyColor(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getGunColor(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getRadarColor(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getScanColor(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isDroid(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isSentryRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isPaintRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isPaintEnabled(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isSGPaintEnabled(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/control/snapshot/IDebugProperty;")] - robocode.control.snapshot.IDebugProperty[] getDebugProperties(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getOutputStreamSnapshot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Lrobocode/control/snapshot/IScoreSnapshot;")] - global::robocode.control.snapshot.IScoreSnapshot getScoreSnapshot(); - } - #endregion - - #region Component Designer generated code - public partial class IRobotSnapshot_ { - - public static global::java.lang.Class _class { - get { - return global::robocode.control.snapshot.@__IRobotSnapshot.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::robocode.control.snapshot.IRobotSnapshot), typeof(global::robocode.control.snapshot.IRobotSnapshot_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::robocode.control.snapshot.IRobotSnapshot), typeof(global::robocode.control.snapshot.IRobotSnapshot_))] - internal sealed partial class @__IRobotSnapshot : global::java.lang.Object, global::robocode.control.snapshot.IRobotSnapshot { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getName0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getState1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTeamName2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getX3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getY4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getShortName5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getVeryShortName6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobotIndex7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTeamIndex8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getContestantIndex9; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getEnergy10; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getVelocity11; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getBodyHeading12; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getGunHeading13; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRadarHeading14; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getGunHeat15; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getBodyColor16; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getGunColor17; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRadarColor18; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getScanColor19; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isDroid20; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isSentryRobot21; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isPaintRobot22; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isPaintEnabled23; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isSGPaintEnabled24; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getDebugProperties25; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getOutputStreamSnapshot26; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getScoreSnapshot27; - - private @__IRobotSnapshot(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.snapshot.@__IRobotSnapshot.staticClass = @__class; - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getName0 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getName", "()Ljava/lang/String;"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getState1 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getState", "()Lrobocode/control/snapshot/RobotState;"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getTeamName2 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getTeamName", "()Ljava/lang/String;"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getX3 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getX", "()D"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getY4 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getY", "()D"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getShortName5 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getShortName", "()Ljava/lang/String;"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getVeryShortName6 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getVeryShortName", "()Ljava/lang/String;"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getRobotIndex7 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getRobotIndex", "()I"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getTeamIndex8 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getTeamIndex", "()I"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getContestantIndex9 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getContestantIndex", "()I"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getEnergy10 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getEnergy", "()D"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getVelocity11 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getVelocity", "()D"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getBodyHeading12 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getBodyHeading", "()D"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getGunHeading13 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getGunHeading", "()D"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getRadarHeading14 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getRadarHeading", "()D"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getGunHeat15 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getGunHeat", "()D"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getBodyColor16 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getBodyColor", "()I"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getGunColor17 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getGunColor", "()I"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getRadarColor18 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getRadarColor", "()I"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getScanColor19 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getScanColor", "()I"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_isDroid20 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "isDroid", "()Z"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_isSentryRobot21 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "isSentryRobot", "()Z"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_isPaintRobot22 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "isPaintRobot", "()Z"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_isPaintEnabled23 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "isPaintEnabled", "()Z"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_isSGPaintEnabled24 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "isSGPaintEnabled", "()Z"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getDebugProperties25 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getDebugProperties", "()[Lrobocode/control/snapshot/IDebugProperty;"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getOutputStreamSnapshot26 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getOutputStreamSnapshot", "()Ljava/lang/String;"); - global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getScoreSnapshot27 = @__env.GetMethodID(global::robocode.control.snapshot.@__IRobotSnapshot.staticClass, "getScoreSnapshot", "()Lrobocode/control/snapshot/IScoreSnapshot;"); - } - - public global::java.lang.String getName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getName0)); - } - } - - public global::robocode.control.snapshot.RobotState getState() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getState1)); - } - } - - public global::java.lang.String getTeamName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getTeamName2)); - } - } - - public double getX() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getX3))); - } - } - - public double getY() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getY4))); - } - } - - public global::java.lang.String getShortName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getShortName5)); - } - } - - public global::java.lang.String getVeryShortName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getVeryShortName6)); - } - } - - public int getRobotIndex() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getRobotIndex7))); - } - } - - public int getTeamIndex() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getTeamIndex8))); - } - } - - public int getContestantIndex() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getContestantIndex9))); - } - } - - public double getEnergy() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getEnergy10))); - } - } - - public double getVelocity() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getVelocity11))); - } - } - - public double getBodyHeading() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getBodyHeading12))); - } - } - - public double getGunHeading() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getGunHeading13))); - } - } - - public double getRadarHeading() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getRadarHeading14))); - } - } - - public double getGunHeat() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getGunHeat15))); - } - } - - public int getBodyColor() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getBodyColor16))); - } - } - - public int getGunColor() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getGunColor17))); - } - } - - public int getRadarColor() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getRadarColor18))); - } - } - - public int getScanColor() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getScanColor19))); - } - } - - public bool isDroid() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_isDroid20))); - } - } - - public bool isSentryRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_isSentryRobot21))); - } - } - - public bool isPaintRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_isPaintRobot22))); - } - } - - public bool isPaintEnabled() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_isPaintEnabled23))); - } - } - - public bool isSGPaintEnabled() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_isSGPaintEnabled24))); - } - } - - public robocode.control.snapshot.IDebugProperty[] getDebugProperties() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayFullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getDebugProperties25)); - } - } - - public global::java.lang.String getOutputStreamSnapshot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getOutputStreamSnapshot26)); - } - } - - public global::robocode.control.snapshot.IScoreSnapshot getScoreSnapshot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IRobotSnapshot.j4n_getScoreSnapshot27)); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IRobotSnapshot); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getName", "getName0", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getState", "getState1", "()Lrobocode/control/snapshot/RobotState;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTeamName", "getTeamName2", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getX", "getX3", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getY", "getY4", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getShortName", "getShortName5", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getVeryShortName", "getVeryShortName6", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRobotIndex", "getRobotIndex7", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTeamIndex", "getTeamIndex8", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getContestantIndex", "getContestantIndex9", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getEnergy", "getEnergy10", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getVelocity", "getVelocity11", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getBodyHeading", "getBodyHeading12", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getGunHeading", "getGunHeading13", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRadarHeading", "getRadarHeading14", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getGunHeat", "getGunHeat15", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getBodyColor", "getBodyColor16", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getGunColor", "getGunColor17", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRadarColor", "getRadarColor18", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getScanColor", "getScanColor19", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isDroid", "isDroid20", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isSentryRobot", "isSentryRobot21", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isPaintRobot", "isPaintRobot22", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isPaintEnabled", "isPaintEnabled23", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isSGPaintEnabled", "isSGPaintEnabled24", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getDebugProperties", "getDebugProperties25", "()[Lrobocode/control/snapshot/IDebugProperty;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getOutputStreamSnapshot", "getOutputStreamSnapshot26", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getScoreSnapshot", "getScoreSnapshot27", "()Lrobocode/control/snapshot/IScoreSnapshot;")); - return methods; - } - - private static global::net.sf.jni4net.utils.JniHandle getName0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getState1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Lrobocode/control/snapshot/RobotState; - // ()Lrobocode/control/snapshot/RobotState; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getState()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getTeamName2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getTeamName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getX3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getX())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getY4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getY())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getShortName5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getShortName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getVeryShortName6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getVeryShortName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getRobotIndex7(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getRobotIndex())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getTeamIndex8(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getTeamIndex())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getContestantIndex9(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getContestantIndex())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getEnergy10(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getEnergy())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getVelocity11(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getVelocity())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getBodyHeading12(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getBodyHeading())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getGunHeading13(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getGunHeading())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getRadarHeading14(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getRadarHeading())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getGunHeat15(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getGunHeat())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getBodyColor16(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getBodyColor())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getGunColor17(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getGunColor())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getRadarColor18(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getRadarColor())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getScanColor19(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getScanColor())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isDroid20(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isDroid())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isSentryRobot21(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isSentryRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isPaintRobot22(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isPaintRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isPaintEnabled23(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isPaintEnabled())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isSGPaintEnabled24(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isSGPaintEnabled())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getDebugProperties25(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()[Lrobocode/control/snapshot/IDebugProperty; - // ()[Lrobocode/control/snapshot/IDebugProperty; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.ArrayFullC2J(@__env, @__real.getDebugProperties()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getOutputStreamSnapshot26(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getOutputStreamSnapshot()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getScoreSnapshot27(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Lrobocode/control/snapshot/IScoreSnapshot; - // ()Lrobocode/control/snapshot/IScoreSnapshot; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IRobotSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.FullC2J(@__env, @__real.getScoreSnapshot()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.snapshot.@__IRobotSnapshot(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IScoreSnapshot.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IScoreSnapshot.generated.cs deleted file mode 100644 index 374c181..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/IScoreSnapshot.generated.cs +++ /dev/null @@ -1,558 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.snapshot { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IScoreSnapshot : global::java.lang.Comparable { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getName(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getTotalScore(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getTotalSurvivalScore(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getTotalLastSurvivorBonus(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getTotalBulletDamageScore(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getTotalBulletKillBonus(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getTotalRammingDamageScore(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getTotalRammingKillBonus(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getTotalFirsts(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getTotalSeconds(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getTotalThirds(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getCurrentScore(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getCurrentSurvivalScore(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getCurrentSurvivalBonus(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getCurrentBulletDamageScore(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getCurrentBulletKillBonus(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getCurrentRammingDamageScore(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()D")] - double getCurrentRammingKillBonus(); - } - #endregion - - #region Component Designer generated code - public partial class IScoreSnapshot_ { - - public static global::java.lang.Class _class { - get { - return global::robocode.control.snapshot.@__IScoreSnapshot.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::robocode.control.snapshot.IScoreSnapshot), typeof(global::robocode.control.snapshot.IScoreSnapshot_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::robocode.control.snapshot.IScoreSnapshot), typeof(global::robocode.control.snapshot.IScoreSnapshot_))] - internal sealed partial class @__IScoreSnapshot : global::java.lang.Object, global::robocode.control.snapshot.IScoreSnapshot { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_compareTo0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getName1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalScore2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalSurvivalScore3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalLastSurvivorBonus4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalBulletDamageScore5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalBulletKillBonus6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalRammingDamageScore7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalRammingKillBonus8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalFirsts9; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalSeconds10; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTotalThirds11; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getCurrentScore12; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getCurrentSurvivalScore13; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getCurrentSurvivalBonus14; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getCurrentBulletDamageScore15; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getCurrentBulletKillBonus16; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getCurrentRammingDamageScore17; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getCurrentRammingKillBonus18; - - private @__IScoreSnapshot(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.snapshot.@__IScoreSnapshot.staticClass = @__class; - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_compareTo0 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "compareTo", "(Ljava/lang/Object;)I"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getName1 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getName", "()Ljava/lang/String;"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalScore2 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getTotalScore", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalSurvivalScore3 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getTotalSurvivalScore", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalLastSurvivorBonus4 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getTotalLastSurvivorBonus", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalBulletDamageScore5 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getTotalBulletDamageScore", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalBulletKillBonus6 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getTotalBulletKillBonus", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalRammingDamageScore7 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getTotalRammingDamageScore", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalRammingKillBonus8 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getTotalRammingKillBonus", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalFirsts9 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getTotalFirsts", "()I"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalSeconds10 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getTotalSeconds", "()I"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalThirds11 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getTotalThirds", "()I"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentScore12 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getCurrentScore", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentSurvivalScore13 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getCurrentSurvivalScore", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentSurvivalBonus14 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getCurrentSurvivalBonus", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentBulletDamageScore15 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getCurrentBulletDamageScore", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentBulletKillBonus16 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getCurrentBulletKillBonus", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentRammingDamageScore17 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getCurrentRammingDamageScore", "()D"); - global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentRammingKillBonus18 = @__env.GetMethodID(global::robocode.control.snapshot.@__IScoreSnapshot.staticClass, "getCurrentRammingKillBonus", "()D"); - } - - public int compareTo(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_compareTo0, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0)))); - } - } - - public global::java.lang.String getName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getName1)); - } - } - - public double getTotalScore() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalScore2))); - } - } - - public double getTotalSurvivalScore() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalSurvivalScore3))); - } - } - - public double getTotalLastSurvivorBonus() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalLastSurvivorBonus4))); - } - } - - public double getTotalBulletDamageScore() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalBulletDamageScore5))); - } - } - - public double getTotalBulletKillBonus() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalBulletKillBonus6))); - } - } - - public double getTotalRammingDamageScore() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalRammingDamageScore7))); - } - } - - public double getTotalRammingKillBonus() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalRammingKillBonus8))); - } - } - - public int getTotalFirsts() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalFirsts9))); - } - } - - public int getTotalSeconds() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalSeconds10))); - } - } - - public int getTotalThirds() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getTotalThirds11))); - } - } - - public double getCurrentScore() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentScore12))); - } - } - - public double getCurrentSurvivalScore() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentSurvivalScore13))); - } - } - - public double getCurrentSurvivalBonus() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentSurvivalBonus14))); - } - } - - public double getCurrentBulletDamageScore() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentBulletDamageScore15))); - } - } - - public double getCurrentBulletKillBonus() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentBulletKillBonus16))); - } - } - - public double getCurrentRammingDamageScore() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentRammingDamageScore17))); - } - } - - public double getCurrentRammingKillBonus() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((double)(@__env.CallDoubleMethod(this, global::robocode.control.snapshot.@__IScoreSnapshot.j4n_getCurrentRammingKillBonus18))); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IScoreSnapshot); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "compareTo", "compareTo0", "(Ljava/lang/Object;)I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getName", "getName1", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTotalScore", "getTotalScore2", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTotalSurvivalScore", "getTotalSurvivalScore3", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTotalLastSurvivorBonus", "getTotalLastSurvivorBonus4", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTotalBulletDamageScore", "getTotalBulletDamageScore5", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTotalBulletKillBonus", "getTotalBulletKillBonus6", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTotalRammingDamageScore", "getTotalRammingDamageScore7", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTotalRammingKillBonus", "getTotalRammingKillBonus8", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTotalFirsts", "getTotalFirsts9", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTotalSeconds", "getTotalSeconds10", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTotalThirds", "getTotalThirds11", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getCurrentScore", "getCurrentScore12", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getCurrentSurvivalScore", "getCurrentSurvivalScore13", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getCurrentSurvivalBonus", "getCurrentSurvivalBonus14", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getCurrentBulletDamageScore", "getCurrentBulletDamageScore15", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getCurrentBulletKillBonus", "getCurrentBulletKillBonus16", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getCurrentRammingDamageScore", "getCurrentRammingDamageScore17", "()D")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getCurrentRammingKillBonus", "getCurrentRammingKillBonus18", "()D")); - return methods; - } - - private static int compareTo0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Ljava/lang/Object;)I - // (Ljava/lang/Object;)I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(((global::java.lang.Comparable)(@__real)).compareTo(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0)))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getName1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getTotalScore2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getTotalScore())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getTotalSurvivalScore3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getTotalSurvivalScore())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getTotalLastSurvivorBonus4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getTotalLastSurvivorBonus())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getTotalBulletDamageScore5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getTotalBulletDamageScore())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getTotalBulletKillBonus6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getTotalBulletKillBonus())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getTotalRammingDamageScore7(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getTotalRammingDamageScore())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getTotalRammingKillBonus8(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getTotalRammingKillBonus())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getTotalFirsts9(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getTotalFirsts())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getTotalSeconds10(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getTotalSeconds())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getTotalThirds11(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getTotalThirds())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getCurrentScore12(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getCurrentScore())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getCurrentSurvivalScore13(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getCurrentSurvivalScore())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getCurrentSurvivalBonus14(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getCurrentSurvivalBonus())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getCurrentBulletDamageScore15(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getCurrentBulletDamageScore())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getCurrentBulletKillBonus16(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getCurrentBulletKillBonus())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getCurrentRammingDamageScore17(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getCurrentRammingDamageScore())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static double getCurrentRammingKillBonus18(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()D - // ()D - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - double @__return = default(double); - try { - global::robocode.control.snapshot.IScoreSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((double)(@__real.getCurrentRammingKillBonus())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.snapshot.@__IScoreSnapshot(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/ITurnSnapshot.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/ITurnSnapshot.generated.cs deleted file mode 100644 index 417e14f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/ITurnSnapshot.generated.cs +++ /dev/null @@ -1,249 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.snapshot { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface ITurnSnapshot { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/control/snapshot/IRobotSnapshot;")] - robocode.control.snapshot.IRobotSnapshot[] getRobots(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/control/snapshot/IBulletSnapshot;")] - robocode.control.snapshot.IBulletSnapshot[] getBullets(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getTPS(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getRound(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getTurn(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/control/snapshot/IScoreSnapshot;")] - robocode.control.snapshot.IScoreSnapshot[] getSortedTeamScores(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/control/snapshot/IScoreSnapshot;")] - robocode.control.snapshot.IScoreSnapshot[] getIndexedTeamScores(); - } - #endregion - - #region Component Designer generated code - public partial class ITurnSnapshot_ { - - public static global::java.lang.Class _class { - get { - return global::robocode.control.snapshot.@__ITurnSnapshot.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::robocode.control.snapshot.ITurnSnapshot), typeof(global::robocode.control.snapshot.ITurnSnapshot_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::robocode.control.snapshot.ITurnSnapshot), typeof(global::robocode.control.snapshot.ITurnSnapshot_))] - internal sealed partial class @__ITurnSnapshot : global::java.lang.Object, global::robocode.control.snapshot.ITurnSnapshot { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobots0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getBullets1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTPS2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRound3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTurn4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getSortedTeamScores5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getIndexedTeamScores6; - - private @__ITurnSnapshot(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.snapshot.@__ITurnSnapshot.staticClass = @__class; - global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getRobots0 = @__env.GetMethodID(global::robocode.control.snapshot.@__ITurnSnapshot.staticClass, "getRobots", "()[Lrobocode/control/snapshot/IRobotSnapshot;"); - global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getBullets1 = @__env.GetMethodID(global::robocode.control.snapshot.@__ITurnSnapshot.staticClass, "getBullets", "()[Lrobocode/control/snapshot/IBulletSnapshot;"); - global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getTPS2 = @__env.GetMethodID(global::robocode.control.snapshot.@__ITurnSnapshot.staticClass, "getTPS", "()I"); - global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getRound3 = @__env.GetMethodID(global::robocode.control.snapshot.@__ITurnSnapshot.staticClass, "getRound", "()I"); - global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getTurn4 = @__env.GetMethodID(global::robocode.control.snapshot.@__ITurnSnapshot.staticClass, "getTurn", "()I"); - global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getSortedTeamScores5 = @__env.GetMethodID(global::robocode.control.snapshot.@__ITurnSnapshot.staticClass, "getSortedTeamScores", "()[Lrobocode/control/snapshot/IScoreSnapshot;"); - global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getIndexedTeamScores6 = @__env.GetMethodID(global::robocode.control.snapshot.@__ITurnSnapshot.staticClass, "getIndexedTeamScores", "()[Lrobocode/control/snapshot/IScoreSnapshot;"); - } - - public robocode.control.snapshot.IRobotSnapshot[] getRobots() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayFullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getRobots0)); - } - } - - public robocode.control.snapshot.IBulletSnapshot[] getBullets() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayFullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getBullets1)); - } - } - - public int getTPS() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getTPS2))); - } - } - - public int getRound() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getRound3))); - } - } - - public int getTurn() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getTurn4))); - } - } - - public robocode.control.snapshot.IScoreSnapshot[] getSortedTeamScores() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayFullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getSortedTeamScores5)); - } - } - - public robocode.control.snapshot.IScoreSnapshot[] getIndexedTeamScores() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayFullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::robocode.control.snapshot.@__ITurnSnapshot.j4n_getIndexedTeamScores6)); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__ITurnSnapshot); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRobots", "getRobots0", "()[Lrobocode/control/snapshot/IRobotSnapshot;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getBullets", "getBullets1", "()[Lrobocode/control/snapshot/IBulletSnapshot;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTPS", "getTPS2", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRound", "getRound3", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getTurn", "getTurn4", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getSortedTeamScores", "getSortedTeamScores5", "()[Lrobocode/control/snapshot/IScoreSnapshot;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getIndexedTeamScores", "getIndexedTeamScores6", "()[Lrobocode/control/snapshot/IScoreSnapshot;")); - return methods; - } - - private static global::net.sf.jni4net.utils.JniHandle getRobots0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()[Lrobocode/control/snapshot/IRobotSnapshot; - // ()[Lrobocode/control/snapshot/IRobotSnapshot; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.ITurnSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.ArrayFullC2J(@__env, @__real.getRobots()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getBullets1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()[Lrobocode/control/snapshot/IBulletSnapshot; - // ()[Lrobocode/control/snapshot/IBulletSnapshot; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.ITurnSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.ArrayFullC2J(@__env, @__real.getBullets()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getTPS2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.ITurnSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getTPS())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getRound3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.ITurnSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getRound())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getTurn4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::robocode.control.snapshot.ITurnSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getTurn())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getSortedTeamScores5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()[Lrobocode/control/snapshot/IScoreSnapshot; - // ()[Lrobocode/control/snapshot/IScoreSnapshot; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.ITurnSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.ArrayFullC2J(@__env, @__real.getSortedTeamScores()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getIndexedTeamScores6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()[Lrobocode/control/snapshot/IScoreSnapshot; - // ()[Lrobocode/control/snapshot/IScoreSnapshot; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::robocode.control.snapshot.ITurnSnapshot @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.ArrayFullC2J(@__env, @__real.getIndexedTeamScores()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.snapshot.@__ITurnSnapshot(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/RobotState.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/RobotState.generated.cs deleted file mode 100644 index 532ad1b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/generated/robocode/control/snapshot/RobotState.generated.cs +++ /dev/null @@ -1,189 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.control.snapshot { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class RobotState : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_values0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_valueOf1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getValue2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isAlive3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_toState4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isDead5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isHitRobot6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isHitWall7; - - internal static global::net.sf.jni4net.jni.FieldId j4n_ACTIVE8; - - internal static global::net.sf.jni4net.jni.FieldId j4n_HIT_WALL9; - - internal static global::net.sf.jni4net.jni.FieldId j4n_HIT_ROBOT10; - - internal static global::net.sf.jni4net.jni.FieldId j4n_DEAD11; - - protected RobotState(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.control.snapshot.RobotState.staticClass; - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/RobotState;")] - public static global::robocode.control.snapshot.RobotState ACTIVE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.RobotState.staticClass, global::robocode.control.snapshot.RobotState.j4n_ACTIVE8)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/RobotState;")] - public static global::robocode.control.snapshot.RobotState HIT_WALL { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.RobotState.staticClass, global::robocode.control.snapshot.RobotState.j4n_HIT_WALL9)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/RobotState;")] - public static global::robocode.control.snapshot.RobotState HIT_ROBOT { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.RobotState.staticClass, global::robocode.control.snapshot.RobotState.j4n_HIT_ROBOT10)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lrobocode/control/snapshot/RobotState;")] - public static global::robocode.control.snapshot.RobotState DEAD { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::robocode.control.snapshot.RobotState.staticClass, global::robocode.control.snapshot.RobotState.j4n_DEAD11)); - } - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.control.snapshot.RobotState.staticClass = @__class; - global::robocode.control.snapshot.RobotState.j4n_values0 = @__env.GetStaticMethodID(global::robocode.control.snapshot.RobotState.staticClass, "values", "()[Lrobocode/control/snapshot/RobotState;"); - global::robocode.control.snapshot.RobotState.j4n_valueOf1 = @__env.GetStaticMethodID(global::robocode.control.snapshot.RobotState.staticClass, "valueOf", "(Ljava/lang/String;)Lrobocode/control/snapshot/RobotState;"); - global::robocode.control.snapshot.RobotState.j4n_getValue2 = @__env.GetMethodID(global::robocode.control.snapshot.RobotState.staticClass, "getValue", "()I"); - global::robocode.control.snapshot.RobotState.j4n_isAlive3 = @__env.GetMethodID(global::robocode.control.snapshot.RobotState.staticClass, "isAlive", "()Z"); - global::robocode.control.snapshot.RobotState.j4n_toState4 = @__env.GetStaticMethodID(global::robocode.control.snapshot.RobotState.staticClass, "toState", "(I)Lrobocode/control/snapshot/RobotState;"); - global::robocode.control.snapshot.RobotState.j4n_isDead5 = @__env.GetMethodID(global::robocode.control.snapshot.RobotState.staticClass, "isDead", "()Z"); - global::robocode.control.snapshot.RobotState.j4n_isHitRobot6 = @__env.GetMethodID(global::robocode.control.snapshot.RobotState.staticClass, "isHitRobot", "()Z"); - global::robocode.control.snapshot.RobotState.j4n_isHitWall7 = @__env.GetMethodID(global::robocode.control.snapshot.RobotState.staticClass, "isHitWall", "()Z"); - global::robocode.control.snapshot.RobotState.j4n_ACTIVE8 = @__env.GetStaticFieldID(global::robocode.control.snapshot.RobotState.staticClass, "ACTIVE", "Lrobocode/control/snapshot/RobotState;"); - global::robocode.control.snapshot.RobotState.j4n_HIT_WALL9 = @__env.GetStaticFieldID(global::robocode.control.snapshot.RobotState.staticClass, "HIT_WALL", "Lrobocode/control/snapshot/RobotState;"); - global::robocode.control.snapshot.RobotState.j4n_HIT_ROBOT10 = @__env.GetStaticFieldID(global::robocode.control.snapshot.RobotState.staticClass, "HIT_ROBOT", "Lrobocode/control/snapshot/RobotState;"); - global::robocode.control.snapshot.RobotState.j4n_DEAD11 = @__env.GetStaticFieldID(global::robocode.control.snapshot.RobotState.staticClass, "DEAD", "Lrobocode/control/snapshot/RobotState;"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Lrobocode/control/snapshot/RobotState;")] - public static robocode.control.snapshot.RobotState[] values() { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::robocode.control.snapshot.RobotState.staticClass, global::robocode.control.snapshot.RobotState.j4n_values0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)Lrobocode/control/snapshot/RobotState;")] - public static global::robocode.control.snapshot.RobotState valueOf(global::java.lang.String par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::robocode.control.snapshot.RobotState.staticClass, global::robocode.control.snapshot.RobotState.j4n_valueOf1, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getValue() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::robocode.control.snapshot.RobotState.j4n_getValue2))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isAlive() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.RobotState.j4n_isAlive3))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(I)Lrobocode/control/snapshot/RobotState;")] - public static global::robocode.control.snapshot.RobotState toState(int par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::robocode.control.snapshot.RobotState.staticClass, global::robocode.control.snapshot.RobotState.j4n_toState4, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isDead() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.RobotState.j4n_isDead5))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isHitRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.RobotState.j4n_isHitRobot6))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isHitWall() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::robocode.control.snapshot.RobotState.j4n_isHitWall7))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.control.snapshot.RobotState(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/glue/robocode/control/RandomFactory.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/glue/robocode/control/RandomFactory.cs deleted file mode 100644 index 971149f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/glue/robocode/control/RandomFactory.cs +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using net.sf.robocode.security; - -namespace robocode.control -{ - partial class RandomFactory : IHiddenRandomHelper - { - private RandomRedirect rr; - - public RandomFactory(bool fakeInstance) - { - } - - #region IHiddenRandomHelper Members - - public Random GetRandom() - { - if (isDeterministic()) - { - if (rr == null) - { - rr = new RandomRedirect(getRandom()); - } - return rr; - } - return new Random(); - } - - #endregion - } - - public class RandomRedirect : Random - { - private java.util.Random r; - - public RandomRedirect(java.util.Random r) - { - this.r = r; - } - - public override int Next() - { - return r.nextInt(); - } - - public override int Next(int maxValue) - { - return r.nextInt(maxValue); - } - - public override int Next(int minValue, int maxValue) - { - return minValue + r.nextInt(maxValue - minValue); - } - - public override void NextBytes(byte[] buffer) - { - throw new NotImplementedException(); - } - - public override double NextDouble() - { - return r.nextDouble(); - } - } - -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/glue/robocode/control/RobocodeEngine.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/glue/robocode/control/RobocodeEngine.cs deleted file mode 100644 index e6e2ca2..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/glue/robocode/control/RobocodeEngine.cs +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.IO; -using net.sf.jni4net; -using File = java.io.File; - -namespace robocode.control -{ - public partial class RobocodeEngine - { - public static void Init(string robocodeHome) - { - BridgeSetup bridgeSetup = new BridgeSetup(); - bridgeSetup.BindStatic = true; - bridgeSetup.BindNative = true; - bridgeSetup.AddAllJarsClassPath(Path.Combine(robocodeHome, "libs")); - Bridge.CreateJVM(bridgeSetup); - Bridge.LoadAndRegisterAssemblyByName(typeof(RobocodeEngine).Assembly.FullName); - //Bridge.Setup.BindNative = true; - Bridge.Setup.BindStatic = true; - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/BattleSpecification.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/BattleSpecification.cs deleted file mode 100644 index 0401ff0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/BattleSpecification.cs +++ /dev/null @@ -1,257 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control -{ - /// - /// A BattleSpecification defines a battle configuration used by the . - /// - [Serializable] - public class BattleSpecification - { - private readonly int battlefieldWidth; - private readonly int battlefieldHeight; - private readonly int numRounds; - private readonly double gunCoolingRate; - private readonly long inactivityTime; - private readonly bool hideEnemyNames; - private readonly int sentryBorderSize; - private readonly RobotSpecification[] robots; - private readonly RobotSetup[] initialSetups; - - /// - /// Creates a new BattleSpecification with the given number of rounds, - /// battlefield size, and robots. Inactivity time for the robots defaults to - /// 450, and the gun cooling rate defaults to 0.1. - /// - /// The number of rounds in this battle. - /// The battlefield size. - /// The robots participating in this battle. - public BattleSpecification(int numRounds, BattlefieldSpecification battlefieldSize, RobotSpecification[] robots) : - this(numRounds, 450, .1, battlefieldSize, robots) - { - } - - /// - /// Creates a new BattleSpecification with the given settings. - /// - /// The number of rounds in this battle. - /// The inactivity time allowed for the robots before - /// they will loose energy. - /// The gun cooling rate for the robots. - /// The battlefield size. - /// The robots participating in this battle. - public BattleSpecification(int numRounds, long inactivityTime, double gunCoolingRate, BattlefieldSpecification battlefieldSize, RobotSpecification[] robots) : - this(numRounds, inactivityTime, gunCoolingRate, false, battlefieldSize, robots) - { - } - - /// - /// Creates a new BattleSpecification with the given settings. - /// - /// The number of rounds in this battle. - /// The inactivity time allowed for the robots before - /// they will loose energy. - /// The gun cooling rate for the robots. - /// Flag specifying if enemy names are hidden from robots. - /// The battlefield size. - /// The robots participating in this battle. - public BattleSpecification(int numRounds, long inactivityTime, double gunCoolingRate, bool hideEnemyNames, BattlefieldSpecification battlefieldSize, RobotSpecification[] robots) : - this(battlefieldSize, numRounds, inactivityTime, gunCoolingRate, 100, hideEnemyNames, robots) - { - } - - /// - /// Creates a new BattleSpecification with the given settings. - /// - /// The battlefield size. - /// The number of rounds in this battle. - /// The inactivity time allowed for the robots before - /// they will loose energy. - /// The gun cooling rate for the robots. - /// The sentry border size for a BorderSentry. - /// Flag specifying if enemy names are hidden from robots. - /// The robots participating in this battle. - public BattleSpecification(BattlefieldSpecification battlefieldSize, int numRounds, long inactivityTime, double gunCoolingRate, int sentryBorderSize, bool hideEnemyNames, RobotSpecification[] robots) : - this(battlefieldSize, numRounds, inactivityTime, gunCoolingRate, 100, hideEnemyNames, robots, null) - { - } - - /// - /// Creates a new BattleSpecification with the given settings. - /// - /// The battlefield size. - /// The number of rounds in this battle. - /// The inactivity time allowed for the robots before - /// they will loose energy. - /// The gun cooling rate for the robots. - /// The sentry border size for a BorderSentry. - /// Flag specifying if enemy names are hidden from robots. - /// The robots participating in this battle. - /// The initial position and heading of the robots, where the indices matches the indices from the . - public BattleSpecification(BattlefieldSpecification battlefieldSize, int numRounds, long inactivityTime, double gunCoolingRate, int sentryBorderSize, bool hideEnemyNames, RobotSpecification[] robots, RobotSetup[] initialSetups) - { - if (battlefieldSize == null) - { - throw new ArgumentException("battlefieldSize cannot be null"); - } - if (robots == null) - { - throw new ArgumentException("robots cannot be null"); - } - if (robots.Length < 1) - { - throw new ArgumentException("robots.Length must be > 0"); - } - if (initialSetups != null && initialSetups.Length != robots.Length) - { - throw new ArgumentException("initialSetups.Length must be == robots.Length"); - } - if (numRounds < 1) - { - throw new ArgumentException("numRounds must be >= 1"); - } - if (inactivityTime < 1) - { - throw new ArgumentException("inactivityTime must be >= 1"); - } - if (gunCoolingRate < 0.1) - { - throw new ArgumentException("inactivityTime must be >= 0.1"); - } - if (sentryBorderSize < 50) - { - throw new ArgumentException("sentryBorderSize must be >= 50"); - } - this.battlefieldWidth = battlefieldSize.Width; - this.battlefieldHeight = battlefieldSize.Height; - this.numRounds = numRounds; - this.inactivityTime = inactivityTime; - this.gunCoolingRate = gunCoolingRate; - this.sentryBorderSize = sentryBorderSize; - this.hideEnemyNames = hideEnemyNames; - this.robots = robots; - this.initialSetups = initialSetups; - } - - /// - /// Contains the allowed inactivity time for the robots in this battle. - /// - /// - /// The allowed inactivity time for the robots in this battle. - /// - public long InactivityTime - { - get { return inactivityTime; } - } - - /// - /// Contains the gun cooling rate of the robots in this battle. - /// - /// - /// The gun cooling rate of the robots in this battle. - /// - public double GunCoolingRate - { - get { return gunCoolingRate; } - } - - /// - /// Contains the battlefield size for this battle. - /// - /// - /// The battlefield size for this battle. - /// - public BattlefieldSpecification Battlefield - { - get { return new BattlefieldSpecification(battlefieldWidth, battlefieldHeight); } - } - - /// - /// Contains the number of rounds in this battle. - /// - /// - /// The number of rounds in this battle. - /// - public int NumRounds - { - get { return numRounds; } - } - - /// - /// Flag specifying if the enemy names must be hidden from events sent to robots. - /// - /// - /// true if the enemy names must be hidden; false otherwise. - /// - public bool HideEnemyNames - { - get { return hideEnemyNames; } - } - - /// - /// Returns the sentry border size for a BorderSentry that defines the how - /// far a BorderSentry is allowed to move from the border edges measured in units. - ///

- /// Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that - /// border sentry robots cannot leave (they must stay in the border area), but it also define the - /// distance from the border edges where border sentry robots are allowed/able to make damage to robots entering this - /// border area. - ///

- public int SentryBorderSize - { - get { return sentryBorderSize; } - } - - /// - /// Contains the specifications of the robots participating in this battle. - /// - /// - /// An array of instances - one entry for each robot. - /// - /// - public RobotSpecification[] Robots - { - get - { - if (robots == null) - return null; - - RobotSpecification[] copy = new RobotSpecification[robots.Length]; - robots.CopyTo(copy, 0); - return copy; - } - } - - /// - /// Contains the initial position and heading of each robot participating in this battle. - /// - /// - /// An array of instances - one entry for each robot. - /// The the indices of this array matches the array indices from the robot specifications (see ). - /// - /// - public RobotSetup[] InitialSetups - { - get - { - if (initialSetups == null) - return null; - - RobotSetup[] copy = new RobotSetup[initialSetups.Length]; - initialSetups.CopyTo(copy, 0); - return copy; - } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/BattlefieldSpecification.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/BattlefieldSpecification.cs deleted file mode 100644 index d59dab6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/BattlefieldSpecification.cs +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control -{ - /// - /// Defines the size of a battlefield, which is a part of the . - /// - /// - /// - /// - [Serializable] - public class BattlefieldSpecification - { - private readonly int width; - private readonly int height; - - /// - /// Creates a standard 800 x 600 battlefield. - /// - public BattlefieldSpecification() - : this(800, 600) - { - } - - /// - /// Creates a battlefield of the specified width and height. - /// - /// The width of the battlefield, where 400 <= width <= 5000. - /// The height of the battlefield, where 400 <= height <= 5000. - /// Thrown when the width or height is < 400 or > 5000. - /// - public BattlefieldSpecification(int width, int height) - { - if (width < 400 || width > 5000) - throw new ArgumentException("width must be: 400 <= width <= 5000"); - - if (height < 400 || height > 5000) - throw new ArgumentException("height must be: 400 <= height <= 5000"); - - this.width = width; - this.height = height; - } - - /// - /// Contains the width of this battlefield. - /// - /// - /// The width of this battlefield. - /// - public int Width - { - get { return width; } - } - - /// - /// Contains the height of this battlefield. - /// - /// - /// The height of this battlefield. - /// - public int Height - { - get { return height; } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/IRobocodeEngine.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/IRobocodeEngine.cs deleted file mode 100644 index b87d8cc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/IRobocodeEngine.cs +++ /dev/null @@ -1,237 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; -using Robocode.Control.Events; // for the XML documentation - -namespace Robocode.Control -{ - /// - /// Event handler for the . - /// - /// The event. - public delegate void BattleStartedEventHandler(Robocode.Control.Events.BattleStartedEvent evnt); - - /// - /// Event handler for the . - /// - /// The event. - public delegate void BattleFinishedEventHandler(Robocode.Control.Events.BattleFinishedEvent evnt); - - /// - /// Event handler for the . - /// - /// The event. - public delegate void BattleCompletedEventHandler(Robocode.Control.Events.BattleCompletedEvent evnt); - - /// - /// Event handler for the . - /// - /// The event. - public delegate void BattlePausedEventHandler(Robocode.Control.Events.BattlePausedEvent evnt); - - /// - /// Event handler for the . - /// - /// The event. - public delegate void BattleResumedEventHandler(Robocode.Control.Events.BattleResumedEvent evnt); - - /// - /// Event handler for the . - /// - /// The event. - public delegate void RoundStartedEventHandler(Robocode.Control.Events.RoundStartedEvent evnt); - - /// - /// Event handler for the . - /// - /// The event. - public delegate void RoundEndedEventHandler(Robocode.Control.Events.RoundEndedEvent evnt); - - /// - /// Event handler for the . - /// - /// The event. - public delegate void TurnStartedEventHandler(Robocode.Control.Events.TurnStartedEvent evnt); - - /// - /// Event handler for the . - /// - /// The event. - public delegate void TurnEndedEventHandler(Robocode.Control.Events.TurnEndedEvent evnt); - - /// - /// Event handler for the . - /// - /// The event. - public delegate void BattleMessageEventHandler(Robocode.Control.Events.BattleMessageEvent evnt); - - /// - /// Event handler for the . - /// - /// The event. - public delegate void BattleErrorEventHandler(Robocode.Control.Events.BattleErrorEvent evnt); - - /// - /// Interface for a RobocodeEngine. - /// - public interface IRobocodeEngine - { - /// - /// Occurs when a new battle is started. - /// - event BattleStartedEventHandler BattleStarted; - - /// - /// Occurs when the battle is finished, where the battle can be either completed or aborted. - /// - event BattleFinishedEventHandler BattleFinished; - - /// - /// Occurs when the battle is completed successfully and results are available. - /// - event BattleCompletedEventHandler BattleCompleted; - - /// - /// Occurs when the battle is paused. - /// - event BattlePausedEventHandler BattlePaused; - - /// - /// Occurs when the battle is resumed after having been paused. - /// - event BattleResumedEventHandler BattleResumed; - - /// - /// Occurs when a new round is started. - /// - event RoundStartedEventHandler RoundStarted; - - /// - /// Occurs when a round has ended. - /// - event RoundEndedEventHandler RoundEnded; - - /// - /// Occurs when a new turn is started. - /// - event TurnStartedEventHandler TurnStarted; - - /// - /// Occurs when a new turn is ended. - /// - event TurnEndedEventHandler TurnEnded; - - /// - /// Occurs when a message from the battle is sent from the game. - /// - event BattleMessageEventHandler BattleMessage; - - /// - /// Occurs when an error message from the battle is sent from the game. - /// - event BattleErrorEventHandler BattleError; - - /// - /// Closes the RobocodeEngine and releases any allocated resources it holds. - /// You should call this when you have finished using the RobocodeEngine. - /// This method automatically disposes the Robocode window if it open. - /// - void Close(); - - /// - /// Contains the installed version of Robocode controlled by this RobocodeEngine. - /// - /// - /// The installed version of Robocode controlled by this RobocodeEngine. - /// - string Version { get; } - - /// - /// Contains the visible state of the Robocode window. - /// - /// - /// Sets/gets the visible state of the Robocode window, where - /// true means that the window is visible, and - /// false means that the window is hidden. - /// - bool Visible { get; set; } - - /// - /// Returns all robots available from the local robot repository of Robocode. - /// These robots must exists in the \robocode\robots directory, and must be - /// compiled in advance, before these robot are returned with this method. - /// - /// - /// An array of all available robots from the local robot repository. - /// - RobotSpecification[] GetLocalRepository(); - - /// - /// Returns a selection of robots available from the local robot repository - /// of Robocode. These robots must exists in the \robocode\robots directory, - /// and must be compiled in advance, before these robot are returned with this method. - ///

- /// Notice: If a specified robot cannot be found in the repository, it will - /// not be returned in the array of robots returned by this method. - ///

- /// A comma or space separated list of robots to return. - /// The full class name must be used for specifying the individual robot, e.g. - /// "sample.Corners, sample.Crazy". - /// - /// An array containing the available robots from the local robot repository based on - /// the selected robots specified with the selectedRobotList parameter. - /// - RobotSpecification[] GetLocalRepository(String selectedRobotList); - - /// - /// Runs the specified battle. - /// - /// The specification of the battle to run - /// including the participation robots. - /// - void RunBattle(BattleSpecification battleSpecification); - - /// - /// Runs the specified battle. - /// - /// The specification of the battle to run - /// including the participating robots. - /// Will block caller till end of battle if set. - /// - void RunBattle(BattleSpecification battleSpecification, bool waitTillOver); - - /// - /// Runs the specified battle. - /// - /// The specification of the battle to run - /// including the participating robots. - /// A comma or space separated list like: - /// x1,y1,heading1, x2,y2,heading2, which are the coordinates and heading of - /// robot #1 and #2. So e.g. 0,0,180, 50,80,270 means that robot #1 has position - /// (0,0) and heading 180, and robot #2 has position (50,80) and heading 270. - /// Will block caller till end of battle if set. - /// - void RunBattle(BattleSpecification battleSpecification, string initialPositions, bool waitTillOver); - - /// - /// Will block caller until current battle is over. - /// - /// - void WaitTillBattleOver(); - - /// - /// Aborts the current battle if it is running. - /// - /// - void AbortCurrentBattle(); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/RobocodeEngine.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/RobocodeEngine.cs deleted file mode 100644 index 956f270..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/RobocodeEngine.cs +++ /dev/null @@ -1,1682 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Reflection; -using Robocode.Control.Events; -using Robocode.Control.Snapshot; -using net.sf.robocode.security; - -namespace Robocode.Control -{ - /// - /// The RobocodeEngine is the interface provided for external applications - /// in order to let these applications run battles within the Robocode application, - /// and to get the results from these battles. - ///

- /// This class in the main entry class of the namespace. - ///

- /// The RobocodeEngine is used by e.g. RoboRumble@Home client, which is integrated in - /// Robocode. In addition, the RobocodeEngine is also used by the test units for - /// testing the Robocode application itself. - ///

- public class RobocodeEngine : IRobocodeEngine - { - /// - public event BattleStartedEventHandler BattleStarted; - /// - public event BattleFinishedEventHandler BattleFinished; - /// - public event BattleCompletedEventHandler BattleCompleted; - /// - public event BattlePausedEventHandler BattlePaused; - /// - public event BattleResumedEventHandler BattleResumed; - /// - public event RoundStartedEventHandler RoundStarted; - /// - public event RoundEndedEventHandler RoundEnded; - /// - public event TurnStartedEventHandler TurnStarted; - /// - public event TurnEndedEventHandler TurnEnded; - /// - public event BattleMessageEventHandler BattleMessage; - /// - public event BattleErrorEventHandler BattleError; - - // The internal hidden engine that has been generated based on the Java version of the engine - private robocode.control.RobocodeEngine engine; - // The internal robocode.control.events.IBattleListener - private BattleObserver battleObserver; - // Flag specifying if the Robocode window is currently visible - private bool isVisible; - - #region Public API - - /// - /// Creates a new RobocodeEngine for controlling Robocode. - /// In order for this constructor to work, the current working directory must be the - /// home directory directory of Robocode, e.g. C:\Robocode - /// - /// - public RobocodeEngine() : - this(AppDomain.CurrentDomain.BaseDirectory) - { - } - - /// - /// Creates a new RobocodeEngine for controlling Robocode, where the home directory - /// of Robocode is specified. - /// - /// The root directory of Robocode, e.g. "C:\Robocode". - /// - public RobocodeEngine(string robocodeHome) - { - robocode.control.RobocodeEngine.Init(robocodeHome); - engine = new robocode.control.RobocodeEngine(new java.io.File(robocodeHome)); - battleObserver = new BattleObserver(this); - engine.addBattleListener(battleObserver); - } - - ~RobocodeEngine() - { - // Make sure Close() is called to prevent memory leaks - Close(); - } - - /// - public void Close() - { - engine.close(); - } - - /// - public string Version - { - get { return engine.getVersion(); } - } - - /// - /// Returns the current working directory for Robocode. - /// - /// - /// The name of the current working directory. - /// - public static string CurrentWorkingDir - { - get { return robocode.control.RobocodeEngine.getCurrentWorkingDir().getAbsolutePath(); } - } - - /// - /// Returns the directory containing the robots. - /// - /// - /// The name of the robot directory containing all robots. - /// - public static string RobotsDir - { - get { return robocode.control.RobocodeEngine.getRobotsDir().getAbsolutePath(); } - } - - /// - public bool Visible - { - set - { - isVisible = value; - engine.setVisible(value); - } - get - { - return isVisible; - } - } - - /// - public RobotSpecification[] GetLocalRepository() - { - return MapRobotSpecifications(engine.getLocalRepository()); - } - - /// - public RobotSpecification[] GetLocalRepository(string selectedRobots) - { - return MapRobotSpecifications(engine.getLocalRepository(selectedRobots)); - } - - /// - public void RunBattle(BattleSpecification battleSpecification) - { - RunBattle(battleSpecification, null, false); - } - - /// - public void RunBattle(BattleSpecification battleSpecification, bool waitTillOver) - { - RunBattle(battleSpecification, "", waitTillOver); - } - - /// - public void RunBattle(BattleSpecification battleSpecification, string initialPositions, bool waitTillOver) - { - engine.runBattle(MapBattleSpecification(battleSpecification), initialPositions, waitTillOver); - } - - /// - public void WaitTillBattleOver() - { - engine.waitTillBattleOver(); - } - - /// - public void AbortCurrentBattle() - { - engine.abortCurrentBattle(); - } - - /// - /// Prints out all running threads to standard system out. - /// - public static void PrintRunningThreads() - { - robocode.control.RobocodeEngine.printRunningThreads(); - } - - /// - /// Enables or disables messages and warnings logged to Console.Out. - /// - /// - /// true means that log messages must be enabled, and - /// false means that log messages must be disabled. - /// - /// - public static bool LogMessagesEnabled - { - set - { - robocode.control.RobocodeEngine.setLogMessagesEnabled(value); - } - } - - /// - /// Enables or disables errors logged to Console.Error. - /// - /// - /// true means that log errors must be enabled, and - /// false means that log errors must be disabled. - /// - /// - public static bool LogErrorsEnabled - { - set - { - robocode.control.RobocodeEngine.setLogErrorsEnabled(value); - } - } - - #endregion - - #region Event dispatchers - - private void OnBattleStarted(BattleStartedEvent e) - { - if (BattleStarted != null) - BattleStarted(e); - } - - private void OnBattleFinished(BattleFinishedEvent e) - { - if (BattleFinished != null) - BattleFinished(e); - } - - private void OnBattleCompleted(BattleCompletedEvent e) - { - if (BattleCompleted != null) - BattleCompleted(e); - } - - private void OnBattlePaused(BattlePausedEvent e) - { - if (BattlePaused != null) - BattlePaused(e); - } - - private void OnBattleResumed(BattleResumedEvent e) - { - if (BattleResumed != null) - BattleResumed(e); - } - - private void OnRoundStarted(RoundStartedEvent e) - { - if (RoundStarted != null) - RoundStarted(e); - } - - private void OnRoundEnded(Robocode.Control.Events.RoundEndedEvent e) - { - if (RoundEnded != null) - RoundEnded(e); - } - - private void OnTurnStarted(TurnStartedEvent e) - { - if (TurnStarted != null) - TurnStarted(e); - } - - private void OnTurnEnded(TurnEndedEvent e) - { - if (TurnEnded != null) - TurnEnded(e); - } - - private void OnBattleMessage(BattleMessageEvent e) - { - if (BattleMessage != null) - BattleMessage(e); - } - - private void OnBattleError(BattleErrorEvent e) - { - if (BattleError != null) - BattleError(e); - } - - #endregion - - #region Specification mappers - - private RobotSpecification[] MapRobotSpecifications(robocode.control.RobotSpecification[] specifications) - { - if (specifications == null) - { - return null; - } - - RobotSpecification[] mappedSpecifications = new RobotSpecification[specifications.Length]; - - for (int i = 0; i < specifications.Length; i++) - { - mappedSpecifications[i] = MapRobotSpecification(specifications[i]); - } - return mappedSpecifications; - } - - private RobotSpecification MapRobotSpecification(robocode.control.RobotSpecification spec) - { - return new RobotSpecification(spec); - } - - private robocode.control.RobotSpecification[] MapRobotSpecifications(RobotSpecification[] specifications) - { - if (specifications == null) - { - return null; - } - - robocode.control.RobotSpecification[] mappedSpecifications = new robocode.control.RobotSpecification[specifications.Length]; - - for (int i = 0; i < specifications.Length; i++) - { - mappedSpecifications[i] = MapRobotSpecification(specifications[i]); - } - return mappedSpecifications; - } - - private robocode.control.RobotSpecification MapRobotSpecification(RobotSpecification spec) - { - return spec.robotSpecification; - } - - private robocode.control.BattleSpecification MapBattleSpecification(BattleSpecification spec) - { - robocode.control.BattlefieldSpecification battlefieldSpec = new robocode.control.BattlefieldSpecification(spec.Battlefield.Width, spec.Battlefield.Height); - robocode.control.RobotSpecification[] robotSpecs = MapRobotSpecifications(spec.Robots); - robocode.control.RobotSetup[] initialSetups = MapInitialSetups(spec.InitialSetups); - - return new robocode.control.BattleSpecification(battlefieldSpec, spec.NumRounds, spec.InactivityTime, - spec.GunCoolingRate, spec.SentryBorderSize, spec.HideEnemyNames, robotSpecs, initialSetups); - } - - private robocode.control.RobotSetup[] MapInitialSetups(RobotSetup[] setups) - { - if (setups == null) - { - return null; - } - - robocode.control.RobotSetup[] mappedSetups = new robocode.control.RobotSetup[setups.Length]; - - for (int i = 0; i < setups.Length; i++) - { - mappedSetups[i] = MapRobotSetup(setups[i]); - } - return mappedSetups; - } - - private robocode.control.RobotSetup MapRobotSetup(RobotSetup setup) - { - return new robocode.control.RobotSetup(setup.X, setup.Y, setup.Heading); - } - #endregion - - #region Battle observer (internal engine events -> Robocode.Control.Events) - - private class BattleObserver : robocode.control.events.IBattleListener - { - RobocodeEngine engine; - - public BattleObserver(RobocodeEngine engine) - { - this.engine = engine; - } - - public void onBattleStarted(robocode.control.events.BattleStartedEvent evnt) - { - engine.OnBattleStarted(MapEvent(evnt)); - } - - public void onBattleFinished(robocode.control.events.BattleFinishedEvent evnt) - { - engine.OnBattleFinished(MapEvent(evnt)); - } - - public void onBattleCompleted(robocode.control.events.BattleCompletedEvent evnt) - { - engine.OnBattleCompleted(MapEvent(evnt)); - } - - public void onBattlePaused(robocode.control.events.BattlePausedEvent evnt) - { - engine.OnBattlePaused(new BattlePausedEvent()); - } - - public void onBattleResumed(robocode.control.events.BattleResumedEvent evnt) - { - engine.OnBattleResumed(new BattleResumedEvent()); - } - - public void onRoundStarted(robocode.control.events.RoundStartedEvent evnt) - { - engine.OnRoundStarted(MapEvent(evnt)); - } - - public void onRoundEnded(robocode.control.events.RoundEndedEvent evnt) - { - engine.OnRoundEnded(MapEvent(evnt)); - } - - public void onTurnStarted(robocode.control.events.TurnStartedEvent evnt) - { - engine.OnTurnStarted(new TurnStartedEvent()); - } - - public void onTurnEnded(robocode.control.events.TurnEndedEvent evnt) - { - engine.OnTurnEnded(MapEvent(evnt)); - } - - public void onBattleMessage(robocode.control.events.BattleMessageEvent evnt) - { - engine.OnBattleMessage(MapEvent(evnt)); - } - - public void onBattleError(robocode.control.events.BattleErrorEvent evnt) - { - engine.OnBattleError(MapEvent(evnt)); - } - } - - #endregion - - #region Event mappers (generated events -> Robocode.Control.Events) - - private static BattleStartedEvent MapEvent(robocode.control.events.BattleStartedEvent evnt) - { - return new BattleStartedEvent(MapBattleRules(evnt.getBattleRules()), evnt.getRobotsCount(), evnt.isReplay()); - } - - private static BattleFinishedEvent MapEvent(robocode.control.events.BattleFinishedEvent evnt) - { - return new BattleFinishedEvent(evnt.isAborted()); - } - - private static BattleCompletedEvent MapEvent(robocode.control.events.BattleCompletedEvent evnt) - { - return new BattleCompletedEvent(MapBattleRules(evnt.getBattleRules()), MapBattleResults(evnt.getIndexedResults())); - } - - private static BattleMessageEvent MapEvent(robocode.control.events.BattleMessageEvent evnt) - { - return new BattleMessageEvent(evnt.getMessage()); - } - - private static BattleErrorEvent MapEvent(robocode.control.events.BattleErrorEvent evnt) - { - return new BattleErrorEvent(evnt.getError()); - } - - private static RoundStartedEvent MapEvent(robocode.control.events.RoundStartedEvent evnt) - { - return new RoundStartedEvent(MapTurnSnapshot(evnt.getStartSnapshot()), evnt.getRound()); - } - - private static Robocode.Control.Events.RoundEndedEvent MapEvent(robocode.control.events.RoundEndedEvent evnt) - { - return new Robocode.Control.Events.RoundEndedEvent(evnt.getRound(), evnt.getTurns(), evnt.getTotalTurns()); - } - - private static TurnEndedEvent MapEvent(robocode.control.events.TurnEndedEvent evnt) - { - return new TurnEndedEvent(MapTurnSnapshot(evnt.getTurnSnapshot())); - } - - private static BattleCompletedEvent[] MapEvents(robocode.control.events.BattleCompletedEvent[] events) - { - if (events == null) - { - return null; - } - - BattleCompletedEvent[] mappedEvents = new BattleCompletedEvent[events.Length]; - - for (int i = 0; i < events.Length; i++) - { - mappedEvents[i] = MapEvent(events[i]); - } - return mappedEvents; - } - - private static BattleResults[] MapBattleResults(java.lang.Object[] results) - { - if (results == null) - { - return null; - } - - BattleResults[] mappedResults = new BattleResults[results.Length]; - - for (int i = 0; i < results.Length; i++) - { - mappedResults[i] = MapBattleResults(results[i]); - } - return mappedResults; - } - - private static BattleRules MapBattleRules(java.lang.Object obj) - { - int battlefieldWidth = obj.Invoke("getBattlefieldWidth", "()I", new object[] { }); - int battlefieldHeight = obj.Invoke("getBattlefieldHeight", "()I", new object[] { }); - int numRounds = obj.Invoke("getNumRounds", "()I", new object[] { }); - double gunCoolingRate = obj.Invoke("getGunCoolingRate", "()D", new object[] { }); - long inactivityTime = obj.Invoke("getInactivityTime", "()J", new object[] { }); - bool hideEnemyNames = obj.Invoke("getHideEnemyNames", "()Z", new object[] { }); - int sentryBorderSize = obj.Invoke("getSentryBorderSize", "()I", new object[] { }); - - MethodInfo method = typeof(BattleRules).GetMethod("createHiddenHelper", BindingFlags.Static | BindingFlags.NonPublic); - IHiddenRulesHelper rulesHelper = (IHiddenRulesHelper)method.Invoke(null, null); - - return rulesHelper.createRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, hideEnemyNames, sentryBorderSize); - } - - private static BattleResults MapBattleResults(java.lang.Object obj) - { - string teamLeaderName = obj.Invoke("getTeamLeaderName", "()Ljava/lang/String;", new object[] { }); - int rank = obj.Invoke("getRank", "()I", new object[] { }); - int score = obj.Invoke("getScore", "()I", new object[] { }); - int survival = obj.Invoke("getSurvival", "()I", new object[] { }); - int lastSurvivorBonus = obj.Invoke("getLastSurvivorBonus", "()I", new object[] { }); - int bulletDamage = obj.Invoke("getBulletDamage", "()I", new object[] { }); - int bulletDamageBonus = obj.Invoke("getBulletDamageBonus", "()I", new object[] { }); - int ramDamage = obj.Invoke("getRamDamage", "()I", new object[] { }); - int ramDamageBonus = obj.Invoke("getRamDamageBonus", "()I", new object[] { }); - int firsts = obj.Invoke("getFirsts", "()I", new object[] { }); - int seconds = obj.Invoke("getSeconds", "()I", new object[] { }); - int thirds = obj.Invoke("getThirds", "()I", new object[] { }); - - return new BattleResults(teamLeaderName, rank, score, survival, lastSurvivorBonus, - bulletDamage, bulletDamageBonus, ramDamage, ramDamageBonus, firsts, seconds, thirds); - } - - #endregion - - #region Snapshot mappers (generated snapshots -> Robocode.Control.Snapshot) - - private static ITurnSnapshot MapTurnSnapshot(robocode.control.snapshot.ITurnSnapshot turnSnapshot) - { - return new TurnSnapshot(turnSnapshot); - } - - private static IRobotSnapshot[] MapRobotSnapshots(robocode.control.snapshot.IRobotSnapshot[] robotSnapshots) - { - if (robotSnapshots == null) - { - return null; - } - - IRobotSnapshot[] mappedSnapshots = new IRobotSnapshot[robotSnapshots.Length]; - - for (int i = 0; i < robotSnapshots.Length; i++) - { - mappedSnapshots[i] = MapRobotSnapshot(robotSnapshots[i]); - } - return mappedSnapshots; - } - - private static IRobotSnapshot MapRobotSnapshot(robocode.control.snapshot.IRobotSnapshot robotSnapshot) - { - return new RobotSnapshot(robotSnapshot); - } - - private static IScoreSnapshot[] MapScoreSnapshots(robocode.control.snapshot.IScoreSnapshot[] bulletSnapshots) - { - if (bulletSnapshots == null) - { - return null; - } - - IScoreSnapshot[] mappedSnapshots = new IScoreSnapshot[bulletSnapshots.Length]; - - for (int i = 0; i < bulletSnapshots.Length; i++) - { - mappedSnapshots[i] = MapScoreSnapshot(bulletSnapshots[i]); - } - return mappedSnapshots; - } - - private static IScoreSnapshot MapScoreSnapshot(robocode.control.snapshot.IScoreSnapshot scoreSnapshot) - { - return new ScoreSnapshot(scoreSnapshot); - } - - private static IBulletSnapshot[] MapBulletSnapshots(robocode.control.snapshot.IBulletSnapshot[] bulletSnapshots) - { - if (bulletSnapshots == null) - { - return null; - } - - IBulletSnapshot[] mappedSnapshots = new IBulletSnapshot[bulletSnapshots.Length]; - - for (int i = 0; i < bulletSnapshots.Length; i++) - { - mappedSnapshots[i] = MapBulletSnapshot(bulletSnapshots[i]); - } - return mappedSnapshots; - } - - private static IBulletSnapshot MapBulletSnapshot(robocode.control.snapshot.IBulletSnapshot bulletSnapshot) - { - return new BulletSnapshot(bulletSnapshot); - } - - private static IDebugProperty[] MapDebugProperties(robocode.control.snapshot.IDebugProperty[] debugProperties) - { - if (debugProperties == null) - { - return null; - } - - IDebugProperty[] mappedProperties = new IDebugProperty[debugProperties.Length]; - - for (int i = 0; i < debugProperties.Length; i++) - { - mappedProperties[i] = MapDebugProperty(debugProperties[i]); - } - return mappedProperties; - } - - private static IDebugProperty MapDebugProperty(robocode.control.snapshot.IDebugProperty debugProperty) - { - return new DebugProperty(debugProperty.getKey(), debugProperty.getValue()); - } - - private static RobotState MapRobotState(robocode.control.snapshot.RobotState robotState) - { - switch (robotState.getValue()) - { - case 0: - return RobotState.Active; - case 1: - return RobotState.HitWall; - case 2: - return RobotState.HitRobot; - case 3: - default: - return RobotState.Dead; - } - } - - private static BulletState MapBulletState(robocode.control.snapshot.BulletState bulletState) - { - switch (bulletState.getValue()) - { - case 0: - return BulletState.Fired; - case 1: - return BulletState.Moving; - case 2: - return BulletState.HitVictim; - case 3: - return BulletState.HitBullet; - case 4: - return BulletState.HitWall; - case 5: - return BulletState.Exploded; - case 6: - default: - return BulletState.Inactive; - } - } - - #endregion - - #region Robocode.Control.Snapshot implementations - - private class TurnSnapshot : ITurnSnapshot - { - // The real snapshot - private readonly robocode.control.snapshot.ITurnSnapshot turnSnapshot; - - // Cached values created, when needed - private IRobotSnapshot[] robots; - private IBulletSnapshot[] bullets; - private int? tps; - private int? round; - private int? turn; - private IScoreSnapshot[] sortedTeamScores; - private IScoreSnapshot[] indexedTeamScores; - - public TurnSnapshot(robocode.control.snapshot.ITurnSnapshot turnSnapshot) - { - this.turnSnapshot = turnSnapshot; - } - - public IRobotSnapshot[] Robots - { - get - { - if (robots == null) - { - robots = MapRobotSnapshots(turnSnapshot.getRobots()); - } - return robots; - } - } - - public IBulletSnapshot[] Bullets - { - get - { - if (bullets == null) - { - bullets = MapBulletSnapshots(turnSnapshot.getBullets()); - } - return bullets; - } - } - - public int TPS - { - get - { - if (tps == null) - { - tps = turnSnapshot.getTPS(); - } - return tps.Value; - } - } - - public int Round - { - get - { - if (round == null) - { - round = turnSnapshot.getRound(); - } - return round.Value; - } - } - - public int Turn - { - get - { - if (turn == null) - { - turn = turnSnapshot.getTurn(); - } - return turn.Value; - } - } - - public IScoreSnapshot[] SortedTeamScores - { - get - { - if (sortedTeamScores == null) - { - sortedTeamScores = MapScoreSnapshots(turnSnapshot.getSortedTeamScores()); - } - return sortedTeamScores; - } - } - - public IScoreSnapshot[] IndexedTeamScores - { - get - { - if (indexedTeamScores == null) - { - indexedTeamScores = MapScoreSnapshots(turnSnapshot.getIndexedTeamScores()); - } - return indexedTeamScores; - } - } - } - - private class RobotSnapshot : IRobotSnapshot - { - // The real snapshot - private readonly robocode.control.snapshot.IRobotSnapshot robotSnapshot; - - // Cached values created, when needed - private string name; - private string shortName; - private string veryShortName; - private string teamName; - private int? robotIndex; - private int? teamIndex; - private RobotState? state; - private double? energy; - private double? velocity; - private double? bodyHeading; - private double? gunHeading; - private double? radarHeading; - private double? gunHeat; - private double? x; - private double? y; - private int? bodyColor; - private int? gunColor; - private int? radarColor; - private int? scanColor; - private bool? isDroid; - private bool? isPaintRobot; - private bool? isPaintEnabled; - private bool? isSGPaintEnabled; - private IDebugProperty[] debugProperties; - private string outputStreamSnapshot; - private IScoreSnapshot scoreSnapshot; - - public RobotSnapshot(robocode.control.snapshot.IRobotSnapshot robotSnapshot) - { - this.robotSnapshot = robotSnapshot; - } - - public string Name - { - get - { - if (name == null) - { - name = robotSnapshot.getName(); - } - return name; - } - } - - public string ShortName - { - get - { - if (shortName == null) - { - shortName = robotSnapshot.getShortName(); - } - return shortName; - } - } - - public string VeryShortName - { - get - { - if (veryShortName == null) - { - veryShortName = robotSnapshot.getVeryShortName(); - } - return veryShortName; - } - } - - public string TeamName - { - get - { - if (teamName == null) - { - teamName = robotSnapshot.getTeamName(); - } - return teamName; - } - } - - public int RobotIndex - { - get - { - if (robotIndex == null) - { - robotIndex = robotSnapshot.getRobotIndex(); - } - return robotIndex.Value; - } - } - - public int TeamIndex - { - get - { - if (teamIndex == null) - { - teamIndex = robotSnapshot.getTeamIndex(); - } - return teamIndex.Value; - } - } - - public int ContestantIndex - { - get - { - return TeamIndex >= 0 ? TeamIndex : RobotIndex; - } - } - - public RobotState State - { - get - { - if (state == null) - { - state = MapRobotState(robotSnapshot.getState()); - } - return state.Value; - } - } - - public double Energy - { - get - { - if (energy == null) - { - energy = robotSnapshot.getEnergy(); - } - return energy.Value; - } - } - - public double Velocity - { - get - { - if (velocity == null) - { - velocity = robotSnapshot.getVelocity(); - } - return velocity.Value; - } - } - - public double BodyHeading - { - get - { - if (bodyHeading == null) - { - bodyHeading = robotSnapshot.getBodyHeading(); - } - return bodyHeading.Value; - } - } - - public double GunHeading - { - get - { - if (gunHeading == null) - { - gunHeading = robotSnapshot.getGunHeading(); - } - return gunHeading.Value; - } - } - - public double RadarHeading - { - get - { - if (radarHeading == null) - { - radarHeading = robotSnapshot.getRadarHeading(); - } - return radarHeading.Value; - } - } - - public double GunHeat - { - get - { - if (gunHeat == null) - { - gunHeat = robotSnapshot.getGunHeat(); - } - return gunHeat.Value; - } - } - - public double X - { - get - { - if (x == null) - { - x = robotSnapshot.getX(); - } - return x.Value; - } - } - - public double Y - { - get - { - if (y == null) - { - y = robotSnapshot.getY(); - } - return y.Value; - } - } - - public int BodyColor - { - get - { - if (bodyColor == null) - { - bodyColor = robotSnapshot.getBodyColor(); - } - return bodyColor.Value; - } - } - - public int GunColor - { - get - { - if (gunColor == null) - { - gunColor = robotSnapshot.getGunColor(); - } - return gunColor.Value; - } - } - - public int RadarColor - { - get - { - if (radarColor == null) - { - radarColor = robotSnapshot.getRadarColor(); - } - return radarColor.Value; - } - } - - public int ScanColor - { - get - { - if (scanColor == null) - { - scanColor = robotSnapshot.getScanColor(); - } - return scanColor.Value; - } - } - - public bool IsDroid - { - get - { - if (isDroid == null) - { - isDroid = robotSnapshot.isDroid(); - } - return isDroid.Value; - } - } - - public bool IsPaintRobot - { - get - { - if (isPaintRobot == null) - { - isPaintRobot = robotSnapshot.isPaintRobot(); - } - return isPaintRobot.Value; - } - } - - public bool IsPaintEnabled - { - get - { - if (isPaintEnabled == null) - { - isPaintEnabled = robotSnapshot.isPaintEnabled(); - } - return isPaintEnabled.Value; - } - } - - public bool IsSGPaintEnabled - { - get - { - if (isSGPaintEnabled == null) - { - isSGPaintEnabled = robotSnapshot.isSGPaintEnabled(); - } - return isSGPaintEnabled.Value; - } - } - - public IDebugProperty[] DebugProperties - { - get - { - if (debugProperties == null) - { - debugProperties = MapDebugProperties(robotSnapshot.getDebugProperties()); - } - return debugProperties; - } - } - - public string OutputStreamSnapshot - { - get - { - if (outputStreamSnapshot == null) - { - outputStreamSnapshot = robotSnapshot.getOutputStreamSnapshot(); - } - return outputStreamSnapshot; - } - } - - public IScoreSnapshot ScoreSnapshot - { - get - { - if (scoreSnapshot == null) - { - scoreSnapshot = MapScoreSnapshot(robotSnapshot.getScoreSnapshot()); - } - return scoreSnapshot; - } - } - } - - private class BulletSnapshot : IBulletSnapshot - { - // The real snapshot - private readonly robocode.control.snapshot.IBulletSnapshot bulletSnapshot; - - // Cached values created, when needed - private BulletState? state; - private double? power; - private double? x; - private double? y; - private double? paintX; - private double? paintY; - private int? color; - private int? frame; - private bool? isExplosion; - private int? explosionImageIndex; - private int? bulletId; - - public BulletSnapshot(robocode.control.snapshot.IBulletSnapshot bulletSnapshot) - { - this.bulletSnapshot = bulletSnapshot; - } - - public BulletState State - { - get - { - if (state == null) - { - state = MapBulletState(bulletSnapshot.getState()); - } - return state.Value; - } - } - - public double Power - { - get - { - if (power == null) - { - power = bulletSnapshot.getPower(); - } - return power.Value; - } - } - - public double X - { - get - { - if (x == null) - { - x = bulletSnapshot.getX(); - } - return x.Value; - } - } - - public double Y - { - get - { - if (y == null) - { - y = bulletSnapshot.getY(); - } - return y.Value; - } - } - - public double PaintX - { - get - { - if (paintX == null) - { - paintX = bulletSnapshot.getPaintX(); - } - return paintX.Value; - } - } - - public double PaintY - { - get - { - if (paintY == null) - { - paintY = bulletSnapshot.getPaintY(); - } - return paintY.Value; - } - } - - public int Color - { - get - { - if (color == null) - { - color = bulletSnapshot.getColor(); - } - return color.Value; - } - } - - public int Frame - { - get - { - if (frame == null) - { - frame = bulletSnapshot.getFrame(); - } - return frame.Value; - } - } - - public bool IsExplosion - { - get - { - if (isExplosion == null) - { - isExplosion = bulletSnapshot.isExplosion(); - } - return isExplosion.Value; - } - } - - public int ExplosionImageIndex - { - get - { - if (explosionImageIndex == null) - { - explosionImageIndex = bulletSnapshot.getExplosionImageIndex(); - } - return explosionImageIndex.Value; - } - } - - public int BulletId - { - get - { - if (bulletId == null) - { - bulletId = bulletSnapshot.getBulletId(); - } - return bulletId.Value; - } - } - } - - private class ScoreSnapshot : IScoreSnapshot - { - // The real snapshot - private readonly robocode.control.snapshot.IScoreSnapshot scoreSnapshot; - - // Cached values created, when needed - private string name; - private double? totalScore; - private double? totalSurvivalScore; - private double? totalLastSurvivorBonus; - private double? totalBulletDamageScore; - private double? totalBulletKillBonus; - private double? totalRammingDamageScore; - private double? totalRammingKillBonus; - private int? totalFirsts; - private int? totalSeconds; - private int? totalThirds; - private double? currentScore; - private double? currentSurvivalScore; - private double? currentSurvivalBonus; - private double? currentBulletDamageScore; - private double? currentBulletKillBonus; - private double? currentRammingDamageScore; - private double? currentRammingKillBonus; - - public ScoreSnapshot(robocode.control.snapshot.IScoreSnapshot scoreSnapshot) - { - this.scoreSnapshot = scoreSnapshot; - } - - public int CompareTo(IScoreSnapshot snapshot) - { - double myScore = TotalScore + CurrentScore; - double hisScore = snapshot.TotalScore + snapshot.CurrentScore; - - if (myScore < hisScore) - { - return -1; - } - if (myScore > hisScore) - { - return 1; - } - return 0; - } - - public string Name - { - get - { - if (name == null) - { - name = scoreSnapshot.getName(); - } - return name; - } - } - - public double TotalScore - { - get - { - if (totalScore == null) - { - totalScore = scoreSnapshot.getTotalScore(); - } - return totalScore.Value; - } - } - - public double TotalSurvivalScore - { - get - { - if (totalSurvivalScore == null) - { - totalSurvivalScore = scoreSnapshot.getTotalSurvivalScore(); - } - return totalSurvivalScore.Value; - } - } - - public double TotalLastSurvivorBonus - { - get - { - if (totalLastSurvivorBonus == null) - { - totalLastSurvivorBonus = scoreSnapshot.getTotalLastSurvivorBonus(); - } - return totalLastSurvivorBonus.Value; - } - } - - public double TotalBulletDamageScore - { - get - { - if (totalBulletDamageScore == null) - { - totalBulletDamageScore = scoreSnapshot.getTotalBulletDamageScore(); - } - return totalBulletDamageScore.Value; - } - } - - public double TotalBulletKillBonus - { - get - { - if (totalBulletKillBonus == null) - { - totalBulletKillBonus = scoreSnapshot.getTotalBulletKillBonus(); - } - return totalBulletKillBonus.Value; - } - } - - public double TotalRammingDamageScore - { - get - { - if (totalRammingDamageScore == null) - { - totalRammingDamageScore = scoreSnapshot.getTotalRammingDamageScore(); - } - return totalRammingDamageScore.Value; - } - } - - public double TotalRammingKillBonus - { - get - { - if (totalRammingKillBonus == null) - { - totalRammingKillBonus = scoreSnapshot.getTotalRammingKillBonus(); - } - return totalRammingKillBonus.Value; - } - } - - public int TotalFirsts - { - get - { - if (totalFirsts == null) - { - totalFirsts = scoreSnapshot.getTotalFirsts(); - } - return totalFirsts.Value; - } - } - - public int TotalSeconds - { - get - { - if (totalSeconds == null) - { - totalSeconds = scoreSnapshot.getTotalSeconds(); - } - return totalSeconds.Value; - } - } - - public int TotalThirds - { - get - { - if (totalThirds == null) - { - totalThirds = scoreSnapshot.getTotalThirds(); - } - return totalThirds.Value; - } - } - - public double CurrentScore - { - get - { - if (currentScore == null) - { - currentScore = scoreSnapshot.getCurrentScore(); - } - return currentScore.Value; - } - } - - public double CurrentSurvivalScore - { - get - { - if (currentSurvivalScore == null) - { - currentSurvivalScore = scoreSnapshot.getCurrentSurvivalScore(); - } - return currentSurvivalScore.Value; - } - } - - public double CurrentSurvivalBonus - { - get - { - if (currentSurvivalBonus == null) - { - currentSurvivalBonus = scoreSnapshot.getCurrentSurvivalBonus(); - } - return currentSurvivalBonus.Value; - } - } - - public double CurrentBulletDamageScore - { - get - { - if (currentBulletDamageScore == null) - { - currentBulletDamageScore = scoreSnapshot.getCurrentBulletDamageScore(); - } - return currentBulletDamageScore.Value; - } - } - - public double CurrentBulletKillBonus - { - get - { - if (currentBulletKillBonus == null) - { - currentBulletKillBonus = scoreSnapshot.getCurrentBulletKillBonus(); - } - return currentBulletKillBonus.Value; - } - } - - public double CurrentRammingDamageScore - { - get - { - if (currentRammingDamageScore == null) - { - currentRammingDamageScore = scoreSnapshot.getCurrentBulletKillBonus(); - } - return currentRammingDamageScore.Value; - } - } - - public double CurrentRammingKillBonus - { - get - { - if (currentRammingKillBonus == null) - { - currentRammingKillBonus = scoreSnapshot.getCurrentRammingKillBonus(); - } - return currentRammingKillBonus.Value; - } - } - } - - private class DebugProperty : IDebugProperty - { - private readonly string key; - private readonly string value; - - public DebugProperty(string key, string value) - { - this.key = key; - this.value = value; - } - - public string Key - { - get { return key; } - } - - public string Value - { - get { return value; } - } - } - - #endregion - - #region robocode.control.RobotSpecification wrapper - - private class RobotSpecificationWrapper : robocode.control.RobotSpecification - { - private readonly string name; - private readonly string author; - private readonly string webpage; - private readonly string version; - private readonly string robocodeVersion; - private readonly string archiveFilePath; - private readonly string fullClassName; - private readonly string description; - private readonly string teamId; - - public RobotSpecificationWrapper(string name, string author, string webpage, string version, - string robocodeVersion, string archiveFilePath, string fullClassName, string description, string teamId) - : base(null) - { - this.name = name; - this.author = author; - this.webpage = webpage; - this.version = version; - this.robocodeVersion = robocodeVersion; - this.archiveFilePath = archiveFilePath; - this.fullClassName = fullClassName; - this.description = description; - this.teamId = teamId; - } - - public override java.lang.String getName() - { - return name; - } - - public override java.lang.String getVersion() - { - return version; - } - - public override java.lang.String getNameAndVersion() - { - string nameAndVersion = getName(); - string version = getVersion(); - - if (version != null && version.Trim().Length > 0) - { - nameAndVersion += ' ' + version.Trim(); - } - return nameAndVersion; - } - - public override java.lang.String getClassName() - { - return fullClassName; - } - - public override java.io.File getJarFile() - { - return new java.io.File(archiveFilePath); - } - - public override java.lang.String getDescription() - { - return description; - } - - public override java.lang.String getRobocodeVersion() - { - return robocodeVersion; - } - - public override java.lang.String getWebpage() - { - return webpage; - } - - public override java.lang.String getAuthorName() - { - return author; - } - - public override java.lang.String getTeamId() - { - return teamId; - } - } - - #endregion - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/RobotSetup.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/RobotSetup.cs deleted file mode 100644 index 28b4299..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/RobotSetup.cs +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; - -namespace Robocode.Control -{ - /// - /// Contains the initial position and heading for a robot. - /// - [Serializable] - public class RobotSetup - { - private readonly Double x; - private readonly Double y; - private readonly Double heading; - - /// - /// Constructs a new RobotSetup. - /// - /// The x coordinate, where null means random. - /// The y coordinate, where null means random. - /// The heading in degrees of the body, gun, and radar, where null means random. - public RobotSetup(Double x, Double y, Double heading) - { - this.x = x; - this.y = y; - this.heading = heading; - } - - /// - /// Contains the x coordinate. - /// - /// - /// The x coordinate, where null means unspecified (random). - /// - public Double X - { - get { return x; } - } - - /// - /// Contains the y coordinate. - /// - /// - /// The y coordinate, where null means unspecified (random). - /// - public Double Y - { - get { return y; } - } - - /// - /// Contains the body, gun, and radar heading (in degrees). - /// - /// - /// The heading (in degrees), where null means unspecified (random). - /// - public Double Heading - { - get { return heading; } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/RobotSpecification.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/RobotSpecification.cs deleted file mode 100644 index 77d6eff..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/RobotSpecification.cs +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Text; - -namespace Robocode.Control -{ - /// - /// Defines the properties of a robot, which is returned from - /// . - /// - [Serializable] - public class RobotSpecification - { - internal readonly robocode.control.RobotSpecification robotSpecification; - - internal RobotSpecification(robocode.control.RobotSpecification robotSpecification) - { - this.robotSpecification = robotSpecification; - } - - /// - /// Contains the name of this robot or team. - /// - /// - /// The name of this robot or team. - /// - /// - /// - public string Name - { - get { return robotSpecification.getName(); } - } - - /// - /// Contains the version of this robot or team. - /// - /// - /// The version of this robot or team. - /// - /// - /// - public string Version - { - get { return robotSpecification.getVersion(); } - } - - /// - /// Contains the name and version of this robot or team. - /// - /// - /// The name and version of this robot or team. - /// - /// - /// - private string NameAndVersion - { - get { return robotSpecification.getNameAndVersion(); } - } - - /// - /// Contains the full class name of this robot or team. - /// - /// - /// The full class name of this robot or team. - /// - public string ClassName - { - get { return robotSpecification.getClassName(); } - } - - /// - /// Contains the path of the archive file containing this robot or team. - /// - /// - /// The path of the archive file containing this robot or team or null - /// if it does not come from an archive file (could be class files instead). - /// - public string ArchiveFilePath - { - get { return robotSpecification.getJarFile().getAbsolutePath(); } - } - - /// - /// Contains the description provided by the author of this robot or team. - /// - /// - /// The description provided by the author of this robot or team. - /// - public string Description - { - get { return robotSpecification.getDescription(); } - } - - /// - /// Contains the version of Robocode this robot or team was build with. - /// - /// - /// The version of Robocode this robot or team was build with. - /// - public string RobocodeVersion - { - get { return robotSpecification.getRobocodeVersion(); } - } - - /// - /// Contains the link to the web page for this robot or team. - /// - /// - /// The link to the web page for this robot or team. - /// - public string Webpage - { - get { return robotSpecification.getWebpage(); } - } - - /// - /// Contains the name of the author of this robot or team. - /// - /// - /// The name of the author of this robot or team. - /// - public string AuthorName - { - get { return robotSpecification.getAuthorName(); } - } - - /// - /// Contains the id of the robot team. - /// - /// - /// The id of the robot team. - /// - public string TeamId - { - get { return robotSpecification.getTeamId(); } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleCompletedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleCompletedEvent.cs deleted file mode 100644 index 5f5e156..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleCompletedEvent.cs +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when a battle has completed successfully where results are available. - /// This event will not occur if the battle is terminated or aborted by the user before the - /// battle is completed. - /// - /// - /// - public class BattleCompletedEvent : BattleEvent - { - private readonly BattleRules battleRules; - private readonly BattleResults[] results; - - // Called by the game to create an instance of this event. - // Note: This constructor should not be available in the API. - internal BattleCompletedEvent(BattleRules battleRules, BattleResults[] results) - : base() - { - this.battleRules = battleRules; - this.results = results; - } - - /// - /// Contains the rules used in the battle. - /// - /// - /// The rules used in the battle. - /// - public BattleRules BattleRules - { - get { return battleRules; } - } - - /// - /// Contains the battle results sorted on score. - /// Note that the robot index cannot be used to determine the score with the sorted results. - /// - /// - /// An array of sorted BattleResults, where the results with the bigger score are placed first in the list. - /// - /// - public BattleResults[] SortedResults - { - get - { - List copy = new List(results); - copy.Sort(); - copy.Reverse(); - return copy.ToArray(); - } - } - - /// - /// Contains the battle results that can be used to determine the score for the individual robot based - /// on the robot index. - /// - /// - /// An array of indexed BattleResults, where each index matches an index of a specific robot. - /// - /// - public BattleResults[] IndexedResults - { - get - { - BattleResults[] copy = new BattleResults[results.Length]; - results.CopyTo(copy, 0); - return copy; - } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleErrorEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleErrorEvent.cs deleted file mode 100644 index 58ab08c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleErrorEvent.cs +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when an error message is sent from the game in the during the battle. - /// - /// - public class BattleErrorEvent : BattleEvent - { - private readonly string error; - - // Called by the game to create an instance of this event. - // Note: This constructor should not be available in the API. - internal BattleErrorEvent(string error) - : base() - { - this.error = error; - } - - /// - /// Contains the error message. - /// - /// - /// The error message that was sent from the game during the battle. - /// - public string Error - { - get { return error; } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleEvent.cs deleted file mode 100644 index 630c309..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleEvent.cs +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Events -{ - /// - /// This is the base class of all battle events. - /// - public abstract class BattleEvent - { - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleFinishedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleFinishedEvent.cs deleted file mode 100644 index 032783c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleFinishedEvent.cs +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when the battle is finished. This event is always sent as the last battle event, - /// both when the battle is completed successfully, terminated due to an error, or aborted by the user. - /// Hence, this events is well-suited for cleanup after the battle. - /// - /// - /// - public class BattleFinishedEvent : BattleEvent - { - private readonly bool isAborted; - - // Called by the game to create an instance of this event. - // Note: This constructor should not be available in the API. - internal BattleFinishedEvent(bool isAborted) - : base() - { - this.isAborted = isAborted; - } - - /// - /// Flag specifying if the battle was aborted. - /// - /// - /// true if the battle was aborted; false otherwise. - /// - public bool IsAborted - { - get { return isAborted; } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleMessageEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleMessageEvent.cs deleted file mode 100644 index 944f159..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleMessageEvent.cs +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when an informal message is sent from the game in the during the battle. - /// - /// - public class BattleMessageEvent : BattleEvent - { - private readonly string message; - - // Called by the game to create an instance of this event. - // Note: This constructor should not be available in the API. - internal BattleMessageEvent(string message) - : base() - { - this.message = message; - } - - /// - /// Contains the informal message. - /// - /// - /// The informal message that was sent from the game during the battle. - /// - public string Message - { - get { return message; } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattlePausedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattlePausedEvent.cs deleted file mode 100644 index 14a247c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattlePausedEvent.cs +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when a battle has been paused. - /// - /// - public class BattlePausedEvent : BattleEvent - { - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleResumedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleResumedEvent.cs deleted file mode 100644 index 2f267a8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleResumedEvent.cs +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when a battle has been resumed (after having been paused). - /// - /// - public class BattleResumedEvent : BattleEvent - { - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleStartedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleStartedEvent.cs deleted file mode 100644 index 49d81d3..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/BattleStartedEvent.cs +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when a new battle is started. - /// - /// - /// - public class BattleStartedEvent : BattleEvent - { - private readonly BattleRules battleRules; - private readonly bool isReplay; - private readonly int robotsCount; - - // Called by the game to create an instance of this event. - // Note: This constructor should not be available in the API. - internal BattleStartedEvent(BattleRules battleRules, int robotsCount, bool isReplay) - : base() - { - this.battleRules = battleRules; - this.isReplay = isReplay; - this.robotsCount = robotsCount; - } - - /// - /// Contains the rules that will be used in the battle. - /// - /// - /// The rules that will be used in the battle. - /// - public BattleRules BattleRules - { - get { return battleRules; } - } - - /// - /// Contains the number of robots participating in the battle. - /// - /// - /// The number of robots participating in the battle. - /// - public int RobotsCount - { - get { return robotsCount; } - } - - /// - /// Flag specifying if this battle is a replay or a new battle. - /// - /// - /// true if the battle is a replay; false otherwise. - /// - public bool IsReplay - { - get { return isReplay; } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/RoundEndedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/RoundEndedEvent.cs deleted file mode 100644 index 5bbad5f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/RoundEndedEvent.cs +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when the current round of a battle has ended. - /// - /// - public class RoundEndedEvent : BattleEvent - { - private readonly int round; - private readonly int turns; - private readonly int totalTurns; - - // Called by the game to create an instance of this event. - // Note: This constructor should not be available in the API. - internal RoundEndedEvent(int round, int turns, int totalTurns) - : base() - { - this.round = round; - this.turns = turns; - this.totalTurns = totalTurns; - } - - /// - /// Contains the round number that has ended. - /// - /// - /// The round number that has ended, which is zero indexed. - /// - public int Round - { - get { return round; } - } - - /// - /// Contains the number of turns that this round reached. - /// - /// - /// The number of turns that this round reached. - /// - /// - public int Turns - { - get { return turns; } - } - - /// - /// Contains the total number of turns reached in the battle when this round ended. - /// - /// - /// The total number of turns reached in the battle when this round ended. - /// - /// - public int TotalTurns - { - get { return totalTurns; } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/RoundStartedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/RoundStartedEvent.cs deleted file mode 100644 index f8e1530..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/RoundStartedEvent.cs +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; -using Robocode.Control.Snapshot; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when a new round in a battle is started. - /// - /// - public class RoundStartedEvent : BattleEvent - { - private readonly ITurnSnapshot startSnapshot; - private readonly int round; - - // Called by the game to create an instance of this event. - // Note: This constructor should not be available in the API. - internal RoundStartedEvent(ITurnSnapshot startSnapshot, int round) - : base() - { - this.startSnapshot = startSnapshot; - this.round = round; - } - - /// - /// Contains the start snapshot of the participating robots, initial starting positions etc. - /// - /// - /// A that serves as the start snapshot of the round. - /// - public ITurnSnapshot StartSnapshot - { - get { return startSnapshot; } - } - - /// - /// Contains the round number. - /// - /// - /// The round number, which is zero indexed. - /// - public int Round - { - get { return round; } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/TurnEndedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/TurnEndedEvent.cs deleted file mode 100644 index a97ab93..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/TurnEndedEvent.cs +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; -using Robocode.Control.Snapshot; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when when the current turn in a battle round is ended. - /// - /// - public class TurnEndedEvent : BattleEvent - { - private readonly ITurnSnapshot turnSnapshot; - - // Called by the game to create an instance of this event. - // Note: This constructor should not be available in the API. - internal TurnEndedEvent(ITurnSnapshot turnSnapshot) - : base() - { - this.turnSnapshot = turnSnapshot; - } - - /// - /// Contains a snapshot of the turn that has ended. - /// - /// - /// A snapshot of the turn that has ended. - /// - public ITurnSnapshot TurnSnapshot - { - get { return turnSnapshot; } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/TurnStartedEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/TurnStartedEvent.cs deleted file mode 100644 index b6c0284..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/events/TurnStartedEvent.cs +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Events -{ - /// - /// Contains information about a event that is - /// triggered when a new turn in a battle round is started. - /// - /// - public class TurnStartedEvent : BattleEvent - { - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/BulletState.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/BulletState.cs deleted file mode 100644 index bc1ebfd..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/BulletState.cs +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Snapshot -{ - /// - /// Defines a bullet state, which can be: just fired, moving somewhere, hitting a victim, - /// hitting another bullet, hitting the wall, exploded, or inactive. - /// - public enum BulletState - { - /// - /// The bullet has just been fired this turn and hence just been created. - /// This state only last one turn. - /// - Fired = 0, - - /// - /// The bullet is now moving across the battlefield, but has not hit anything yet. - /// - Moving = 1, - - /// - /// The bullet has hit a robot victim. - /// - HitVictim = 2, - - /// - /// The bullet has hit another bullet. - /// - HitBullet = 3, - - /// - /// The bullet has the wall, i.e. one of the four borders of the battlefield. - /// - HitWall = 4, - - /// - /// The bullet currently represents a robot explosion, i.e. a robot death. - /// - Exploded = 5, - - /// - /// The bullet is currently inactive. Hence, it is not active or visible on the battlefield. - /// - Inactive = 6 - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IBulletSnapshot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IBulletSnapshot.cs deleted file mode 100644 index 2a5406f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IBulletSnapshot.cs +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Snapshot -{ - /// - /// Interface of a bullet snapshot at a specific time in a battle. - /// - public interface IBulletSnapshot - { - /// - /// Contains the bullet state. - /// - /// - /// The bullet state. - /// - BulletState State { get; } - - /// - /// Contains the bullet power. - /// - /// - /// The bullet power. - /// - double Power { get; } - - /// - /// Contains the X position of the bullet. - /// - /// - /// The X position of the bullet. - /// - double X { get; } - - /// - /// Contains the Y position of the bullet. - /// - /// - /// The Y position of the bullet. - /// - double Y { get; } - - /// - /// Contains the X painting position of the bullet. - /// Note that this is not necessarily equal to the X position of the bullet, even though - /// it will be in most cases. The painting position of the bullet is needed as the bullet - /// will "stick" to its victim when it has been hit, but only visually. - /// - /// - /// The X painting position of the bullet. - /// - double PaintX { get; } - - /// - /// Contains the Y painting position of the bullet. - /// Note that this is not necessarily equal to the Y position of the bullet, even though - /// it will be in most cases. The painting position of the bullet is needed as the bullet - /// will "stick" to its victim when it has been hit, but only visually. - /// - /// - /// The Y painting position of the bullet. - /// - double PaintY { get; } - - /// - /// Contains the color of the bullet. - /// - /// - /// An ARGB color value. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue) - /// - int Color { get; } - - /// - /// Contains the current frame number to display, i.e. when the bullet explodes. - /// - /// - /// The current frame number. - /// - /// - /// - int Frame { get; } - - /// - /// Flag specifying if the bullet has become an explosion. - /// - /// - /// true if the bullet is an explosion; false otherwise. - /// - /// - /// - bool IsExplosion { get; } - - /// - /// Contains the explosion image index, which is different depending on the type of explosion. - /// E.g. if it is a small explosion on a robot that has been hit by this bullet, - /// or a big explosion when a robot dies. - /// - /// - /// The explosion image index. - /// - /// - /// - int ExplosionImageIndex { get; } - - /// - /// Contains the ID of the bullet used for identifying the bullet in a collection of bullets. - /// - /// - /// The ID of the bullet. - /// - int BulletId { get; } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IDebugProperty.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IDebugProperty.cs deleted file mode 100644 index 5be249e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IDebugProperty.cs +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Snapshot -{ - /// - /// Interface of a debug property, which is a key-value pair. - /// - public interface IDebugProperty - { - /// - /// Contains the key of the property. - /// - /// - /// The key of the property. - /// - string Key { get; } - - /// - /// Contains the value of the property. - /// - /// - /// The value of the property. - /// - string Value { get; } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IRobotSnapshot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IRobotSnapshot.cs deleted file mode 100644 index 82ab270..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IRobotSnapshot.cs +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Snapshot -{ - /// - /// Interface of a robot snapshot at a specific time in a battle. - /// - public interface IRobotSnapshot - { - /// - /// Contains the name of the robot. - /// - /// - /// The name of the robot. - /// - string Name { get; } - - /// - /// Contains the short name of the robot. - /// - /// - /// The short name of the robot. - /// - string ShortName { get; } - - /// - /// Contains the very short name of the robot. - /// - /// - /// The very short name of the robot. - /// - string VeryShortName { get; } - - /// - /// Contains the name of the team, which can be the name of a robot if the contestant is not a team, but a robot. - /// - /// - /// The name of the team. - /// - string TeamName { get; } - - /// - /// Contains the index of the robot, which is unique for the specific robot and constant during a battle. - /// Since: 1.7.4.0 - /// - /// - /// The robot index. - /// - /// - int RobotIndex { get; } - - /// - /// Contains the index of the team that this robot is a member of, which is unique for the specific team and constant - /// during a battle. - /// Since: 1.7.4.0 - /// - /// - /// The team index or -1 if the robot is not a member of a team. - /// - /// - int TeamIndex { get; } - - /// - /// Contains the contestant index, which is unique for each robot or team participating in a battle. - /// Note: If a team of robots is participating in a battle, this method will return the team index (see - /// ); otherwise the robot index (see ) is used instead. - /// This method is used for the battle results as scores are calculated for either a team of robots or individual - /// robot. - /// - /// - /// The contestant index of the robot or team. - /// - /// - /// - int ContestantIndex { get; } - - /// - /// Contains the robot state. - /// - /// - /// The robot state. - /// - RobotState State { get; } - - /// - /// Contains the energy level of the robot. - /// - /// - /// The energy level of the robot. - /// - double Energy { get; } - - /// - /// Contains the velocity of the robot. - /// - /// - /// The velocity of the robot. - /// - double Velocity { get; } - - /// - /// Contains the body heading of the robot in radians. - /// - /// - /// The body heading of the robot in radians. - /// - double BodyHeading { get; } - - /// - /// Contains the gun heading of the robot in radians. - /// - /// - /// The gun heading of the robot in radians. - /// - double GunHeading { get; } - - /// - /// Contains the radar heading of the robot in radians. - /// - /// - /// The radar heading of the robot in radians. - /// - double RadarHeading { get; } - - /// - /// Contains the gun heat of the robot. - /// - /// - /// The gun heat of the robot. - /// - double GunHeat { get; } - - /// - /// Contains the X position of the robot. - /// - /// - /// The X position of the robot. - /// - double X { get; } - - /// - /// Contains the Y position of the robot. - /// - /// - /// The Y position of the robot. - /// - double Y { get; } - - /// - /// Contains the color of the body. - /// - /// - /// An ARGB color value. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue) - /// - int BodyColor { get; } - - /// - /// Contains the color of the gun. - /// - /// - /// An ARGB color value. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue) - /// - int GunColor { get; } - - /// - /// Contains the color of the radar. - /// - /// - /// An ARGB color value. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue) - /// - int RadarColor { get; } - - /// - /// Contains the color of the scan arc. - /// - /// - /// An ARGB color value. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue) - /// - int ScanColor { get; } - - /// - /// Flag specifying if this robot is an . - /// - /// - /// true if this robot is an ; false otherwise. - /// - bool IsDroid { get; } - - /// - /// Flag specifying if this robot is an . - /// - /// - /// true if this robot is an ; false otherwise. - /// - bool IsPaintRobot { get; } - - /// - /// Flag specifying if painting is enabled for this robot. - /// - /// - /// true if painting is enabled for this robot; false otherwise. - /// - bool IsPaintEnabled { get; } - - /// - /// Flag specifying if RobocodeSG painting (the point (0,0) is in the upper left corner) is enabled for this robot. - /// - /// - /// true if RobocodeSG painting is enabled for this robot; false otherwise. - /// - bool IsSGPaintEnabled { get; } - - /// - /// Contains a snapshot of debug properties. - /// - /// - /// A snapshot of debug properties. - /// - IDebugProperty[] DebugProperties { get; } - - /// - /// Contains a snapshot of the output print stream for this robot. - /// - /// - /// A string containing the snapshot of the output print stream. - /// - string OutputStreamSnapshot { get; } - - /// - /// Contains a snapshot of the current score for this robot. - /// - /// - /// A snapshot of the current score for this robot. - /// - IScoreSnapshot ScoreSnapshot { get; } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IScoreSnapshot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IScoreSnapshot.cs deleted file mode 100644 index 8e050e8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/IScoreSnapshot.cs +++ /dev/null @@ -1,165 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Snapshot -{ - /// - /// Interface of a bullet snapshot at a specific time in a battle. - /// - public interface IScoreSnapshot : IComparable - { - /// - /// Contains the name of the contestant, i.e. a robot or team. - /// - /// - /// The name of the contestant, i.e. a robot or team. - /// - string Name { get; } - - /// - /// Contains the total score. - /// - /// - /// The total score. - /// - double TotalScore { get; } - - /// - /// Contains the total survival score. - /// - /// - /// The total survival score. - /// - double TotalSurvivalScore { get; } - - /// - /// Contains the total last survival score. - /// - /// - /// The total last survival score. - /// - double TotalLastSurvivorBonus { get; } - - /// - /// Contains the total bullet damage score. - /// - /// - /// The total bullet damage score. - /// - double TotalBulletDamageScore { get; } - - /// - /// Contains the total bullet kill bonus. - /// - /// - /// The total bullet kill bonus. - /// - double TotalBulletKillBonus { get; } - - /// - /// Contains the total ramming damage score. - /// - /// - /// The total ramming damage score. - /// - double TotalRammingDamageScore { get; } - - /// - /// Contains the total ramming kill bonus. - /// - /// - /// The total ramming kill bonus. - /// - double TotalRammingKillBonus { get; } - - /// - /// Contains the total number of first places. - /// - /// - /// The total number of first places. - /// - int TotalFirsts { get; } - - /// - /// Contains the total number of second places. - /// - /// - /// The total number of second places. - /// - int TotalSeconds { get; } - - /// - /// Contains the total number of third places. - /// - /// - /// The total number of third places. - /// - int TotalThirds { get; } - - /// - /// Contains the current score. - /// - /// - /// The current score. - /// - double CurrentScore { get; } - - /// - /// Contains the current survival score. - /// - /// - /// The current survival score. - /// - double CurrentSurvivalScore { get; } - - /// - /// Contains the current survival bonus. - /// - /// - /// The current survival bonus. - /// - double CurrentSurvivalBonus { get; } - - /// - /// Contains the current bullet damage score. - /// - /// - /// The current bullet damage score. - /// - double CurrentBulletDamageScore { get; } - - /// - /// Contains the current bullet kill bonus. - /// - /// - /// The current bullet kill bonus. - /// - double CurrentBulletKillBonus { get; } - - /// - /// Contains the current ramming damage score. - /// - /// - /// The current ramming damage score. - /// - double CurrentRammingDamageScore { get; } - - /// - /// Contains the current ramming kill bonus. - /// - /// - /// The current ramming kill bonus. - /// - double CurrentRammingKillBonus { get; } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/ITurnSnapshot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/ITurnSnapshot.cs deleted file mode 100644 index 855969f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/ITurnSnapshot.cs +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Snapshot -{ - /// - /// Interface of a battle turn snapshot at a specific time in a battle. - /// - public interface ITurnSnapshot - { - /// - /// Contains a list of snapshots for the robots participating in the battle. - /// - /// - /// A list of snapshots for the robots participating in the battle. - /// - IRobotSnapshot[] Robots { get; } - - /// - /// Contains a list of snapshots for the bullets that are currently on the battlefield. - /// - /// - /// A list of snapshots for the bullets that are currently on the battlefield. - /// - IBulletSnapshot[] Bullets { get; } - - /// - /// Contains the current TPS (turns per second) rate. - /// - /// - /// The current TPS (turns per second) rate. - /// - int TPS { get; } - - /// - /// Contains the current round of the battle. - /// - /// - /// The current round of the battle. - /// - int Round { get; } - - /// - /// Contains the current turn in the battle round. - /// - /// - /// The current turn in the battle round. - /// - int Turn { get; } - - /// - /// Contains an array of sorted scores grouped by teams, ordered by position. - /// Note that the team index cannot be used to determine the score with the sorted scores. - /// - /// - /// An array of sorted IScoreSnapshots, where the bigger scores are placed first in the list. - /// - /// - IScoreSnapshot[] SortedTeamScores { get; } - - /// - /// Contains an array of indexed scores grouped by teams that can be used to determine the score - /// for the individual team based on the team index. - /// - /// - /// An array of indexed IScoreSnapshots, where each index matches an index of a specific team. - /// - /// - IScoreSnapshot[] IndexedTeamScores { get; } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/RobotState.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/RobotState.cs deleted file mode 100644 index c60d2ce..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/implementation/robocode/control/snapshot/RobotState.cs +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.Text; - -namespace Robocode.Control.Snapshot -{ - /// - /// Defines a robot state, which can be: active on the battlefield, hitting a wall or robot this turn, or dead. - /// - public enum RobotState - { - /// - /// The robot is active on the battlefield and has not hit the wall or a robot at this turn. - /// - Active = 0, - - /// - /// The robot has hit a wall, i.e. one of the four borders, at this turn. This state only last one turn. - /// - HitWall = 1, - - /// - /// The robot has hit another robot at this turn. This state only last one turn. - /// - HitRobot = 2, - - /// - /// The robot is dead. - /// - Dead = 3 - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/robocode.dotnet.control.api.csproj b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/robocode.dotnet.control.api.csproj deleted file mode 100644 index 3ac19b0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/robocode.dotnet.control.api.csproj +++ /dev/null @@ -1,200 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {674AED55-B9EC-4C7D-8E0B-1B2471C578B2} - Library - Robocode.Control - robocode.control - v3.5 - 512 - true - ..\..\tools\keys\robocode.snk - - - robocode.ico - - - 3.5 - - - - true - full - false - ..\target\ - ..\target\obj\ - DEBUG;TRACE - prompt - 4 - false - true - - - pdbonly - true - ..\target\ - ..\target\obj\ - - - prompt - 4 - true - - - - False - ..\..\tools\lib\jni4net.n-0.8.7.0.dll - - - - - - - - implementation\robocode\AssemblyInfo.cs - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {7E0900D3-6E8F-48EB-86DB-AA767AA90B84} - robocode.dotnet.api - - - - - - - - - if not exist $(OutDir)\build-sources\generated-sources\META-INF mkdir $(OutDir)\build-sources\generated-sources\META-INF\ -echo [assembly: System.Reflection.AssemblyVersion("1.9.2.4")] > $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs - - copy "$(TargetPath)" "$(SolutionDir)\robocode.dotnet.host\target" -copy "$(SolutionDir)\tools\lib\*.dll" "$(TargetDir)" -copy "$(SolutionDir)\tools\lib\*.jar" "$(TargetDir)" -copy "$(SolutionDir)\tools\lib\*.dll" "$(SolutionDir)\robocode.dotnet.host\target" - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/robocode.ico b/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/robocode.ico deleted file mode 100644 index bbd6ef5..0000000 Binary files a/workspace_robo/plugins/dotnet/robocode.dotnet.control.api/src/robocode.ico and /dev/null differ diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/.classpath b/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/.classpath deleted file mode 100644 index 8faa1e0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/.classpath +++ /dev/null @@ -1,14 +0,0 @@ - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/.project deleted file mode 100644 index 86e4817..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/.project +++ /dev/null @@ -1,22 +0,0 @@ - - - robocode.dotnet.distribution - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.dotnet.api - robocode.dotnet.control.api - robocode.dotnet.installer - robocode.dotnet.content - robocode.dotnet.host - robocode.dotnet.nhost - robocode.dotnet.samples - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 90b2716..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:34:11 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/dotnet-setup.asm.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/dotnet-setup.asm.xml deleted file mode 100644 index 6dbb158..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/dotnet-setup.asm.xml +++ /dev/null @@ -1,119 +0,0 @@ - - - setup - - dir - jar - - false - - - - - net.sf.robocode:robocode.dotnet.api - - libs - false - robocode.${artifact.extension} - - - - - net.sf.robocode:robocode.dotnet.control.api - - libs - false - robocode.control.${artifact.extension} - - - - - net.sf.robocode:robocode.dotnet.* - net.sf.jni4net:* - - - - net.sf.robocode:robocode.dotnet.distribution - - net.sf.robocode:robocode.dotnet.installer - net.sf.robocode:robocode.dotnet.content - net.sf.robocode:robocode.dotnet.samples - - net.sf.robocode:robocode.dotnet.api - - net.sf.robocode:robocode.dotnet.control.api - - libs - false - - - - - net.sf.robocode:robocode.dotnet.installer - net.sf.robocode:robocode.dotnet.content - - true - - - **/META-INF/** - - - - - - - net.sf.robocode:robocode.dotnet.samples - - false - robots - samplescs-${project.version}.${artifact.extension} - - - - - - **/*.csproj - **/*.iws - **/*.user - **/*.bak - **/Thumbs.db - **/~* - **/.* - **/_svn/** - **/.svn/** - **/.git/** - **/.metadata/** - **/bin/** - **/target/** - **/lib/** - **/obj/** - - ../robocode.dotnet.samples/src - robots - - - - - ../robocode.dotnet.api/target/robocode.xml - libs - - - ../robocode.dotnet.api/target/Help/RobotAPI.chm - - - ../robocode.dotnet.control.api/target/robocode.control.xml - libs - - - ../robocode.dotnet.control.api/target/Help/ControlAPI.chm - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/pom.xml deleted file mode 100644 index 8b3150f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/pom.xml +++ /dev/null @@ -1,76 +0,0 @@ - - - 4.0.0 - robocode.dotnet.distribution - Robocode .NET Distribution - - net.sf.robocode - robocode.dotnet - ${robocode.dotnet.version} - - - - net.sf.robocode - robocode.dotnet.api - ${project.version} - dotnet:library - - - net.sf.robocode - robocode.dotnet.control.api - ${project.version} - dotnet:library - - - net.sf.robocode - robocode.dotnet.installer - ${project.version} - jar - - - net.sf.robocode - robocode.dotnet.content - ${project.version} - jar - - - net.sf.robocode - robocode.dotnet.samples - ${project.version} - dotnet:library - - - - - - org.sonatype.nmaven.plugins - maven-dotnet-compiler-plugin - - - maven-assembly-plugin - - ${project.parent.artifactId}-${robocode.version} - true - - dotnet-setup.asm.xml - - - - net.sf.robocode.installer.AutoExtract - - - - - - make-assembly - package - - single - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/robocode.dotnet.distribution.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/robocode.dotnet.distribution.iml deleted file mode 100644 index 7e826aa..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.distribution/robocode.dotnet.distribution.iml +++ /dev/null @@ -1,149 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/.classpath b/workspace_robo/plugins/dotnet/robocode.dotnet.host/.classpath deleted file mode 100644 index 7a6e7a0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/.classpath +++ /dev/null @@ -1,16 +0,0 @@ - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.host/.project deleted file mode 100644 index 158bb23..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/.project +++ /dev/null @@ -1,18 +0,0 @@ - - - robocode.dotnet.host - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.dotnet.nhost - robocode.dotnet.api - robocode.dotnet.control.api - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.host/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 15519c1..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:34:10 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/test/java=8859_1 -encoding/src/main/resources=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.host/pom.xml deleted file mode 100644 index 1e5b88d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/pom.xml +++ /dev/null @@ -1,164 +0,0 @@ - - - 4.0.0 - robocode.dotnet.host - Robocode .NET Host - ${robocode.version} - - net.sf.robocode - robocode.dotnet - ${robocode.dotnet.version} - - - - net.sf.robocode - robocode.host - ${robocode.version} - - - net.sf.robocode - robocode.repository - ${robocode.version} - - - net.sf.robocode - robocode.dotnet.nhost - ${robocode.dotnet.version} - dotnet:library - - - net.sf.jni4net - jni4net.j - 0.8.7.0 - - - net.sf.jni4net - jni4net.n - 0.8.7.0 - dotnet:library - - - net.sf.jni4net - jni4net.n.w32.v20 - 0.8.7.0 - dotnet:library - - - net.sf.jni4net - jni4net.n.w64.v20 - 0.8.7.0 - dotnet:library - - - net.sf.jni4net - jni4net.n.w32.v40 - 0.8.7.0 - dotnet:library - - - net.sf.jni4net - jni4net.n.w64.v40 - 0.8.7.0 - dotnet:library - - - junit - junit - 4.11 - test - - - - - - org.jvnet.maven-antrun-extended-plugin - maven-antrun-extended-plugin - - - process-classes - - - - - - - - - - - - - - - - - - - - - - run - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/robocode.dotnet.host.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.host/robocode.dotnet.host.iml deleted file mode 100644 index 3fdf0ce..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/robocode.dotnet.host.iml +++ /dev/null @@ -1,169 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/java_/util/Random_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/java_/util/Random_.java deleted file mode 100644 index 56d7c37..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/java_/util/Random_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package java_.util; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class Random_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return java_.util.Random_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - java_.util.Random_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/core/ContainerBase_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/core/ContainerBase_.java deleted file mode 100644 index 752fc5b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/core/ContainerBase_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.core; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class ContainerBase_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.core.ContainerBase_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.core.ContainerBase_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/host/DotNetHost.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/host/DotNetHost.java deleted file mode 100644 index 5c26c80..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/host/DotNetHost.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.dotnet.host; - -@net.sf.jni4net.attributes.ClrType -public class DotNetHost extends system.Object implements net.sf.robocode.host.IHost { - - // - private static system.Type staticType; - - protected DotNetHost(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrConstructor("()V") - public DotNetHost() { - super(((net.sf.jni4net.inj.INJEnv)(null)), 0); - net.sf.robocode.dotnet.host.DotNetHost.__ctorDotNetHost0(this); - } - - @net.sf.jni4net.attributes.ClrMethod("()V") - private native static void __ctorDotNetHost0(net.sf.jni4net.inj.IClrProxy thiz); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/host/IHostManager;Lrobocode/control/RobotSpecification;Lnet/sf/robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/host/proxies/IHostingRobotProxy;") - public native net.sf.robocode.host.proxies.IHostingRobotProxy createRobotProxy(net.sf.robocode.host.IHostManager par0, robocode.control.RobotSpecification par1, net.sf.robocode.peer.IRobotStatics par2, net.sf.robocode.peer.IRobotPeer par3); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String;") - public native java.lang.String[] getReferencedClasses(net.sf.robocode.repository.IRobotItem par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType;") - public native net.sf.robocode.repository.RobotType getRobotType(net.sf.robocode.repository.IRobotItem par0, boolean par1, boolean par2); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/host/IHostManager;Ljava/lang/Object;Lnet/sf/robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/host/proxies/IHostingRobotProxy;") - public native net.sf.robocode.host.proxies.IHostingRobotProxy createRobotProxy(net.sf.robocode.host.IHostManager hostManager, java.lang.Object robotSpecification, net.sf.robocode.peer.IRobotStatics statics, net.sf.robocode.peer.IRobotPeer peer); - - public static system.Type typeof() { - return net.sf.robocode.dotnet.host.DotNetHost.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.dotnet.host.DotNetHost.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/host/Module.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/host/Module.java deleted file mode 100644 index 2867a6f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/host/Module.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.dotnet.host; - - -import net.sf.robocode.core.*; -import net.sf.robocode.dotnet.repository.items.handlers.DotNetPropertiesHandler; -import net.sf.robocode.dotnet.repository.root.handlers.DllHandler; -import net.sf.robocode.manager.IVersionManagerBase; -import net.sf.robocode.io.Logger; -import net.sf.jni4net.Bridge; - -import java.io.File; -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public class Module extends BaseModule { - static { - // .NET proxies and their interfaces must be loaded in system class loader in order to call native methods - Init(); - } - - private static void Init() { - try { - - String libsDir; - final String version = ContainerBase.getComponent(IVersionManagerBase.class).getVersionN(); - - final java.security.CodeSource source = Module.class.getProtectionDomain().getCodeSource(); - final File file = new File(source.getLocation().toURI()).getCanonicalFile(); - - if (file.getName().equals("classes")) { - libsDir = file.getParent(); - } else if (file.getName().endsWith(".jar")) { - libsDir = file.getParent(); - } else { - throw new Error("Can't find " + file); - } - - final String nhost = libsDir + "/robocode.dotnet.nhost-" + version + ".dll"; - final String ncontrol = libsDir + "/robocode.control.dll"; - - Bridge.init(new File(libsDir)); - // Bridge.setVerbose(true); - // Bridge.setDebug(true); - Bridge.SetSystemClassLoader(Container.engineLoader); - Bridge.LoadAndRegisterAssemblyFrom(new File(ncontrol)); - Bridge.LoadAndRegisterAssemblyFrom(new File(nhost)); - - Container.cache.addComponent("DllItemHandler", DllHandler.class); - Container.cache.addComponent("CsPropertiesHandler", DotNetPropertiesHandler.class); - Container.cache.addComponent("VbPropertiesHandler", DotNetPropertiesHandler.class); - Container.cache.addComponent("DotNetPropertiesHandler", DotNetPropertiesHandler.class); - - // .NET proxies - Container.cache.addComponent("robocode.host.cs", DotNetHost.class); - Container.cache.addComponent("robocode.host.vb", DotNetHost.class); - Container.cache.addComponent("robocode.host.dotnet", DotNetHost.class); - - } catch (Throwable e) { - Logger.logError(e); - throw new Error("Can't initialize .NET Robocode", e); - } - } - - public void afterLoaded(List allModules) { - net.sf.robocode.dotnet.nhost.ModuleN.InitN(); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/nhost/ModuleN.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/nhost/ModuleN.java deleted file mode 100644 index f5d9c0b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/nhost/ModuleN.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.dotnet.nhost; - -@net.sf.jni4net.attributes.ClrType -public class ModuleN extends system.Object { - - // - private static system.Type staticType; - - protected ModuleN(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrConstructor("()V") - public ModuleN() { - super(((net.sf.jni4net.inj.INJEnv)(null)), 0); - net.sf.robocode.dotnet.nhost.ModuleN.__ctorModuleN0(this); - } - - @net.sf.jni4net.attributes.ClrMethod("()V") - private native static void __ctorModuleN0(net.sf.jni4net.inj.IClrProxy thiz); - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native static void InitN(); - - public static system.Type typeof() { - return net.sf.robocode.dotnet.nhost.ModuleN.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.dotnet.nhost.ModuleN.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/items/DotNetRobotItem.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/items/DotNetRobotItem.java deleted file mode 100644 index bf1c457..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/items/DotNetRobotItem.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.dotnet.repository.items; - - -import net.sf.robocode.repository.items.RobotItem; -import net.sf.robocode.repository.root.IRepositoryRoot; - -import java.net.URL; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class DotNetRobotItem extends RobotItem { - private static final long serialVersionUID = 1L; - - public DotNetRobotItem(IRepositoryRoot root, URL itemURL) { - super(itemURL, root); - - properties.setProperty(ROBOT_PLATFORM, "DotNet"); // instead of ".NET", as it is used for class names etc. - isPropertiesLoaded = true; - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/items/handlers/DotNetPropertiesHandler.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/items/handlers/DotNetPropertiesHandler.java deleted file mode 100644 index e89c439..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/items/handlers/DotNetPropertiesHandler.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.dotnet.repository.items.handlers; - - -import net.sf.robocode.repository.items.handlers.PropertiesHandler; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.items.RobotItem; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.dotnet.repository.items.DotNetRobotItem; -import net.sf.robocode.dotnet.repository.root.DllRoot; - -import java.net.URL; -import java.io.File; - - -/** - * @author Pavel Savara (original) - */ -public class DotNetPropertiesHandler extends PropertiesHandler { - - /** - * {@inheritDoc} - */ - @Override - protected IRepositoryItem acceptItem(URL itemURL, IRepositoryRoot root, IRepository repository) { - // Accept and register the item if it is a .NET properties file - String name = itemURL.toString().toLowerCase(); - if (name.contains(".dll!/")) { - return register(itemURL, root, repository); - } - return null; - } - - private IRepositoryItem register(URL itemURL, IRepositoryRoot root, IRepository repository) { - RobotItem item = (RobotItem) repository.getItem(itemURL.toString()); - if (item == null) { - item = createItem(itemURL, root, repository); - } - repository.addOrUpdateItem(item); - return item; - } - - protected RobotItem createItem(URL itemURL, IRepositoryRoot root, IRepository repository) { - File file = new File(itemURL.toString().replace(".properties", ".dll")); - DotNetRobotItem item = new DotNetRobotItem(new DllRoot(repository, file), itemURL); - - item.setClassURL(itemURL); - return item; - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/root/DllRoot.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/root/DllRoot.java deleted file mode 100644 index 527f029..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/root/DllRoot.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.dotnet.repository.root; - - -import net.sf.robocode.repository.root.BaseRoot; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.items.RobotItem; -import net.sf.robocode.repository.items.handlers.ItemHandler; -import net.sf.robocode.io.Logger; - -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.MalformedURLException; -import java.io.File; -import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.List; -import java.lang.String; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public final class DllRoot extends BaseRoot implements IRepositoryRoot { - private static final long serialVersionUID = 1L; - - private final String dllPath; - private final URL dllUrl; - - private long lastModified; - - public DllRoot(IRepository repository, File rootPath) { - super(repository, rootPath); - String dllPath = null; - URL dllUrl = null; - try { - dllPath = rootPath.toURI().toString(); - dllUrl = new URL(dllPath + "!/"); - dllPath = URLDecoder.decode(dllPath, "UTF8"); - } catch (MalformedURLException e) { - Logger.logError(e); - } catch (UnsupportedEncodingException e) { - Logger.logError(e); - } - this.dllPath = dllPath; - this.dllUrl = dllUrl; - } - - /** - * {@inheritDoc} - */ - public void updateItems(boolean force) { - setStatus("Updating DLL: " + rootPath.toString()); - - long lastModified = rootPath.lastModified(); - - if (lastModified > this.lastModified) { - repository.removeItemsFromRoot(this); - this.lastModified = lastModified; - - List repositoryItems = new ArrayList(); - - visitItems(repositoryItems); - for (IRepositoryItem repositoryItem : repositoryItems) { - repositoryItem.update(lastModified, force); - } - } - } - - private void visitItems(List items) { - String[] dllItems = DllRootHelper.findItems(dllPath); - - for (String url : dllItems) { - createItem(items, dllUrl, url); - } - } - - private void createItem(List items, URL root, String url) { - try { - IRepositoryItem item = ItemHandler.registerItem(new URL(url), DllRoot.this, repository); - if (item != null) { - if (item instanceof RobotItem) { - ((RobotItem) item).setClassPathURL(root); - } - items.add(item); - } - } catch (MalformedURLException e) { - Logger.logError(e); - } - } - - public void updateItem(IRepositoryItem item, boolean force) { - item.update(rootPath.lastModified(), force); - } - - public boolean isChanged(IRepositoryItem item) { - return rootPath.lastModified() > lastModified; - } - - public URL getRootUrl() { - return dllUrl; - } - - public boolean isDevelopmentRoot() { - return false; - } - - public boolean isJAR() { - return true; - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/root/DllRootHelper.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/root/DllRootHelper.java deleted file mode 100644 index 4e485d6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/root/DllRootHelper.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.dotnet.repository.root; - -@net.sf.jni4net.attributes.ClrType -public class DllRootHelper extends system.Object { - - // - private static system.Type staticType; - - protected DllRootHelper(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - protected DllRootHelper() { - super(((net.sf.jni4net.inj.INJEnv)(null)), 0); - } - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native static void Open(); - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native static void Close(); - - @net.sf.jni4net.attributes.ClrMethod("(LSystem/String;)[LSystem/String;") - public native static java.lang.String[] findItems(java.lang.String dllPath); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/repository/IRobotItem;)Lnet/sf/robocode/repository/RobotType;") - public native static net.sf.robocode.repository.RobotType GetRobotType(net.sf.robocode.repository.IRobotItem robotItem); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/repository/IRobotItem;)LSystem/String;") - public native static java.lang.String GetDllFileName(net.sf.robocode.repository.IRobotItem robotItem); - - public static system.Type typeof() { - return net.sf.robocode.dotnet.repository.root.DllRootHelper.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.dotnet.repository.root.DllRootHelper.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/root/handlers/DllHandler.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/root/handlers/DllHandler.java deleted file mode 100644 index 9e8502d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/dotnet/repository/root/handlers/DllHandler.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.dotnet.repository.root.handlers; - - -import net.sf.robocode.dotnet.repository.root.DllRootHelper; -import net.sf.robocode.dotnet.repository.root.DllRoot; -import net.sf.robocode.repository.root.handlers.RootHandler; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.repository.IRepository; - -import java.io.File; -import java.io.FileFilter; -import java.util.Map; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class DllHandler extends RootHandler { - - public void open() { - DllRootHelper.Open(); - } - - public void close() { - DllRootHelper.Close(); - } - - public void visitDirectory(File dir, boolean isDevel, Map newRoots, IRepository repository, boolean force) { - // find dll files - final File[] dlls = dir.listFiles(new FileFilter() { - public boolean accept(File pathname) { - String path = pathname.toString().toLowerCase(); - return pathname.isFile() && path.endsWith(".dll") && !path.equalsIgnoreCase("robocode.dll") - && !path.contains("jni4net"); - } - }); - - if (dlls != null) { - // update DLL files - for (File dll : dlls) { - String key = dll.toURI().toString(); - IRepositoryRoot root = repository.getRoots().get(key); - if (root == null) { - root = new DllRoot(repository, dll); - } else { - repository.removeRoot(key); - } - - root.updateItems(force); - newRoots.put(dll.toURI().toString(), root); - } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/IHostManager_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/IHostManager_.java deleted file mode 100644 index 53456b8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/IHostManager_.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.host; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IHostManager_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.host.IHostManager_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.host.IHostManager_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IHostManager extends system.Object implements net.sf.robocode.host.IHostManager { - - protected __IHostManager(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native void cleanup(); - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/lang/Object;Ljava/lang/Object;Lnet/sf/robocode/peer/IRobotPeer;)Ljava/lang/Object;") - public native java.lang.Object createRobotProxy(robocode.control.RobotSpecification par0, net.sf.robocode.host.RobotStatics par1, net.sf.robocode.peer.IRobotPeer par2); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String;") - public native java.lang.String[] getReferencedClasses(net.sf.robocode.repository.IRobotItem par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType;") - public native net.sf.robocode.repository.RobotType getRobotType(net.sf.robocode.repository.IRobotItem par0, boolean par1, boolean par2); - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native void initSecurity(); - - @net.sf.jni4net.attributes.ClrMethod("()J") - public native long getRobotFilesystemQuota(); - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native void resetThreadManager(); - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/lang/Object;)V") - public native void addSafeThread(java.lang.Thread par0); - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/lang/Object;)V") - public native void removeSafeThread(java.lang.Thread par0); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/io/PrintStream;") - public native java.io.PrintStream getRobotOutputStream(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/IHost_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/IHost_.java deleted file mode 100644 index b1752e3..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/IHost_.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.host; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IHost_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.host.IHost_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.host.IHost_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IHost extends system.Object implements net.sf.robocode.host.IHost { - - protected __IHost(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/host/IHostManager;Ljava/lang/Object;Lnet/sf/robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/host/proxies/IHostingRobotProxy;") - public native net.sf.robocode.host.proxies.IHostingRobotProxy createRobotProxy(net.sf.robocode.host.IHostManager par0, robocode.control.RobotSpecification par1, net.sf.robocode.peer.IRobotStatics par2, net.sf.robocode.peer.IRobotPeer par3); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String;") - public native java.lang.String[] getReferencedClasses(net.sf.robocode.repository.IRobotItem par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType;") - public native net.sf.robocode.repository.RobotType getRobotType(net.sf.robocode.repository.IRobotItem par0, boolean par1, boolean par2); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/RobotStatics_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/RobotStatics_.java deleted file mode 100644 index f0e0348..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/RobotStatics_.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.host; - - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RobotStatics_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.host.RobotStatics_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.host.RobotStatics_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/proxies/IHostingRobotProxy_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/proxies/IHostingRobotProxy_.java deleted file mode 100644 index 5bf220e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/host/proxies/IHostingRobotProxy_.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.host.proxies; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IHostingRobotProxy_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.host.proxies.IHostingRobotProxy_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.host.proxies.IHostingRobotProxy_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IHostingRobotProxy extends system.Object implements net.sf.robocode.host.proxies.IHostingRobotProxy { - - protected __IHostingRobotProxy(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native void cleanup(); - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/lang/Object;Ljava/lang/Object;)V") - public native void startRound(net.sf.robocode.peer.ExecCommands par0, robocode.RobotStatus par1); - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native void forceStopThread(); - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native void waitForStopThread(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/io/Logger_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/io/Logger_.java deleted file mode 100644 index c010fde..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/io/Logger_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.io; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class Logger_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.io.Logger_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.io.Logger_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/manager/IVersionManagerBase_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/manager/IVersionManagerBase_.java deleted file mode 100644 index cded2c3..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/manager/IVersionManagerBase_.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.manager; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IVersionManagerBase_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.manager.IVersionManagerBase_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.manager.IVersionManagerBase_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IVersionManagerBase extends system.Object implements net.sf.robocode.manager.IVersionManagerBase { - - protected __IVersionManagerBase(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getVersionAsInt(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getVersionN(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isLastRunVersionChanged(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/peer/BadBehavior_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/peer/BadBehavior_.java deleted file mode 100644 index e44a81b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/peer/BadBehavior_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.peer; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BadBehavior_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.peer.BadBehavior_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.peer.BadBehavior_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/peer/IRobotPeer_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/peer/IRobotPeer_.java deleted file mode 100644 index 58f7867..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/peer/IRobotPeer_.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.peer; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IRobotPeer_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.peer.IRobotPeer_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.peer.IRobotPeer_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IRobotPeer extends system.Object implements net.sf.robocode.peer.IRobotPeer { - - protected __IRobotPeer(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native void drainEnergy(); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/peer/BadBehavior;)V") - public native void punishBadBehavior(net.sf.robocode.peer.BadBehavior par0); - - @net.sf.jni4net.attributes.ClrMethod("(Z)V") - public native void setRunning(boolean par0); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isRunning(); - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/lang/Object;)Ljava/lang/Object;") - public native net.sf.robocode.peer.ExecResults waitForBattleEndImpl(net.sf.robocode.peer.ExecCommands par0); - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/lang/Object;)Ljava/lang/Object;") - public native net.sf.robocode.peer.ExecResults executeImpl(net.sf.robocode.peer.ExecCommands par0); - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/nio/ByteBuffer;)V") - public native void setupBuffer(java.nio.ByteBuffer par0); - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native void executeImplSerial(); - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native void waitForBattleEndImplSerial(); - - @net.sf.jni4net.attributes.ClrMethod("()V") - public native void setupThread(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/peer/IRobotStatics_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/peer/IRobotStatics_.java deleted file mode 100644 index 3fbbe89..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/peer/IRobotStatics_.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.peer; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IRobotStatics_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.peer.IRobotStatics_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.peer.IRobotStatics_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IRobotStatics extends system.Object implements net.sf.robocode.peer.IRobotStatics { - - protected __IRobotStatics(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isAdvancedRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isTeamRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isInteractiveRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isPaintRobot(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/repository/IRobotItem_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/repository/IRobotItem_.java deleted file mode 100644 index 217ce55..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/repository/IRobotItem_.java +++ /dev/null @@ -1,166 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.repository; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IRobotItem_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.repository.IRobotItem_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.repository.IRobotItem_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IRobotItem extends system.Object implements net.sf.robocode.repository.IRobotItem { - - protected __IRobotItem(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/lang/Object;)I") - public native int compareTo(java.lang.Object par0); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isValid(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isTeam(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isInJAR(); - - @net.sf.jni4net.attributes.ClrMethod("(Z)V") - public native void setValid(boolean par0); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getDescription(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getAuthorName(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/net/URL;") - public native java.net.URL getWebpage(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean getIncludeSource(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean getIncludeData(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isSourceIncluded(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getRootPath(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/net/URL;") - public native java.net.URL getItemURL(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isDevelopmentVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getRobocodeVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getFullPackage(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getRelativePath(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getRootPackage(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getFullClassNameWithVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getUniqueFullClassName(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getUniqueFullClassNameWithVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getUniqueShortClassNameWithVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getUniqueVeryShortClassNameWithVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getFullClassName(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getShortClassName(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/Object;") - public native robocode.control.RobotSpecification createRobotSpecification(); - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/io/OutputStream;Ljava/lang/Object;)V") - public native void storeProperties(java.io.OutputStream par0, net.sf.robocode.repository.RobotProperties par1); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getPlatform(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isJuniorRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isStandardRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isAdvancedRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isTeamRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isDroid(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isSentryRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isInteractiveRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isPaintRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/net/URL;") - public native java.net.URL getClassPathURL(); - - @net.sf.jni4net.attributes.ClrMethod("()[Ljava/net/URL;") - public native java.net.URL[] getSourcePathURLs(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getWritableDirectory(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getReadableDirectory(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/repository/IRobotSpecItem_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/repository/IRobotSpecItem_.java deleted file mode 100644 index 1dabc34..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/repository/IRobotSpecItem_.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.repository; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IRobotSpecItem_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.repository.IRobotSpecItem_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.repository.IRobotSpecItem_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IRobotSpecItem extends system.Object implements net.sf.robocode.repository.IRobotSpecItem { - - protected __IRobotSpecItem(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/lang/Object;)I") - public native int compareTo(java.lang.Object par0); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isValid(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isTeam(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isInJAR(); - - @net.sf.jni4net.attributes.ClrMethod("(Z)V") - public native void setValid(boolean par0); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getDescription(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getAuthorName(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/net/URL;") - public native java.net.URL getWebpage(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean getIncludeSource(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean getIncludeData(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isSourceIncluded(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getRootPath(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/net/URL;") - public native java.net.URL getItemURL(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isDevelopmentVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getRobocodeVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getFullPackage(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getRelativePath(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getRootPackage(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getFullClassNameWithVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getUniqueFullClassName(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getUniqueFullClassNameWithVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getUniqueShortClassNameWithVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getUniqueVeryShortClassNameWithVersion(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getFullClassName(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getShortClassName(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/Object;") - public native robocode.control.RobotSpecification createRobotSpecification(); - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/io/OutputStream;Ljava/lang/Object;)V") - public native void storeProperties(java.io.OutputStream par0, net.sf.robocode.repository.RobotProperties par1); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/repository/RobotType_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/repository/RobotType_.java deleted file mode 100644 index 3c0292d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/repository/RobotType_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.repository; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RobotType_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.repository.RobotType_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.repository.RobotType_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/security/HiddenAccess_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/security/HiddenAccess_.java deleted file mode 100644 index 24bf34b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/security/HiddenAccess_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.security; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class HiddenAccess_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.security.HiddenAccess_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.security.HiddenAccess_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/serialization/ISerializableHelper_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/serialization/ISerializableHelper_.java deleted file mode 100644 index 3dbeb3d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/serialization/ISerializableHelper_.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.serialization; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class ISerializableHelper_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.serialization.ISerializableHelper_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.serialization.ISerializableHelper_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __ISerializableHelper extends system.Object implements net.sf.robocode.serialization.ISerializableHelper { - - protected __ISerializableHelper(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;Ljava/lang/Object;)V") - public native void serialize(net.sf.robocode.serialization.RbSerializer par0, java.nio.ByteBuffer par1, java.lang.Object par2); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;)Ljava/lang/Object;") - public native java.lang.Object deserialize(net.sf.robocode.serialization.RbSerializer par0, java.nio.ByteBuffer par1); - - @net.sf.jni4net.attributes.ClrMethod("(Lnet/sf/robocode/serialization/RbSerializer;Ljava/lang/Object;)I") - public native int sizeOf(net.sf.robocode.serialization.RbSerializer par0, java.lang.Object par1); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/serialization/RbSerializer_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/serialization/RbSerializer_.java deleted file mode 100644 index 3244d98..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/net/sf/robocode/serialization/RbSerializer_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package net.sf.robocode.serialization; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RbSerializer_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return net.sf.robocode.serialization.RbSerializer_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - net.sf.robocode.serialization.RbSerializer_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/BattleRules_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/BattleRules_.java deleted file mode 100644 index 8825c15..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/BattleRules_.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode; - - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattleRules_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.BattleRules_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.BattleRules_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/BattleSpecification_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/BattleSpecification_.java deleted file mode 100644 index 1ef3b27..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/BattleSpecification_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattleSpecification_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.BattleSpecification_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.BattleSpecification_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/BattlefieldSpecification_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/BattlefieldSpecification_.java deleted file mode 100644 index 5bb04f6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/BattlefieldSpecification_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattlefieldSpecification_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.BattlefieldSpecification_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.BattlefieldSpecification_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RandomFactory_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RandomFactory_.java deleted file mode 100644 index 11488c8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RandomFactory_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RandomFactory_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.RandomFactory_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.RandomFactory_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobocodeEngine_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobocodeEngine_.java deleted file mode 100644 index 474d910..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobocodeEngine_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RobocodeEngine_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.RobocodeEngine_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.RobocodeEngine_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobotResults_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobotResults_.java deleted file mode 100644 index 8662aed..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobotResults_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RobotResults_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.RobotResults_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.RobotResults_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobotSetup_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobotSetup_.java deleted file mode 100644 index b96a88d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobotSetup_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RobotSetup_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.RobotSetup_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.RobotSetup_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobotSpecification_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobotSpecification_.java deleted file mode 100644 index af1254f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/RobotSpecification_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RobotSpecification_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.RobotSpecification_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.RobotSpecification_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleCompletedEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleCompletedEvent_.java deleted file mode 100644 index c8e28be..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleCompletedEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattleCompletedEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.BattleCompletedEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.BattleCompletedEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleErrorEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleErrorEvent_.java deleted file mode 100644 index 64b99ea..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleErrorEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattleErrorEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.BattleErrorEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.BattleErrorEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleEvent_.java deleted file mode 100644 index cc80540..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattleEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.BattleEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.BattleEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleFinishedEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleFinishedEvent_.java deleted file mode 100644 index 6c664aa..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleFinishedEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattleFinishedEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.BattleFinishedEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.BattleFinishedEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleMessageEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleMessageEvent_.java deleted file mode 100644 index 219e593..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleMessageEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattleMessageEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.BattleMessageEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.BattleMessageEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattlePausedEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattlePausedEvent_.java deleted file mode 100644 index ec6f7f6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattlePausedEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattlePausedEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.BattlePausedEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.BattlePausedEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleResumedEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleResumedEvent_.java deleted file mode 100644 index 7be0da3..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleResumedEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattleResumedEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.BattleResumedEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.BattleResumedEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleStartedEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleStartedEvent_.java deleted file mode 100644 index ded5769..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/BattleStartedEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BattleStartedEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.BattleStartedEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.BattleStartedEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/IBattleListener_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/IBattleListener_.java deleted file mode 100644 index 3be3fb9..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/IBattleListener_.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IBattleListener_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.IBattleListener_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.IBattleListener_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IBattleListener extends system.Object implements robocode.control.events.IBattleListener { - - protected __IBattleListener(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/BattleStartedEvent;)V") - public native void onBattleStarted(robocode.control.events.BattleStartedEvent par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/BattleFinishedEvent;)V") - public native void onBattleFinished(robocode.control.events.BattleFinishedEvent par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/BattleCompletedEvent;)V") - public native void onBattleCompleted(robocode.control.events.BattleCompletedEvent par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/BattlePausedEvent;)V") - public native void onBattlePaused(robocode.control.events.BattlePausedEvent par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/BattleResumedEvent;)V") - public native void onBattleResumed(robocode.control.events.BattleResumedEvent par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/RoundStartedEvent;)V") - public native void onRoundStarted(robocode.control.events.RoundStartedEvent par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/RoundEndedEvent;)V") - public native void onRoundEnded(robocode.control.events.RoundEndedEvent par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/TurnStartedEvent;)V") - public native void onTurnStarted(robocode.control.events.TurnStartedEvent par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/TurnEndedEvent;)V") - public native void onTurnEnded(robocode.control.events.TurnEndedEvent par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/BattleMessageEvent;)V") - public native void onBattleMessage(robocode.control.events.BattleMessageEvent par0); - - @net.sf.jni4net.attributes.ClrMethod("(Lrobocode/control/events/BattleErrorEvent;)V") - public native void onBattleError(robocode.control.events.BattleErrorEvent par0); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/RoundEndedEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/RoundEndedEvent_.java deleted file mode 100644 index 093cd60..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/RoundEndedEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RoundEndedEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.RoundEndedEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.RoundEndedEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/RoundStartedEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/RoundStartedEvent_.java deleted file mode 100644 index 43df805..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/RoundStartedEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RoundStartedEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.RoundStartedEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.RoundStartedEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/TurnEndedEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/TurnEndedEvent_.java deleted file mode 100644 index efbc4cb..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/TurnEndedEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class TurnEndedEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.TurnEndedEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.TurnEndedEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/TurnStartedEvent_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/TurnStartedEvent_.java deleted file mode 100644 index 0fb4c2b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/events/TurnStartedEvent_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.events; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class TurnStartedEvent_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.events.TurnStartedEvent_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.events.TurnStartedEvent_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/BulletState_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/BulletState_.java deleted file mode 100644 index c27d210..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/BulletState_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.snapshot; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class BulletState_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.snapshot.BulletState_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.snapshot.BulletState_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IBulletSnapshot_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IBulletSnapshot_.java deleted file mode 100644 index 390c165..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IBulletSnapshot_.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.snapshot; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IBulletSnapshot_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.snapshot.IBulletSnapshot_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.snapshot.IBulletSnapshot_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IBulletSnapshot extends system.Object implements robocode.control.snapshot.IBulletSnapshot { - - protected __IBulletSnapshot(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("()Lrobocode/control/snapshot/BulletState;") - public native robocode.control.snapshot.BulletState getState(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getX(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getY(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getHeading(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getPower(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getPaintX(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getPaintY(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getColor(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getFrame(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isExplosion(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getExplosionImageIndex(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getBulletId(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getVictimIndex(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getOwnerIndex(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IDebugProperty_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IDebugProperty_.java deleted file mode 100644 index 66f78f4..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IDebugProperty_.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.snapshot; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IDebugProperty_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.snapshot.IDebugProperty_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.snapshot.IDebugProperty_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IDebugProperty extends system.Object implements robocode.control.snapshot.IDebugProperty { - - protected __IDebugProperty(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getValue(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getKey(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IRobotSnapshot_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IRobotSnapshot_.java deleted file mode 100644 index 8d11a00..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IRobotSnapshot_.java +++ /dev/null @@ -1,127 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.snapshot; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IRobotSnapshot_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.snapshot.IRobotSnapshot_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.snapshot.IRobotSnapshot_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IRobotSnapshot extends system.Object implements robocode.control.snapshot.IRobotSnapshot { - - protected __IRobotSnapshot(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getName(); - - @net.sf.jni4net.attributes.ClrMethod("()Lrobocode/control/snapshot/RobotState;") - public native robocode.control.snapshot.RobotState getState(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getTeamName(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getX(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getY(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getShortName(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getVeryShortName(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getRobotIndex(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getTeamIndex(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getContestantIndex(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getEnergy(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getVelocity(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getBodyHeading(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getGunHeading(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getRadarHeading(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getGunHeat(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getBodyColor(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getGunColor(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getRadarColor(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getScanColor(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isDroid(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isSentryRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isPaintRobot(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isPaintEnabled(); - - @net.sf.jni4net.attributes.ClrMethod("()Z") - public native boolean isSGPaintEnabled(); - - @net.sf.jni4net.attributes.ClrMethod("()[Lrobocode/control/snapshot/IDebugProperty;") - public native robocode.control.snapshot.IDebugProperty[] getDebugProperties(); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getOutputStreamSnapshot(); - - @net.sf.jni4net.attributes.ClrMethod("()Lrobocode/control/snapshot/IScoreSnapshot;") - public native robocode.control.snapshot.IScoreSnapshot getScoreSnapshot(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IScoreSnapshot_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IScoreSnapshot_.java deleted file mode 100644 index bac14e4..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/IScoreSnapshot_.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.snapshot; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class IScoreSnapshot_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.snapshot.IScoreSnapshot_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.snapshot.IScoreSnapshot_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __IScoreSnapshot extends system.Object implements robocode.control.snapshot.IScoreSnapshot { - - protected __IScoreSnapshot(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("(Ljava/lang/Object;)I") - public native int compareTo(java.lang.Object par0); - - @net.sf.jni4net.attributes.ClrMethod("()Ljava/lang/String;") - public native java.lang.String getName(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getTotalScore(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getTotalSurvivalScore(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getTotalLastSurvivorBonus(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getTotalBulletDamageScore(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getTotalBulletKillBonus(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getTotalRammingDamageScore(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getTotalRammingKillBonus(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getTotalFirsts(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getTotalSeconds(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getTotalThirds(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getCurrentScore(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getCurrentSurvivalScore(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getCurrentSurvivalBonus(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getCurrentBulletDamageScore(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getCurrentBulletKillBonus(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getCurrentRammingDamageScore(); - - @net.sf.jni4net.attributes.ClrMethod("()D") - public native double getCurrentRammingKillBonus(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/ITurnSnapshot_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/ITurnSnapshot_.java deleted file mode 100644 index 7513dd2..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/ITurnSnapshot_.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.snapshot; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class ITurnSnapshot_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.snapshot.ITurnSnapshot_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.snapshot.ITurnSnapshot_.staticType = staticType; - } - // -} - -// -@net.sf.jni4net.attributes.ClrProxy -class __ITurnSnapshot extends system.Object implements robocode.control.snapshot.ITurnSnapshot { - - protected __ITurnSnapshot(net.sf.jni4net.inj.INJEnv __env, long __handle) { - super(__env, __handle); - } - - @net.sf.jni4net.attributes.ClrMethod("()[Lrobocode/control/snapshot/IRobotSnapshot;") - public native robocode.control.snapshot.IRobotSnapshot[] getRobots(); - - @net.sf.jni4net.attributes.ClrMethod("()[Lrobocode/control/snapshot/IBulletSnapshot;") - public native robocode.control.snapshot.IBulletSnapshot[] getBullets(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getTPS(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getRound(); - - @net.sf.jni4net.attributes.ClrMethod("()I") - public native int getTurn(); - - @net.sf.jni4net.attributes.ClrMethod("()[Lrobocode/control/snapshot/IScoreSnapshot;") - public native robocode.control.snapshot.IScoreSnapshot[] getSortedTeamScores(); - - @net.sf.jni4net.attributes.ClrMethod("()[Lrobocode/control/snapshot/IScoreSnapshot;") - public native robocode.control.snapshot.IScoreSnapshot[] getIndexedTeamScores(); -} -// diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/RobotState_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/RobotState_.java deleted file mode 100644 index 91f7cdc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/control/snapshot/RobotState_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.control.snapshot; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class RobotState_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.control.snapshot.RobotState_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.control.snapshot.RobotState_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/AbortedException_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/AbortedException_.java deleted file mode 100644 index b36c4c8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/AbortedException_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.exception; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class AbortedException_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.exception.AbortedException_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.exception.AbortedException_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/DeathException_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/DeathException_.java deleted file mode 100644 index dfef221..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/DeathException_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.exception; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class DeathException_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.exception.DeathException_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.exception.DeathException_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/DisabledException_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/DisabledException_.java deleted file mode 100644 index 9c69e46..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/DisabledException_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.exception; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class DisabledException_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.exception.DisabledException_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.exception.DisabledException_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/WinException_.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/WinException_.java deleted file mode 100644 index 75df821..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/main/java/robocode/exception/WinException_.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// ------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -// ------------------------------------------------------------------------------ - -package robocode.exception; - -@net.sf.jni4net.attributes.ClrTypeInfo -public final class WinException_ { - - // - private static system.Type staticType; - - public static system.Type typeof() { - return robocode.exception.WinException_.staticType; - } - - private static void InitJNI(net.sf.jni4net.inj.INJEnv env, system.Type staticType) { - robocode.exception.WinException_.staticType = staticType; - } - // -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/test/java/net/sf/robocode/dotnet/host/TestCLR.java b/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/test/java/net/sf/robocode/dotnet/host/TestCLR.java deleted file mode 100644 index 858fd26..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.host/src/test/java/net/sf/robocode/dotnet/host/TestCLR.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.dotnet.host; - - -import org.junit.Test; - - -/** - * @author Pavel Savara (original) - */ -public class TestCLR { - - @Test - public void test1() {} - - @Test - public void test2() {} -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.iml deleted file mode 100644 index c163c5f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.iml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/.classpath b/workspace_robo/plugins/dotnet/robocode.dotnet.installer/.classpath deleted file mode 100644 index 5114d59..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.installer/.project deleted file mode 100644 index 26afbc5..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/.project +++ /dev/null @@ -1,14 +0,0 @@ - - - robocode.dotnet.installer - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.installer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 764c3ab..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:34:11 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/test/java=8859_1 -encoding/src/main/resources=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.installer/pom.xml deleted file mode 100644 index 66dc7b8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - robocode.dotnet.installer - Robocode .NET Installer - - robocode.dotnet - net.sf.robocode - ${robocode.dotnet.version} - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - net.sf.robocode.installer.AutoExtract - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/robocode.dotnet.installer.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.installer/robocode.dotnet.installer.iml deleted file mode 100644 index 93c108a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/robocode.dotnet.installer.iml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java b/workspace_robo/plugins/dotnet/robocode.dotnet.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java deleted file mode 100644 index eaba300..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java +++ /dev/null @@ -1,382 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.installer; - - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; -import java.net.URL; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.JarInputStream; - - -/** - * Installer for Robocode. - * - * @author Mathew A. Nelsen (original) - * @author Flemming N. Larsen (contributor) - */ -public class AutoExtract implements ActionListener { - private JDialog licenseDialog; - private boolean accepted; - private final String[] spinner = { "-", "\\", "|", "/"}; - private String message = ""; - private static File installDir; - private static final String javaVersion = System.getProperty("java.version"); - - private boolean acceptLicense() { - String licenseText = ""; - - InputStream is; - - try { - JarFile extractJar = new JarFile("extract.jar"); - - is = extractJar.getInputStream(extractJar.getJarEntry("license/cpl-v10.html")); - } catch (IOException e) { - return true; - } - if (is == null) { - return true; - } - - BufferedReader r = new BufferedReader(new InputStreamReader(is)); - - try { - String line = r.readLine(); - - while (line != null) { - licenseText += line; - line = r.readLine(); - } - return acceptReject(licenseText); - - } catch (IOException e) { - System.err.println("Could not read line from license file: " + e); - } - return true; - } - - private boolean acceptReject(String text) { - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - licenseDialog = new JDialog(); - licenseDialog.setTitle("License Agreement"); - licenseDialog.setModal(true); - licenseDialog.setLocation((screenSize.width - 500) / 2, (screenSize.height - 400) / 2); - licenseDialog.setSize(500, 400); - JTextPane t = new JTextPane(); - - t.setContentType("text/html"); - t.setText(text); - t.setFont(new Font("Dialog", Font.PLAIN, 12)); - t.setEditable(false); - - JScrollPane s = new JScrollPane(); - - s.setViewportView(t); - - licenseDialog.getContentPane().setLayout(new BorderLayout()); - licenseDialog.getContentPane().add(s, BorderLayout.CENTER); - - JPanel p = new JPanel(); - - p.setLayout(new BorderLayout()); - JButton b1 = new JButton("Accept"); - JButton b2 = new JButton("Cancel"); - - p.add(b1, BorderLayout.WEST); - p.add(b2, BorderLayout.EAST); - - b1.addActionListener(this); - b2.addActionListener(this); - - licenseDialog.getContentPane().add(p, BorderLayout.SOUTH); - - licenseDialog.setVisible(true); - - return accepted; - } - - public void actionPerformed(ActionEvent e) { - accepted = e.getActionCommand().equals("Accept"); - licenseDialog.dispose(); - licenseDialog = null; - } - - private boolean extract(File dest) { - JDialog statusDialog = new JDialog(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - int width = 500; - int height = 100; - - statusDialog.setTitle("Installing"); - statusDialog.setLocation((screenSize.width - width) / 2, (screenSize.height - height) / 2); - statusDialog.setSize(width, height); - JLabel status = new JLabel(); - - statusDialog.getContentPane().setLayout(new BorderLayout()); - statusDialog.getContentPane().add(status, BorderLayout.CENTER); - - statusDialog.setVisible(true); - - FileOutputStream fos; - String entryName; - - byte buf[] = new byte[2048]; - - final String name = AutoExtract.class.getName().replaceAll("\\.", "/") + ".class"; - String urlJar = AutoExtract.class.getClassLoader().getResource(name).toString(); - final String src = urlJar.substring("jar:file:/".length(), urlJar.indexOf("!/")); - - if (src.indexOf('!') > -1) { - final String message = src - + "\nContains an exclamation point. Please move the file to a different directory."; - - JOptionPane.showMessageDialog(null, message); - System.err.println(message); - System.exit(0); - } - JarInputStream jarIS = null; - try { - final URL url = new URL("file:/" + src); - InputStream is = url.openStream(); - jarIS = new JarInputStream(is); - - JarEntry entry = jarIS.getNextJarEntry(); - - while (entry != null) { - int spin = 0; - - entryName = entry.getName(); - if (entry.isDirectory()) { - if (!entryName.startsWith("net")) { - File dir = new File(dest, entry.getName()); - - if (!dir.exists() && !dir.mkdirs()) { - System.out.println("Can't create dir " + dir); - } - } - } else { - if (!entryName.equals(name)) { - status.setText(entryName + " " + spinner[spin++]); - - File out = new File(dest, entry.getName()); - File parentDirectory = new File(out.getParent()); - - if (!parentDirectory.exists() && !parentDirectory.mkdirs()) { - System.out.println("Can't create dir " + parentDirectory); - } - fos = new FileOutputStream(out); - - int index = 0; - int num; - int count = 0; - - while ((num = jarIS.read(buf, 0, 2048)) != -1) { - fos.write(buf, 0, num); - index += num; - count++; - if (count > 80) { - status.setText(entryName + " " + spinner[spin++] + " (" + index + " bytes)"); - if (spin > 3) { - spin = 0; - } - count = 0; - } - } - fos.close(); - - if (entryName.length() > 3 && entryName.substring(entryName.length() - 3).equals(".sh")) { - if (File.separatorChar == '/') { - Runtime.getRuntime().exec("chmod 755 " + out.toString()); - } - } - - status.setText(entryName + " " + spinner[spin] + " (" + index + " bytes)"); - } - } - entry = jarIS.getNextJarEntry(); - } - statusDialog.dispose(); - message = "Installation successful"; - return true; - } catch (IOException e) { - message = "Installation failed" + e; - return false; - } finally { - if (jarIS != null) { - try { - jarIS.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - public static void main(String argv[]) { - // Verify that the Java version is version 6 (1.6.0) or newer - if (javaVersion.startsWith("1.") && javaVersion.charAt(2) < '5') { - final String message = "Robocode requires Java 6 (1.6.0) or newer.\n" - + "Your system is currently running Java " + javaVersion + ".\n" - + "If you have not installed (or activated) at least\n" + "JRE 6 or JDK 6, please do so."; - - JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE); - System.err.println(message); - System.exit(0); - } - - // Set native look and feel - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF - } - - File suggestedDir; - - AutoExtract extractor = new AutoExtract(); - - if (extractor.acceptLicense()) { - if (argv.length == 1) { - suggestedDir = new File(argv[0]); - } else if (File.separatorChar == '\\') { - suggestedDir = new File("c:\\robocode\\"); - } else { - suggestedDir = new File(System.getProperty("user.home") + File.separator + "robocode" + File.separator); - } - - boolean done = false; - - while (!done) { - int rc = JOptionPane.showConfirmDialog(null, - "Robocode plugin will be installed in:\n" + suggestedDir + "\nIs this ok?", "Installing Robocode", - JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); - - if (rc == JOptionPane.YES_OPTION) { - installDir = suggestedDir; - done = true; - } else if (rc == JOptionPane.NO_OPTION) { - Object r = JOptionPane.showInputDialog(null, "Please type in the installation directory", - "Installation Directory", JOptionPane.PLAIN_MESSAGE, null, null, suggestedDir); - - if (r == null) { - JOptionPane.showMessageDialog(null, "Installation cancelled."); - System.exit(0); - } else { - suggestedDir = new File(((String) r).trim()); - } - } else if (rc == JOptionPane.CANCEL_OPTION) { - JOptionPane.showMessageDialog(null, "Installation cancelled."); - System.exit(0); - } - } - if (!installDir.exists()) { - int rc = JOptionPane.showConfirmDialog(null, - installDir.getPath() + "\ndoes not exist. Would you like to create it?", "Installing Robocode", - JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); - - if (rc == JOptionPane.YES_OPTION) { - if (!installDir.exists() && !installDir.mkdirs()) { - System.out.println("Can't create dir " + installDir); - } - } else { - JOptionPane.showMessageDialog(null, "Installation cancelled."); - System.exit(0); - } - } - boolean rv = extractor.extract(installDir); - - if (!rv) { - JOptionPane.showMessageDialog(null, extractor.message); - } - } else { - JOptionPane.showMessageDialog(null, "Installation cancelled."); - } - - // Delete the class file with the installer and it's parent folders in the robocode home dir - if (installDir != null) { - String installerPath = AutoExtract.class.getName().replaceAll("\\.", "/") + "$1.class"; - - deleteFileAndParentDirsIfEmpty(new File(installDir, installerPath)); - } - - System.exit(0); - } - - private static boolean deleteDir(File dir) { - if (dir.isDirectory()) { - for (File file : dir.listFiles()) { - if (file.isDirectory()) { - // Skip directories ending with ".data" - if (file.getName().endsWith(".data")) { - continue; - } - try { - // Test for symlink and ignore. - // Robocode won't create one, but just in case a user does... - if (file.getCanonicalFile().getParentFile().equals(dir.getCanonicalFile())) { - deleteDir(file); - if (file.exists() && !file.delete()) { - System.err.println("Can't delete: " + file); - } - } else { - System.out.println("Warning: " + file + " may be a symlink. It has been ignored"); - } - } catch (IOException e) { - System.out.println( - "Warning: Cannot determine canonical file for " + file + ". It has been ignored"); - } - } else { - if (file.exists() && !file.delete()) { - System.err.println("Can't delete: " + file); - } - } - } - return dir.delete(); - } - return false; - } - - /** - * Deletes a file and afterwards deletes the parent directories that are empty. - * - * @param file the file or directory to delete - * @return true if success - */ - private static boolean deleteFileAndParentDirsIfEmpty(final File file) { - boolean wasDeleted = false; - - if (file != null && file.exists()) { - if (file.isDirectory()) { - wasDeleted = deleteDir(file); - } else { - wasDeleted = file.delete(); - - File parent = file; - - while (wasDeleted && (parent = parent.getParentFile()) != null) { - // Delete parent directory, but only if it is empty - File[] files = parent.listFiles(); - - if (files != null && files.length == 0) { - wasDeleted = deleteDir(parent); - } else { - wasDeleted = false; - } - } - } - } - return wasDeleted; - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.ipr b/workspace_robo/plugins/dotnet/robocode.dotnet.ipr deleted file mode 100644 index d223cbc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.ipr +++ /dev/null @@ -1,118 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.iws b/workspace_robo/plugins/dotnet/robocode.dotnet.iws deleted file mode 100644 index 03c854e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.iws +++ /dev/null @@ -1,418 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/.project deleted file mode 100644 index 8426045..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - robocode.dotnet.nhost - .NET nhost for Robocode. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.dotnet.api - robocode.dotnet.control.api - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 070758f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,10 +0,0 @@ -#Tue Nov 27 22:34:10 CET 2012 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 -encoding/src/main/resources=8859_1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/test/resources=8859_1 -encoding/src=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/pom.xml deleted file mode 100644 index 5b166f5..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/pom.xml +++ /dev/null @@ -1,93 +0,0 @@ - - - 4.0.0 - robocode.dotnet.nhost - Robocode .NET nHost - .NET nhost for Robocode - dotnet:library - - robocode.dotnet - net.sf.robocode - ${robocode.dotnet.version} - - - - net.sf.jni4net - jni4net.n - 0.8.7.0 - dotnet:library - - - net.sf.robocode - robocode.dotnet.api - ${project.version} - dotnet:library - - - net.sf.robocode - robocode.dotnet.control.api - ${project.version} - dotnet:library - - - - src - - - org.sonatype.nmaven.plugins - maven-dotnet-compiler-plugin - - /unsafe /warn:0 /nowarn:1591 /keyfile:"${basedir}/../tools/keys/robocode.snk" - - - - org.jvnet.maven-antrun-extended-plugin - maven-antrun-extended-plugin - - - process-classes - - - - - - - - - - - - - - run - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/robocode.dotnet.nhost.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/robocode.dotnet.nhost.iml deleted file mode 100644 index f4981fc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/robocode.dotnet.nhost.iml +++ /dev/null @@ -1,75 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/.gitignore b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/.gitignore deleted file mode 100644 index 7c7991e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/.gitignore +++ /dev/null @@ -1,3 +0,0 @@ -/robocode.dotnet.nhost.sln -/robocode.dotnet.nhost.suo -/obj diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/core/ContainerBase.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/core/ContainerBase.generated.cs deleted file mode 100644 index 321b090..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/core/ContainerBase.generated.cs +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.core { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class ContainerBase : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getComponent0; - - internal static global::net.sf.jni4net.jni.FieldId j4n_instance1; - - protected ContainerBase(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.core.ContainerBase.staticClass; - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lnet/sf/robocode/core/ContainerBase;")] - public static global::net.sf.robocode.core.ContainerBase instance { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::net.sf.robocode.core.ContainerBase.staticClass, global::net.sf.robocode.core.ContainerBase.j4n_instance1)); - } - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.core.ContainerBase.staticClass = @__class; - global::net.sf.robocode.core.ContainerBase.j4n_getComponent0 = @__env.GetStaticMethodID(global::net.sf.robocode.core.ContainerBase.staticClass, "getComponent", "(Ljava/lang/Class;)Ljava/lang/Object;"); - global::net.sf.robocode.core.ContainerBase.j4n_instance1 = @__env.GetStaticFieldID(global::net.sf.robocode.core.ContainerBase.staticClass, "instance", "Lnet/sf/robocode/core/ContainerBase;"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/Class;)Ljava/lang/Object;")] - public static global::java.lang.Object getComponent(global::java.lang.Class par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallStaticObjectMethodPtr(global::net.sf.robocode.core.ContainerBase.staticClass, global::net.sf.robocode.core.ContainerBase.j4n_getComponent0, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.core.ContainerBase(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/dotnet/host/DotNetHost.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/dotnet/host/DotNetHost.generated.cs deleted file mode 100644 index b981589..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/dotnet/host/DotNetHost.generated.cs +++ /dev/null @@ -1,129 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.dotnet.host { - - - #region Component Designer generated code - public partial class DotNetHost_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.dotnet.host.@__DotNetHost.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.dotnet.host.DotNetHost), typeof(global::net.sf.robocode.dotnet.host.DotNetHost_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.dotnet.host.DotNetHost), typeof(global::net.sf.robocode.dotnet.host.DotNetHost_))] - internal sealed partial class @__DotNetHost : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - private @__DotNetHost(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.dotnet.host.@__DotNetHost.staticClass = @__class; - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__DotNetHost); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "createRobotProxy", "createRobotProxy0", "(Lnet/sf/robocode/host/IHostManager;Lrobocode/control/RobotSpecification;Lnet/sf/" + - "robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/h" + - "ost/proxies/IHostingRobotProxy;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getReferencedClasses", "getReferencedClasses1", "(Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRobotType", "getRobotType2", "(Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType;" + - "")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "createRobotProxy", "createRobotProxy3", "(Lnet/sf/robocode/host/IHostManager;Ljava/lang/Object;Lnet/sf/robocode/peer/IRobo" + - "tStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/host/proxies/IHostin" + - "gRobotProxy;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "__ctorDotNetHost0", "__ctorDotNetHost0", "(Lnet/sf/jni4net/inj/IClrProxy;)V")); - return methods; - } - - private static global::net.sf.jni4net.utils.JniHandle createRobotProxy0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, global::net.sf.jni4net.utils.JniLocalHandle par1, global::net.sf.jni4net.utils.JniLocalHandle par2, global::net.sf.jni4net.utils.JniLocalHandle par3) { - // (Lnet/sf/robocode/host/IHostManager;Lrobocode/control/RobotSpecification;Lnet/sf/robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/host/proxies/IHostingRobotProxy; - // (Lnet/sf/robocode/host/IHostManager;Lrobocode/control/RobotSpecification;Lnet/sf/robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/host/proxies/IHostingRobotProxy; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.dotnet.host.DotNetHost @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.FullC2J(@__env, ((global::net.sf.robocode.host.IHost)(@__real)).createRobotProxy(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0), global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par1), global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par2), global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par3))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getReferencedClasses1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String; - // (Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.dotnet.host.DotNetHost @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.ArrayStrongCp2J(@__env, ((global::net.sf.robocode.host.IHost)(@__real)).getReferencedClasses(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRobotType2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, bool par1, bool par2) { - // (Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType; - // (Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.dotnet.host.DotNetHost @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.host.IHost)(@__real)).getRobotType(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0), par1, par2)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle createRobotProxy3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle hostManager, global::net.sf.jni4net.utils.JniLocalHandle robotSpecification, global::net.sf.jni4net.utils.JniLocalHandle statics, global::net.sf.jni4net.utils.JniLocalHandle peer) { - // (Lnet/sf/robocode/host/IHostManager;Ljava/lang/Object;Lnet/sf/robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/host/proxies/IHostingRobotProxy; - // (Lnet/sf/robocode/host/IHostManager;Ljava/lang/Object;Lnet/sf/robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/host/proxies/IHostingRobotProxy; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.dotnet.host.DotNetHost @__real = global::net.sf.jni4net.utils.Convertor.StrongJp2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.FullC2J(@__env, @__real.createRobotProxy(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, hostManager), global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, robotSpecification), global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, statics), global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, peer))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static void @__ctorDotNetHost0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.dotnet.host.DotNetHost @__real = new global::net.sf.robocode.dotnet.host.DotNetHost(); - global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.dotnet.host.@__DotNetHost(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/dotnet/nhost/ModuleN.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/dotnet/nhost/ModuleN.generated.cs deleted file mode 100644 index 27b66cc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/dotnet/nhost/ModuleN.generated.cs +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.dotnet.nhost { - - - #region Component Designer generated code - public partial class ModuleN_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.dotnet.nhost.@__ModuleN.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.dotnet.nhost.ModuleN), typeof(global::net.sf.robocode.dotnet.nhost.ModuleN_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.dotnet.nhost.ModuleN), typeof(global::net.sf.robocode.dotnet.nhost.ModuleN_))] - internal sealed partial class @__ModuleN : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - private @__ModuleN(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.dotnet.nhost.@__ModuleN.staticClass = @__class; - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__ModuleN); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "InitN", "InitN0", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "__ctorModuleN0", "__ctorModuleN0", "(Lnet/sf/jni4net/inj/IClrProxy;)V")); - return methods; - } - - private static void InitN0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.dotnet.nhost.ModuleN.InitN(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void @__ctorModuleN0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.dotnet.nhost.ModuleN @__real = new global::net.sf.robocode.dotnet.nhost.ModuleN(); - global::net.sf.jni4net.utils.Convertor.InitProxy(@__env, @__obj, @__real); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.dotnet.nhost.@__ModuleN(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/dotnet/repository/root/DllRootHelper.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/dotnet/repository/root/DllRootHelper.generated.cs deleted file mode 100644 index c0c5016..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/dotnet/repository/root/DllRootHelper.generated.cs +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.dotnet.repository.root { - - - #region Component Designer generated code - public partial class DllRootHelper_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.dotnet.repository.root.@__DllRootHelper.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.dotnet.repository.root.DllRootHelper), typeof(global::net.sf.robocode.dotnet.repository.root.DllRootHelper_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.dotnet.repository.root.DllRootHelper), typeof(global::net.sf.robocode.dotnet.repository.root.DllRootHelper_))] - internal sealed partial class @__DllRootHelper : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - private @__DllRootHelper(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.dotnet.repository.root.@__DllRootHelper.staticClass = @__class; - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__DllRootHelper); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "Open", "Open0", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "Close", "Close1", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "findItems", "findItems2", "(Ljava/lang/String;)[Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "GetRobotType", "GetRobotType3", "(Lnet/sf/robocode/repository/IRobotItem;)Lnet/sf/robocode/repository/RobotType;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "GetDllFileName", "GetDllFileName4", "(Lnet/sf/robocode/repository/IRobotItem;)Ljava/lang/String;")); - return methods; - } - - private static void Open0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.dotnet.repository.root.DllRootHelper.Open(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void Close1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.dotnet.repository.root.DllRootHelper.Close(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static global::net.sf.jni4net.utils.JniHandle findItems2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle dllPath) { - // (Ljava/lang/String;)[Ljava/lang/String; - // (LSystem/String;)[LSystem/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - @__return = global::net.sf.jni4net.utils.Convertor.ArrayStrongC2JString(@__env, global::net.sf.robocode.dotnet.repository.root.DllRootHelper.findItems(global::net.sf.jni4net.utils.Convertor.StrongJ2CString(@__env, dllPath))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle GetRobotType3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle robotItem) { - // (Lnet/sf/robocode/repository/IRobotItem;)Lnet/sf/robocode/repository/RobotType; - // (Lnet/sf/robocode/repository/IRobotItem;)Lnet/sf/robocode/repository/RobotType; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(global::net.sf.robocode.dotnet.repository.root.DllRootHelper.GetRobotType(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, robotItem))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle GetDllFileName4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__class, global::net.sf.jni4net.utils.JniLocalHandle robotItem) { - // (Lnet/sf/robocode/repository/IRobotItem;)Ljava/lang/String; - // (Lnet/sf/robocode/repository/IRobotItem;)LSystem/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - @__return = global::net.sf.jni4net.utils.Convertor.StrongC2JString(@__env, global::net.sf.robocode.dotnet.repository.root.DllRootHelper.GetDllFileName(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, robotItem))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.dotnet.repository.root.@__DllRootHelper(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/host/IHost.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/host/IHost.generated.cs deleted file mode 100644 index d2ea4ea..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/host/IHost.generated.cs +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.host { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IHost { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/host/IHostManager;Lrobocode/control/RobotSpecification;Lnet/sf/" + - "robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/h" + - "ost/proxies/IHostingRobotProxy;")] - global::net.sf.robocode.host.proxies.IHostingRobotProxy createRobotProxy(global::net.sf.robocode.host.IHostManager par0, global::java.lang.Object par1, global::net.sf.robocode.peer.IRobotStatics par2, global::net.sf.robocode.peer.IRobotPeer par3); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String;")] - java.lang.String[] getReferencedClasses(global::net.sf.robocode.repository.IRobotItem par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType;" + - "")] - global::net.sf.robocode.repository.RobotType getRobotType(global::net.sf.robocode.repository.IRobotItem par0, bool par1, bool par2); - } - #endregion - - #region Component Designer generated code - public partial class IHost_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.host.@__IHost.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.host.IHost), typeof(global::net.sf.robocode.host.IHost_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.host.IHost), typeof(global::net.sf.robocode.host.IHost_))] - internal sealed partial class @__IHost : global::java.lang.Object, global::net.sf.robocode.host.IHost { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_createRobotProxy0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getReferencedClasses1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobotType2; - - private @__IHost(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.host.@__IHost.staticClass = @__class; - global::net.sf.robocode.host.@__IHost.j4n_createRobotProxy0 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHost.staticClass, "createRobotProxy", "(Lnet/sf/robocode/host/IHostManager;Lrobocode/control/RobotSpecification;Lnet/sf/" + - "robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/h" + - "ost/proxies/IHostingRobotProxy;"); - global::net.sf.robocode.host.@__IHost.j4n_getReferencedClasses1 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHost.staticClass, "getReferencedClasses", "(Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String;"); - global::net.sf.robocode.host.@__IHost.j4n_getRobotType2 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHost.staticClass, "getRobotType", "(Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType;" + - ""); - } - - public global::net.sf.robocode.host.proxies.IHostingRobotProxy createRobotProxy(global::net.sf.robocode.host.IHostManager par0, global::java.lang.Object par1, global::net.sf.robocode.peer.IRobotStatics par2, global::net.sf.robocode.peer.IRobotPeer par3) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 18)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.host.@__IHost.j4n_createRobotProxy0, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par2), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par3))); - } - } - - public java.lang.String[] getReferencedClasses(global::net.sf.robocode.repository.IRobotItem par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.host.@__IHost.j4n_getReferencedClasses1, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0))); - } - } - - public global::net.sf.robocode.repository.RobotType getRobotType(global::net.sf.robocode.repository.IRobotItem par0, bool par1, bool par2) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.host.@__IHost.j4n_getRobotType2, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2))); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IHost); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "createRobotProxy", "createRobotProxy0", "(Lnet/sf/robocode/host/IHostManager;Lrobocode/control/RobotSpecification;Lnet/sf/" + - "robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/h" + - "ost/proxies/IHostingRobotProxy;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getReferencedClasses", "getReferencedClasses1", "(Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRobotType", "getRobotType2", "(Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType;" + - "")); - return methods; - } - - private static global::net.sf.jni4net.utils.JniHandle createRobotProxy0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, global::net.sf.jni4net.utils.JniLocalHandle par1, global::net.sf.jni4net.utils.JniLocalHandle par2, global::net.sf.jni4net.utils.JniLocalHandle par3) { - // (Lnet/sf/robocode/host/IHostManager;Lrobocode/control/RobotSpecification;Lnet/sf/robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/host/proxies/IHostingRobotProxy; - // (Lnet/sf/robocode/host/IHostManager;Ljava/lang/Object;Lnet/sf/robocode/peer/IRobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Lnet/sf/robocode/host/proxies/IHostingRobotProxy; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.host.IHost @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.FullC2J(@__env, @__real.createRobotProxy(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0), global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par1), global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par2), global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par3))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getReferencedClasses1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String; - // (Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.host.IHost @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.ArrayStrongCp2J(@__env, @__real.getReferencedClasses(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRobotType2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, bool par1, bool par2) { - // (Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType; - // (Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.host.IHost @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getRobotType(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0), par1, par2)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.host.@__IHost(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/host/IHostManager.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/host/IHostManager.generated.cs deleted file mode 100644 index f8aa9fd..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/host/IHostManager.generated.cs +++ /dev/null @@ -1,323 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.host { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IHostManager { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - void cleanup(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/RobotSpecification;Lnet/sf/robocode/host/RobotStatics;Lnet/sf/" + - "robocode/peer/IRobotPeer;)Ljava/lang/Object;")] - global::java.lang.Object createRobotProxy(global::java.lang.Object par0, global::java.lang.Object par1, global::net.sf.robocode.peer.IRobotPeer par2); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String;")] - java.lang.String[] getReferencedClasses(global::net.sf.robocode.repository.IRobotItem par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType;" + - "")] - global::net.sf.robocode.repository.RobotType getRobotType(global::net.sf.robocode.repository.IRobotItem par0, bool par1, bool par2); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - void initSecurity(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()J")] - long getRobotFilesystemQuota(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - void resetThreadManager(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/Thread;)V")] - void addSafeThread(global::java.lang.Object par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/Thread;)V")] - void removeSafeThread(global::java.lang.Object par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/io/PrintStream;")] - global::java.io.PrintStream getRobotOutputStream(); - } - #endregion - - #region Component Designer generated code - public partial class IHostManager_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.host.@__IHostManager.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.host.IHostManager), typeof(global::net.sf.robocode.host.IHostManager_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.host.IHostManager), typeof(global::net.sf.robocode.host.IHostManager_))] - internal sealed partial class @__IHostManager : global::java.lang.Object, global::net.sf.robocode.host.IHostManager { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_cleanup0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_createRobotProxy1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getReferencedClasses2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobotType3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_initSecurity4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobotFilesystemQuota5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_resetThreadManager6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_addSafeThread7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_removeSafeThread8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobotOutputStream9; - - private @__IHostManager(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.host.@__IHostManager.staticClass = @__class; - global::net.sf.robocode.host.@__IHostManager.j4n_cleanup0 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHostManager.staticClass, "cleanup", "()V"); - global::net.sf.robocode.host.@__IHostManager.j4n_createRobotProxy1 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHostManager.staticClass, "createRobotProxy", "(Lrobocode/control/RobotSpecification;Lnet/sf/robocode/host/RobotStatics;Lnet/sf/" + - "robocode/peer/IRobotPeer;)Ljava/lang/Object;"); - global::net.sf.robocode.host.@__IHostManager.j4n_getReferencedClasses2 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHostManager.staticClass, "getReferencedClasses", "(Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String;"); - global::net.sf.robocode.host.@__IHostManager.j4n_getRobotType3 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHostManager.staticClass, "getRobotType", "(Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType;" + - ""); - global::net.sf.robocode.host.@__IHostManager.j4n_initSecurity4 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHostManager.staticClass, "initSecurity", "()V"); - global::net.sf.robocode.host.@__IHostManager.j4n_getRobotFilesystemQuota5 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHostManager.staticClass, "getRobotFilesystemQuota", "()J"); - global::net.sf.robocode.host.@__IHostManager.j4n_resetThreadManager6 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHostManager.staticClass, "resetThreadManager", "()V"); - global::net.sf.robocode.host.@__IHostManager.j4n_addSafeThread7 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHostManager.staticClass, "addSafeThread", "(Ljava/lang/Thread;)V"); - global::net.sf.robocode.host.@__IHostManager.j4n_removeSafeThread8 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHostManager.staticClass, "removeSafeThread", "(Ljava/lang/Thread;)V"); - global::net.sf.robocode.host.@__IHostManager.j4n_getRobotOutputStream9 = @__env.GetMethodID(global::net.sf.robocode.host.@__IHostManager.staticClass, "getRobotOutputStream", "()Ljava/io/PrintStream;"); - } - - public void cleanup() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.host.@__IHostManager.j4n_cleanup0); - } - } - - public global::java.lang.Object createRobotProxy(global::java.lang.Object par0, global::java.lang.Object par1, global::net.sf.robocode.peer.IRobotPeer par2) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.host.@__IHostManager.j4n_createRobotProxy1, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par2))); - } - } - - public java.lang.String[] getReferencedClasses(global::net.sf.robocode.repository.IRobotItem par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.host.@__IHostManager.j4n_getReferencedClasses2, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0))); - } - } - - public global::net.sf.robocode.repository.RobotType getRobotType(global::net.sf.robocode.repository.IRobotItem par0, bool par1, bool par2) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.host.@__IHostManager.j4n_getRobotType3, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2))); - } - } - - public void initSecurity() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.host.@__IHostManager.j4n_initSecurity4); - } - } - - public long getRobotFilesystemQuota() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((long)(@__env.CallLongMethod(this, global::net.sf.robocode.host.@__IHostManager.j4n_getRobotFilesystemQuota5))); - } - } - - public void resetThreadManager() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.host.@__IHostManager.j4n_resetThreadManager6); - } - } - - public void addSafeThread(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.host.@__IHostManager.j4n_addSafeThread7, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void removeSafeThread(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.host.@__IHostManager.j4n_removeSafeThread8, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public global::java.io.PrintStream getRobotOutputStream() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.host.@__IHostManager.j4n_getRobotOutputStream9)); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IHostManager); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "cleanup", "cleanup0", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "createRobotProxy", "createRobotProxy1", "(Lrobocode/control/RobotSpecification;Lnet/sf/robocode/host/RobotStatics;Lnet/sf/" + - "robocode/peer/IRobotPeer;)Ljava/lang/Object;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getReferencedClasses", "getReferencedClasses2", "(Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRobotType", "getRobotType3", "(Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType;" + - "")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "initSecurity", "initSecurity4", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRobotFilesystemQuota", "getRobotFilesystemQuota5", "()J")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "resetThreadManager", "resetThreadManager6", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "addSafeThread", "addSafeThread7", "(Ljava/lang/Thread;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "removeSafeThread", "removeSafeThread8", "(Ljava/lang/Thread;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRobotOutputStream", "getRobotOutputStream9", "()Ljava/io/PrintStream;")); - return methods; - } - - private static void cleanup0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.host.IHostManager @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.cleanup(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static global::net.sf.jni4net.utils.JniHandle createRobotProxy1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, global::net.sf.jni4net.utils.JniLocalHandle par1, global::net.sf.jni4net.utils.JniLocalHandle par2) { - // (Lrobocode/control/RobotSpecification;Lnet/sf/robocode/host/RobotStatics;Lnet/sf/robocode/peer/IRobotPeer;)Ljava/lang/Object; - // (Ljava/lang/Object;Ljava/lang/Object;Lnet/sf/robocode/peer/IRobotPeer;)Ljava/lang/Object; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.host.IHostManager @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.FullC2J(@__env, @__real.createRobotProxy(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0), global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par1), global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par2))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getReferencedClasses2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String; - // (Lnet/sf/robocode/repository/IRobotItem;)[Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.host.IHostManager @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.ArrayStrongCp2J(@__env, @__real.getReferencedClasses(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRobotType3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, bool par1, bool par2) { - // (Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType; - // (Lnet/sf/robocode/repository/IRobotItem;ZZ)Lnet/sf/robocode/repository/RobotType; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.host.IHostManager @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getRobotType(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0), par1, par2)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static void initSecurity4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.host.IHostManager @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.initSecurity(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static long getRobotFilesystemQuota5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()J - // ()J - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - long @__return = default(long); - try { - global::net.sf.robocode.host.IHostManager @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((long)(@__real.getRobotFilesystemQuota())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static void resetThreadManager6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.host.IHostManager @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.resetThreadManager(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void addSafeThread7(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Ljava/lang/Thread;)V - // (Ljava/lang/Object;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.host.IHostManager @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.addSafeThread(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void removeSafeThread8(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Ljava/lang/Thread;)V - // (Ljava/lang/Object;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.host.IHostManager @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.removeSafeThread(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static global::net.sf.jni4net.utils.JniHandle getRobotOutputStream9(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/io/PrintStream; - // ()Ljava/io/PrintStream; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.host.IHostManager @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getRobotOutputStream()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.host.@__IHostManager(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/host/proxies/IHostingRobotProxy.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/host/proxies/IHostingRobotProxy.generated.cs deleted file mode 100644 index 9ee4cf0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/host/proxies/IHostingRobotProxy.generated.cs +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.host.proxies { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IHostingRobotProxy { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - void cleanup(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/peer/ExecCommands;Lrobocode/RobotStatus;)V")] - void startRound(global::java.lang.Object par0, global::java.lang.Object par1); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - void forceStopThread(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - void waitForStopThread(); - } - #endregion - - #region Component Designer generated code - public partial class IHostingRobotProxy_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.host.proxies.IHostingRobotProxy), typeof(global::net.sf.robocode.host.proxies.IHostingRobotProxy_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.host.proxies.IHostingRobotProxy), typeof(global::net.sf.robocode.host.proxies.IHostingRobotProxy_))] - internal sealed partial class @__IHostingRobotProxy : global::java.lang.Object, global::net.sf.robocode.host.proxies.IHostingRobotProxy { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_cleanup0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_startRound1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_forceStopThread2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_waitForStopThread3; - - private @__IHostingRobotProxy(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.staticClass = @__class; - global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.j4n_cleanup0 = @__env.GetMethodID(global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.staticClass, "cleanup", "()V"); - global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.j4n_startRound1 = @__env.GetMethodID(global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.staticClass, "startRound", "(Lnet/sf/robocode/peer/ExecCommands;Lrobocode/RobotStatus;)V"); - global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.j4n_forceStopThread2 = @__env.GetMethodID(global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.staticClass, "forceStopThread", "()V"); - global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.j4n_waitForStopThread3 = @__env.GetMethodID(global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.staticClass, "waitForStopThread", "()V"); - } - - public void cleanup() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.j4n_cleanup0); - } - } - - public void startRound(global::java.lang.Object par0, global::java.lang.Object par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.j4n_startRound1, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1)); - } - } - - public void forceStopThread() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.j4n_forceStopThread2); - } - } - - public void waitForStopThread() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.host.proxies.@__IHostingRobotProxy.j4n_waitForStopThread3); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IHostingRobotProxy); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "cleanup", "cleanup0", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "startRound", "startRound1", "(Lnet/sf/robocode/peer/ExecCommands;Lrobocode/RobotStatus;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "forceStopThread", "forceStopThread2", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "waitForStopThread", "waitForStopThread3", "()V")); - return methods; - } - - private static void cleanup0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.host.proxies.IHostingRobotProxy @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.cleanup(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void startRound1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, global::net.sf.jni4net.utils.JniLocalHandle par1) { - // (Lnet/sf/robocode/peer/ExecCommands;Lrobocode/RobotStatus;)V - // (Ljava/lang/Object;Ljava/lang/Object;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.host.proxies.IHostingRobotProxy @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.startRound(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0), global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par1)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void forceStopThread2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.host.proxies.IHostingRobotProxy @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.forceStopThread(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void waitForStopThread3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.host.proxies.IHostingRobotProxy @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.waitForStopThread(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.host.proxies.@__IHostingRobotProxy(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/io/Logger.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/io/Logger.generated.cs deleted file mode 100644 index ed6fce7..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/io/Logger.generated.cs +++ /dev/null @@ -1,175 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.io { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class Logger : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_logError0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_logError1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_logError2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setLogListener3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_logMessage4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_logMessage5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_logWarning6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_printlnToRobotsConsole7; - - internal static global::net.sf.jni4net.jni.FieldId j4n_realOut8; - - internal static global::net.sf.jni4net.jni.FieldId j4n_realErr9; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorLogger10; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public Logger() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n__ctorLogger10, this); - } - } - - protected Logger(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.io.Logger.staticClass; - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Ljava/io/PrintStream;")] - public static global::java.io.PrintStream realOut { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n_realOut8)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Ljava/io/PrintStream;")] - public static global::java.io.PrintStream realErr { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n_realErr9)); - } - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.io.Logger.staticClass = @__class; - global::net.sf.robocode.io.Logger.j4n_logError0 = @__env.GetStaticMethodID(global::net.sf.robocode.io.Logger.staticClass, "logError", "(Ljava/lang/Throwable;)V"); - global::net.sf.robocode.io.Logger.j4n_logError1 = @__env.GetStaticMethodID(global::net.sf.robocode.io.Logger.staticClass, "logError", "(Ljava/lang/String;)V"); - global::net.sf.robocode.io.Logger.j4n_logError2 = @__env.GetStaticMethodID(global::net.sf.robocode.io.Logger.staticClass, "logError", "(Ljava/lang/String;Ljava/lang/Throwable;)V"); - global::net.sf.robocode.io.Logger.j4n_setLogListener3 = @__env.GetStaticMethodID(global::net.sf.robocode.io.Logger.staticClass, "setLogListener", "(Lrobocode/control/events/IBattleListener;)V"); - global::net.sf.robocode.io.Logger.j4n_logMessage4 = @__env.GetStaticMethodID(global::net.sf.robocode.io.Logger.staticClass, "logMessage", "(Ljava/lang/String;Z)V"); - global::net.sf.robocode.io.Logger.j4n_logMessage5 = @__env.GetStaticMethodID(global::net.sf.robocode.io.Logger.staticClass, "logMessage", "(Ljava/lang/String;)V"); - global::net.sf.robocode.io.Logger.j4n_logWarning6 = @__env.GetStaticMethodID(global::net.sf.robocode.io.Logger.staticClass, "logWarning", "(Ljava/lang/String;)V"); - global::net.sf.robocode.io.Logger.j4n_printlnToRobotsConsole7 = @__env.GetStaticMethodID(global::net.sf.robocode.io.Logger.staticClass, "printlnToRobotsConsole", "(Ljava/lang/String;)V"); - global::net.sf.robocode.io.Logger.j4n_realOut8 = @__env.GetStaticFieldID(global::net.sf.robocode.io.Logger.staticClass, "realOut", "Ljava/io/PrintStream;"); - global::net.sf.robocode.io.Logger.j4n_realErr9 = @__env.GetStaticFieldID(global::net.sf.robocode.io.Logger.staticClass, "realErr", "Ljava/io/PrintStream;"); - global::net.sf.robocode.io.Logger.j4n__ctorLogger10 = @__env.GetMethodID(global::net.sf.robocode.io.Logger.staticClass, "", "()V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/Throwable;)V")] - public static void logError(global::java.lang.Throwable par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n_logError0, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)V")] - public static void logError(global::java.lang.String par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n_logError1, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;Ljava/lang/Throwable;)V")] - public static void logError(global::java.lang.String par0, global::java.lang.Throwable par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n_logError2, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/events/IBattleListener;)V")] - public static void setLogListener(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n_setLogListener3, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;Z)V")] - public static void logMessage(global::java.lang.String par0, bool par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n_logMessage4, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)V")] - public static void logMessage(global::java.lang.String par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n_logMessage5, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)V")] - public static void logWarning(global::java.lang.String par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n_logWarning6, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)V")] - public static void printlnToRobotsConsole(global::java.lang.String par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.io.Logger.staticClass, global::net.sf.robocode.io.Logger.j4n_printlnToRobotsConsole7, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.io.Logger(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/manager/IVersionManagerBase.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/manager/IVersionManagerBase.generated.cs deleted file mode 100644 index 70279dc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/manager/IVersionManagerBase.generated.cs +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.manager { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IVersionManagerBase { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getVersion(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - int getVersionAsInt(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getVersionN(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isLastRunVersionChanged(); - } - #endregion - - #region Component Designer generated code - public partial class IVersionManagerBase_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.manager.@__IVersionManagerBase.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.manager.IVersionManagerBase), typeof(global::net.sf.robocode.manager.IVersionManagerBase_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.manager.IVersionManagerBase), typeof(global::net.sf.robocode.manager.IVersionManagerBase_))] - internal sealed partial class @__IVersionManagerBase : global::java.lang.Object, global::net.sf.robocode.manager.IVersionManagerBase { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getVersion0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getVersionAsInt1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getVersionN2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isLastRunVersionChanged3; - - private @__IVersionManagerBase(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.manager.@__IVersionManagerBase.staticClass = @__class; - global::net.sf.robocode.manager.@__IVersionManagerBase.j4n_getVersion0 = @__env.GetMethodID(global::net.sf.robocode.manager.@__IVersionManagerBase.staticClass, "getVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.manager.@__IVersionManagerBase.j4n_getVersionAsInt1 = @__env.GetMethodID(global::net.sf.robocode.manager.@__IVersionManagerBase.staticClass, "getVersionAsInt", "()I"); - global::net.sf.robocode.manager.@__IVersionManagerBase.j4n_getVersionN2 = @__env.GetMethodID(global::net.sf.robocode.manager.@__IVersionManagerBase.staticClass, "getVersionN", "()Ljava/lang/String;"); - global::net.sf.robocode.manager.@__IVersionManagerBase.j4n_isLastRunVersionChanged3 = @__env.GetMethodID(global::net.sf.robocode.manager.@__IVersionManagerBase.staticClass, "isLastRunVersionChanged", "()Z"); - } - - public global::java.lang.String getVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.manager.@__IVersionManagerBase.j4n_getVersion0)); - } - } - - public int getVersionAsInt() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::net.sf.robocode.manager.@__IVersionManagerBase.j4n_getVersionAsInt1))); - } - } - - public global::java.lang.String getVersionN() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.manager.@__IVersionManagerBase.j4n_getVersionN2)); - } - } - - public bool isLastRunVersionChanged() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.manager.@__IVersionManagerBase.j4n_isLastRunVersionChanged3))); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IVersionManagerBase); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getVersion", "getVersion0", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getVersionAsInt", "getVersionAsInt1", "()I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getVersionN", "getVersionN2", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isLastRunVersionChanged", "isLastRunVersionChanged3", "()Z")); - return methods; - } - - private static global::net.sf.jni4net.utils.JniHandle getVersion0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.manager.IVersionManagerBase @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int getVersionAsInt1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()I - // ()I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::net.sf.robocode.manager.IVersionManagerBase @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.getVersionAsInt())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getVersionN2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.manager.IVersionManagerBase @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getVersionN()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isLastRunVersionChanged3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.manager.IVersionManagerBase @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isLastRunVersionChanged())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.manager.@__IVersionManagerBase(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/peer/BadBehavior.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/peer/BadBehavior.generated.cs deleted file mode 100644 index a794055..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/peer/BadBehavior.generated.cs +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.peer { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class BadBehavior : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_valueOf0; - - internal static global::net.sf.jni4net.jni.FieldId j4n_CANNOT_START1; - - internal static global::net.sf.jni4net.jni.FieldId j4n_SKIPPED_TOO_MANY_TURNS2; - - internal static global::net.sf.jni4net.jni.FieldId j4n_UNSTOPPABLE3; - - internal static global::net.sf.jni4net.jni.FieldId j4n_SECURITY_VIOLATION4; - - protected BadBehavior(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.peer.BadBehavior.staticClass; - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lnet/sf/robocode/peer/BadBehavior;")] - public static global::net.sf.robocode.peer.BadBehavior CANNOT_START { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::net.sf.robocode.peer.BadBehavior.staticClass, global::net.sf.robocode.peer.BadBehavior.j4n_CANNOT_START1)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lnet/sf/robocode/peer/BadBehavior;")] - public static global::net.sf.robocode.peer.BadBehavior SKIPPED_TOO_MANY_TURNS { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::net.sf.robocode.peer.BadBehavior.staticClass, global::net.sf.robocode.peer.BadBehavior.j4n_SKIPPED_TOO_MANY_TURNS2)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lnet/sf/robocode/peer/BadBehavior;")] - public static global::net.sf.robocode.peer.BadBehavior UNSTOPPABLE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::net.sf.robocode.peer.BadBehavior.staticClass, global::net.sf.robocode.peer.BadBehavior.j4n_UNSTOPPABLE3)); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lnet/sf/robocode/peer/BadBehavior;")] - public static global::net.sf.robocode.peer.BadBehavior SECURITY_VIOLATION { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::net.sf.robocode.peer.BadBehavior.staticClass, global::net.sf.robocode.peer.BadBehavior.j4n_SECURITY_VIOLATION4)); - } - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.peer.BadBehavior.staticClass = @__class; - global::net.sf.robocode.peer.BadBehavior.j4n_valueOf0 = @__env.GetStaticMethodID(global::net.sf.robocode.peer.BadBehavior.staticClass, "valueOf", "(Ljava/lang/String;)Lnet/sf/robocode/peer/BadBehavior;"); - global::net.sf.robocode.peer.BadBehavior.j4n_CANNOT_START1 = @__env.GetStaticFieldID(global::net.sf.robocode.peer.BadBehavior.staticClass, "CANNOT_START", "Lnet/sf/robocode/peer/BadBehavior;"); - global::net.sf.robocode.peer.BadBehavior.j4n_SKIPPED_TOO_MANY_TURNS2 = @__env.GetStaticFieldID(global::net.sf.robocode.peer.BadBehavior.staticClass, "SKIPPED_TOO_MANY_TURNS", "Lnet/sf/robocode/peer/BadBehavior;"); - global::net.sf.robocode.peer.BadBehavior.j4n_UNSTOPPABLE3 = @__env.GetStaticFieldID(global::net.sf.robocode.peer.BadBehavior.staticClass, "UNSTOPPABLE", "Lnet/sf/robocode/peer/BadBehavior;"); - global::net.sf.robocode.peer.BadBehavior.j4n_SECURITY_VIOLATION4 = @__env.GetStaticFieldID(global::net.sf.robocode.peer.BadBehavior.staticClass, "SECURITY_VIOLATION", "Lnet/sf/robocode/peer/BadBehavior;"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)Lnet/sf/robocode/peer/BadBehavior;")] - public static global::net.sf.robocode.peer.BadBehavior valueOf(global::java.lang.String par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::net.sf.robocode.peer.BadBehavior.staticClass, global::net.sf.robocode.peer.BadBehavior.j4n_valueOf0, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.peer.BadBehavior(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/peer/IRobotPeer.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/peer/IRobotPeer.generated.cs deleted file mode 100644 index e3e1c34..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/peer/IRobotPeer.generated.cs +++ /dev/null @@ -1,313 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.peer { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IRobotPeer { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - void drainEnergy(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/peer/BadBehavior;)V")] - void punishBadBehavior(global::net.sf.robocode.peer.BadBehavior par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Z)V")] - void setRunning(bool par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isRunning(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/peer/ExecCommands;)Lnet/sf/robocode/peer/ExecResults;")] - global::java.lang.Object waitForBattleEndImpl(global::java.lang.Object par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/peer/ExecCommands;)Lnet/sf/robocode/peer/ExecResults;")] - global::java.lang.Object executeImpl(global::java.lang.Object par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)V")] - void setupBuffer(global::java.nio.ByteBuffer par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - void executeImplSerial(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - void waitForBattleEndImplSerial(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - void setupThread(); - } - #endregion - - #region Component Designer generated code - public partial class IRobotPeer_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.peer.@__IRobotPeer.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.peer.IRobotPeer), typeof(global::net.sf.robocode.peer.IRobotPeer_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.peer.IRobotPeer), typeof(global::net.sf.robocode.peer.IRobotPeer_))] - internal sealed partial class @__IRobotPeer : global::java.lang.Object, global::net.sf.robocode.peer.IRobotPeer { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_drainEnergy0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_punishBadBehavior1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setRunning2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isRunning3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_waitForBattleEndImpl4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_executeImpl5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setupBuffer6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_executeImplSerial7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_waitForBattleEndImplSerial8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setupThread9; - - private @__IRobotPeer(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.peer.@__IRobotPeer.staticClass = @__class; - global::net.sf.robocode.peer.@__IRobotPeer.j4n_drainEnergy0 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotPeer.staticClass, "drainEnergy", "()V"); - global::net.sf.robocode.peer.@__IRobotPeer.j4n_punishBadBehavior1 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotPeer.staticClass, "punishBadBehavior", "(Lnet/sf/robocode/peer/BadBehavior;)V"); - global::net.sf.robocode.peer.@__IRobotPeer.j4n_setRunning2 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotPeer.staticClass, "setRunning", "(Z)V"); - global::net.sf.robocode.peer.@__IRobotPeer.j4n_isRunning3 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotPeer.staticClass, "isRunning", "()Z"); - global::net.sf.robocode.peer.@__IRobotPeer.j4n_waitForBattleEndImpl4 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotPeer.staticClass, "waitForBattleEndImpl", "(Lnet/sf/robocode/peer/ExecCommands;)Lnet/sf/robocode/peer/ExecResults;"); - global::net.sf.robocode.peer.@__IRobotPeer.j4n_executeImpl5 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotPeer.staticClass, "executeImpl", "(Lnet/sf/robocode/peer/ExecCommands;)Lnet/sf/robocode/peer/ExecResults;"); - global::net.sf.robocode.peer.@__IRobotPeer.j4n_setupBuffer6 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotPeer.staticClass, "setupBuffer", "(Ljava/nio/ByteBuffer;)V"); - global::net.sf.robocode.peer.@__IRobotPeer.j4n_executeImplSerial7 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotPeer.staticClass, "executeImplSerial", "()V"); - global::net.sf.robocode.peer.@__IRobotPeer.j4n_waitForBattleEndImplSerial8 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotPeer.staticClass, "waitForBattleEndImplSerial", "()V"); - global::net.sf.robocode.peer.@__IRobotPeer.j4n_setupThread9 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotPeer.staticClass, "setupThread", "()V"); - } - - public void drainEnergy() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.peer.@__IRobotPeer.j4n_drainEnergy0); - } - } - - public void punishBadBehavior(global::net.sf.robocode.peer.BadBehavior par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.peer.@__IRobotPeer.j4n_punishBadBehavior1, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void setRunning(bool par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.peer.@__IRobotPeer.j4n_setRunning2, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - public bool isRunning() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.peer.@__IRobotPeer.j4n_isRunning3))); - } - } - - public global::java.lang.Object waitForBattleEndImpl(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.peer.@__IRobotPeer.j4n_waitForBattleEndImpl4, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - public global::java.lang.Object executeImpl(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.peer.@__IRobotPeer.j4n_executeImpl5, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - public void setupBuffer(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.peer.@__IRobotPeer.j4n_setupBuffer6, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - public void executeImplSerial() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.peer.@__IRobotPeer.j4n_executeImplSerial7); - } - } - - public void waitForBattleEndImplSerial() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.peer.@__IRobotPeer.j4n_waitForBattleEndImplSerial8); - } - } - - public void setupThread() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.peer.@__IRobotPeer.j4n_setupThread9); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IRobotPeer); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "drainEnergy", "drainEnergy0", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "punishBadBehavior", "punishBadBehavior1", "(Lnet/sf/robocode/peer/BadBehavior;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "setRunning", "setRunning2", "(Z)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isRunning", "isRunning3", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "waitForBattleEndImpl", "waitForBattleEndImpl4", "(Lnet/sf/robocode/peer/ExecCommands;)Lnet/sf/robocode/peer/ExecResults;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "executeImpl", "executeImpl5", "(Lnet/sf/robocode/peer/ExecCommands;)Lnet/sf/robocode/peer/ExecResults;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "setupBuffer", "setupBuffer6", "(Ljava/nio/ByteBuffer;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "executeImplSerial", "executeImplSerial7", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "waitForBattleEndImplSerial", "waitForBattleEndImplSerial8", "()V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "setupThread", "setupThread9", "()V")); - return methods; - } - - private static void drainEnergy0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.peer.IRobotPeer @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.drainEnergy(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void punishBadBehavior1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lnet/sf/robocode/peer/BadBehavior;)V - // (Lnet/sf/robocode/peer/BadBehavior;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.peer.IRobotPeer @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.punishBadBehavior(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void setRunning2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, bool par0) { - // (Z)V - // (Z)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.peer.IRobotPeer @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.setRunning(par0); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static bool isRunning3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.peer.IRobotPeer @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isRunning())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle waitForBattleEndImpl4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lnet/sf/robocode/peer/ExecCommands;)Lnet/sf/robocode/peer/ExecResults; - // (Ljava/lang/Object;)Ljava/lang/Object; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.peer.IRobotPeer @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.waitForBattleEndImpl(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle executeImpl5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Lnet/sf/robocode/peer/ExecCommands;)Lnet/sf/robocode/peer/ExecResults; - // (Ljava/lang/Object;)Ljava/lang/Object; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.peer.IRobotPeer @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.executeImpl(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static void setupBuffer6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Ljava/nio/ByteBuffer;)V - // (Ljava/nio/ByteBuffer;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.peer.IRobotPeer @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.setupBuffer(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void executeImplSerial7(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.peer.IRobotPeer @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.executeImplSerial(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void waitForBattleEndImplSerial8(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.peer.IRobotPeer @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.waitForBattleEndImplSerial(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static void setupThread9(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()V - // ()V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.peer.IRobotPeer @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.setupThread(); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.peer.@__IRobotPeer(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/peer/IRobotStatics.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/peer/IRobotStatics.generated.cs deleted file mode 100644 index 50f44bd..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/peer/IRobotStatics.generated.cs +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.peer { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IRobotStatics { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isAdvancedRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isTeamRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isInteractiveRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isPaintRobot(); - } - #endregion - - #region Component Designer generated code - public partial class IRobotStatics_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.peer.@__IRobotStatics.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.peer.IRobotStatics), typeof(global::net.sf.robocode.peer.IRobotStatics_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.peer.IRobotStatics), typeof(global::net.sf.robocode.peer.IRobotStatics_))] - internal sealed partial class @__IRobotStatics : global::java.lang.Object, global::net.sf.robocode.peer.IRobotStatics { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isAdvancedRobot0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isTeamRobot1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isInteractiveRobot2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isPaintRobot3; - - private @__IRobotStatics(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.peer.@__IRobotStatics.staticClass = @__class; - global::net.sf.robocode.peer.@__IRobotStatics.j4n_isAdvancedRobot0 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotStatics.staticClass, "isAdvancedRobot", "()Z"); - global::net.sf.robocode.peer.@__IRobotStatics.j4n_isTeamRobot1 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotStatics.staticClass, "isTeamRobot", "()Z"); - global::net.sf.robocode.peer.@__IRobotStatics.j4n_isInteractiveRobot2 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotStatics.staticClass, "isInteractiveRobot", "()Z"); - global::net.sf.robocode.peer.@__IRobotStatics.j4n_isPaintRobot3 = @__env.GetMethodID(global::net.sf.robocode.peer.@__IRobotStatics.staticClass, "isPaintRobot", "()Z"); - } - - public bool isAdvancedRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.peer.@__IRobotStatics.j4n_isAdvancedRobot0))); - } - } - - public bool isTeamRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.peer.@__IRobotStatics.j4n_isTeamRobot1))); - } - } - - public bool isInteractiveRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.peer.@__IRobotStatics.j4n_isInteractiveRobot2))); - } - } - - public bool isPaintRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.peer.@__IRobotStatics.j4n_isPaintRobot3))); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IRobotStatics); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isAdvancedRobot", "isAdvancedRobot0", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isTeamRobot", "isTeamRobot1", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isInteractiveRobot", "isInteractiveRobot2", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isPaintRobot", "isPaintRobot3", "()Z")); - return methods; - } - - private static bool isAdvancedRobot0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.peer.IRobotStatics @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isAdvancedRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isTeamRobot1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.peer.IRobotStatics @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isTeamRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isInteractiveRobot2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.peer.IRobotStatics @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isInteractiveRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isPaintRobot3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.peer.IRobotStatics @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isPaintRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.peer.@__IRobotStatics(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/repository/IRobotItem.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/repository/IRobotItem.generated.cs deleted file mode 100644 index 4c46208..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/repository/IRobotItem.generated.cs +++ /dev/null @@ -1,1045 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.repository { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IRobotItem : global::net.sf.robocode.repository.IRobotSpecItem { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getPlatform(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isJuniorRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isStandardRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isAdvancedRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isTeamRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isDroid(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isSentryRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isInteractiveRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isPaintRobot(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/net/URL;")] - global::java.net.URL getClassPathURL(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()[Ljava/net/URL;")] - java.net.URL[] getSourcePathURLs(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getWritableDirectory(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getReadableDirectory(); - } - #endregion - - #region Component Designer generated code - public partial class IRobotItem_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.repository.@__IRobotItem.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.repository.IRobotItem), typeof(global::net.sf.robocode.repository.IRobotItem_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.repository.IRobotItem), typeof(global::net.sf.robocode.repository.IRobotItem_))] - internal sealed partial class @__IRobotItem : global::java.lang.Object, global::net.sf.robocode.repository.IRobotItem { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_compareTo0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isValid1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getVersion2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isTeam3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isInJAR4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setValid5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getDescription6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getAuthorName7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getWebpage8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getIncludeSource9; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getIncludeData10; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isSourceIncluded11; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRootPath12; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getItemURL13; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isDevelopmentVersion14; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobocodeVersion15; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getFullPackage16; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRelativePath17; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRootPackage18; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getFullClassNameWithVersion19; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getUniqueFullClassName20; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getUniqueFullClassNameWithVersion21; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getUniqueShortClassNameWithVersion22; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getUniqueVeryShortClassNameWithVersion23; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getFullClassName24; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getShortClassName25; - - internal static global::net.sf.jni4net.jni.MethodId j4n_createRobotSpecification26; - - internal static global::net.sf.jni4net.jni.MethodId j4n_storeProperties27; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getPlatform28; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isJuniorRobot29; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isStandardRobot30; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isAdvancedRobot31; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isTeamRobot32; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isDroid33; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isSentryRobot34; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isInteractiveRobot35; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isPaintRobot36; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getClassPathURL37; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getSourcePathURLs38; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getWritableDirectory39; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getReadableDirectory40; - - private @__IRobotItem(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.repository.@__IRobotItem.staticClass = @__class; - global::net.sf.robocode.repository.@__IRobotItem.j4n_compareTo0 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "compareTo", "(Ljava/lang/Object;)I"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isValid1 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isValid", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getVersion2 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isTeam3 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isTeam", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isInJAR4 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isInJAR", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_setValid5 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "setValid", "(Z)V"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getDescription6 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getDescription", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getAuthorName7 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getAuthorName", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getWebpage8 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getWebpage", "()Ljava/net/URL;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getIncludeSource9 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getIncludeSource", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getIncludeData10 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getIncludeData", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isSourceIncluded11 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isSourceIncluded", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getRootPath12 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getRootPath", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getItemURL13 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getItemURL", "()Ljava/net/URL;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isDevelopmentVersion14 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isDevelopmentVersion", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getRobocodeVersion15 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getRobocodeVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getFullPackage16 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getFullPackage", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getRelativePath17 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getRelativePath", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getRootPackage18 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getRootPackage", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getFullClassNameWithVersion19 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getFullClassNameWithVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getUniqueFullClassName20 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getUniqueFullClassName", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getUniqueFullClassNameWithVersion21 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getUniqueFullClassNameWithVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getUniqueShortClassNameWithVersion22 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getUniqueShortClassNameWithVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getUniqueVeryShortClassNameWithVersion23 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getUniqueVeryShortClassNameWithVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getFullClassName24 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getFullClassName", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getShortClassName25 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getShortClassName", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_createRobotSpecification26 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "createRobotSpecification", "()Lrobocode/control/RobotSpecification;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_storeProperties27 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "storeProperties", "(Ljava/io/OutputStream;Lnet/sf/robocode/repository/RobotProperties;)V"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getPlatform28 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getPlatform", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isJuniorRobot29 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isJuniorRobot", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isStandardRobot30 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isStandardRobot", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isAdvancedRobot31 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isAdvancedRobot", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isTeamRobot32 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isTeamRobot", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isDroid33 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isDroid", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isSentryRobot34 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isSentryRobot", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isInteractiveRobot35 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isInteractiveRobot", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_isPaintRobot36 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "isPaintRobot", "()Z"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getClassPathURL37 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getClassPathURL", "()Ljava/net/URL;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getSourcePathURLs38 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getSourcePathURLs", "()[Ljava/net/URL;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getWritableDirectory39 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getWritableDirectory", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotItem.j4n_getReadableDirectory40 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotItem.staticClass, "getReadableDirectory", "()Ljava/lang/String;"); - } - - public int compareTo(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((int)(@__env.CallIntMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_compareTo0, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0)))); - } - } - - public bool isValid() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isValid1))); - } - } - - public global::java.lang.String getVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getVersion2)); - } - } - - public bool isTeam() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isTeam3))); - } - } - - public bool isInJAR() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isInJAR4))); - } - } - - public void setValid(bool par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_setValid5, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - public global::java.lang.String getDescription() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getDescription6)); - } - } - - public global::java.lang.String getAuthorName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getAuthorName7)); - } - } - - public global::java.net.URL getWebpage() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getWebpage8)); - } - } - - public bool getIncludeSource() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getIncludeSource9))); - } - } - - public bool getIncludeData() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getIncludeData10))); - } - } - - public bool isSourceIncluded() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isSourceIncluded11))); - } - } - - public global::java.lang.String getRootPath() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getRootPath12)); - } - } - - public global::java.net.URL getItemURL() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getItemURL13)); - } - } - - public bool isDevelopmentVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isDevelopmentVersion14))); - } - } - - public global::java.lang.String getRobocodeVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getRobocodeVersion15)); - } - } - - public global::java.lang.String getFullPackage() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getFullPackage16)); - } - } - - public global::java.lang.String getRelativePath() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getRelativePath17)); - } - } - - public global::java.lang.String getRootPackage() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getRootPackage18)); - } - } - - public global::java.lang.String getFullClassNameWithVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getFullClassNameWithVersion19)); - } - } - - public global::java.lang.String getUniqueFullClassName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getUniqueFullClassName20)); - } - } - - public global::java.lang.String getUniqueFullClassNameWithVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getUniqueFullClassNameWithVersion21)); - } - } - - public global::java.lang.String getUniqueShortClassNameWithVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getUniqueShortClassNameWithVersion22)); - } - } - - public global::java.lang.String getUniqueVeryShortClassNameWithVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getUniqueVeryShortClassNameWithVersion23)); - } - } - - public global::java.lang.String getFullClassName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getFullClassName24)); - } - } - - public global::java.lang.String getShortClassName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getShortClassName25)); - } - } - - public global::java.lang.Object createRobotSpecification() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_createRobotSpecification26)); - } - } - - public void storeProperties(global::java.io.OutputStream par0, global::java.lang.Object par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_storeProperties27, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1)); - } - } - - public global::java.lang.String getPlatform() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getPlatform28)); - } - } - - public bool isJuniorRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isJuniorRobot29))); - } - } - - public bool isStandardRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isStandardRobot30))); - } - } - - public bool isAdvancedRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isAdvancedRobot31))); - } - } - - public bool isTeamRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isTeamRobot32))); - } - } - - public bool isDroid() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isDroid33))); - } - } - - public bool isSentryRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isSentryRobot34))); - } - } - - public bool isInteractiveRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isInteractiveRobot35))); - } - } - - public bool isPaintRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_isPaintRobot36))); - } - } - - public global::java.net.URL getClassPathURL() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getClassPathURL37)); - } - } - - public java.net.URL[] getSourcePathURLs() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.ArrayStrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getSourcePathURLs38)); - } - } - - public global::java.lang.String getWritableDirectory() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getWritableDirectory39)); - } - } - - public global::java.lang.String getReadableDirectory() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotItem.j4n_getReadableDirectory40)); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IRobotItem); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "compareTo", "compareTo0", "(Ljava/lang/Object;)I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isValid", "isValid1", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getVersion", "getVersion2", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isTeam", "isTeam3", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isInJAR", "isInJAR4", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "setValid", "setValid5", "(Z)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getDescription", "getDescription6", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getAuthorName", "getAuthorName7", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getWebpage", "getWebpage8", "()Ljava/net/URL;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getIncludeSource", "getIncludeSource9", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getIncludeData", "getIncludeData10", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isSourceIncluded", "isSourceIncluded11", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRootPath", "getRootPath12", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getItemURL", "getItemURL13", "()Ljava/net/URL;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isDevelopmentVersion", "isDevelopmentVersion14", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRobocodeVersion", "getRobocodeVersion15", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getFullPackage", "getFullPackage16", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRelativePath", "getRelativePath17", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRootPackage", "getRootPackage18", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getFullClassNameWithVersion", "getFullClassNameWithVersion19", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getUniqueFullClassName", "getUniqueFullClassName20", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getUniqueFullClassNameWithVersion", "getUniqueFullClassNameWithVersion21", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getUniqueShortClassNameWithVersion", "getUniqueShortClassNameWithVersion22", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getUniqueVeryShortClassNameWithVersion", "getUniqueVeryShortClassNameWithVersion23", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getFullClassName", "getFullClassName24", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getShortClassName", "getShortClassName25", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "createRobotSpecification", "createRobotSpecification26", "()Lrobocode/control/RobotSpecification;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "storeProperties", "storeProperties27", "(Ljava/io/OutputStream;Lnet/sf/robocode/repository/RobotProperties;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getPlatform", "getPlatform28", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isJuniorRobot", "isJuniorRobot29", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isStandardRobot", "isStandardRobot30", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isAdvancedRobot", "isAdvancedRobot31", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isTeamRobot", "isTeamRobot32", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isDroid", "isDroid33", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isSentryRobot", "isSentryRobot34", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isInteractiveRobot", "isInteractiveRobot35", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isPaintRobot", "isPaintRobot36", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getClassPathURL", "getClassPathURL37", "()Ljava/net/URL;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getSourcePathURLs", "getSourcePathURLs38", "()[Ljava/net/URL;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getWritableDirectory", "getWritableDirectory39", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getReadableDirectory", "getReadableDirectory40", "()Ljava/lang/String;")); - return methods; - } - - private static int compareTo0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Ljava/lang/Object;)I - // (Ljava/lang/Object;)I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(((global::java.lang.Comparable)(@__real)).compareTo(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0)))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isValid1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).isValid())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getVersion2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isTeam3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).isTeam())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isInJAR4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).isInJAR())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static void setValid5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, bool par0) { - // (Z)V - // (Z)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - ((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).setValid(par0); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static global::net.sf.jni4net.utils.JniHandle getDescription6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getDescription()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getAuthorName7(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getAuthorName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getWebpage8(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/net/URL; - // ()Ljava/net/URL; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getWebpage()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool getIncludeSource9(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getIncludeSource())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool getIncludeData10(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getIncludeData())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isSourceIncluded11(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).isSourceIncluded())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRootPath12(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getRootPath()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getItemURL13(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/net/URL; - // ()Ljava/net/URL; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getItemURL()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isDevelopmentVersion14(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).isDevelopmentVersion())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRobocodeVersion15(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getRobocodeVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getFullPackage16(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getFullPackage()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRelativePath17(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getRelativePath()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRootPackage18(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getRootPackage()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getFullClassNameWithVersion19(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getFullClassNameWithVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getUniqueFullClassName20(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getUniqueFullClassName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getUniqueFullClassNameWithVersion21(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getUniqueFullClassNameWithVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getUniqueShortClassNameWithVersion22(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getUniqueShortClassNameWithVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getUniqueVeryShortClassNameWithVersion23(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getUniqueVeryShortClassNameWithVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getFullClassName24(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getFullClassName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getShortClassName25(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).getShortClassName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle createRobotSpecification26(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Lrobocode/control/RobotSpecification; - // ()Ljava/lang/Object; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).createRobotSpecification()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static void storeProperties27(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, global::net.sf.jni4net.utils.JniLocalHandle par1) { - // (Ljava/io/OutputStream;Lnet/sf/robocode/repository/RobotProperties;)V - // (Ljava/io/OutputStream;Ljava/lang/Object;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - ((global::net.sf.robocode.repository.IRobotSpecItem)(@__real)).storeProperties(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0), global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par1)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static global::net.sf.jni4net.utils.JniHandle getPlatform28(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getPlatform()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isJuniorRobot29(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isJuniorRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isStandardRobot30(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isStandardRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isAdvancedRobot31(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isAdvancedRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isTeamRobot32(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isTeamRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isDroid33(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isDroid())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isSentryRobot34(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isSentryRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isInteractiveRobot35(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isInteractiveRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isPaintRobot36(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isPaintRobot())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getClassPathURL37(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/net/URL; - // ()Ljava/net/URL; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getClassPathURL()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getSourcePathURLs38(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()[Ljava/net/URL; - // ()[Ljava/net/URL; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.ArrayStrongCp2J(@__env, @__real.getSourcePathURLs()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getWritableDirectory39(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getWritableDirectory()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getReadableDirectory40(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getReadableDirectory()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.repository.@__IRobotItem(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/repository/IRobotSpecItem.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/repository/IRobotSpecItem.generated.cs deleted file mode 100644 index 5200f27..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/repository/IRobotSpecItem.generated.cs +++ /dev/null @@ -1,788 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.repository { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface IRobotSpecItem : global::java.lang.Comparable { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isValid(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getVersion(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isTeam(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isInJAR(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Z)V")] - void setValid(bool par0); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getDescription(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getAuthorName(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/net/URL;")] - global::java.net.URL getWebpage(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool getIncludeSource(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool getIncludeData(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isSourceIncluded(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getRootPath(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/net/URL;")] - global::java.net.URL getItemURL(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - bool isDevelopmentVersion(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getRobocodeVersion(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getFullPackage(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getRelativePath(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getRootPackage(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getFullClassNameWithVersion(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getUniqueFullClassName(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getUniqueFullClassNameWithVersion(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getUniqueShortClassNameWithVersion(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getUniqueVeryShortClassNameWithVersion(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getFullClassName(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Ljava/lang/String;")] - global::java.lang.String getShortClassName(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Lrobocode/control/RobotSpecification;")] - global::java.lang.Object createRobotSpecification(); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/io/OutputStream;Lnet/sf/robocode/repository/RobotProperties;)V")] - void storeProperties(global::java.io.OutputStream par0, global::java.lang.Object par1); - } - #endregion - - #region Component Designer generated code - public partial class IRobotSpecItem_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.repository.IRobotSpecItem), typeof(global::net.sf.robocode.repository.IRobotSpecItem_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.repository.IRobotSpecItem), typeof(global::net.sf.robocode.repository.IRobotSpecItem_))] - internal sealed partial class @__IRobotSpecItem : global::java.lang.Object, global::net.sf.robocode.repository.IRobotSpecItem { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_compareTo0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isValid1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getVersion2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isTeam3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isInJAR4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setValid5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getDescription6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getAuthorName7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getWebpage8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getIncludeSource9; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getIncludeData10; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isSourceIncluded11; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRootPath12; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getItemURL13; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isDevelopmentVersion14; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobocodeVersion15; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getFullPackage16; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRelativePath17; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRootPackage18; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getFullClassNameWithVersion19; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getUniqueFullClassName20; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getUniqueFullClassNameWithVersion21; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getUniqueShortClassNameWithVersion22; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getUniqueVeryShortClassNameWithVersion23; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getFullClassName24; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getShortClassName25; - - internal static global::net.sf.jni4net.jni.MethodId j4n_createRobotSpecification26; - - internal static global::net.sf.jni4net.jni.MethodId j4n_storeProperties27; - - private @__IRobotSpecItem(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass = @__class; - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_compareTo0 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "compareTo", "(Ljava/lang/Object;)I"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_isValid1 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "isValid", "()Z"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getVersion2 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_isTeam3 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "isTeam", "()Z"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_isInJAR4 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "isInJAR", "()Z"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_setValid5 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "setValid", "(Z)V"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getDescription6 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getDescription", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getAuthorName7 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getAuthorName", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getWebpage8 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getWebpage", "()Ljava/net/URL;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getIncludeSource9 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getIncludeSource", "()Z"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getIncludeData10 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getIncludeData", "()Z"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_isSourceIncluded11 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "isSourceIncluded", "()Z"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getRootPath12 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getRootPath", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getItemURL13 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getItemURL", "()Ljava/net/URL;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_isDevelopmentVersion14 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "isDevelopmentVersion", "()Z"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getRobocodeVersion15 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getRobocodeVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getFullPackage16 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getFullPackage", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getRelativePath17 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getRelativePath", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getRootPackage18 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getRootPackage", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getFullClassNameWithVersion19 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getFullClassNameWithVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getUniqueFullClassName20 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getUniqueFullClassName", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getUniqueFullClassNameWithVersion21 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getUniqueFullClassNameWithVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getUniqueShortClassNameWithVersion22 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getUniqueShortClassNameWithVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getUniqueVeryShortClassNameWithVersion23 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getUniqueVeryShortClassNameWithVersion", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getFullClassName24 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getFullClassName", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getShortClassName25 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "getShortClassName", "()Ljava/lang/String;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_createRobotSpecification26 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "createRobotSpecification", "()Lrobocode/control/RobotSpecification;"); - global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_storeProperties27 = @__env.GetMethodID(global::net.sf.robocode.repository.@__IRobotSpecItem.staticClass, "storeProperties", "(Ljava/io/OutputStream;Lnet/sf/robocode/repository/RobotProperties;)V"); - } - - public int compareTo(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((int)(@__env.CallIntMethod(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_compareTo0, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0)))); - } - } - - public bool isValid() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_isValid1))); - } - } - - public global::java.lang.String getVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getVersion2)); - } - } - - public bool isTeam() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_isTeam3))); - } - } - - public bool isInJAR() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_isInJAR4))); - } - } - - public void setValid(bool par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_setValid5, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - public global::java.lang.String getDescription() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getDescription6)); - } - } - - public global::java.lang.String getAuthorName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getAuthorName7)); - } - } - - public global::java.net.URL getWebpage() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getWebpage8)); - } - } - - public bool getIncludeSource() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getIncludeSource9))); - } - } - - public bool getIncludeData() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getIncludeData10))); - } - } - - public bool isSourceIncluded() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_isSourceIncluded11))); - } - } - - public global::java.lang.String getRootPath() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getRootPath12)); - } - } - - public global::java.net.URL getItemURL() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getItemURL13)); - } - } - - public bool isDevelopmentVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_isDevelopmentVersion14))); - } - } - - public global::java.lang.String getRobocodeVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getRobocodeVersion15)); - } - } - - public global::java.lang.String getFullPackage() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getFullPackage16)); - } - } - - public global::java.lang.String getRelativePath() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getRelativePath17)); - } - } - - public global::java.lang.String getRootPackage() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getRootPackage18)); - } - } - - public global::java.lang.String getFullClassNameWithVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getFullClassNameWithVersion19)); - } - } - - public global::java.lang.String getUniqueFullClassName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getUniqueFullClassName20)); - } - } - - public global::java.lang.String getUniqueFullClassNameWithVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getUniqueFullClassNameWithVersion21)); - } - } - - public global::java.lang.String getUniqueShortClassNameWithVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getUniqueShortClassNameWithVersion22)); - } - } - - public global::java.lang.String getUniqueVeryShortClassNameWithVersion() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getUniqueVeryShortClassNameWithVersion23)); - } - } - - public global::java.lang.String getFullClassName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getFullClassName24)); - } - } - - public global::java.lang.String getShortClassName() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_getShortClassName25)); - } - } - - public global::java.lang.Object createRobotSpecification() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_createRobotSpecification26)); - } - } - - public void storeProperties(global::java.io.OutputStream par0, global::java.lang.Object par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.repository.@__IRobotSpecItem.j4n_storeProperties27, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1)); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__IRobotSpecItem); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "compareTo", "compareTo0", "(Ljava/lang/Object;)I")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isValid", "isValid1", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getVersion", "getVersion2", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isTeam", "isTeam3", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isInJAR", "isInJAR4", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "setValid", "setValid5", "(Z)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getDescription", "getDescription6", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getAuthorName", "getAuthorName7", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getWebpage", "getWebpage8", "()Ljava/net/URL;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getIncludeSource", "getIncludeSource9", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getIncludeData", "getIncludeData10", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isSourceIncluded", "isSourceIncluded11", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRootPath", "getRootPath12", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getItemURL", "getItemURL13", "()Ljava/net/URL;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "isDevelopmentVersion", "isDevelopmentVersion14", "()Z")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRobocodeVersion", "getRobocodeVersion15", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getFullPackage", "getFullPackage16", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRelativePath", "getRelativePath17", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getRootPackage", "getRootPackage18", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getFullClassNameWithVersion", "getFullClassNameWithVersion19", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getUniqueFullClassName", "getUniqueFullClassName20", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getUniqueFullClassNameWithVersion", "getUniqueFullClassNameWithVersion21", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getUniqueShortClassNameWithVersion", "getUniqueShortClassNameWithVersion22", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getUniqueVeryShortClassNameWithVersion", "getUniqueVeryShortClassNameWithVersion23", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getFullClassName", "getFullClassName24", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "getShortClassName", "getShortClassName25", "()Ljava/lang/String;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "createRobotSpecification", "createRobotSpecification26", "()Lrobocode/control/RobotSpecification;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "storeProperties", "storeProperties27", "(Ljava/io/OutputStream;Lnet/sf/robocode/repository/RobotProperties;)V")); - return methods; - } - - private static int compareTo0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0) { - // (Ljava/lang/Object;)I - // (Ljava/lang/Object;)I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(((global::java.lang.Comparable)(@__real)).compareTo(global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par0)))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isValid1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isValid())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getVersion2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isTeam3(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isTeam())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isInJAR4(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isInJAR())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static void setValid5(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, bool par0) { - // (Z)V - // (Z)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.setValid(par0); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static global::net.sf.jni4net.utils.JniHandle getDescription6(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getDescription()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getAuthorName7(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getAuthorName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getWebpage8(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/net/URL; - // ()Ljava/net/URL; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getWebpage()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool getIncludeSource9(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.getIncludeSource())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool getIncludeData10(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.getIncludeData())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isSourceIncluded11(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isSourceIncluded())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRootPath12(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getRootPath()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getItemURL13(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/net/URL; - // ()Ljava/net/URL; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getItemURL()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static bool isDevelopmentVersion14(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Z - // ()Z - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - bool @__return = default(bool); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((bool)(@__real.isDevelopmentVersion())); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRobocodeVersion15(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getRobocodeVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getFullPackage16(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getFullPackage()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRelativePath17(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getRelativePath()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getRootPackage18(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getRootPackage()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getFullClassNameWithVersion19(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getFullClassNameWithVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getUniqueFullClassName20(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getUniqueFullClassName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getUniqueFullClassNameWithVersion21(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getUniqueFullClassNameWithVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getUniqueShortClassNameWithVersion22(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getUniqueShortClassNameWithVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getUniqueVeryShortClassNameWithVersion23(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getUniqueVeryShortClassNameWithVersion()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getFullClassName24(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getFullClassName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle getShortClassName25(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Ljava/lang/String; - // ()Ljava/lang/String; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.getShortClassName()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static global::net.sf.jni4net.utils.JniHandle createRobotSpecification26(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj) { - // ()Lrobocode/control/RobotSpecification; - // ()Ljava/lang/Object; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.StrongCp2J(@__real.createRobotSpecification()); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static void storeProperties27(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, global::net.sf.jni4net.utils.JniLocalHandle par1) { - // (Ljava/io/OutputStream;Lnet/sf/robocode/repository/RobotProperties;)V - // (Ljava/io/OutputStream;Ljava/lang/Object;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.repository.IRobotSpecItem @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.storeProperties(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0), global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par1)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.repository.@__IRobotSpecItem(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/repository/RobotType.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/repository/RobotType.generated.cs deleted file mode 100644 index 83b0eb4..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/repository/RobotType.generated.cs +++ /dev/null @@ -1,196 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.repository { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class RobotType : global::java.lang.Object, global::java.io.Serializable { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isValid0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isJuniorRobot1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isStandardRobot2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isAdvancedRobot3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isTeamRobot4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isDroid5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isSentryRobot6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isInteractiveRobot7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isPaintRobot8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getTypeFlags9; - - internal static global::net.sf.jni4net.jni.FieldId j4n_INVALID10; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRobotType11; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRobotType12; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(ZZZZZZZZ)V")] - public RobotType(bool par0, bool par1, bool par2, bool par3, bool par4, bool par5, bool par6, bool par7) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 26)){ - @__env.NewObject(global::net.sf.robocode.repository.RobotType.staticClass, global::net.sf.robocode.repository.RobotType.j4n__ctorRobotType11, this, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par3), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par4), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par5), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par6), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par7)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(I)V")] - public RobotType(int par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::net.sf.robocode.repository.RobotType.staticClass, global::net.sf.robocode.repository.RobotType.j4n__ctorRobotType12, this, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0)); - } - } - - protected RobotType(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.repository.RobotType.staticClass; - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("Lnet/sf/robocode/repository/RobotType;")] - public static global::net.sf.robocode.repository.RobotType INVALID { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.GetStaticObjectFieldPtr(global::net.sf.robocode.repository.RobotType.staticClass, global::net.sf.robocode.repository.RobotType.j4n_INVALID10)); - } - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.repository.RobotType.staticClass = @__class; - global::net.sf.robocode.repository.RobotType.j4n_isValid0 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "isValid", "()Z"); - global::net.sf.robocode.repository.RobotType.j4n_isJuniorRobot1 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "isJuniorRobot", "()Z"); - global::net.sf.robocode.repository.RobotType.j4n_isStandardRobot2 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "isStandardRobot", "()Z"); - global::net.sf.robocode.repository.RobotType.j4n_isAdvancedRobot3 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "isAdvancedRobot", "()Z"); - global::net.sf.robocode.repository.RobotType.j4n_isTeamRobot4 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "isTeamRobot", "()Z"); - global::net.sf.robocode.repository.RobotType.j4n_isDroid5 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "isDroid", "()Z"); - global::net.sf.robocode.repository.RobotType.j4n_isSentryRobot6 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "isSentryRobot", "()Z"); - global::net.sf.robocode.repository.RobotType.j4n_isInteractiveRobot7 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "isInteractiveRobot", "()Z"); - global::net.sf.robocode.repository.RobotType.j4n_isPaintRobot8 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "isPaintRobot", "()Z"); - global::net.sf.robocode.repository.RobotType.j4n_getTypeFlags9 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "getTypeFlags", "()I"); - global::net.sf.robocode.repository.RobotType.j4n_INVALID10 = @__env.GetStaticFieldID(global::net.sf.robocode.repository.RobotType.staticClass, "INVALID", "Lnet/sf/robocode/repository/RobotType;"); - global::net.sf.robocode.repository.RobotType.j4n__ctorRobotType11 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "", "(ZZZZZZZZ)V"); - global::net.sf.robocode.repository.RobotType.j4n__ctorRobotType12 = @__env.GetMethodID(global::net.sf.robocode.repository.RobotType.staticClass, "", "(I)V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isValid() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.RobotType.j4n_isValid0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isJuniorRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.RobotType.j4n_isJuniorRobot1))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isStandardRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.RobotType.j4n_isStandardRobot2))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isAdvancedRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.RobotType.j4n_isAdvancedRobot3))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isTeamRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.RobotType.j4n_isTeamRobot4))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isDroid() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.RobotType.j4n_isDroid5))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isSentryRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.RobotType.j4n_isSentryRobot6))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isInteractiveRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.RobotType.j4n_isInteractiveRobot7))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public virtual bool isPaintRobot() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.repository.RobotType.j4n_isPaintRobot8))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()I")] - public virtual int getTypeFlags() { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.CallIntMethod(this, global::net.sf.robocode.repository.RobotType.j4n_getTypeFlags9))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.repository.RobotType(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/security/HiddenAccess.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/security/HiddenAccess.generated.cs deleted file mode 100644 index 074fe17..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/security/HiddenAccess.generated.cs +++ /dev/null @@ -1,293 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.security { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class HiddenAccess : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_dispatch0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_init1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_cleanup2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_update3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_initContainer4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_robocodeMain5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isCriticalEvent6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setEventTime7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setEventPriority8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setDefaultPriority9; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getSerializationType10; - - internal static global::net.sf.jni4net.jni.MethodId j4n_createSpecification11; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getFileSpecification12; - - internal static global::net.sf.jni4net.jni.MethodId j4n_getRobotTeamName13; - - internal static global::net.sf.jni4net.jni.MethodId j4n_setTeamId14; - - internal static global::net.sf.jni4net.jni.MethodId j4n_createStatus15; - - internal static global::net.sf.jni4net.jni.MethodId j4n_createRules16; - - internal static global::net.sf.jni4net.jni.MethodId j4n_isSafeThread17; - - internal static global::net.sf.jni4net.jni.MethodId j4n_initContainerForRobotEngine18; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorHiddenAccess19; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public HiddenAccess() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n__ctorHiddenAccess19, this); - } - } - - protected HiddenAccess(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.security.HiddenAccess.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.security.HiddenAccess.staticClass = @__class; - global::net.sf.robocode.security.HiddenAccess.j4n_dispatch0 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "dispatch", "(Lrobocode/Event;Lrobocode/robotinterfaces/IBasicRobot;Lnet/sf/robocode/peer/IRob" + - "otStatics;Ljava/awt/Graphics2D;)V"); - global::net.sf.robocode.security.HiddenAccess.j4n_init1 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "init", "()V"); - global::net.sf.robocode.security.HiddenAccess.j4n_cleanup2 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "cleanup", "()V"); - global::net.sf.robocode.security.HiddenAccess.j4n_update3 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "update", "(Lrobocode/Bullet;DDLjava/lang/String;Z)V"); - global::net.sf.robocode.security.HiddenAccess.j4n_initContainer4 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "initContainer", "()V"); - global::net.sf.robocode.security.HiddenAccess.j4n_robocodeMain5 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "robocodeMain", "([Ljava/lang/String;)V"); - global::net.sf.robocode.security.HiddenAccess.j4n_isCriticalEvent6 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "isCriticalEvent", "(Lrobocode/Event;)Z"); - global::net.sf.robocode.security.HiddenAccess.j4n_setEventTime7 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "setEventTime", "(Lrobocode/Event;J)V"); - global::net.sf.robocode.security.HiddenAccess.j4n_setEventPriority8 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "setEventPriority", "(Lrobocode/Event;I)V"); - global::net.sf.robocode.security.HiddenAccess.j4n_setDefaultPriority9 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "setDefaultPriority", "(Lrobocode/Event;)V"); - global::net.sf.robocode.security.HiddenAccess.j4n_getSerializationType10 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "getSerializationType", "(Lrobocode/Event;)B"); - global::net.sf.robocode.security.HiddenAccess.j4n_createSpecification11 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "createSpecification", "(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/la" + - "ng/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Strin" + - "g;)Lrobocode/control/RobotSpecification;"); - global::net.sf.robocode.security.HiddenAccess.j4n_getFileSpecification12 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "getFileSpecification", "(Lrobocode/control/RobotSpecification;)Ljava/lang/Object;"); - global::net.sf.robocode.security.HiddenAccess.j4n_getRobotTeamName13 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "getRobotTeamName", "(Lrobocode/control/RobotSpecification;)Ljava/lang/String;"); - global::net.sf.robocode.security.HiddenAccess.j4n_setTeamId14 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "setTeamId", "(Lrobocode/control/RobotSpecification;Ljava/lang/String;)V"); - global::net.sf.robocode.security.HiddenAccess.j4n_createStatus15 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "createStatus", "(DDDDDDDDDDDDIIIIJ)Lrobocode/RobotStatus;"); - global::net.sf.robocode.security.HiddenAccess.j4n_createRules16 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "createRules", "(IIIDJZI)Lrobocode/BattleRules;"); - global::net.sf.robocode.security.HiddenAccess.j4n_isSafeThread17 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "isSafeThread", "()Z"); - global::net.sf.robocode.security.HiddenAccess.j4n_initContainerForRobotEngine18 = @__env.GetStaticMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "initContainerForRobotEngine", "(Ljava/io/File;Lrobocode/control/events/IBattleListener;)V"); - global::net.sf.robocode.security.HiddenAccess.j4n__ctorHiddenAccess19 = @__env.GetMethodID(global::net.sf.robocode.security.HiddenAccess.staticClass, "", "()V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/Event;Lrobocode/robotinterfaces/IBasicRobot;Lnet/sf/robocode/peer/IRob" + - "otStatics;Ljava/awt/Graphics2D;)V")] - public static void dispatch(global::java.lang.Object par0, global::java.lang.Object par1, global::net.sf.robocode.peer.IRobotStatics par2, global::java.lang.Object par3) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 18)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_dispatch0, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par1), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par2), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par3)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public static void init() { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_init1); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public static void cleanup() { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_cleanup2); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/Bullet;DDLjava/lang/String;Z)V")] - public static void update(global::java.lang.Object par0, double par1, double par2, global::java.lang.String par3, bool par4) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 20)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_update3, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par3), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par4)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public static void initContainer() { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_initContainer4); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("([Ljava/lang/String;)V")] - public static void robocodeMain(java.lang.String[] par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_robocodeMain5, global::net.sf.jni4net.utils.Convertor.ParArrayStrongCp2J(@__env, par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/Event;)Z")] - public static bool isCriticalEvent(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((bool)(@__env.CallStaticBooleanMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_isCriticalEvent6, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/Event;J)V")] - public static void setEventTime(global::java.lang.Object par0, long par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_setEventTime7, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/Event;I)V")] - public static void setEventPriority(global::java.lang.Object par0, int par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_setEventPriority8, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/Event;)V")] - public static void setDefaultPriority(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_setDefaultPriority9, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/Event;)B")] - public static byte getSerializationType(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((byte)(@__env.CallStaticByteMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_getSerializationType10, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/Object;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/la" + - "ng/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;Ljava/lang/Strin" + - "g;)Lrobocode/control/RobotSpecification;")] - public static global::java.lang.Object createSpecification(global::java.lang.Object par0, global::java.lang.String par1, global::java.lang.String par2, global::java.lang.String par3, global::java.lang.String par4, global::java.lang.String par5, global::java.lang.String par6, global::java.lang.String par7, global::java.lang.String par8) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 28)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_createSpecification11, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par2), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par3), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par4), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par5), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par6), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par7), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par8))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/RobotSpecification;)Ljava/lang/Object;")] - public static global::java.lang.Object getFileSpecification(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallStaticObjectMethodPtr(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_getFileSpecification12, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/RobotSpecification;)Ljava/lang/String;")] - public static global::java.lang.String getRobotTeamName(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallStaticObjectMethodPtr(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_getRobotTeamName13, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/control/RobotSpecification;Ljava/lang/String;)V")] - public static void setTeamId(global::java.lang.Object par0, global::java.lang.String par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_setTeamId14, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(DDDDDDDDDDDDIIIIJ)Lrobocode/RobotStatus;")] - public static global::java.lang.Object createStatus( - double par0, - double par1, - double par2, - double par3, - double par4, - double par5, - double par6, - double par7, - double par8, - double par9, - double par10, - double par11, - int par12, - int par13, - int par14, - int par15, - long par16) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 44)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_createStatus15, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par3), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par4), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par5), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par6), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par7), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par8), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par9), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par10), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par11), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par12), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par13), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par14), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par15), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par16))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(IIIDJZI)Lrobocode/BattleRules;")] - public static global::java.lang.Object createRules(int par0, int par1, int par2, double par3, long par4, bool par5, int par6) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 24)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_createRules16, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par2), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par3), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par4), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par5), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par6))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()Z")] - public static bool isSafeThread() { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((bool)(@__env.CallStaticBooleanMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_isSafeThread17))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/io/File;Lrobocode/control/events/IBattleListener;)V")] - public static void initContainerForRobotEngine(global::java.io.File par0, global::java.lang.Object par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.security.HiddenAccess.staticClass, global::net.sf.robocode.security.HiddenAccess.j4n_initContainerForRobotEngine18, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par1)); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.security.HiddenAccess(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/serialization/ISerializableHelper.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/serialization/ISerializableHelper.generated.cs deleted file mode 100644 index 7c4c9d8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/serialization/ISerializableHelper.generated.cs +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.serialization { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaInterfaceAttribute()] - public partial interface ISerializableHelper { - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;Ljava/lang/Obje" + - "ct;)V")] - void serialize(global::net.sf.robocode.serialization.RbSerializer par0, global::java.nio.ByteBuffer par1, global::java.lang.Object par2); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;)Ljava/lang/Obj" + - "ect;")] - global::java.lang.Object deserialize(global::net.sf.robocode.serialization.RbSerializer par0, global::java.nio.ByteBuffer par1); - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lnet/sf/robocode/serialization/RbSerializer;Ljava/lang/Object;)I")] - int sizeOf(global::net.sf.robocode.serialization.RbSerializer par0, global::java.lang.Object par1); - } - #endregion - - #region Component Designer generated code - public partial class ISerializableHelper_ { - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.serialization.@__ISerializableHelper.staticClass; - } - } - } - #endregion - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaProxyAttribute(typeof(global::net.sf.robocode.serialization.ISerializableHelper), typeof(global::net.sf.robocode.serialization.ISerializableHelper_))] - [global::net.sf.jni4net.attributes.ClrWrapperAttribute(typeof(global::net.sf.robocode.serialization.ISerializableHelper), typeof(global::net.sf.robocode.serialization.ISerializableHelper_))] - internal sealed partial class @__ISerializableHelper : global::java.lang.Object, global::net.sf.robocode.serialization.ISerializableHelper { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserialize1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_sizeOf2; - - private @__ISerializableHelper(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.serialization.@__ISerializableHelper.staticClass = @__class; - global::net.sf.robocode.serialization.@__ISerializableHelper.j4n_serialize0 = @__env.GetMethodID(global::net.sf.robocode.serialization.@__ISerializableHelper.staticClass, "serialize", "(Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;Ljava/lang/Obje" + - "ct;)V"); - global::net.sf.robocode.serialization.@__ISerializableHelper.j4n_deserialize1 = @__env.GetMethodID(global::net.sf.robocode.serialization.@__ISerializableHelper.staticClass, "deserialize", "(Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;)Ljava/lang/Obj" + - "ect;"); - global::net.sf.robocode.serialization.@__ISerializableHelper.j4n_sizeOf2 = @__env.GetMethodID(global::net.sf.robocode.serialization.@__ISerializableHelper.staticClass, "sizeOf", "(Lnet/sf/robocode/serialization/RbSerializer;Ljava/lang/Object;)I"); - } - - public void serialize(global::net.sf.robocode.serialization.RbSerializer par0, global::java.nio.ByteBuffer par1, global::java.lang.Object par2) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.@__ISerializableHelper.j4n_serialize0, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par2)); - } - } - - public global::java.lang.Object deserialize(global::net.sf.robocode.serialization.RbSerializer par0, global::java.nio.ByteBuffer par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.@__ISerializableHelper.j4n_deserialize1, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1))); - } - } - - public int sizeOf(global::net.sf.robocode.serialization.RbSerializer par0, global::java.lang.Object par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - return ((int)(@__env.CallIntMethod(this, global::net.sf.robocode.serialization.@__ISerializableHelper.j4n_sizeOf2, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par1)))); - } - } - - private static global::System.Collections.Generic.List @__Init(global::net.sf.jni4net.jni.JNIEnv @__env, global::java.lang.Class @__class) { - global::System.Type @__type = typeof(__ISerializableHelper); - global::System.Collections.Generic.List methods = new global::System.Collections.Generic.List(); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "serialize", "serialize0", "(Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;Ljava/lang/Obje" + - "ct;)V")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "deserialize", "deserialize1", "(Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;)Ljava/lang/Obj" + - "ect;")); - methods.Add(global::net.sf.jni4net.jni.JNINativeMethod.Create(@__type, "sizeOf", "sizeOf2", "(Lnet/sf/robocode/serialization/RbSerializer;Ljava/lang/Object;)I")); - return methods; - } - - private static void serialize0(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, global::net.sf.jni4net.utils.JniLocalHandle par1, global::net.sf.jni4net.utils.JniLocalHandle par2) { - // (Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;Ljava/lang/Object;)V - // (Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;Ljava/lang/Object;)V - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - try { - global::net.sf.robocode.serialization.ISerializableHelper @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__real.serialize(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0), global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par1), global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par2)); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - } - - private static global::net.sf.jni4net.utils.JniHandle deserialize1(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, global::net.sf.jni4net.utils.JniLocalHandle par1) { - // (Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;)Ljava/lang/Object; - // (Lnet/sf/robocode/serialization/RbSerializer;Ljava/nio/ByteBuffer;)Ljava/lang/Object; - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - global::net.sf.jni4net.utils.JniHandle @__return = default(global::net.sf.jni4net.utils.JniHandle); - try { - global::net.sf.robocode.serialization.ISerializableHelper @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = global::net.sf.jni4net.utils.Convertor.FullC2J(@__env, @__real.deserialize(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0), global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par1))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - private static int sizeOf2(global::System.IntPtr @__envp, global::net.sf.jni4net.utils.JniLocalHandle @__obj, global::net.sf.jni4net.utils.JniLocalHandle par0, global::net.sf.jni4net.utils.JniLocalHandle par1) { - // (Lnet/sf/robocode/serialization/RbSerializer;Ljava/lang/Object;)I - // (Lnet/sf/robocode/serialization/RbSerializer;Ljava/lang/Object;)I - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.Wrap(@__envp); - int @__return = default(int); - try { - global::net.sf.robocode.serialization.ISerializableHelper @__real = global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__obj); - @__return = ((int)(@__real.sizeOf(global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, par0), global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, par1)))); - }catch (global::System.Exception __ex){@__env.ThrowExisting(__ex);} - return @__return; - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.serialization.@__ISerializableHelper(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/serialization/RbSerializer.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/serialization/RbSerializer.generated.cs deleted file mode 100644 index aa01b31..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/net/sf/robocode/serialization/RbSerializer.generated.cs +++ /dev/null @@ -1,1036 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace net.sf.robocode.serialization { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - public partial class RbSerializer : global::java.lang.Object { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n_register0; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize1; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize2; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize3; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize4; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize5; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize6; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize7; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize8; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize9; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize10; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize11; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize12; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize13; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize14; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serialize15; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serializeToBuffer16; - - internal static global::net.sf.jni4net.jni.MethodId j4n_serializeToBuffer17; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserialize18; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserialize19; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeAny20; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeString21; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeBytes22; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeIntegers23; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeFloats24; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeChars25; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeDoubles26; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeBoolean27; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeChar28; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeInt29; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeFloat30; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeDouble31; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeLong32; - - internal static global::net.sf.jni4net.jni.MethodId j4n_sizeOf33; - - internal static global::net.sf.jni4net.jni.MethodId j4n_sizeOf34; - - internal static global::net.sf.jni4net.jni.MethodId j4n_sizeOf35; - - internal static global::net.sf.jni4net.jni.MethodId j4n_sizeOf36; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deserializeFromBuffer37; - - internal static global::net.sf.jni4net.jni.MethodId j4n_deepCopy38; - - internal static global::net.sf.jni4net.jni.FieldId j4n_SIZEOF_TYPEINFO39; - - internal static global::net.sf.jni4net.jni.FieldId j4n_SIZEOF_BYTE40; - - internal static global::net.sf.jni4net.jni.FieldId j4n_SIZEOF_BOOL41; - - internal static global::net.sf.jni4net.jni.FieldId j4n_SIZEOF_CHAR42; - - internal static global::net.sf.jni4net.jni.FieldId j4n_SIZEOF_INT43; - - internal static global::net.sf.jni4net.jni.FieldId j4n_SIZEOF_LONG44; - - internal static global::net.sf.jni4net.jni.FieldId j4n_SIZEOF_DOUBLE45; - - internal static global::net.sf.jni4net.jni.FieldId j4n_TERMINATOR_TYPE46; - - internal static global::net.sf.jni4net.jni.FieldId j4n_ExecCommands_TYPE47; - - internal static global::net.sf.jni4net.jni.FieldId j4n_BulletCommand_TYPE48; - - internal static global::net.sf.jni4net.jni.FieldId j4n_TeamMessage_TYPE49; - - internal static global::net.sf.jni4net.jni.FieldId j4n_DebugProperty_TYPE50; - - internal static global::net.sf.jni4net.jni.FieldId j4n_ExecResults_TYPE51; - - internal static global::net.sf.jni4net.jni.FieldId j4n_RobotStatus_TYPE52; - - internal static global::net.sf.jni4net.jni.FieldId j4n_BulletStatus_TYPE53; - - internal static global::net.sf.jni4net.jni.FieldId j4n_BattleResults_TYPE54; - - internal static global::net.sf.jni4net.jni.FieldId j4n_Bullet_TYPE55; - - internal static global::net.sf.jni4net.jni.FieldId j4n_RobotStatics_TYPE56; - - internal static global::net.sf.jni4net.jni.FieldId j4n_BattleEndedEvent_TYPE57; - - internal static global::net.sf.jni4net.jni.FieldId j4n_BulletHitBulletEvent_TYPE58; - - internal static global::net.sf.jni4net.jni.FieldId j4n_BulletHitEvent_TYPE59; - - internal static global::net.sf.jni4net.jni.FieldId j4n_BulletMissedEvent_TYPE60; - - internal static global::net.sf.jni4net.jni.FieldId j4n_DeathEvent_TYPE61; - - internal static global::net.sf.jni4net.jni.FieldId j4n_WinEvent_TYPE62; - - internal static global::net.sf.jni4net.jni.FieldId j4n_HitWallEvent_TYPE63; - - internal static global::net.sf.jni4net.jni.FieldId j4n_RobotDeathEvent_TYPE64; - - internal static global::net.sf.jni4net.jni.FieldId j4n_SkippedTurnEvent_TYPE65; - - internal static global::net.sf.jni4net.jni.FieldId j4n_ScannedRobotEvent_TYPE66; - - internal static global::net.sf.jni4net.jni.FieldId j4n_HitByBulletEvent_TYPE67; - - internal static global::net.sf.jni4net.jni.FieldId j4n_HitRobotEvent_TYPE68; - - internal static global::net.sf.jni4net.jni.FieldId j4n_KeyPressedEvent_TYPE69; - - internal static global::net.sf.jni4net.jni.FieldId j4n_KeyReleasedEvent_TYPE70; - - internal static global::net.sf.jni4net.jni.FieldId j4n_KeyTypedEvent_TYPE71; - - internal static global::net.sf.jni4net.jni.FieldId j4n_MouseClickedEvent_TYPE72; - - internal static global::net.sf.jni4net.jni.FieldId j4n_MouseDraggedEvent_TYPE73; - - internal static global::net.sf.jni4net.jni.FieldId j4n_MouseEnteredEvent_TYPE74; - - internal static global::net.sf.jni4net.jni.FieldId j4n_MouseExitedEvent_TYPE75; - - internal static global::net.sf.jni4net.jni.FieldId j4n_MouseMovedEvent_TYPE76; - - internal static global::net.sf.jni4net.jni.FieldId j4n_MousePressedEvent_TYPE77; - - internal static global::net.sf.jni4net.jni.FieldId j4n_MouseReleasedEvent_TYPE78; - - internal static global::net.sf.jni4net.jni.FieldId j4n_MouseWheelMovedEvent_TYPE79; - - internal static global::net.sf.jni4net.jni.FieldId j4n_RoundEndedEvent_TYPE80; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorRbSerializer81; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public RbSerializer() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n__ctorRbSerializer81, this); - } - } - - protected RbSerializer(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - public static global::java.lang.Class _class { - get { - return global::net.sf.robocode.serialization.RbSerializer.staticClass; - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("I")] - public static int SIZEOF_TYPEINFO { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.GetStaticIntField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_TYPEINFO39))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("I")] - public static int SIZEOF_BYTE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.GetStaticIntField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_BYTE40))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("I")] - public static int SIZEOF_BOOL { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.GetStaticIntField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_BOOL41))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("I")] - public static int SIZEOF_CHAR { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.GetStaticIntField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_CHAR42))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("I")] - public static int SIZEOF_INT { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.GetStaticIntField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_INT43))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("I")] - public static int SIZEOF_LONG { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.GetStaticIntField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_LONG44))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("I")] - public static int SIZEOF_DOUBLE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((int)(@__env.GetStaticIntField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_DOUBLE45))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte TERMINATOR_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_TERMINATOR_TYPE46))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte ExecCommands_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_ExecCommands_TYPE47))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte BulletCommand_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_BulletCommand_TYPE48))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte TeamMessage_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_TeamMessage_TYPE49))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte DebugProperty_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_DebugProperty_TYPE50))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte ExecResults_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_ExecResults_TYPE51))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte RobotStatus_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_RobotStatus_TYPE52))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte BulletStatus_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_BulletStatus_TYPE53))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte BattleResults_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_BattleResults_TYPE54))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte Bullet_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_Bullet_TYPE55))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte RobotStatics_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_RobotStatics_TYPE56))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte BattleEndedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_BattleEndedEvent_TYPE57))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte BulletHitBulletEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_BulletHitBulletEvent_TYPE58))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte BulletHitEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_BulletHitEvent_TYPE59))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte BulletMissedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_BulletMissedEvent_TYPE60))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte DeathEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_DeathEvent_TYPE61))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte WinEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_WinEvent_TYPE62))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte HitWallEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_HitWallEvent_TYPE63))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte RobotDeathEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_RobotDeathEvent_TYPE64))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte SkippedTurnEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_SkippedTurnEvent_TYPE65))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte ScannedRobotEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_ScannedRobotEvent_TYPE66))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte HitByBulletEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_HitByBulletEvent_TYPE67))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte HitRobotEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_HitRobotEvent_TYPE68))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte KeyPressedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_KeyPressedEvent_TYPE69))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte KeyReleasedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_KeyReleasedEvent_TYPE70))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte KeyTypedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_KeyTypedEvent_TYPE71))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte MouseClickedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_MouseClickedEvent_TYPE72))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte MouseDraggedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_MouseDraggedEvent_TYPE73))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte MouseEnteredEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_MouseEnteredEvent_TYPE74))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte MouseExitedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_MouseExitedEvent_TYPE75))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte MouseMovedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_MouseMovedEvent_TYPE76))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte MousePressedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_MousePressedEvent_TYPE77))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte MouseReleasedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_MouseReleasedEvent_TYPE78))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte MouseWheelMovedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_MouseWheelMovedEvent_TYPE79))); - } - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("B")] - public static byte RoundEndedEvent_TYPE { - get { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - return ((byte)(@__env.GetStaticByteField(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_RoundEndedEvent_TYPE80))); - } - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::net.sf.robocode.serialization.RbSerializer.staticClass = @__class; - global::net.sf.robocode.serialization.RbSerializer.j4n_register0 = @__env.GetStaticMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "register", "(Ljava/lang/Class;B)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize1 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/io/OutputStream;BLjava/lang/Object;)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize2 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;Lrobocode/Event;)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize3 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;BLjava/lang/Object;)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize4 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;Ljava/lang/String;)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize5 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;[B)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize6 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;[I)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize7 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;[C)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize8 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;[D)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize9 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;[F)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize10 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;Z)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize11 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;D)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize12 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;C)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize13 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;J)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize14 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(Ljava/nio/ByteBuffer;I)V"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serialize15 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serialize", "(BLjava/lang/Object;)Ljava/nio/ByteBuffer;"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serializeToBuffer16 = @__env.GetStaticMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serializeToBuffer", "(Ljava/lang/Object;)Ljava/nio/ByteBuffer;"); - global::net.sf.robocode.serialization.RbSerializer.j4n_serializeToBuffer17 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "serializeToBuffer", "(Ljava/nio/ByteBuffer;BLjava/lang/Object;)Ljava/nio/ByteBuffer;"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserialize18 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserialize", "(Ljava/io/InputStream;)Ljava/lang/Object;"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserialize19 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserialize", "(Ljava/nio/ByteBuffer;)Ljava/lang/Object;"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeAny20 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeAny", "(Ljava/nio/ByteBuffer;)Ljava/lang/Object;"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeString21 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeString", "(Ljava/nio/ByteBuffer;)Ljava/lang/String;"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeBytes22 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeBytes", "(Ljava/nio/ByteBuffer;)[B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeIntegers23 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeIntegers", "(Ljava/nio/ByteBuffer;)[I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeFloats24 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeFloats", "(Ljava/nio/ByteBuffer;)[F"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeChars25 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeChars", "(Ljava/nio/ByteBuffer;)[C"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeDoubles26 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeDoubles", "(Ljava/nio/ByteBuffer;)[D"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeBoolean27 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeBoolean", "(Ljava/nio/ByteBuffer;)Z"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeChar28 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeChar", "(Ljava/nio/ByteBuffer;)C"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeInt29 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeInt", "(Ljava/nio/ByteBuffer;)I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeFloat30 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeFloat", "(Ljava/nio/ByteBuffer;)Ljava/lang/Float;"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeDouble31 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeDouble", "(Ljava/nio/ByteBuffer;)D"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeLong32 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeLong", "(Ljava/nio/ByteBuffer;)J"); - global::net.sf.robocode.serialization.RbSerializer.j4n_sizeOf33 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "sizeOf", "(BLjava/lang/Object;)I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_sizeOf34 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "sizeOf", "(Lrobocode/Event;)I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_sizeOf35 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "sizeOf", "([B)I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_sizeOf36 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "sizeOf", "(Ljava/lang/String;)I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeFromBuffer37 = @__env.GetStaticMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deserializeFromBuffer", "(Ljava/nio/ByteBuffer;)Ljava/lang/Object;"); - global::net.sf.robocode.serialization.RbSerializer.j4n_deepCopy38 = @__env.GetStaticMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "deepCopy", "(BLjava/lang/Object;)Ljava/lang/Object;"); - global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_TYPEINFO39 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "SIZEOF_TYPEINFO", "I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_BYTE40 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "SIZEOF_BYTE", "I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_BOOL41 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "SIZEOF_BOOL", "I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_CHAR42 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "SIZEOF_CHAR", "I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_INT43 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "SIZEOF_INT", "I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_LONG44 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "SIZEOF_LONG", "I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_SIZEOF_DOUBLE45 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "SIZEOF_DOUBLE", "I"); - global::net.sf.robocode.serialization.RbSerializer.j4n_TERMINATOR_TYPE46 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "TERMINATOR_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_ExecCommands_TYPE47 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "ExecCommands_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_BulletCommand_TYPE48 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "BulletCommand_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_TeamMessage_TYPE49 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "TeamMessage_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_DebugProperty_TYPE50 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "DebugProperty_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_ExecResults_TYPE51 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "ExecResults_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_RobotStatus_TYPE52 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "RobotStatus_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_BulletStatus_TYPE53 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "BulletStatus_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_BattleResults_TYPE54 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "BattleResults_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_Bullet_TYPE55 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "Bullet_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_RobotStatics_TYPE56 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "RobotStatics_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_BattleEndedEvent_TYPE57 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "BattleEndedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_BulletHitBulletEvent_TYPE58 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "BulletHitBulletEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_BulletHitEvent_TYPE59 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "BulletHitEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_BulletMissedEvent_TYPE60 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "BulletMissedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_DeathEvent_TYPE61 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "DeathEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_WinEvent_TYPE62 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "WinEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_HitWallEvent_TYPE63 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "HitWallEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_RobotDeathEvent_TYPE64 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "RobotDeathEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_SkippedTurnEvent_TYPE65 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "SkippedTurnEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_ScannedRobotEvent_TYPE66 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "ScannedRobotEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_HitByBulletEvent_TYPE67 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "HitByBulletEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_HitRobotEvent_TYPE68 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "HitRobotEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_KeyPressedEvent_TYPE69 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "KeyPressedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_KeyReleasedEvent_TYPE70 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "KeyReleasedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_KeyTypedEvent_TYPE71 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "KeyTypedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_MouseClickedEvent_TYPE72 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "MouseClickedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_MouseDraggedEvent_TYPE73 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "MouseDraggedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_MouseEnteredEvent_TYPE74 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "MouseEnteredEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_MouseExitedEvent_TYPE75 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "MouseExitedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_MouseMovedEvent_TYPE76 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "MouseMovedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_MousePressedEvent_TYPE77 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "MousePressedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_MouseReleasedEvent_TYPE78 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "MouseReleasedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_MouseWheelMovedEvent_TYPE79 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "MouseWheelMovedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n_RoundEndedEvent_TYPE80 = @__env.GetStaticFieldID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "RoundEndedEvent_TYPE", "B"); - global::net.sf.robocode.serialization.RbSerializer.j4n__ctorRbSerializer81 = @__env.GetMethodID(global::net.sf.robocode.serialization.RbSerializer.staticClass, "", "()V"); - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/Class;B)V")] - public static void register(global::java.lang.Class par0, byte par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallStaticVoidMethod(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_register0, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/io/OutputStream;BLjava/lang/Object;)V")] - public virtual void serialize(global::java.io.OutputStream par0, byte par1, global::java.lang.Object par2) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize1, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par2)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;Lrobocode/Event;)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, global::java.lang.Object par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize2, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;BLjava/lang/Object;)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, byte par1, global::java.lang.Object par2) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize3, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par2)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;Ljava/lang/String;)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, global::java.lang.String par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize4, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;[B)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, byte[] par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize5, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParArrayPrimC2J(@__env, par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;[I)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, int[] par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize6, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParArrayPrimC2J(@__env, par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;[C)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, char[] par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize7, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParArrayPrimC2J(@__env, par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;[D)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, double[] par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize8, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParArrayPrimC2J(@__env, par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;[F)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, float[] par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize9, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParArrayPrimC2J(@__env, par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;Z)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, bool par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize10, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;D)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, double par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize11, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;C)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, char par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize12, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;J)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, long par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize13, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;I)V")] - public virtual void serialize(global::java.nio.ByteBuffer par0, int par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - @__env.CallVoidMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize14, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1)); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(BLjava/lang/Object;)Ljava/nio/ByteBuffer;")] - public virtual global::java.nio.ByteBuffer serialize(byte par0, global::java.lang.Object par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serialize15, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par1))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/Object;)Ljava/nio/ByteBuffer;")] - public static global::java.nio.ByteBuffer serializeToBuffer(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallStaticObjectMethodPtr(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_serializeToBuffer16, global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;BLjava/lang/Object;)Ljava/nio/ByteBuffer;")] - public virtual global::java.nio.ByteBuffer serializeToBuffer(global::java.nio.ByteBuffer par0, byte par1, global::java.lang.Object par2) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 16)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_serializeToBuffer17, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0), global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par1), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par2))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/io/InputStream;)Ljava/lang/Object;")] - public virtual global::java.lang.Object deserialize(global::java.io.InputStream par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserialize18, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)Ljava/lang/Object;")] - public virtual global::java.lang.Object deserialize(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserialize19, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)Ljava/lang/Object;")] - public virtual global::java.lang.Object deserializeAny(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeAny20, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)Ljava/lang/String;")] - public virtual global::java.lang.String deserializeString(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2CpString(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeString21, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)[B")] - public virtual byte[] deserializeBytes(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.ArrayPrimJ2Cbyte(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeBytes22, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)[I")] - public virtual int[] deserializeIntegers(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.ArrayPrimJ2Cint(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeIntegers23, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)[F")] - public virtual float[] deserializeFloats(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.ArrayPrimJ2Cfloat(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeFloats24, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)[C")] - public virtual char[] deserializeChars(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.ArrayPrimJ2Cchar(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeChars25, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)[D")] - public virtual double[] deserializeDoubles(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.ArrayPrimJ2Cdouble(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeDoubles26, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)Z")] - public virtual bool deserializeBoolean(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((bool)(@__env.CallBooleanMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeBoolean27, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)C")] - public virtual char deserializeChar(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((char)(@__env.CallCharMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeChar28, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)I")] - public virtual int deserializeInt(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((int)(@__env.CallIntMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeInt29, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)Ljava/lang/Float;")] - public virtual global::java.lang.Float deserializeFloat(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.StrongJ2Cp(@__env, @__env.CallObjectMethodPtr(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeFloat30, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)D")] - public virtual double deserializeDouble(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((double)(@__env.CallDoubleMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeDouble31, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)J")] - public virtual long deserializeLong(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((long)(@__env.CallLongMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeLong32, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(BLjava/lang/Object;)I")] - public virtual int sizeOf(byte par0, global::java.lang.Object par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - return ((int)(@__env.CallIntMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_sizeOf33, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par1)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Lrobocode/Event;)I")] - public virtual int sizeOf(global::java.lang.Object par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((int)(@__env.CallIntMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_sizeOf34, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("([B)I")] - public virtual int sizeOf(byte[] par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((int)(@__env.CallIntMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_sizeOf35, global::net.sf.jni4net.utils.Convertor.ParArrayPrimC2J(@__env, par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)I")] - public virtual int sizeOf(global::java.lang.String par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = this.Env; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return ((int)(@__env.CallIntMethod(this, global::net.sf.robocode.serialization.RbSerializer.j4n_sizeOf36, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/nio/ByteBuffer;)Ljava/lang/Object;")] - public static global::java.lang.Object deserializeFromBuffer(global::java.nio.ByteBuffer par0) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallStaticObjectMethodPtr(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_deserializeFromBuffer37, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0))); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(BLjava/lang/Object;)Ljava/lang/Object;")] - public static global::java.lang.Object deepCopy(byte par0, global::java.lang.Object par1) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 14)){ - return global::net.sf.jni4net.utils.Convertor.FullJ2C(@__env, @__env.CallStaticObjectMethodPtr(global::net.sf.robocode.serialization.RbSerializer.staticClass, global::net.sf.robocode.serialization.RbSerializer.j4n_deepCopy38, global::net.sf.jni4net.utils.Convertor.ParPrimC2J(par0), global::net.sf.jni4net.utils.Convertor.ParFullC2J(@__env, par1))); - } - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::net.sf.robocode.serialization.RbSerializer(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/AbortedException.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/AbortedException.generated.cs deleted file mode 100644 index 7143de0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/AbortedException.generated.cs +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.exception { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - [global::System.SerializableAttribute()] - public partial class AbortedException : global::java.lang.Error { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorAbortedException0; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorAbortedException1; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public AbortedException() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::robocode.exception.AbortedException.staticClass, global::robocode.exception.AbortedException.j4n__ctorAbortedException0, this); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)V")] - public AbortedException(global::java.lang.String par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.exception.AbortedException.staticClass, global::robocode.exception.AbortedException.j4n__ctorAbortedException1, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - protected AbortedException(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - protected AbortedException(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : - base(info, context) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.exception.AbortedException.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.exception.AbortedException.staticClass = @__class; - global::robocode.exception.AbortedException.j4n__ctorAbortedException0 = @__env.GetMethodID(global::robocode.exception.AbortedException.staticClass, "", "()V"); - global::robocode.exception.AbortedException.j4n__ctorAbortedException1 = @__env.GetMethodID(global::robocode.exception.AbortedException.staticClass, "", "(Ljava/lang/String;)V"); - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.exception.AbortedException(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/DeathException.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/DeathException.generated.cs deleted file mode 100644 index 7b57751..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/DeathException.generated.cs +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.exception { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - [global::System.SerializableAttribute()] - public partial class DeathException : global::java.lang.Error { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorDeathException0; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorDeathException1; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public DeathException() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::robocode.exception.DeathException.staticClass, global::robocode.exception.DeathException.j4n__ctorDeathException0, this); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)V")] - public DeathException(global::java.lang.String par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.exception.DeathException.staticClass, global::robocode.exception.DeathException.j4n__ctorDeathException1, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - protected DeathException(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - protected DeathException(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : - base(info, context) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.exception.DeathException.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.exception.DeathException.staticClass = @__class; - global::robocode.exception.DeathException.j4n__ctorDeathException0 = @__env.GetMethodID(global::robocode.exception.DeathException.staticClass, "", "()V"); - global::robocode.exception.DeathException.j4n__ctorDeathException1 = @__env.GetMethodID(global::robocode.exception.DeathException.staticClass, "", "(Ljava/lang/String;)V"); - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.exception.DeathException(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/DisabledException.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/DisabledException.generated.cs deleted file mode 100644 index 4672eed..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/DisabledException.generated.cs +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.exception { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - [global::System.SerializableAttribute()] - public partial class DisabledException : global::java.lang.Error { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorDisabledException0; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorDisabledException1; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public DisabledException() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::robocode.exception.DisabledException.staticClass, global::robocode.exception.DisabledException.j4n__ctorDisabledException0, this); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)V")] - public DisabledException(global::java.lang.String par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.exception.DisabledException.staticClass, global::robocode.exception.DisabledException.j4n__ctorDisabledException1, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - protected DisabledException(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - protected DisabledException(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : - base(info, context) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.exception.DisabledException.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.exception.DisabledException.staticClass = @__class; - global::robocode.exception.DisabledException.j4n__ctorDisabledException0 = @__env.GetMethodID(global::robocode.exception.DisabledException.staticClass, "", "()V"); - global::robocode.exception.DisabledException.j4n__ctorDisabledException1 = @__env.GetMethodID(global::robocode.exception.DisabledException.staticClass, "", "(Ljava/lang/String;)V"); - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.exception.DisabledException(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/WinException.generated.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/WinException.generated.cs deleted file mode 100644 index 2787601..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/generated/robocode/exception/WinException.generated.cs +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -//------------------------------------------------------------------------------ -// -// This code was generated by jni4net. See http://jni4net.sourceforge.net/ -// Runtime Version:2.0.50727.8669 -// -// Changes to this file may cause incorrect behavior and will be lost if -// the code is regenerated. -// -//------------------------------------------------------------------------------ - -namespace robocode.exception { - - - #region Component Designer generated code - [global::net.sf.jni4net.attributes.JavaClassAttribute()] - [global::System.SerializableAttribute()] - public partial class WinException : global::java.lang.Error { - - internal new static global::java.lang.Class staticClass; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorWinException0; - - internal static global::net.sf.jni4net.jni.MethodId j4n__ctorWinException1; - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("()V")] - public WinException() : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 10)){ - @__env.NewObject(global::robocode.exception.WinException.staticClass, global::robocode.exception.WinException.j4n__ctorWinException0, this); - } - } - - [global::net.sf.jni4net.attributes.JavaMethodAttribute("(Ljava/lang/String;)V")] - public WinException(global::java.lang.String par0) : - base(((global::net.sf.jni4net.jni.JNIEnv)(null))) { - global::net.sf.jni4net.jni.JNIEnv @__env = global::net.sf.jni4net.jni.JNIEnv.ThreadEnv; - using(new global::net.sf.jni4net.jni.LocalFrame(@__env, 12)){ - @__env.NewObject(global::robocode.exception.WinException.staticClass, global::robocode.exception.WinException.j4n__ctorWinException1, this, global::net.sf.jni4net.utils.Convertor.ParStrongCp2J(par0)); - } - } - - protected WinException(global::net.sf.jni4net.jni.JNIEnv @__env) : - base(@__env) { - } - - protected WinException(global::System.Runtime.Serialization.SerializationInfo info, global::System.Runtime.Serialization.StreamingContext context) : - base(info, context) { - } - - public static global::java.lang.Class _class { - get { - return global::robocode.exception.WinException.staticClass; - } - } - - private static void InitJNI(global::net.sf.jni4net.jni.JNIEnv @__env, java.lang.Class @__class) { - global::robocode.exception.WinException.staticClass = @__class; - global::robocode.exception.WinException.j4n__ctorWinException0 = @__env.GetMethodID(global::robocode.exception.WinException.staticClass, "", "()V"); - global::robocode.exception.WinException.j4n__ctorWinException1 = @__env.GetMethodID(global::robocode.exception.WinException.staticClass, "", "(Ljava/lang/String;)V"); - } - - new internal sealed class ContructionHelper : global::net.sf.jni4net.utils.IConstructionHelper { - - public global::net.sf.jni4net.jni.IJvmProxy CreateProxy(global::net.sf.jni4net.jni.JNIEnv @__env) { - return new global::robocode.exception.WinException(@__env); - } - } - } - #endregion -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/DotNetHost.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/DotNetHost.cs deleted file mode 100644 index befcc51..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/DotNetHost.cs +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.IO; -using net.sf.jni4net; -using net.sf.robocode.dotnet.host.seed; -using net.sf.robocode.dotnet.repository.root; -using net.sf.robocode.host; -using net.sf.robocode.host.proxies; -using net.sf.robocode.peer; -using net.sf.robocode.repository; -using net.sf.robocode.security; -using robocode.control; -using Object = java.lang.Object; -using String = java.lang.String; - -namespace net.sf.robocode.dotnet.host -{ - public class DotNetHost : IHost - { - #region IHost Members - - public IHostingRobotProxy createRobotProxy(IHostManager hostManager, Object robotSpecification, IRobotStatics statics, IRobotPeer peer) - { - Object s = HiddenAccess.getFileSpecification(robotSpecification); - var itemSpecification = Bridge.Cast(s); - string file = DllRootHelper.GetDllFileName(itemSpecification); - HostingShell hostingShell = new HostingShell(itemSpecification, hostManager, peer, statics, file); - return hostingShell; - } - - public String[] getReferencedClasses(IRobotItem robotItem) - { - return new String[] {}; - } - - public RobotType getRobotType(IRobotItem robotItem, bool resolve, bool message) - { - return DllRootHelper.GetRobotType(robotItem); - } - - #endregion - - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/ModuleN.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/ModuleN.cs deleted file mode 100644 index af2dc39..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/ModuleN.cs +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Globalization; -using System.Windows.Forms; -using net.sf.jni4net; -using net.sf.robocode.core; -using net.sf.robocode.dotnet.peer; -using net.sf.robocode.host; -using net.sf.robocode.io; -using net.sf.robocode.manager; -using net.sf.robocode.security; -using net.sf.robocode.serialization; -using Robocode; -using robocode.control; - -namespace net.sf.robocode.dotnet.nhost -{ - public class ModuleN - { - public static void InitN() - { - System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; - System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; - HiddenAccessN.init(); - LoggerN.IsSafeThread = true; - LoggerN.setLogListener(new Logger(true)); - HiddenAccessN.randomHelper = new RandomFactory(true); - - var versionManager = - Bridge.Cast(ContainerBase.getComponent(IVersionManagerBase_._class)); - int currentVersion = versionManager.getVersionAsInt(); - RbSerializer.Init(currentVersion); - RbSerializerN.Init(currentVersion); - - RbSerializerN.register(typeof (RobotStatus), RbSerializerN.RobotStatus_TYPE); - RbSerializerN.register(typeof (BattleResults), RbSerializerN.BattleResults_TYPE); - RbSerializerN.register(typeof (Bullet), RbSerializerN.Bullet_TYPE); - RbSerializerN.register(typeof (RobotStatics), RbSerializerN.RobotStatics_TYPE); - - // events - RbSerializerN.register(typeof (RoundEndedEvent), RbSerializerN.RoundEndedEvent_TYPE); - RbSerializerN.register(typeof (BattleEndedEvent), RbSerializerN.BattleEndedEvent_TYPE); - RbSerializerN.register(typeof (BulletHitBulletEvent), RbSerializerN.BulletHitBulletEvent_TYPE); - RbSerializerN.register(typeof (BulletHitEvent), RbSerializerN.BulletHitEvent_TYPE); - RbSerializerN.register(typeof (BulletMissedEvent), RbSerializerN.BulletMissedEvent_TYPE); - RbSerializerN.register(typeof (DeathEvent), RbSerializerN.DeathEvent_TYPE); - RbSerializerN.register(typeof (WinEvent), RbSerializerN.WinEvent_TYPE); - RbSerializerN.register(typeof (HitWallEvent), RbSerializerN.HitWallEvent_TYPE); - RbSerializerN.register(typeof (RobotDeathEvent), RbSerializerN.RobotDeathEvent_TYPE); - RbSerializerN.register(typeof (SkippedTurnEvent), RbSerializerN.SkippedTurnEvent_TYPE); - RbSerializerN.register(typeof (ScannedRobotEvent), RbSerializerN.ScannedRobotEvent_TYPE); - RbSerializerN.register(typeof (HitByBulletEvent), RbSerializerN.HitByBulletEvent_TYPE); - RbSerializerN.register(typeof (HitRobotEvent), RbSerializerN.HitRobotEvent_TYPE); - RbSerializerN.register(typeof (KeyPressedEvent), RbSerializerN.KeyPressedEvent_TYPE); - RbSerializerN.register(typeof (KeyReleasedEvent), RbSerializerN.KeyReleasedEvent_TYPE); - RbSerializerN.register(typeof (KeyTypedEvent), RbSerializerN.KeyTypedEvent_TYPE); - RbSerializerN.register(typeof (MouseClickedEvent), RbSerializerN.MouseClickedEvent_TYPE); - RbSerializerN.register(typeof (MouseDraggedEvent), RbSerializerN.MouseDraggedEvent_TYPE); - RbSerializerN.register(typeof (MouseEnteredEvent), RbSerializerN.MouseEnteredEvent_TYPE); - RbSerializerN.register(typeof (MouseExitedEvent), RbSerializerN.MouseExitedEvent_TYPE); - RbSerializerN.register(typeof (MouseMovedEvent), RbSerializerN.MouseMovedEvent_TYPE); - RbSerializerN.register(typeof (MousePressedEvent), RbSerializerN.MousePressedEvent_TYPE); - RbSerializerN.register(typeof (MouseReleasedEvent), RbSerializerN.MouseReleasedEvent_TYPE); - RbSerializerN.register(typeof (MouseWheelMovedEvent), RbSerializerN.MouseWheelMovedEvent_TYPE); - - RbSerializerN.register(typeof (ExecCommands), RbSerializerN.ExecCommands_TYPE); - RbSerializerN.register(typeof (BulletCommand), RbSerializerN.BulletCommand_TYPE); - RbSerializerN.register(typeof (TeamMessage), RbSerializerN.TeamMessage_TYPE); - RbSerializerN.register(typeof (DebugProperty), RbSerializerN.DebugProperty_TYPE); - RbSerializerN.register(typeof (ExecResults), RbSerializerN.ExecResults_TYPE); - RbSerializerN.register(typeof (BulletStatus), RbSerializerN.BulletStatus_TYPE); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/RobotStatics.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/RobotStatics.cs deleted file mode 100644 index 9267e4f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/RobotStatics.cs +++ /dev/null @@ -1,312 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using net.sf.robocode.nio; -using net.sf.robocode.peer; -using net.sf.robocode.security; -using net.sf.robocode.serialization; -using Robocode; - -namespace net.sf.robocode.host -{ - [Serializable] - public class RobotStatics : IRobotStaticsN - { - private readonly string robocodeVersion; - private readonly BattleRules battleRules; - private readonly int contestantIndex; - private readonly string fullClassName; - private readonly int index; - private readonly bool isJuniorRobot; - private readonly bool isAdvancedRobot; - private readonly bool isTeamRobot; - private readonly bool isDroid; - private readonly bool isSentryRobot; - private readonly bool isInteractiveRobot; - private readonly bool isPaintRobot; - private readonly bool isTeamLeader; - private readonly string name; - private readonly string shortClassName; - private readonly string shortName; - private readonly string teamName; - private readonly string[] teammates; - private readonly string veryShortName; - - public RobotStatics(string robocodeVersion, bool isJuniorRobot, bool isInteractiveRobot, bool isPaintRobot, bool isAdvancedRobot, - bool isTeamRobot, bool isTeamLeader, bool isDroid, bool isSentryRobot, string name, string shortName, - string veryShortName, string fullClassName, string shortClassName, BattleRules battleRules, - string[] teammates, string teamName, int index, int contestantIndex) - { - this.robocodeVersion = robocodeVersion; - this.isJuniorRobot = isJuniorRobot; - this.isAdvancedRobot = isAdvancedRobot; - this.isTeamRobot = isTeamRobot; - this.isDroid = isDroid; - this.isSentryRobot = isSentryRobot; - this.isInteractiveRobot = isInteractiveRobot; - this.isPaintRobot = isPaintRobot; - this.isTeamLeader = isTeamLeader; - this.name = name; - this.shortName = shortName; - this.veryShortName = veryShortName; - this.fullClassName = fullClassName; - this.shortClassName = shortClassName; - this.battleRules = battleRules; - this.teammates = teammates; - this.teamName = teamName; - this.index = index; - this.contestantIndex = contestantIndex; - } - - #region IRobotStaticsN Members - - public bool IsInteractiveRobot() - { - return isInteractiveRobot; - } - - public bool IsPaintRobot() - { - return isPaintRobot; - } - - public bool IsAdvancedRobot() - { - return isAdvancedRobot; - } - - public bool IsTeamRobot() - { - return isTeamRobot; - } - - #endregion - - public string getRobocodeVersion() - { - return robocodeVersion; - } - - public bool IsJuniorRobot() - { - return isJuniorRobot; - } - - public bool IsDroid() - { - return isDroid; - } - - public bool IsTeamLeader() - { - return isTeamLeader; - } - - public string getName() - { - return name; - } - - public string getShortName() - { - return shortName; - } - - public string getVeryShortName() - { - return veryShortName; - } - - public string getFullClassName() - { - return fullClassName; - } - - public string getShortClassName() - { - return shortClassName; - } - - public BattleRules getBattleRules() - { - return battleRules; - } - - public string[] getTeammates() - { - if (teammates == null) - { - return null; - } - var copy = new string[teammates.Length]; - Array.Copy(teammates, copy, teammates.Length); - return copy; - } - - public string getTeamName() - { - return teamName; - } - - public int getIndex() - { - return index; - } - - public int getContestIndex() - { - return contestantIndex; - } - - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - #region Nested type: SerializableHelper - - private class SerializableHelper : ISerializableHelperN - { - #region ISerializableHelperN Members - - public int sizeOf(RbSerializerN serializer, object obje) - { - var obj = (RobotStatics) obje; - int size = RbSerializerN.SIZEOF_TYPEINFO - + serializer.sizeOf(obj.robocodeVersion) - + RbSerializerN.SIZEOF_BOOL * 9 - + serializer.sizeOf(obj.name) - + serializer.sizeOf(obj.shortName) - + serializer.sizeOf(obj.veryShortName) - + serializer.sizeOf(obj.fullClassName) - + serializer.sizeOf(obj.shortClassName) - + RbSerializerN.SIZEOF_INT*6 - + RbSerializerN.SIZEOF_DOUBLE - + RbSerializerN.SIZEOF_LONG; - if (obj.teammates != null) - { - foreach (String mate in obj.teammates) - { - size += serializer.sizeOf(mate); - } - } - size += RbSerializerN.SIZEOF_INT; - size += serializer.sizeOf(obj.teamName); - - return size; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, object obje) - { - var obj = (RobotStatics) obje; - - serializer.serialize(buffer, obj.robocodeVersion); - serializer.serialize(buffer, obj.isJuniorRobot); - serializer.serialize(buffer, obj.isInteractiveRobot); - serializer.serialize(buffer, obj.isPaintRobot); - serializer.serialize(buffer, obj.isAdvancedRobot); - serializer.serialize(buffer, obj.isTeamRobot); - serializer.serialize(buffer, obj.isTeamLeader); - serializer.serialize(buffer, obj.isDroid); - serializer.serialize(buffer, obj.isSentryRobot); - serializer.serialize(buffer, obj.name); - serializer.serialize(buffer, obj.shortName); - serializer.serialize(buffer, obj.veryShortName); - serializer.serialize(buffer, obj.fullClassName); - serializer.serialize(buffer, obj.shortClassName); - serializer.serialize(buffer, obj.battleRules.BattlefieldWidth); - serializer.serialize(buffer, obj.battleRules.BattlefieldHeight); - serializer.serialize(buffer, obj.battleRules.NumRounds); - serializer.serialize(buffer, obj.battleRules.GunCoolingRate); - serializer.serialize(buffer, obj.battleRules.InactivityTime); - serializer.serialize(buffer, obj.battleRules.HideEnemyNames); - serializer.serialize(buffer, obj.battleRules.SentryBorderSize); - if (obj.teammates != null) - { - foreach (string mate in obj.teammates) - { - serializer.serialize(buffer, mate); - } - } - buffer.putInt(-1); - serializer.serialize(buffer, obj.teamName); - serializer.serialize(buffer, obj.index); - serializer.serialize(buffer, obj.contestantIndex); - } - - public object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - string robocodeVersion = serializer.deserializeString(buffer); - bool isJuniorRobot = serializer.deserializeBoolean(buffer); - bool isInteractiveRobot = serializer.deserializeBoolean(buffer); - bool isPaintRobot = serializer.deserializeBoolean(buffer); - bool isAdvancedRobot = serializer.deserializeBoolean(buffer); - bool isTeamRobot = serializer.deserializeBoolean(buffer); - bool isTeamLeader = serializer.deserializeBoolean(buffer); - bool isDroid = serializer.deserializeBoolean(buffer); - bool isSentryRobot = serializer.deserializeBoolean(buffer); - string name = serializer.deserializeString(buffer); - string shortName = serializer.deserializeString(buffer); - string veryShortName = serializer.deserializeString(buffer); - string fullClassName = serializer.deserializeString(buffer); - string shortClassName = serializer.deserializeString(buffer); - BattleRules battleRules = HiddenAccessN.createRules( - serializer.deserializeInt(buffer), // BattlefieldWidth - serializer.deserializeInt(buffer), // BattlefieldHeight - serializer.deserializeInt(buffer), // NumRounds - serializer.deserializeDouble(buffer), // GunCoolingRate - serializer.deserializeLong(buffer), // InactivityTime - serializer.deserializeBoolean(buffer), // HideEnemyNames - serializer.deserializeInt(buffer) // SentryBorderSize - ); - - var teammates = new List(); - object item = serializer.deserializeString(buffer); - while (item != null) - { - if (item is string) - { - teammates.Add((string) item); - } - item = serializer.deserializeString(buffer); - } - - string teamName = serializer.deserializeString(buffer); - int index = serializer.deserializeInt(buffer); - int contestantIndex = serializer.deserializeInt(buffer); - - return new RobotStatics( - robocodeVersion, - isJuniorRobot, - isInteractiveRobot, - isPaintRobot, - isAdvancedRobot, - isTeamRobot, - isTeamLeader, - isDroid, - isSentryRobot, - name, - shortName, - veryShortName, - fullClassName, - shortClassName, - battleRules, - teammates.ToArray(), - teamName, - index, - contestantIndex - ); - } - - #endregion - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/events/EventManager.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/events/EventManager.cs deleted file mode 100644 index 85a9daa..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/events/EventManager.cs +++ /dev/null @@ -1,702 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using System.Security; -using System.Security.Permissions; -using net.sf.robocode.dotnet.host.proxies; -using net.sf.robocode.security; -using Robocode; -using robocode.exception; -using Robocode.Exception; -using Robocode.RobotInterfaces; - -namespace net.sf.robocode.dotnet.host.events -{ - /// - /// This class is used for managing the event queue for a robot. - /// - public sealed class EventManager - { - private const int MAX_PRIORITY = 100; - public const int MAX_EVENT_STACK = 2; - public const int MAX_QUEUE_SIZE = 256; - - private readonly List customEvents = new List(); - private readonly EventQueue eventQueue; - - private readonly bool[] interruptible = new bool[MAX_PRIORITY + 1]; - private Event currentTopEvent; - private int currentTopEventPriority; - private ScannedRobotEvent dummyScannedRobotEvent; - private Dictionary eventNames; - - private IBasicRobot robot; - private BasicRobotProxy robotProxy; - - /// - /// Constructs a new EventManager. - /// - /// the robot proxy that this event manager applies to. - public EventManager(BasicRobotProxy robotProxy) - { - this.robotProxy = robotProxy; - eventQueue = new EventQueue(); - - RegisterEventNames(); - Reset(); - } - - /// - /// Adds an event to the event queue. - /// - /// is the event to add to the event queue. - public void Add(Event evnt) - { - if (!HiddenAccessN.IsCriticalEvent(evnt)) - { - int priority = GetEventPriority(evnt.GetType().Name); - HiddenAccessN.SetEventPriority(evnt, priority); - } - AddImpl(evnt); - } - - /// - /// Internal method for adding an event to the event queue. - /// - /// is the event to add to the event queue. - private void AddImpl(Event evnt) - { - if (eventQueue != null) - { - if (eventQueue.Count > MAX_QUEUE_SIZE) - { - robotProxy.println( - "Not adding to " + robotProxy.getStatics().getName() + "'s queue, exceeded " + MAX_QUEUE_SIZE - + " events in queue."); - } - else - { - HiddenAccessN.SetEventTime(evnt, Time); - eventQueue.Add(evnt); - } - } - } - - /// - /// Adds an custom event to the event queue based on a condition. - /// - /// is the condition that must be met in order to trigger the custom event. - public void AddCustomEvent(Condition condition) - { - customEvents.Add(condition); - } - - /// - /// Removes all events from the event queue. - /// - /// - /// true if system events must be removed as well; - /// false if system events should stay on the event queue. - /// - public void ClearAllEvents(bool includingSystemEvents) - { - eventQueue.clear(includingSystemEvents); - // customEvents.clear(); // Custom event should not be cleared here - } - - /// - /// Cleans up the event queue. - /// - /// - /// This method should be called when the event queue is no longer needed, - /// i.e. before it must be garbage collected. - /// - public void Cleanup() - { - // Remove all events - Reset(); - - // Remove all references to robots - robot = null; - robotProxy = null; - } - - - /// - /// Returns a list containing all events currently in the robot's queue. - /// - public List GetAllEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - events.Add(e); - } - } - return events; - } - - /// - /// Returns a list containing all BulletHitBulletEvents currently in the robot's queue. - /// - public List GetBulletHitBulletEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - var c = e as BulletHitBulletEvent; - if (c != null) - { - events.Add(c); - } - } - } - return events; - } - - /// - /// Returns a list containing all BulletHitEvents currently in the robot's queue. - /// - public List GetBulletHitEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - var c = e as BulletHitEvent; - if (c != null) - { - events.Add(c); - } - } - } - return events; - } - - /// - /// Returns a list containing all BulletMissedEvents currently in the robot's queue. - /// - public List GetBulletMissedEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - var c = e as BulletMissedEvent; - if (c != null) - { - events.Add(c); - } - } - } - return events; - } - - /// - /// Returns a list containing all HitByBulletEvent currently in the robot's queue. - /// - public List GetHitByBulletEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - var c = e as HitByBulletEvent; - if (c != null) - { - events.Add(c); - } - } - } - return events; - } - - /// - /// Returns a list containing all HitRobotEvent currently in the robot's queue. - /// - public List GetHitRobotEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - var c = e as HitRobotEvent; - if (c != null) - { - events.Add(c); - } - } - } - return events; - } - - /// - /// Returns a list containing all HitWallEvent currently in the robot's queue. - /// - public List GetHitWallEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - var c = e as HitWallEvent; - if (c != null) - { - events.Add(c); - } - } - } - return events; - } - - /// - /// Returns a list containing all RobotDeathEvent currently in the robot's queue. - /// - public List GetRobotDeathEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - var c = e as RobotDeathEvent; - if (c != null) - { - events.Add(c); - } - } - } - return events; - } - - /// - /// Returns a list containing all ScannedRobotEvent currently in the robot's queue. - /// - public List GetScannedRobotEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - var c = e as ScannedRobotEvent; - if (c != null) - { - events.Add(c); - } - } - } - return events; - } - - /// - /// Returns a list containing all MessageEvent currently in the robot's queue. - /// - public List GetMessageEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - var c = e as MessageEvent; - if (c != null) - { - events.Add(c); - } - } - } - return events; - } - - /// - /// Returns a list containing all StatusEvent currently in the robot's queue. - /// - public List GetStatusEvents() - { - var events = new List(); - lock (eventQueue) - { - foreach (Event e in eventQueue) - { - var c = e as StatusEvent; - if (c != null) - { - events.Add(c); - } - } - } - return events; - } - - /// - /// Priority of the current top event. - /// - public int CurrentTopEventPriority - { - get { return currentTopEventPriority; } - } - - /// - /// Current top event. - /// - public Event CurrentTopEvent - { - get { return currentTopEvent; } - } - - /// - /// Checks if events with a specific event priority are interruptible. - /// - /// is the event priority that must be checked. - /// - public bool IsInterruptible(int priority) - { - return interruptible[priority]; - } - - /// - /// Sets the robot that will receive events dispatched from the event queue. - /// - /// is the robot that will receive event dispatched from the event queue. - public void SetRobot(IBasicRobot robot) - { - this.robot = robot; - } - - /// - /// The priority of a ScannedRobotEvent. - /// - public int ScannedRobotEventPriority - { - get { return dummyScannedRobotEvent.Priority; } - } - - /// - /// The current time/turn of the battle round. - /// - public long Time - { - get { return robotProxy.getTimeImpl(); } - } - - /// - /// This is the heart of the event manager, which processes the events for a robot. - /// - public void ProcessEvents() - { - // Remove old events - eventQueue.clear(Time - MAX_EVENT_STACK); - - // Copy list of custom events prior iteration, because user could call RemoveCustomEvent - List eventsCopy = new List(customEvents); - - // Process custom events - foreach (Condition customEvent in eventsCopy) - { - bool conditionSatisfied = CallUserCode(customEvent); - if (conditionSatisfied) - { - AddImpl(new CustomEvent(customEvent)); - } - } - - // Process event queue here - eventQueue.sort(); - - Event currentEvent; - while ((currentEvent = (eventQueue.Count > 0) ? eventQueue[0] : null) != null - && currentEvent.Priority >= currentTopEventPriority) - { - if (currentEvent.Priority == currentTopEventPriority) - { - if (currentTopEventPriority > int.MinValue && IsInterruptible(currentTopEventPriority)) - { - SetInterruptible(currentTopEventPriority, false); // we're going to restart it, so reset. - - // We are already in an event handler, took action, and a new event was generated. - // So we want to break out of the old handler to process it here. - throw new EventInterruptedException(currentEvent.Priority); - } - break; - } - - int oldTopEventPriority = currentTopEventPriority; - - currentTopEventPriority = currentEvent.Priority; - currentTopEvent = currentEvent; - - eventQueue.Remove(currentEvent); - try - { - Dispatch(currentEvent); - - SetInterruptible(currentTopEventPriority, false); - } - catch (EventInterruptedException) - { - currentTopEvent = null; - } - catch (Exception) - { - currentTopEvent = null; - throw; - } - finally - { - currentTopEventPriority = oldTopEventPriority; - } - } - } - - /// - /// Checks if the user's condition for a custom event is satisfied. - /// - /// is the condition to check. - /// - /// true if the condition is satisfied; false otherwise. - /// - [SecurityPermission(SecurityAction.Deny)] - [ReflectionPermission(SecurityAction.Deny)] - [FileIOPermission(SecurityAction.Deny)] - [UIPermission(SecurityAction.Deny)] - private bool CallUserCode(Condition condition) - { - bool conditionSatisfied; - robotProxy.setTestingCondition(true); - try - { - conditionSatisfied = condition.Test(); - } - finally - { - robotProxy.setTestingCondition(false); - } - return conditionSatisfied; - } - - /// - /// Dispatches an event for a robot. - /// - /// - /// Too old events will not be dispatched and a critical event is always dispatched. - /// - /// is the event to dispatch to the robot. - private void Dispatch(Event evnt) - { - if (robot != null && evnt != null) - { - try - { - // skip too old events - if ((evnt.Time > Time - MAX_EVENT_STACK) || HiddenAccessN.IsCriticalEvent(evnt)) - { - HiddenAccessN.Dispatch(evnt, robot, robotProxy.getStatics(), robotProxy.getGraphicsImpl()); - } - } - catch (Exception ex) - { - if (ex is SecurityException) - { - robotProxy.punishSecurityViolation(robotProxy.getStatics().getName() + " " + ex.Message); - } - else if (ex.InnerException is SecurityException) - { - robotProxy.punishSecurityViolation(robotProxy.getStatics().getName() + " " + ex.InnerException + ": " + ex.Message); - } - else if (!(ex is EventInterruptedException || ex is AbortedException || ex is DeathException || ex is DisabledException || ex is WinException)) - { - robotProxy.println("SYSTEM: " + ex.GetType().Name + " occurred on " + evnt.GetType().Name); - robotProxy.GetOut().WriteLine(ex.StackTrace); - } - throw; - } - } - } - - /// - /// Removes the custom event with the specified condition from the event queue. - /// - /// is the condition of the custom event to remove. - public void RemoveCustomEvent(Condition condition) - { - customEvents.Remove(condition); - } - - /// - /// Removes all custom events from the event queue. - /// - public void ResetCustomEvents() - { - customEvents.Clear(); - } - - /// - /// Resets this event manager by removing all events from the event queue. - /// - public void Reset() - { - lock (this) - { - currentTopEventPriority = int.MinValue; - ClearAllEvents(true); - customEvents.Clear(); - } - } - - /// - /// Changes the interruptible flag for events with a specific priority. - /// - /// - /// When an event is interrupted, events with the same priority are allowed to restart the event handler. - /// - /// is the priority of the event to set the interruptible flag for. - /// - /// true if events with the specified priority must be interruptible - /// allowing events with the same priority to restart the event handler. - /// false if events with the specified priority must not be interruptible - /// disallowing events with the same priority to restart the event handler. - /// - public void SetInterruptible(int priority, bool interruptable) - { - if (priority < 0 || priority > 99) - { - return; - } - interruptible[priority] = interruptable; - } - - /// - /// Returns the priority of events belonging to a specific class. - /// - /// - /// is a string with the full class name of the event type to get the priority from. - /// the event priority of the specified event class. - /// - public int GetEventPriority(string eventClass) - { - if (eventClass == null) - { - return -1; - } - Event evnt; - if (!eventNames.TryGetValue(eventClass, out evnt)) - { - return -1; - } - return evnt.Priority; - } - - /// - /// Sets the event priority of events belonging to a specific class. - /// - /// - /// is a string with the full class name of the event type to set the priority for. - /// is the new priority - public void SetEventPriority(string eventClass, int priority) - { - if (eventClass == null) - { - return; - } - Event evnt; - if (!eventNames.TryGetValue(eventClass, out evnt)) - { - robotProxy.println("SYSTEM: Unknown event class: " + eventClass); - return; - } - if (HiddenAccessN.IsCriticalEvent(evnt)) - { - robotProxy.println("SYSTEM: You may not change the priority of a system event."); - } - HiddenAccessN.SetEventPriority(evnt, priority); - } - - /// - /// Registers the full and simple class names of all events used by and - /// and sets the default priority of each event class. - /// - private void RegisterEventNames() - { - eventNames = new Dictionary(); - dummyScannedRobotEvent = new ScannedRobotEvent(null, 0, 0, 0, 0, 0); - registerEventNames(new BattleEndedEvent(false, null)); - registerEventNames(new BulletHitBulletEvent(null, null)); - registerEventNames(new BulletHitEvent(null, 0, null)); - registerEventNames(new BulletMissedEvent(null)); - registerEventNames(new DeathEvent()); - registerEventNames(new HitByBulletEvent(0, null)); - registerEventNames(new HitRobotEvent(null, 0, 0, false)); - registerEventNames(new HitWallEvent(0)); - registerEventNames(new KeyPressedEvent('a', 0, 0, 0, 0, 0)); - registerEventNames(new KeyReleasedEvent('a', 0, 0, 0, 0, 0)); - registerEventNames(new KeyTypedEvent('a', 0, 0, 0, 0, 0)); - registerEventNames(new MessageEvent(null, null)); - registerEventNames(new MouseClickedEvent(0, 0, 0, 0, 0, 0, 0)); - registerEventNames(new MouseDraggedEvent(0, 0, 0, 0, 0, 0, 0)); - registerEventNames(new MouseEnteredEvent(0, 0, 0, 0, 0, 0, 0)); - registerEventNames(new MouseExitedEvent(0, 0, 0, 0, 0, 0, 0)); - registerEventNames(new MouseMovedEvent(0, 0, 0, 0, 0, 0, 0)); - registerEventNames(new MousePressedEvent(0, 0, 0, 0, 0, 0, 0)); - registerEventNames(new MouseReleasedEvent(0, 0, 0, 0, 0, 0, 0)); - registerEventNames(new MouseWheelMovedEvent(0, 0, 0, 0, 0, 0, 0, 0, 0)); - registerEventNames(new PaintEvent()); - registerEventNames(new RobotDeathEvent(null)); - registerEventNames(dummyScannedRobotEvent); - registerEventNames(new SkippedTurnEvent(0)); - registerEventNames(new StatusEvent(null)); - registerEventNames(new WinEvent()); - - // same as any line above but for custom event - var customEvent = new DummyCustomEvent(); - eventNames.Add("robocode.CustomEvent", customEvent); // full name with package name - eventNames.Add("CustomEvent", customEvent); // only the class name - } - - /// - /// Registers the full and simple class name of the specified event and sets the default - /// priority of the event class. - /// - /// an event belonging to the event class to register the class name for etc. - private void registerEventNames(Event evnt) - { - if (!HiddenAccessN.IsCriticalEvent(evnt)) - { - HiddenAccessN.SetDefaultPriority(evnt); - } - Type type = evnt.GetType(); - eventNames.Add(type.FullName, evnt); // full name with package name - eventNames.Add(type.Name, evnt); // only the class name - } - - #region Nested type: DummyCustomEvent - - /// - /// A dummy CustomEvent used only for registering the class name. - /// - private sealed class DummyCustomEvent : CustomEvent - { - public DummyCustomEvent() - : base(null) - { - } - } - - #endregion - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/events/EventQueue.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/events/EventQueue.cs deleted file mode 100644 index 69d9089..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/events/EventQueue.cs +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Collections.Generic; -using net.sf.robocode.security; -using Robocode; - -namespace net.sf.robocode.dotnet.host.events -{ - internal class EventQueue : List - { - public void clear(bool includingSystemEvents) - { - if (includingSystemEvents) - { - Clear(); - return; - } - - for (int i = 0; i < Count; i++) - { - Event e = this[i]; - - if (!HiddenAccessN.IsCriticalEvent(e)) - { - RemoveAt(i--); - } - } - } - - public void clear(long clearTime) - { - for (int i = 0; i < Count; i++) - { - Event e = this[i]; - - if ((e.Time <= clearTime) && !HiddenAccessN.IsCriticalEvent(e)) - { - RemoveAt(i--); - } - } - } - - public void sort() - { - Sort(); - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/AdvancedRobotProxy.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/AdvancedRobotProxy.cs deleted file mode 100644 index 8220b51..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/AdvancedRobotProxy.cs +++ /dev/null @@ -1,227 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using System.IO; -using net.sf.robocode.host; -using net.sf.robocode.peer; -using net.sf.robocode.repository; -using Robocode; -using Robocode.RobotInterfaces.Peer; - -namespace net.sf.robocode.dotnet.host.proxies -{ - internal class AdvancedRobotProxy : StandardRobotProxy, IAdvancedRobotPeer - { - public AdvancedRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, - RobotStatics statics) - : base(specification, hostManager, peer, statics) - { - } - - // asynchronous actions - - #region IAdvancedRobotPeer Members - - public void SetResume() - { - SetCall(); - setResumeImpl(); - } - - public void SetStop(bool overwrite) - { - SetCall(); - setStopImpl(overwrite); - } - - public void SetMove(double distance) - { - SetCall(); - setMoveImpl(distance); - } - - public void SetTurnBody(double radians) - { - SetCall(); - setTurnBodyImpl(radians); - } - - public void SetTurnGun(double radians) - { - SetCall(); - setTurnGunImpl(radians); - } - - public void SetTurnRadar(double radians) - { - SetCall(); - setTurnRadarImpl(radians); - } - - // blocking actions - public void WaitFor(Condition condition) - { - waitCondition = condition; - do - { - Execute(); // Always tick at least once - } while (!condition.Test()); - - waitCondition = null; - } - - // fast setters - public void SetMaxTurnRate(double newTurnRate) - { - SetCall(); - if (Double.IsNaN(newTurnRate)) - { - println("You cannot SetMaxTurnRate to: " + newTurnRate); - return; - } - commands.setMaxTurnRate(newTurnRate); - } - - public void SetMaxVelocity(double newVelocity) - { - SetCall(); - if (Double.IsNaN(newVelocity)) - { - println("You cannot SetMaxVelocity to: " + newVelocity); - return; - } - commands.setMaxVelocity(newVelocity); - } - - // events manipulation - public void SetInterruptible(bool interruptable) - { - SetCall(); - eventManager.SetInterruptible(eventManager.CurrentTopEventPriority, interruptable); - } - - public void SetEventPriority(String eventClass, int priority) - { - SetCall(); - eventManager.SetEventPriority(eventClass, priority); - } - - public int GetEventPriority(String eventClass) - { - GetCall(); - return eventManager.GetEventPriority(eventClass); - } - - public void RemoveCustomEvent(Condition condition) - { - SetCall(); - eventManager.RemoveCustomEvent(condition); - } - - public void AddCustomEvent(Condition condition) - { - SetCall(); - eventManager.AddCustomEvent(condition); - } - - public void clearAllEvents() - { - SetCall(); - eventManager.ClearAllEvents(false); - } - - public IList GetAllEvents() - { - GetCall(); - return eventManager.GetAllEvents(); - } - - public IList GetStatusEvents() - { - GetCall(); - return eventManager.GetStatusEvents(); - } - - public IList GetBulletMissedEvents() - { - GetCall(); - return eventManager.GetBulletMissedEvents(); - } - - public IList GetBulletHitBulletEvents() - { - GetCall(); - return eventManager.GetBulletHitBulletEvents(); - } - - public IList GetBulletHitEvents() - { - GetCall(); - return eventManager.GetBulletHitEvents(); - } - - public IList GetHitByBulletEvents() - { - GetCall(); - return eventManager.GetHitByBulletEvents(); - } - - public IList GetHitRobotEvents() - { - GetCall(); - return eventManager.GetHitRobotEvents(); - } - - public IList GetHitWallEvents() - { - GetCall(); - return eventManager.GetHitWallEvents(); - } - - public IList GetRobotDeathEvents() - { - GetCall(); - return eventManager.GetRobotDeathEvents(); - } - - public IList GetScannedRobotEvents() - { - GetCall(); - return eventManager.GetScannedRobotEvents(); - } - - // data - public string GetDataDirectory() - { - GetCall(); - commands.setIORobot(); - return robotFileSystemManager.getWritableDirectory(); - } - - public Stream GetDataFile(string filename) - { - GetCall(); - commands.setIORobot(); - if (filename.Contains("..")) - { - throw new AccessViolationException("no relative path allowed"); - } - - return robotFileSystemManager.getDataFile(filename); - } - - public long GetDataQuotaAvailable() - { - GetCall(); - return robotFileSystemManager.getDataQuotaAvailable(); - } - - #endregion - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/BasicRobotProxy.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/BasicRobotProxy.cs deleted file mode 100644 index 125e00c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/BasicRobotProxy.cs +++ /dev/null @@ -1,716 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.Threading; -using net.sf.jni4net.nio; -using net.sf.robocode.dotnet.host.events; -using net.sf.robocode.dotnet.peer; -using net.sf.robocode.host; -using net.sf.robocode.io; -using net.sf.robocode.peer; -using net.sf.robocode.repository; -using net.sf.robocode.security; -using net.sf.robocode.serialization; -using Robocode; -using robocode.exception; -using Robocode.Exception; -using Robocode.RobotInterfaces.Peer; -using Robocode.Util; -using ByteBuffer = net.sf.robocode.nio.ByteBuffer; -using Thread = System.Threading.Thread; - -namespace net.sf.robocode.dotnet.host.proxies -{ - public class BasicRobotProxy : HostingRobotProxy, IBasicRobotPeer - { - private const long - MAX_SET_CALL_COUNT = 10000, - MAX_GET_CALL_COUNT = 10000; - - private GraphicsProxy graphicsProxy; - - private RobotStatus status; - private bool isDisabled; - protected ExecCommands commands; - private ExecResults execResults; - - private readonly Dictionary bullets = new Dictionary(); - private int bulletCounter; - - private int setCallCount; - private int getCallCount; - - protected Condition waitCondition; - private bool testingCondition; - private double firedEnergy; - private double firedHeat; - - private readonly DirectByteBuffer execJavaBuffer; - private readonly ByteBuffer execNetBuffer; - private readonly RbSerializerN rbSerializerN; - - public BasicRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, RobotStatics statics) - : base(specification, hostManager, peer, statics) - { - eventManager = new EventManager(this); - - graphicsProxy = new GraphicsProxy(); - - // dummy - execResults = new ExecResults(null, null, null, null, null, false, false, false); - - setSetCallCount(0); - setGetCallCount(0); - - var sharedBuffer = new byte[10*1024*100]; - execJavaBuffer = new DirectByteBuffer(sharedBuffer); - execNetBuffer = ByteBuffer.wrap(sharedBuffer); - rbSerializerN = new RbSerializerN(); - this.peer.setupBuffer(execJavaBuffer); - } - - // asynchronous actions - - #region IBasicRobotPeer Members - - public Bullet SetFire(double power) - { - SetCall(); - return setFireImpl(power); - } - - // blocking actions - public void Execute() - { - executeImpl(); - } - - public void Move(double distance) - { - setMoveImpl(distance); - do - { - Execute(); // Always tick at least once - } while (GetDistanceRemaining() != 0); - } - - public void TurnBody(double radians) - { - setTurnBodyImpl(radians); - do - { - Execute(); // Always tick at least once - } while (GetBodyTurnRemaining() != 0); - } - - public void TurnGun(double radians) - { - setTurnGunImpl(radians); - do - { - Execute(); // Always tick at least once - } while (GetGunTurnRemaining() != 0); - } - - public Bullet Fire(double power) - { - Bullet bullet = SetFire(power); - - Execute(); - return bullet; - } - - // fast setters - public void SetBodyColor(Color color) - { - SetCall(); - commands.setBodyColor(color.ToArgb()); - } - - public Color GetBodyColor() - { - GetCall(); - return Color.FromArgb(commands.getBodyColor()); - } - - public void SetGunColor(Color color) - { - SetCall(); - commands.setGunColor(color.ToArgb()); - } - - public Color GetGunColor() - { - GetCall(); - return Color.FromArgb(commands.getGunColor()); - } - - public void SetRadarColor(Color color) - { - SetCall(); - commands.setRadarColor(color.ToArgb()); - } - - public Color GetRadarColor() - { - GetCall(); - return Color.FromArgb(commands.getRadarColor()); - } - - public void SetBulletColor(Color color) - { - SetCall(); - commands.setBulletColor(color.ToArgb()); - } - - public Color GetBulletColor() - { - GetCall(); - return Color.FromArgb(commands.getBulletColor()); - } - - public void SetScanColor(Color color) - { - SetCall(); - commands.setScanColor(color.ToArgb()); - } - - public Color GetScanColor() - { - GetCall(); - return Color.FromArgb(commands.getScanColor()); - } - - // counters - public void SetCall() - { - if (!isDisabled) - { - int res = Interlocked.Increment(ref setCallCount); - - if (res >= MAX_SET_CALL_COUNT) - { - isDisabled = true; - println("SYSTEM: You have made " + res + " calls to setXX methods without calling Execute()"); - throw new DisabledException("Too many calls to setXX methods"); - } - } - } - - public void GetCall() - { - if (!isDisabled) - { - int res = Interlocked.Increment(ref getCallCount); - - if (res >= MAX_GET_CALL_COUNT) - { - isDisabled = true; - println("SYSTEM: You have made " + res + " calls to getXX methods without calling Execute()"); - throw new DisabledException("Too many calls to getXX methods"); - } - } - } - - public double GetDistanceRemaining() - { - GetCall(); - return commands.getDistanceRemaining(); - } - - public double GetRadarTurnRemaining() - { - GetCall(); - return commands.getRadarTurnRemaining(); - } - - public double GetBodyTurnRemaining() - { - GetCall(); - return commands.getBodyTurnRemaining(); - } - - public double GetGunTurnRemaining() - { - GetCall(); - return commands.getGunTurnRemaining(); - } - - public double GetVelocity() - { - GetCall(); - return status.Velocity; - } - - public double GetGunCoolingRate() - { - GetCall(); - return statics.getBattleRules().GunCoolingRate; - } - - public String GetName() - { - GetCall(); - return statics.getName(); - } - - public long GetTime() - { - GetCall(); - return getTimeImpl(); - } - - public double GetBodyHeading() - { - GetCall(); - return status.HeadingRadians; - } - - public double GetGunHeading() - { - GetCall(); - return status.GunHeadingRadians; - } - - public double GetRadarHeading() - { - GetCall(); - return status.RadarHeadingRadians; - } - - public double GetEnergy() - { - GetCall(); - return getEnergyImpl(); - } - - public double GetGunHeat() - { - GetCall(); - return getGunHeatImpl(); - } - - public double GetX() - { - GetCall(); - return status.X; - } - - public double GetY() - { - GetCall(); - return status.Y; - } - - public int GetOthers() - { - GetCall(); - return status.Others; - } - - public int GetNumSentries() - { - GetCall(); - return status.NumSentries; - } - - public double GetBattleFieldHeight() - { - GetCall(); - return statics.getBattleRules().BattlefieldHeight; - } - - public double GetBattleFieldWidth() - { - GetCall(); - return statics.getBattleRules().BattlefieldWidth; - } - - public int GetNumRounds() - { - GetCall(); - return statics.getBattleRules().NumRounds; - } - - public int GetRoundNum() - { - GetCall(); - return status.RoundNum; - } - - public int GetSentryBorderSize() - { - GetCall(); - return statics.getBattleRules().SentryBorderSize; - } - - public IGraphics GetGraphics() - { - GetCall(); - commands.setTryingToPaint(true); - return getGraphicsImpl(); - } - - public void SetDebugProperty(String key, String value) - { - SetCall(); - commands.setDebugProperty(key, value); - } - - public void Rescan() - { - bool reset = false; - bool origInterruptableValue = false; - - if (eventManager.CurrentTopEventPriority == eventManager.ScannedRobotEventPriority) - { - reset = true; - origInterruptableValue = eventManager.IsInterruptible(eventManager.ScannedRobotEventPriority); - eventManager.SetInterruptible(eventManager.ScannedRobotEventPriority, true); - } - - commands.setScan(true); - executeImpl(); - - if (reset) - { - eventManager.SetInterruptible(eventManager.ScannedRobotEventPriority, origInterruptableValue); - } - } - - #endregion - - internal override void initializeRound(ExecCommands commands, RobotStatus status) - { - updateStatus(commands, status); - eventManager.Reset(); - var start = new StatusEvent(status); - - eventManager.Add(start); - setSetCallCount(0); - setGetCallCount(0); - } - - public override void cleanup() - { - base.cleanup(); - - // Cleanup and remove current wait condition - waitCondition = null; - - // Cleanup and remove the event manager - if (eventManager != null) - { - eventManager.Cleanup(); - eventManager = null; - } - - graphicsProxy = null; - execResults = null; - status = null; - commands = null; - } - - // ----------- - // implementations - // ----------- - - public long getTimeImpl() - { - return status.Time; - } - - public IGraphics getGraphicsImpl() - { - return graphicsProxy; - } - - protected override sealed void executeImpl() - { - if (execResults == null) - { - // this is to slow down undead robot after cleanup, from fast exception-loop - Thread.Sleep(1000); - } - - // Entering tick - if (testingCondition) - { - throw new RobotException( - "You cannot take action inside Condition.Test(). You should handle OnCustomEvent instead."); - } - - setSetCallCount(0); - setGetCallCount(0); - - // This stops autoscan from scanning... - if (waitCondition != null && waitCondition.Test()) - { - waitCondition = null; - commands.setScan(true); - } - - commands.setOutputText(GetOutTextAndReset()); - commands.setGraphicsCalls(graphicsProxy.readoutQueuedCalls()); - - // call server - SerializeCommands(); - peer.executeImplSerial(); - DeserializeResults(); - - if (execResults == null) - { - throw new InvalidOperationException(); - } - - updateStatus(execResults.getCommands(), execResults.getStatus()); - - graphicsProxy.setPaintingEnabled(execResults.isPaintEnabled()); - firedEnergy = 0; - firedHeat = 0; - - // add new events - eventManager.Add(new StatusEvent(execResults.getStatus())); - if (statics.IsPaintRobot() && execResults.isPaintEnabled()) - { - // Add paint event, if robot is a paint robot and its painting is enabled - eventManager.Add(new PaintEvent()); - } - - // add other events - if (execResults.getEvents() != null) - { - foreach (Event evnt in execResults.getEvents()) - { - eventManager.Add(evnt); - HiddenAccessN.UpdateBullets(evnt, bullets); - } - } - - if (execResults.getBulletUpdates() != null) - { - foreach (BulletStatus bulletStatus in execResults.getBulletUpdates()) - { - Bullet bullet; - if (bullets.TryGetValue(bulletStatus.bulletId, out bullet)) - { - HiddenAccessN.Update(bullet, bulletStatus.x, bulletStatus.y, bulletStatus.victimName, bulletStatus.isActive); - if (!bulletStatus.isActive) - { - bullets.Remove(bulletStatus.bulletId); - } - } - } - } - - // add new team messages - loadTeamMessages(execResults.getTeamMessages()); - - eventManager.ProcessEvents(); - } - - private string GetOutTextAndReset() - { - string res; - lock (output) - { - output.Flush(); - res = outputSb.ToString(); - outputSb.Length = 0; - } - return res; - } - - - private void SerializeCommands() - { - execNetBuffer.clear(); - rbSerializerN.serializeToBuffer(execNetBuffer, RbSerializerN.ExecCommands_TYPE, commands); - execJavaBuffer.Position(0); - execJavaBuffer.Limit(execNetBuffer.limit()); - } - - private void DeserializeResults() - { - execNetBuffer.position(0); - execNetBuffer.limit(execJavaBuffer.limit()); - execResults = (ExecResults) rbSerializerN.deserialize(execNetBuffer); - } - - protected override sealed void waitForBattleEndImpl() - { - eventManager.ClearAllEvents(false); - graphicsProxy.setPaintingEnabled(false); - do - { - commands.setOutputText(GetOutTextAndReset()); - commands.setGraphicsCalls(graphicsProxy.readoutQueuedCalls()); - - // call server - try - { - SerializeCommands(); - peer.waitForBattleEndImplSerial(); - DeserializeResults(); - } - catch (Exception ex) - { - LoggerN.logMessage(statics.getName() + ": Exception: " + ex); // without stack here - return; - } - - updateStatus(execResults.getCommands(), execResults.getStatus()); - - // add new events - if (execResults.getEvents() != null) - { - foreach (Event evnt in execResults.getEvents()) - { - if (evnt is BattleEndedEvent) - { - eventManager.Add(evnt); - } - } - } - eventManager.ResetCustomEvents(); - - eventManager.ProcessEvents(); - - } while (!execResults.isHalt() && execResults.isShouldWait()); - } - - private void updateStatus(ExecCommands commands, RobotStatus status) - { - this.status = status; - this.commands = commands; - } - - protected virtual void loadTeamMessages(List teamMessages) - { - } - - protected double getEnergyImpl() - { - return status.Energy - firedEnergy; - } - - protected double getGunHeatImpl() - { - return status.GunHeat + firedHeat; - } - - protected void setMoveImpl(double distance) - { - if (getEnergyImpl() == 0) - { - return; - } - commands.setDistanceRemaining(distance); - commands.setMoved(true); - } - - protected Bullet setFireImpl(double power) - { - if (Double.IsNaN(power)) - { - println("SYSTEM: You cannot call Fire(NaN)"); - return null; - } - if (getGunHeatImpl() > 0 || getEnergyImpl() == 0) - { - return null; - } - - power = Math.Min(getEnergyImpl(), Math.Min(Math.Max(power, Rules.MIN_BULLET_POWER), Rules.MAX_BULLET_POWER)); - - Bullet bullet; - BulletCommand wrapper; - Event currentTopEvent = eventManager.CurrentTopEvent; - - bulletCounter++; - - if (currentTopEvent != null && currentTopEvent.Time == status.Time && !statics.IsAdvancedRobot() - && status.GunHeadingRadians == status.RadarHeadingRadians - && typeof (ScannedRobotEvent).IsAssignableFrom(currentTopEvent.GetType())) - { - // this is angle assisted bullet - var e = (ScannedRobotEvent) currentTopEvent; - double fireAssistAngle = Utils.NormalAbsoluteAngle(status.HeadingRadians + e.BearingRadians); - - bullet = new Bullet(fireAssistAngle, GetX(), GetY(), power, statics.getName(), null, true, bulletCounter); - wrapper = new BulletCommand(power, true, fireAssistAngle, bulletCounter); - } - else - { - // this is normal bullet - bullet = new Bullet(status.GunHeadingRadians, GetX(), GetY(), power, statics.getName(), null, true, - bulletCounter); - wrapper = new BulletCommand(power, false, 0, bulletCounter); - } - - firedEnergy += power; - firedHeat += Rules.GetGunHeat(power); - - commands.getBullets().Add(wrapper); - - bullets.Add(bulletCounter, bullet); - - return bullet; - } - - protected void setTurnGunImpl(double radians) - { - commands.setGunTurnRemaining(radians); - } - - protected void setTurnBodyImpl(double radians) - { - if (getEnergyImpl() > 0) - { - commands.setBodyTurnRemaining(radians); - } - } - - protected void setTurnRadarImpl(double radians) - { - commands.setRadarTurnRemaining(radians); - } - - // ----------- - // battle driven methods - // ----------- - - private void setSetCallCount(int setCallCount) - { - this.setCallCount = setCallCount; - } - - private void setGetCallCount(int getCallCount) - { - this.getCallCount = getCallCount; - } - - // ----------- - // for robot thread - // ----------- - - public void setTestingCondition(bool testingCondition) - { - this.testingCondition = testingCondition; - } - - - public override String ToString() - { - return statics.getShortName() + "(" + (int) status.Energy + ") X" + (int) status.X + " Y" - + (int) status.Y; - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/GraphicsProxy.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/GraphicsProxy.cs deleted file mode 100644 index b47450a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/GraphicsProxy.cs +++ /dev/null @@ -1,1284 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using net.sf.robocode.nio; -using net.sf.robocode.serialization; -using Robocode; - -namespace net.sf.robocode.dotnet.host.proxies -{ - public class GraphicsProxy : IGraphics - { - private const int INITIAL_BUFFER_SIZE = 2*1024; - private const int MAX_BUFFER_SIZE = 64*1024; - - private readonly bool isDebugging; - private readonly RbSerializerN serializer = new RbSerializerN(); - private ByteBuffer calls; - private bool isPaintingEnabled; - private int unrecoveredBufferOverflowCount; - - public GraphicsProxy() - { - calls = ByteBuffer.allocate(INITIAL_BUFFER_SIZE); - calls.order(ByteOrder.LITTLE_ENDIAN); - calls.put(calls.order() == ByteOrder.BIG_ENDIAN ? (byte) 1 : (byte) 0); - isDebugging = java.lang.System.getProperty("debug", "false") == "true"; - } - - #region IGraphics Members - - public void DrawRectangle(Pen pen, RectangleF rect) - { - DrawRectangle(pen, (int) rect.X, (int) rect.Y, (int) rect.Width, (int) rect.Height); - } - - public void DrawRectangle(Pen pen, Rectangle rect) - { - DrawRectangle(pen, rect.X, rect.Y, rect.Width, rect.Height); - } - - public void DrawRectangle(Pen pen, float x, float y, float width, float height) - { - DrawRectangle(pen, (int) x, (int) y, (int) width, (int) height); - } - - public void DrawRectangle(Pen pen, int x, int y, int width, int height) - { - if (isPaintingEnabled) - { - setColor(pen); - calls.mark(); // Mark for rollback - try - { - put(Method.DRAW_RECT); - put(x); - put(y); - put(width); - put(height); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - DrawRectangle(pen, x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - public void FillRectangle(Brush brush, RectangleF rect) - { - FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height); - } - - public void FillRectangle(Brush brush, float x, float y, float width, float height) - { - FillRectangle(brush, (int) x, (int) y, (int) width, (int) height); - } - - public void FillRectangle(Brush brush, Rectangle rect) - { - FillRectangle(brush, rect.X, rect.Y, rect.Width, rect.Height); - } - - public void FillRectangle(Brush brush, int x, int y, int width, int height) - { - if (isPaintingEnabled) - { - setColor(brush); - calls.mark(); // Mark for rollback - try - { - put(Method.FILL_RECT); - put(x); - put(y); - put(width); - put(height); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - FillRectangle(brush, x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - - public void DrawEllipse(Pen pen, int x, int y, int width, int height) - { - if (isPaintingEnabled) - { - setColor(pen); - calls.mark(); // Mark for rollback - try - { - put(Method.DRAW_OVAL); - put(x); - put(y); - put(width); - put(height); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - DrawEllipse(pen, x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - public void DrawEllipse(Pen pen, RectangleF rect) - { - DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height); - } - - public void DrawEllipse(Pen pen, float x, float y, float width, float height) - { - DrawEllipse(pen, (int) x, (int) y, (int) width, (int) height); - } - - public void DrawEllipse(Pen pen, Rectangle rect) - { - DrawEllipse(pen, rect.X, rect.Y, rect.Width, rect.Height); - } - - public void FillEllipse(Brush brush, int x, int y, int width, int height) - { - if (isPaintingEnabled) - { - setColor(brush); - calls.mark(); // Mark for rollback - try - { - put(Method.FILL_OVAL); - put(x); - put(y); - put(width); - put(height); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - FillEllipse(brush, x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - public void FillEllipse(Brush brush, RectangleF rect) - { - FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height); - } - - public void FillEllipse(Brush brush, float x, float y, float width, float height) - { - FillEllipse(brush, (int) x, (int) y, (int) width, (int) height); - } - - public void FillEllipse(Brush brush, Rectangle rect) - { - FillEllipse(brush, rect.X, rect.Y, rect.Width, rect.Height); - } - - public void DrawLine(Pen pen, float x1, float y1, float x2, float y2) - { - DrawLine(pen, (int) x1, (int) y1, (int) x2, (int) y2); - } - - public void DrawLine(Pen pen, PointF pt1, PointF pt2) - { - DrawLine(pen, (int) pt1.X, (int) pt1.Y, (int) pt2.X, (int) pt2.Y); - } - - public void DrawLine(Pen pen, Point pt1, Point pt2) - { - DrawLine(pen, pt1.X, pt1.Y, pt2.X, pt2.Y); - } - - public void DrawLine(Pen pen, int x1, int y1, int x2, int y2) - { - if (isPaintingEnabled) - { - setColor(pen); - calls.mark(); // Mark for rollback - try - { - put(Method.DRAW_LINE); - put(x1); - put(y1); - put(x2); - put(y2); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - DrawLine(pen, x1, y1, x2, y2); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - public void DrawArc(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle) - { - DrawArc(pen, (int) x, (int) y, (int) width, (int) height, (int) startAngle, (int) sweepAngle); - } - - public void DrawArc(Pen pen, RectangleF rect, float startAngle, float sweepAngle) - { - DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle); - } - - public void DrawArc(Pen pen, Rectangle rect, float startAngle, float sweepAngle) - { - DrawArc(pen, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle); - } - - public void DrawArc(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle) - { - if (isPaintingEnabled) - { - setColor(pen); - calls.mark(); // Mark for rollback - try - { - put(Method.DRAW_ARC); - put(x); - put(y); - put(width); - put(height); - put(startAngle); - put(sweepAngle); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - DrawArc(pen, x, y, width, height, startAngle, sweepAngle); - // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - public void DrawPie(Pen pen, RectangleF rect, float startAngle, float sweepAngle) - { - //for now redirected to arc, I wonder if java have Pie as well - DrawArc(pen, rect, startAngle, sweepAngle); - } - - public void DrawPie(Pen pen, float x, float y, float width, float height, float startAngle, float sweepAngle) - { - //for now redirected to arc, I wonder if java have Pie as well - DrawArc(pen, x, y, width, height, startAngle, sweepAngle); - } - - public void DrawPie(Pen pen, Rectangle rect, float startAngle, float sweepAngle) - { - //for now redirected to arc, I wonder if java have Pie as well - DrawArc(pen, rect, startAngle, sweepAngle); - } - - public void DrawPie(Pen pen, int x, int y, int width, int height, int startAngle, int sweepAngle) - { - //for now redirected to arc, I wonder if java have Pie as well - DrawArc(pen, x, y, width, height, startAngle, sweepAngle); - } - - public void FillPie(Brush brush, Rectangle rect, float startAngle, float sweepAngle) - { - FillPie(brush, rect.X, rect.Y, rect.Width, rect.Height, startAngle, sweepAngle); - } - - public void FillPie(Brush brush, float x, float y, float width, float height, float startAngle, float sweepAngle) - { - FillPie(brush, (int) x, (int) y, (int) width, (int) height, (int) startAngle, (int) sweepAngle); - } - - public void FillPie(Brush brush, int x, int y, int width, int height, int startAngle, int sweepAngle) - { - if (isPaintingEnabled) - { - setColor(brush); - calls.mark(); // Mark for rollback - try - { - put(Method.DRAW_ARC); - put(x); - put(y); - put(width); - put(height); - put(startAngle); - put(sweepAngle); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - FillPie(brush, x, y, width, height, startAngle, sweepAngle); - // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - public void DrawPolygon(Pen pen, PointF[] points) - { - if (isPaintingEnabled) - { - int[] xPoints = new int[points.Length]; - int[] yPoints = new int[points.Length]; - for (int i = 0; i < points.Length; i++) - { - xPoints[i] = (int) points[i].X; - yPoints[i] = (int) points[i].Y; - } - setColor(pen); - calls.mark(); // Mark for rollback - try - { - put(Method.DRAW_POLYGON); - put(xPoints); - put(yPoints); - put(points.Length); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - DrawPolygon(pen, points); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - public void DrawPolygon(Pen pen, Point[] points) - { - if (isPaintingEnabled) - { - int[] xPoints = new int[points.Length]; - int[] yPoints = new int[points.Length]; - for (int i = 0; i < points.Length; i++) - { - xPoints[i] = points[i].X; - yPoints[i] = points[i].Y; - } - setColor(pen); - calls.mark(); // Mark for rollback - try - { - put(Method.DRAW_POLYGON); - put(xPoints); - put(yPoints); - put(points.Length); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - DrawPolygon(pen, points); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - - public void FillPolygon(Brush brush, PointF[] points) - { - if (isPaintingEnabled) - { - int[] xPoints = new int[points.Length]; - int[] yPoints = new int[points.Length]; - for (int i = 0; i < points.Length; i++) - { - xPoints[i] = (int) points[i].X; - yPoints[i] = (int) points[i].Y; - } - setColor(brush); - calls.mark(); // Mark for rollback - try - { - put(Method.FILL_POLYGON); - put(xPoints); - put(yPoints); - put(points.Length); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - FillPolygon(brush, points); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - public void FillPolygon(Brush brush, Point[] points) - { - if (isPaintingEnabled) - { - int[] xPoints = new int[points.Length]; - int[] yPoints = new int[points.Length]; - for (int i = 0; i < points.Length; i++) - { - xPoints[i] = points[i].X; - yPoints[i] = points[i].Y; - } - setColor(brush); - calls.mark(); // Mark for rollback - try - { - put(Method.FILL_POLYGON); - put(xPoints); - put(yPoints); - put(points.Length); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - FillPolygon(brush, points); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - public void DrawString(string s, Font font, Brush brush, float x, float y) - { - DrawString(s, font, brush, (int) x, (int) y); - } - - public void DrawString(string s, Font font, Brush brush, PointF point) - { - DrawString(s, font, brush, point.X, point.Y); - } - - public void DrawString(string s, Font font, Brush brush, Point point) - { - DrawString(s, font, brush, point.X, point.Y); - } - - public void DrawString(string s, Font font, Brush brush, int x, int y) - { - if (string.IsNullOrEmpty(s)) - { - return; - } - if (isPaintingEnabled) - { - setColor(brush); - calls.mark(); // Mark for rollback - try - { - put(Method.DRAW_STRING_INT); - put(s); - put(x); - put(y); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - DrawString(s, font, brush, x, y); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - #endregion - - #region TODO - /* - - public void FillPolygon(Brush brush, PointF[] points, FillMode fillMode) - { - throw new NotImplementedException(); - } - - public void FillPolygon(Brush brush, Point[] points, FillMode fillMode) - { - throw new NotImplementedException(); - } - - public void ResetTransform() - { - throw new NotImplementedException(); - } - - public void MultiplyTransform(Matrix matrix) - { - throw new NotImplementedException(); - } - - public void MultiplyTransform(Matrix matrix, MatrixOrder order) - { - throw new NotImplementedException(); - } - - public void TranslateTransform(float dx, float dy) - { - throw new NotImplementedException(); - } - - public void TranslateTransform(float dx, float dy, MatrixOrder order) - { - throw new NotImplementedException(); - } - - public void ScaleTransform(float sx, float sy) - { - throw new NotImplementedException(); - } - - public void ScaleTransform(float sx, float sy, MatrixOrder order) - { - throw new NotImplementedException(); - } - - public void RotateTransform(float angle) - { - throw new NotImplementedException(); - } - - public void RotateTransform(float angle, MatrixOrder order) - { - throw new NotImplementedException(); - } - - public void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, PointF[] pts) - { - throw new NotImplementedException(); - } - - public void TransformPoints(CoordinateSpace destSpace, CoordinateSpace srcSpace, Point[] pts) - { - throw new NotImplementedException(); - } - - public void DrawLines(Pen pen, PointF[] points) - { - throw new NotImplementedException(); - } - - public void DrawLines(Pen pen, Point[] points) - { - throw new NotImplementedException(); - } - - public void DrawRectangles(Pen pen, RectangleF[] rects) - { - throw new NotImplementedException(); - } - - public void DrawRectangles(Pen pen, Rectangle[] rects) - { - throw new NotImplementedException(); - } - - public void DrawPath(Pen pen, GraphicsPath path) - { - throw new NotImplementedException(); - } - - public void DrawCurve(Pen pen, PointF[] points) - { - throw new NotImplementedException(); - } - - public void DrawCurve(Pen pen, PointF[] points, float tension) - { - throw new NotImplementedException(); - } - - public void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments) - { - throw new NotImplementedException(); - } - - public void DrawCurve(Pen pen, PointF[] points, int offset, int numberOfSegments, float tension) - { - throw new NotImplementedException(); - } - - public void DrawCurve(Pen pen, Point[] points) - { - throw new NotImplementedException(); - } - - public void DrawCurve(Pen pen, Point[] points, float tension) - { - throw new NotImplementedException(); - } - - public void DrawCurve(Pen pen, Point[] points, int offset, int numberOfSegments, float tension) - { - throw new NotImplementedException(); - } - - public void DrawClosedCurve(Pen pen, PointF[] points) - { - throw new NotImplementedException(); - } - - public void DrawClosedCurve(Pen pen, PointF[] points, float tension, FillMode fillmode) - { - throw new NotImplementedException(); - } - - public void DrawClosedCurve(Pen pen, Point[] points) - { - throw new NotImplementedException(); - } - - public void DrawClosedCurve(Pen pen, Point[] points, float tension, FillMode fillmode) - { - throw new NotImplementedException(); - } - - public void FillRectangles(Brush brush, RectangleF[] rects) - { - throw new NotImplementedException(); - } - - public void FillRectangles(Brush brush, Rectangle[] rects) - { - throw new NotImplementedException(); - } - - public void FillPath(Brush brush, GraphicsPath path) - { - throw new NotImplementedException(); - } - - public void FillClosedCurve(Brush brush, PointF[] points) - { - throw new NotImplementedException(); - } - - public void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode) - { - throw new NotImplementedException(); - } - - public void FillClosedCurve(Brush brush, PointF[] points, FillMode fillmode, float tension) - { - throw new NotImplementedException(); - } - - public void FillClosedCurve(Brush brush, Point[] points) - { - throw new NotImplementedException(); - } - - public void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode) - { - throw new NotImplementedException(); - } - - public void FillClosedCurve(Brush brush, Point[] points, FillMode fillmode, float tension) - { - throw new NotImplementedException(); - } - - public void FillRegion(Brush brush, Region region) - { - throw new NotImplementedException(); - } - - public void DrawString(string s, Font font, Brush brush, float x, float y, StringFormat format) - { - throw new NotImplementedException(); - } - - public void DrawString(string s, Font font, Brush brush, PointF point, StringFormat format) - { - throw new NotImplementedException(); - } - - public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle) - { - throw new NotImplementedException(); - } - - public void DrawString(string s, Font font, Brush brush, RectangleF layoutRectangle, StringFormat format) - { - throw new NotImplementedException(); - } - - public SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat, - out int charactersFitted, out int linesFilled) - { - throw new NotImplementedException(); - } - - public SizeF MeasureString(string text, Font font, PointF origin, StringFormat stringFormat) - { - throw new NotImplementedException(); - } - - public SizeF MeasureString(string text, Font font, SizeF layoutArea) - { - throw new NotImplementedException(); - } - - public SizeF MeasureString(string text, Font font, SizeF layoutArea, StringFormat stringFormat) - { - throw new NotImplementedException(); - } - - public SizeF MeasureString(string text, Font font) - { - throw new NotImplementedException(); - } - - public SizeF MeasureString(string text, Font font, int width) - { - throw new NotImplementedException(); - } - - public SizeF MeasureString(string text, Font font, int width, StringFormat format) - { - throw new NotImplementedException(); - } - - public Region[] MeasureCharacterRanges(string text, Font font, RectangleF layoutRect, StringFormat stringFormat) - { - throw new NotImplementedException(); - } - - public void SetClip(Graphics g) - { - throw new NotImplementedException(); - } - - public void SetClip(Graphics g, CombineMode combineMode) - { - throw new NotImplementedException(); - } - - public void SetClip(Rectangle rect) - { - throw new NotImplementedException(); - } - - public void SetClip(Rectangle rect, CombineMode combineMode) - { - throw new NotImplementedException(); - } - - public void SetClip(RectangleF rect) - { - throw new NotImplementedException(); - } - - public void SetClip(RectangleF rect, CombineMode combineMode) - { - throw new NotImplementedException(); - } - - public void SetClip(GraphicsPath path) - { - throw new NotImplementedException(); - } - - public void SetClip(GraphicsPath path, CombineMode combineMode) - { - throw new NotImplementedException(); - } - - public void SetClip(Region region, CombineMode combineMode) - { - throw new NotImplementedException(); - } - - public void IntersectClip(Rectangle rect) - { - throw new NotImplementedException(); - } - - public void IntersectClip(RectangleF rect) - { - throw new NotImplementedException(); - } - - public void IntersectClip(Region region) - { - throw new NotImplementedException(); - } - - public void ExcludeClip(Rectangle rect) - { - throw new NotImplementedException(); - } - - public void ExcludeClip(Region region) - { - throw new NotImplementedException(); - } - - public void ResetClip() - { - throw new NotImplementedException(); - } - - public void TranslateClip(float dx, float dy) - { - throw new NotImplementedException(); - } - - public void TranslateClip(int dx, int dy) - { - throw new NotImplementedException(); - } - - public bool IsVisible(int x, int y) - { - throw new NotImplementedException(); - } - - public bool IsVisible(Point point) - { - throw new NotImplementedException(); - } - - public bool IsVisible(float x, float y) - { - throw new NotImplementedException(); - } - - public bool IsVisible(PointF point) - { - throw new NotImplementedException(); - } - - public bool IsVisible(int x, int y, int width, int height) - { - throw new NotImplementedException(); - } - - public bool IsVisible(Rectangle rect) - { - throw new NotImplementedException(); - } - - public bool IsVisible(float x, float y, float width, float height) - { - throw new NotImplementedException(); - } - - public bool IsVisible(RectangleF rect) - { - throw new NotImplementedException(); - } - - public CompositingMode CompositingMode - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public Point RenderingOrigin - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public CompositingQuality CompositingQuality - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public TextRenderingHint TextRenderingHint - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public int TextContrast - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public SmoothingMode SmoothingMode - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public PixelOffsetMode PixelOffsetMode - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public InterpolationMode InterpolationMode - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public Matrix Transform - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public GraphicsUnit PageUnit - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public float PageScale - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public float DpiX - { - get { throw new NotImplementedException(); } - } - - public float DpiY - { - get { throw new NotImplementedException(); } - } - - public Region Clip - { - get { throw new NotImplementedException(); } - set { throw new NotImplementedException(); } - } - - public RectangleF ClipBounds - { - get { throw new NotImplementedException(); } - } - - public bool IsClipEmpty - { - get { throw new NotImplementedException(); } - } - - public RectangleF VisibleClipBounds - { - get { throw new NotImplementedException(); } - } - - public bool IsVisibleClipEmpty - { - get { throw new NotImplementedException(); } - } - */ - - #endregion - - #region Helpers - - public void setPaintingEnabled(bool value) - { - isPaintingEnabled = value; - } - - public byte[] readoutQueuedCalls() - { - if (calls == null || calls.position() == 0) - { - return null; - } - var res = new byte[calls.position()]; - - calls.flip(); - calls.get(res); - - calls.clear(); - calls.put(calls.order() == ByteOrder.BIG_ENDIAN ? (byte) 1 : (byte) 0); - - return res; - } - - private void setColor(Brush brush) - { - var sb = brush as SolidBrush; - if (sb != null) - { - setColor(sb.Color); - } - } - - private void setColor(Pen p) - { - setColor(p.Color); - } - - private void setColor(Color c) - { - if (isPaintingEnabled) - { - calls.mark(); // Mark for rollback - try - { - put(Method.SET_COLOR); - put(c); - } - catch (BufferOverflowException) - { - if (recoverFromBufferOverflow()) - { - setColor(c); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - - private bool reallocBuffer() - { - int bufferSize; - - if (calls == null) - { - // No buffer -> Use initial buffer size - bufferSize = INITIAL_BUFFER_SIZE; - } - else - { - // Otherwise, double up capacity - bufferSize = 2*calls.capacity(); - } - - // Check if the max. buffer size has been reached - if (!isDebugging && bufferSize > MAX_BUFFER_SIZE) - { - return false; // not reallocated! - } - - // Allocate new buffer - ByteBuffer newBuffer = ByteBuffer.allocate(bufferSize); -// newBuffer.order(ByteOrder.LITTLE_ENDIAN); - - if (calls != null) - { - // Copy all bytes contained in the current buffer to the new buffer - - var copiedBytes = new byte[calls.position()]; - - calls.clear(); - calls.get(copiedBytes); - - newBuffer.put(copiedBytes); - } - - // Switch to the new buffer - calls = newBuffer; - - return true; // buffer was reallocated - } - - private bool recoverFromBufferOverflow() - { - calls.reset(); // Rollback buffer - - bool recovered = reallocBuffer(); - - if (!recovered) - { - if (unrecoveredBufferOverflowCount++ == 1) - { - // Prevent spamming - java.lang.System.@out.println( - "SYSTEM: This robot is painting too much between actions.\n" - + "SYSTEM: Max. buffer capacity (" - + MAX_BUFFER_SIZE + " bytes per turn) has been reached.\n" - + "SYSTEM: Last painting operations are being dropped.\n"); - } - } - return recovered; - } - - private void put(Method m) - { - // FOR-DEBUG calls.putInt(0xBADF00D); - calls.put((byte) m); - // FOR-DEBUG calls.putInt(0xBADF00D); - } - - private void put(String value) - { - serializer.serialize(calls, value); - } - - private void put(bool value) - { - serializer.serialize(calls, value); - } - - private void put(byte value) - { - calls.put(value); - } - - private void put(int value) - { - calls.putInt(value); - } - - private void put(int[] values) - { - serializer.serialize(calls, values); - } - - private void put(byte[] values) - { - serializer.serialize(calls, values); - } - - private void put(char[] values) - { - serializer.serialize(calls, values); - } - - private void put(double[] values) - { - serializer.serialize(calls, values); - } - - private void put(float[] values) - { - serializer.serialize(calls, values); - } - - private void put(double value) - { - calls.putDouble(value); - } - - private void put(float value) - { - calls.putFloat(value); - } - - private void put(Color value) - { - if (value == null) - { - calls.put((byte)0); - } - else - { - calls.put((byte)1); - calls.putInt(value.ToArgb()); - } - } - - private void put(Font font) - { - if (font == null) - { - calls.put((byte)0); - } - else - { - calls.put((byte)1); - serializer.serialize(calls, font.Name); - calls.putInt((int)font.Style); - calls.putInt((int)font.Size); - } - } - - #endregion - - #region Nested type: Method - - private enum Method - { - TRANSLATE_INT, // translate(int, int) - SET_COLOR, // setColor(Color) - SET_PAINT_MODE, // setPaintMode() - SET_XOR_MODE, // setXORMode(Color) - SET_FONT, // setFont(Font) - CLIP_RECT, // clipRect(int, int, int, int) - SET_CLIP, // setClip(int, int, int, int) - SET_CLIP_SHAPE, // setClip(Shape) - COPY_AREA, // copyArea(int, int, int, int, int, int) - DRAW_LINE, // drawLine(int, int, int, int) - FILL_RECT, // fillRect(int, int, int, int) - DRAW_RECT, // drawRect(int, int, int, int) - CLEAR_RECT, // clearRect(int, int, int, int) - DRAW_ROUND_RECT, // drawRoundRect(int, int, int, int, int, int) - FILL_ROUND_RECT, // fillRoundRect(int, int, int, int, int, int) - DRAW_3D_RECT, // draw3DRect(int, int, int, int, boolean) - FILL_3D_RECT, // draw3DRect(int, int, int, int, boolean) - DRAW_OVAL, // drawOval(int, int, int, int) - FILL_OVAL, // fillOval(int, int, int, int) - DRAW_ARC, // drawArc(int, int, int, int, int, int) - FILL_ARC, // fillArc(int, int, int, int, int, int) - DRAW_POLYLINE, // drawPolyline(int[], int[], int) - DRAW_POLYGON, // drawPolygon(int[], int[], int) - FILL_POLYGON, // fillPolygon(int[], int[], int) - DRAW_STRING_INT, // drawString(String, int, int) - DRAW_STRING_ACI_INT, // drawString(AttributedCharacterIterator, int, int) - DRAW_CHARS, // drawChars(char[], int, int, int, int) - DRAW_BYTES, // drawBytes(byte[], int, int, int, int) - DRAW_IMAGE_1, // drawImage(Image, int, int, ImageObserver) - DRAW_IMAGE_2, // drawImage(Image, int, int, int, int, ImageObserver) - DRAW_IMAGE_3, // drawImage(Image, int, int, Color, ImageObserver) - DRAW_IMAGE_4, // drawImage(Image, int, int, int, int, Color, ImageObserver) - DRAW_IMAGE_5, // drawImage(Image, int, int, int, int, int, int, int, int, ImageObserver) - DRAW_IMAGE_6, // drawImage(Image, int, int, int, int, int, int, int, int, Color, ImageObserver) - DRAW_SHAPE, // draw(Shape) - DRAW_IMAGE_7, // drawImage(Image, AffineTransform, ImageObserver) - DRAW_IMAGE_8, // drawImage(BufferedImage, BufferedImageOp, int, int) - DRAW_RENDERED_IMAGE, // drawRenderedImage(RenderedImage, AffineTransform) - DRAW_RENDERABLE_IMAGE, // drawRenderableImage(RenderableImage, AffineTransform) - DRAW_STRING_FLOAT, // drawString(String, float, float) - DRAW_STRING_ACI_FLOAT, // drawString(AttributedCharacterIterator, float, float) - DRAW_GLYPH_VECTOR, // drawGlyphVector(GlyphVector gv, float x, float y) - FILL_SHAPE, // fill(Shape) - SET_COMPOSITE, // setComposite(Composite) - SET_PAINT, // setPaint(Paint) - SET_STROKE, // setStroke(Stroke) - SET_RENDERING_HINT, // setRenderingHint(Key, Object) - SET_RENDERING_HINTS, // setRenderingHints(Map) - ADD_RENDERING_HINTS, // addRenderingHints(Map) - TRANSLATE_DOUBLE, // translate(double, double) - ROTATE, // rotate(double) - ROTATE_XY, // rotate(double, double, double) - SCALE, // scale(double, double) - SHEAR, // shear(double, double) - TRANSFORM, // transform(AffineTransform) - SET_TRANSFORM, // setTransform(AffineTransform Tx) - SET_BACKGROUND, // setBackground(Color) - CLIP, // clip(Shape) - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/HostingRobotProxy.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/HostingRobotProxy.cs deleted file mode 100644 index ecbb9a2..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/HostingRobotProxy.cs +++ /dev/null @@ -1,302 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections; -using System.Collections.Generic; -using System.IO; -using System.Security; -using System.Security.Permissions; -using java.io; -using java.lang; -using net.sf.robocode.dotnet.host.events; -using net.sf.robocode.dotnet.host.security; -using net.sf.robocode.dotnet.peer; -using net.sf.robocode.host; -using net.sf.robocode.io; -using net.sf.robocode.peer; -using net.sf.robocode.repository; -using Robocode; -using robocode.exception; -using Robocode.Exception; -using Robocode.RobotInterfaces; -using Robocode.RobotInterfaces.Peer; -using Exception = System.Exception; -using String = System.String; -using StringBuilder = System.Text.StringBuilder; - -namespace net.sf.robocode.dotnet.host.proxies -{ - public abstract class HostingRobotProxy - { - private readonly IRobotItem robotSpecification; - - protected EventManager eventManager; - protected IHostManager hostManager; - protected RobotFileSystemManager robotFileSystemManager; - - protected IBasicRobot robot; - protected IRobotPeer peer; - private Type robotType; - - protected RobotStatics statics; - protected TextWriter output; - protected StringBuilder outputSb; - - private readonly Hashtable securityViolations = Hashtable.Synchronized(new Hashtable()); - - protected HostingRobotProxy(IRobotItem robotSpecification, IHostManager hostManager, IRobotPeer peer, - RobotStatics statics) - { - this.peer = peer; - this.statics = statics; - this.hostManager = hostManager; - this.robotSpecification = robotSpecification; - - outputSb = new StringBuilder(5000); - output = TextWriter.Synchronized(new StringWriter(outputSb)); - LoggerN.robotOut = output; - - robotFileSystemManager = new RobotFileSystemManager(this, (int) hostManager.getRobotFilesystemQuota(), - robotSpecification.getWritableDirectory(), - robotSpecification.getReadableDirectory()); - } - - public void setRobotType(Type robotType) - { - this.robotType = robotType; - } - - public virtual void cleanup() - { - robot = null; - - // Remove the file system and the manager - robotFileSystemManager.cleanup(); - robotFileSystemManager = null; - } - - public TextWriter GetOut() - { - return output; - } - - public void println(String s) - { - output.WriteLine(s); - } - - public void println(Exception ex) - { - output.WriteLine(ex); - } - - public void println(java.lang.String par0) - { - output.WriteLine(par0); - } - - public RobotStatics getStatics() - { - return statics; - } - - public RobotFileSystemManager getRobotFileSystemManager() - { - return robotFileSystemManager; - } - - public ClassLoader getRobotClassloader() - { - return null; - } - - // ----------- - // battle driven methods - // ----------- - - internal abstract void initializeRound(ExecCommands commands, RobotStatus status); - - [ReflectionPermission(SecurityAction.Assert, Unrestricted = true)] - private bool loadRobotRound() - { - robot = null; - try - { - object instance = Activator.CreateInstance(robotType); - robot = instance as IBasicRobot; - if (robot == null) - { - println("SYSTEM: Skipping robot: " + statics.getName()); - return false; - } - robot.SetOut(output); - robot.SetPeer((IBasicRobotPeer) this); - Console.SetOut(output); - Console.SetError(output); - eventManager.SetRobot(robot); - } - - catch (MissingMethodException e) - { - punishSecurityViolation(statics.getName() + " " + e.Message); - return false; - } - catch (SecurityException e) - { - punishSecurityViolation(statics.getName() + " " + e.Message); - return false; - } - catch (Exception e) - { - if (e.InnerException is SecurityException) - { - - } - println("SYSTEM: An error occurred during initialization of " + statics.getName()); - println("SYSTEM: " + e); - println(e); - robot = null; - LoggerN.logMessage(e); - return false; - } - return true; - } - - protected abstract void executeImpl(); - - public void run() - { - peer.setRunning(true); - - if (robotSpecification.isValid() && loadRobotRound()) - { - try - { - if (robot != null) - { -// peer.setRunning(true); // Does not work with .NET version - - // Process all events for the first turn. - // This is done as the first robot status event must occur before the robot - // has started running. - eventManager.ProcessEvents(); - - // Call user code - CallUserCode(); - } - - // noinspection InfiniteLoopStatement - for (;;) - { - executeImpl(); - } - } - catch (WinException) - { - // Do nothing - } - catch (AbortedException) - { - // Do nothing - } - catch (DeathException) - { - println("SYSTEM: " + statics.getName() + " has died"); - } - catch (DisabledException e) - { - drainEnergy(); - - string msg = e.getMessage(); - if (msg == null) - { - msg = ""; - } - else - { - msg = ": " + msg; - } - println("SYSTEM: Robot disabled: " + msg); - LoggerN.logMessage("Robot disabled: " + statics.getName()); - } - catch (SecurityException e) - { - punishSecurityViolation(statics.getName() + " Exception: " + e); - } - catch (Exception e) - { - if (e.InnerException is SecurityException) - { - punishSecurityViolation(statics.getName() + " " + e.InnerException + " Exception: " + e); - } - else - { - drainEnergy(); - println(e); - LoggerN.logMessage(statics.getName() + ": Exception: " + e); // without stack here - } - } - finally - { - waitForBattleEndImpl(); - } - } - else - { - drainEnergy(); - peer.punishBadBehavior(BadBehavior.CANNOT_START); - waitForBattleEndImpl(); - } - - peer.setRunning(false); - } - - [SecurityPermission(SecurityAction.Deny)] - [ReflectionPermission(SecurityAction.Deny)] - [FileIOPermission(SecurityAction.Deny)] - [UIPermission(SecurityAction.Deny)] - private void CallUserCode() - { - IRunnable runnable = robot.GetRobotRunnable(); - - if (runnable != null) - { - runnable.Run(); - } - } - - protected abstract void waitForBattleEndImpl(); - - public void drainEnergy() - { - peer.drainEnergy(); - } - - public void punishSecurityViolation(java.lang.String message) - { - // Prevent unit tests of failing if multiple threads are calling this method in the same time. - // We only want the a specific type of security violation logged once so we only get one error - // per security violation. - lock (securityViolations) - { - if (!securityViolations.ContainsKey(message)) - { - securityViolations.Add(message, null); - LoggerN.logError(message); - println("SYSTEM: " + message); - - if (securityViolations.Count == 1) - { - peer.drainEnergy(); - peer.punishBadBehavior(BadBehavior.SECURITY_VIOLATION); - } - } - } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/JuniorRobotProxy.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/JuniorRobotProxy.cs deleted file mode 100644 index c660779..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/JuniorRobotProxy.cs +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using net.sf.robocode.host; -using net.sf.robocode.peer; -using net.sf.robocode.repository; -using Robocode; -using Robocode.RobotInterfaces.Peer; -using Robocode.Util; - -namespace net.sf.robocode.dotnet.host.proxies -{ - internal class JuniorRobotProxy : BasicRobotProxy, IJuniorRobotPeer - { - public JuniorRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, - RobotStatics statics) - : base(specification, hostManager, peer, statics) - { - } - - #region IJuniorRobotPeer Members - - public void TurnAndMove(double distance, double radians) - { - if (distance == 0) - { - TurnBody(radians); - return; - } - - // Save current max. velocity and max. turn rate so they can be restored - double savedMaxVelocity = commands.getMaxVelocity(); - double savedMaxTurnRate = commands.getMaxTurnRate(); - - double absDegrees = Math.Abs(Utils.ToDegrees(radians)); - double absDistance = Math.Abs(distance); - - // -- Calculate max. velocity for moving perfect in a circle -- - - // maxTurnRate = 10 * 0.75 * velocity (Robocode rule), and - // maxTurnRate = velocity * degrees / distance (curve turn rate) - // - // Hence, max. velocity = 10 / (degrees / distance + 0.75) - - double maxVelocity = Math.Min(Rules.MAX_VELOCITY, 10/(absDegrees/absDistance + 0.75)); - - // -- Calculate number of turns for acceleration + deceleration -- - - double accDist = 0; // accumulated distance during acceleration - double decDist = 0; // accumulated distance during deceleration - - int turns = 0; // number of turns to it will take to move the distance - - // Calculate the amount of turn it will take to accelerate + decelerate - // up to the max. velocity, but stop if the distance for used for - // acceleration + deceleration gets bigger than the total distance to move - for (int t = 1; t < maxVelocity; t++) - { - // Add the current velocity to the acceleration distance - accDist += t; - - // Every 2nd time we add the deceleration distance needed to - // get to a velocity of 0 - if (t > 2 && (t%2) > 0) - { - decDist += t - 2; - } - - // Stop if the acceleration + deceleration > total distance to move - if ((accDist + decDist) >= absDistance) - { - break; - } - - // Increment turn for acceleration - turns++; - - // Every 2nd time we increment time for deceleration - if (t > 2 && (t%2) > 0) - { - turns++; - } - } - - // Add number of turns for the remaining distance at max velocity - if ((accDist + decDist) < absDistance) - { - turns += (int) ((absDistance - accDist - decDist)/maxVelocity + 1); - } - - // -- Move and turn in a curve -- - - // Set the calculated max. velocity - commands.setMaxVelocity(maxVelocity); - - // Set the robot to move the specified distance - setMoveImpl(distance); - // Set the robot to turn its body to the specified amount of radians - setTurnBodyImpl(radians); - - // Loop thru the number of turns it will take to move the distance and adjust - // the max. turn rate so it fit the current velocity of the robot - for (int t = turns; t >= 0; t--) - { - commands.setMaxTurnRate(GetVelocity()*radians/absDistance); - Execute(); // Perform next turn - } - - // Restore the saved max. velocity and max. turn rate - commands.setMaxVelocity(savedMaxVelocity); - commands.setMaxTurnRate(savedMaxTurnRate); - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/StandardRobotProxy.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/StandardRobotProxy.cs deleted file mode 100644 index 13162aa..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/StandardRobotProxy.cs +++ /dev/null @@ -1,136 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using net.sf.robocode.dotnet.peer; -using net.sf.robocode.host; -using net.sf.robocode.peer; -using net.sf.robocode.repository; -using Robocode; -using Robocode.RobotInterfaces.Peer; - -namespace net.sf.robocode.dotnet.host.proxies -{ - internal class StandardRobotProxy : BasicRobotProxy, IStandardRobotPeer - { - private bool isStopped; - private double saveAngleToTurn; - private double saveDistanceToGo; - private double saveGunAngleToTurn; - private double saveRadarAngleToTurn; - - public StandardRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, - RobotStatics statics) - : base(specification, hostManager, peer, statics) - { - } - - - // blocking actions - - #region IStandardRobotPeer Members - - public void Stop(bool overwrite) - { - setStopImpl(overwrite); - Execute(); - } - - public void Resume() - { - setResumeImpl(); - Execute(); - } - - public void TurnRadar(double radians) - { - setTurnRadarImpl(radians); - do - { - Execute(); // Always tick at least once - } while (GetRadarTurnRemaining() != 0); - } - - // fast setters - public void SetAdjustGunForBodyTurn(bool newAdjustGunForBodyTurn) - { - SetCall(); - commands.setAdjustGunForBodyTurn(newAdjustGunForBodyTurn); - } - - public void SetAdjustRadarForGunTurn(bool newAdjustRadarForGunTurn) - { - SetCall(); - commands.setAdjustRadarForGunTurn(newAdjustRadarForGunTurn); - if (!commands.IsAdjustRadarForBodyTurnSet()) - { - commands.setAdjustRadarForBodyTurn(newAdjustRadarForGunTurn); - } - } - - public void SetAdjustRadarForBodyTurn(bool newAdjustRadarForBodyTurn) - { - SetCall(); - commands.setAdjustRadarForBodyTurn(newAdjustRadarForBodyTurn); - commands.setAdjustRadarForBodyTurnSet(true); - } - - public bool IsAdjustGunForBodyTurn() - { - GetCall(); - return commands.IsAdjustGunForBodyTurn(); - } - - public bool IsAdjustRadarForGunTurn() - { - GetCall(); - return commands.IsAdjustRadarForGunTurn(); - } - - public bool IsAdjustRadarForBodyTurn() - { - GetCall(); - return commands.IsAdjustRadarForBodyTurn(); - } - - #endregion - - internal override void initializeRound(ExecCommands commands, RobotStatus status) - { - base.initializeRound(commands, status); - isStopped = true; - } - - protected void setResumeImpl() - { - if (isStopped) - { - isStopped = false; - commands.setDistanceRemaining(saveDistanceToGo); - commands.setBodyTurnRemaining(saveAngleToTurn); - commands.setGunTurnRemaining(saveGunAngleToTurn); - commands.setRadarTurnRemaining(saveRadarAngleToTurn); - } - } - - protected void setStopImpl(bool overwrite) - { - if (!isStopped || overwrite) - { - saveDistanceToGo = GetDistanceRemaining(); - saveAngleToTurn = GetBodyTurnRemaining(); - saveGunAngleToTurn = GetGunTurnRemaining(); - saveRadarAngleToTurn = GetRadarTurnRemaining(); - } - isStopped = true; - - commands.setDistanceRemaining(0); - commands.setBodyTurnRemaining(0); - commands.setGunTurnRemaining(0); - commands.setRadarTurnRemaining(0); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/TeamRobotProxy.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/TeamRobotProxy.cs deleted file mode 100644 index 7215118..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/proxies/TeamRobotProxy.cs +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using System.IO; -using System.Runtime.Serialization; -using System.Runtime.Serialization.Formatters.Binary; -using System.Security.Permissions; -using net.sf.robocode.dotnet.peer; -using net.sf.robocode.host; -using net.sf.robocode.peer; -using net.sf.robocode.repository; -using Robocode; -using Robocode.RobotInterfaces.Peer; - -namespace net.sf.robocode.dotnet.host.proxies -{ - internal class TeamRobotProxy : AdvancedRobotProxy, ITeamRobotPeer - { - private const int MAX_MESSAGE_SIZE = 32768; - - public TeamRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, - RobotStatics statics) - : base(specification, hostManager, peer, statics) - { - } - - // team - - #region ITeamRobotPeer Members - - public string[] GetTeammates() - { - GetCall(); - return statics.getTeammates(); - } - - public bool IsTeammate(String name) - { - GetCall(); - if (name == statics.getName()) - { - return true; - } - String[] teammates = statics.getTeammates(); - - if (teammates != null) - { - foreach (string mate in teammates) - { - if (mate == name) - { - return true; - } - } - } - return false; - } - - public void BroadcastMessage(object message) - { - SendMessage(null, message); - } - - [SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.SerializationFormatter)] - public void SendMessage(String name, object message) - { - SetCall(); - - try - { - if (!statics.IsTeamRobot()) - { - throw new IOException("You are not on a team."); - } - using (var byteStreamWriter = new MemoryStream(MAX_MESSAGE_SIZE)) - { - var bf = new BinaryFormatter(new SerializationGuard(), new StreamingContext()); - bf.Serialize(byteStreamWriter, message); - byte[] bytes = byteStreamWriter.ToArray(); - commands.getTeamMessages().Add(new TeamMessage(GetName(), name, bytes)); - } - } - catch (Exception e) - { - output.WriteLine(e); - throw; - } - } - - // events - public IList GetMessageEvents() - { - GetCall(); - return eventManager.GetMessageEvents(); - } - - #endregion - - [SecurityPermission(SecurityAction.Assert, Flags = SecurityPermissionFlag.SerializationFormatter)] - protected override sealed void loadTeamMessages(List teamMessages) - { - if (teamMessages == null) - { - return; - } - foreach (TeamMessage teamMessage in teamMessages) - { - try - { - using (var ms = new MemoryStream(teamMessage.message)) - { - var bf = new BinaryFormatter(); - object message = bf.Deserialize(ms); - var evnt = new MessageEvent(teamMessage.sender, message); - - eventManager.Add(evnt); - } - } - catch (Exception e) - { - output.WriteLine(e); - } - } - } - - #region Nested type: SerializationGuard - - private class SerializationGuard : SurrogateSelector - { - public override ISerializationSurrogate GetSurrogate(Type type, StreamingContext context, - out ISurrogateSelector selector) - { - if (typeof (MarshalByRefObject).IsAssignableFrom(type)) - { - throw new AccessViolationException("Messages should not contain MarshalByRefObject objects"); - } - return base.GetSurrogate(type, context, out selector); - } - } - - #endregion - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/security/QuotaStream.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/security/QuotaStream.cs deleted file mode 100644 index 96e9df0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/security/QuotaStream.cs +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.IO; -using System.Runtime.Remoting; -using System.Threading; -using Microsoft.Win32.SafeHandles; - -namespace net.sf.robocode.dotnet.host.security -{ - internal class QuotaStream : FileStream - { - private readonly RobotFileSystemManager manager; - - public QuotaStream(RobotFileSystemManager manager, String path, FileMode mode, FileAccess access, - FileShare share) - : base(path, mode, access, share) - { - this.manager = manager; - } - - [Obsolete] - public override IntPtr Handle - { - get { throw new AccessViolationException(); } - } - - public override SafeFileHandle SafeFileHandle - { - get { throw new AccessViolationException(); } - } - - public override void SetLength(long value) - { - manager.appendQuotaUsed(value - Length); - base.SetLength(value); - } - - public override void WriteByte(byte value) - { - long delta = Position + 1 - Length; - if (delta > 0) - { - manager.appendQuotaUsed(delta); - } - base.WriteByte(value); - } - - public override void Write(byte[] array, int offset, int count) - { - long delta = Position + count - Length; - if (delta > 0) - { - manager.appendQuotaUsed(delta); - } - base.Write(array, offset, count); - } - - public override IAsyncResult BeginWrite(byte[] array, int offset, int numBytes, AsyncCallback userCallback, - object stateObject) - { - long delta = Position + numBytes - Length; - if (delta > 0) - { - manager.appendQuotaUsed(delta); - } - return base.BeginWrite(array, offset, numBytes, userCallback, stateObject); - } - - /*public override long Position - { - get { return base.Position; } - set - { - base.Position = value; - } - } - - public override long Seek(long offset, SeekOrigin origin) - { - return base.Seek(offset, origin); - }*/ - - public override ObjRef CreateObjRef(Type requestedType) - { - throw new AccessViolationException(); - } - - [Obsolete] - protected override WaitHandle CreateWaitHandle() - { - throw new AccessViolationException(); - } - - public override object InitializeLifetimeService() - { - throw new AccessViolationException(); - } - - public override void Lock(long position, long length) - { - throw new AccessViolationException(); - } - - public override void Unlock(long position, long length) - { - throw new AccessViolationException(); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/security/RobotFileSystemManager.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/security/RobotFileSystemManager.cs deleted file mode 100644 index 15f456c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/security/RobotFileSystemManager.cs +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Collections.Generic; -using System.IO; -using System.Security.Permissions; -using net.sf.robocode.dotnet.host.proxies; -using net.sf.robocode.io; - -namespace net.sf.robocode.dotnet.host.security -{ - [FileIOPermission(SecurityAction.Assert, Unrestricted = true)] - public class RobotFileSystemManager - { - private long maxQuota; - private string readableRootDirectory; - private List streams = new List(); - private long usedQuota; - private string writableRootDirectory; - private HostingRobotProxy hostingProxy; - - public RobotFileSystemManager(HostingRobotProxy hostingProxy , int maxQuota, string writableRootDirectory, string readableRootDirectory) - { - this.hostingProxy = hostingProxy; - this.maxQuota = maxQuota; - this.writableRootDirectory = Path.GetFullPath(writableRootDirectory); - this.readableRootDirectory = Path.GetFullPath(readableRootDirectory); - - if (Directory.Exists(writableRootDirectory)) - { - var di = new DirectoryInfo(writableRootDirectory); - foreach (FileInfo file in di.GetFiles()) - { - usedQuota += file.Length; - } - } - } - - public long getMaxQuota() - { - return maxQuota; - } - - public long getQuotaUsed() - { - lock (this) - { - return usedQuota; - } - } - - public long appendQuotaUsed(long bytes) - { - lock (this) - { - if (usedQuota + bytes > maxQuota) - { - string message = "You have reached your filesystem quota: " + maxQuota + " bytes per robot."; - if (hostingProxy != null) - { - hostingProxy.punishSecurityViolation(message); - } - throw new AccessViolationException(message); - } - usedQuota += bytes; - return usedQuota; - } - } - - public long getDataQuotaAvailable() - { - return maxQuota - getQuotaUsed(); - } - - public Stream getDataFile(string filename) - { - lock (this) - { - if (Path.IsPathRooted(filename)) - { - filename = Path.GetFullPath(filename); - } - else - { - filename = Path.GetFullPath(Path.Combine(writableRootDirectory, Path.GetFileName(filename))); - } - if (Path.GetDirectoryName(filename).ToLower() != writableRootDirectory.ToLower()) - { - throw new AccessViolationException("Access is allowed only in " + writableRootDirectory + ". Use "); - } - if (!Directory.Exists(writableRootDirectory)) - { - Directory.CreateDirectory(writableRootDirectory); - } - var quotaStream = new QuotaStream(this, filename, FileMode.OpenOrCreate, FileAccess.ReadWrite, - FileShare.ReadWrite); - streams.Add(quotaStream); - return quotaStream; - } - } - - public string getReadableDirectory() - { - return readableRootDirectory; - } - - public string getWritableDirectory() - { - return writableRootDirectory; - } - - public void cleanup() - { - foreach (QuotaStream stream in streams) - { - try - { - stream.Dispose(); - } - catch (Exception ex) - { - LoggerN.logError(ex); - } - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/AppDomainSeed.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/AppDomainSeed.cs deleted file mode 100644 index a5030dc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/AppDomainSeed.cs +++ /dev/null @@ -1,170 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.IO; -using System.Reflection; -using System.Security; -using System.Security.Permissions; -using java.nio; -using net.sf.jni4net; -using net.sf.jni4net.jni; -using net.sf.jni4net.nio; -using net.sf.jni4net.utils; -using net.sf.robocode.dotnet.utils; -using net.sf.robocode.io; -using net.sf.robocode.repository; -using net.sf.robocode.serialization; -using Buffer = java.nio.Buffer; -using ByteBuffer = java.nio.ByteBuffer; -using Exception = System.Exception; -using StringBuilder = System.Text.StringBuilder; -using robocode.control; - -namespace net.sf.robocode.dotnet.host.seed -{ - [ReflectionPermission(SecurityAction.Assert, Unrestricted = true)] - [FileIOPermission(SecurityAction.Assert, Unrestricted = true)] - public class AppDomainSeed - { - protected static string robotAssemblyFileName; - protected static string robotAssemblyShadowFileName; - protected static AppDomain domain; - - public static void Load(string[] args) - { - try - { - domain = AppDomain.CurrentDomain; - domain.UnhandledException += (domain_UnhandledException); - domain.AssemblyLoad += (domain_AssemblyLoad); - } - catch (Exception ex) - { - LoggerN.logError(ex); - throw; - } - } - - static void domain_UnhandledException(object sender, UnhandledExceptionEventArgs e) - { - LoggerN.logError(e.ExceptionObject.ToString()); - } - - static void domain_AssemblyLoad(object sender, AssemblyLoadEventArgs args) - { - bool knownLocation = args.LoadedAssembly.Location != null && - robotAssemblyShadowFileName != null && - Path.GetFullPath(args.LoadedAssembly.Location).ToLower() == - Path.GetFullPath(robotAssemblyShadowFileName).ToLower(); - if (args.LoadedAssembly != typeof(Bridge).Assembly && - args.LoadedAssembly != typeof(AppDomainSeed).Assembly && - args.LoadedAssembly != typeof(RobocodeEngine).Assembly && - !knownLocation && - !args.LoadedAssembly.GlobalAssemblyCache) - { - string message = "dependent assemblies are not alowed" + args.LoadedAssembly.Location; - LoggerN.logError(message); - throw new SecurityException(message); - } - } - - public static void Open() - { - try - { - robotAssemblyFileName = (string)domain.GetData("robotAssemblyFileName"); - robotAssemblyShadowFileName = (string)domain.GetData("robotAssemblyShadowFileName"); - } - catch (Exception ex) - { - LoggerN.logError(ex); - throw; - } - } - - public static void Bind() - { - try - { - bool fullBind = (bool)domain.GetData("fullBind"); - if (fullBind) - { - var setup = new BridgeSetup(false); - setup.BindCoreOnly = true; - setup.BindNative = false; - setup.BindStatic = false; - setup.JavaHome = (string)domain.GetData("JavaHome"); - Bridge.CreateJVM(setup); - JNIEnv env = JNIEnv.ThreadEnv; - Registry.RegisterType(typeof(ByteBuffer), true, env); - Registry.RegisterType(typeof(Buffer), true, env); - Registry.RegisterType(typeof(DirectByteBuffer), true, env); - Registry.RegisterType(typeof(java.lang.System), true, env); - Registry.RegisterType(typeof(ByteOrder), true, env); - Bridge.RegisterAssembly(typeof(RbSerializer).Assembly); - } - } - catch (Exception ex) - { - LoggerN.logError(ex); - throw; - } - } - - public static void FindRobots() - { - try - { - var sb = new StringBuilder(); - Assembly assembly = Assembly.LoadFrom(robotAssemblyShadowFileName); - foreach (Type type in assembly.GetTypes()) - { - if (Reflection.CheckInterfaces(type) != RobotTypeN.INVALID) - { - sb.Append("file://"); - sb.Append(robotAssemblyFileName); - sb.Append("!/"); - sb.Append(type.FullName); - sb.Append(";"); - } - } - if (sb.Length > 0) - { - sb.Length--; - } - domain.SetData("robotsFound", sb.ToString()); - } - catch (Exception ex) - { - LoggerN.logError(ex); - throw; - } - } - - - public static void GetRobotType() - { - try - { - var robotFullName = (string) domain.GetData("loadRobot"); - Assembly assembly = Assembly.LoadFrom(robotAssemblyShadowFileName); - Reflection.CheckAssembly(assembly); - Type robotType = assembly.GetType(robotFullName, false); - if (robotType != null) - { - domain.SetData("robotLoaded", (int)Reflection.CheckInterfaces(robotType)); - } - } - catch (Exception ex) - { - domain.SetData("robotLoaded", 0); - LoggerN.logError(ex); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/AppDomainShell.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/AppDomainShell.cs deleted file mode 100644 index 117db9e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/AppDomainShell.cs +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.IO; -using System.Reflection; -using System.Security; -using System.Security.Permissions; -using System.Security.Policy; -using net.sf.jni4net; -using net.sf.robocode.dotnet.utils; -using net.sf.robocode.io; -using net.sf.robocode.peer; -using net.sf.robocode.repository; -using Robocode; -using robocode.control; - -namespace net.sf.robocode.dotnet.host.seed -{ - public class AppDomainShell : IDisposable - { - private static readonly Assembly robocodeAssembly = typeof (Robot).Assembly; - private static readonly Assembly controlAssembly = typeof (RobocodeEngine).Assembly; - private static readonly Assembly hostAssembly = typeof(AppDomainShell).Assembly; - private static readonly Assembly jniAssembly = typeof(Bridge).Assembly; - protected AppDomain domain; - private string robotAssemblyFileName; - protected IRobotPeer robotPeer; - private string robotShadow; - private string tempDir; - - #region IDisposable Members - - public void Dispose() - { - if (domain != null) - { - try - { - AppDomain.Unload(domain); - domain = null; - GC.Collect(); - } - catch (Exception ex) - { - LoggerN.logError(ex); - if (robotPeer != null) - { - robotPeer.punishBadBehavior(BadBehavior.UNSTOPPABLE); - } - } - } - if (tempDir != null && Directory.Exists(tempDir)) - { - try - { - Directory.Delete(tempDir, true); - } - catch (IOException) - { - //ignore - } - catch (UnauthorizedAccessException) - { - //ignore - } - tempDir = null; - } - } - - #endregion - - public void Init(bool fullBind) - { - string name = Path.GetRandomFileName(); - tempDir = Path.Combine(Path.GetTempPath(), name); - string robocodeShadow = Path.Combine(tempDir, Path.GetFileName(robocodeAssembly.Location)); - string hostShadow = Path.Combine(tempDir, Path.GetFileName(hostAssembly.Location)); - string controlShadow = Path.Combine(tempDir, Path.GetFileName(controlAssembly.Location)); - string jniShadow = Path.Combine(tempDir, Path.GetFileName(jniAssembly.Location)); - - Directory.CreateDirectory(tempDir); - File.Copy(robocodeAssembly.Location, robocodeShadow); - File.Copy(controlAssembly.Location, controlShadow); - File.Copy(hostAssembly.Location, hostShadow); - File.Copy(jniAssembly.Location, jniShadow); - - var trustAssemblies = new[] - { - Reflection.GetStrongName(robocodeAssembly), - Reflection.GetStrongName(controlAssembly), - Reflection.GetStrongName(hostAssembly), - Reflection.GetStrongName(jniAssembly), - }; - var domainSetup = new AppDomainSetup(); - Evidence securityInfo = AppDomain.CurrentDomain.Evidence; - var permissionSet = new PermissionSet(PermissionState.None); - permissionSet.AddPermission( - new SecurityPermission(SecurityPermissionFlag.Execution | SecurityPermissionFlag.Assertion)); - permissionSet.AddPermission(new FileIOPermission(FileIOPermissionAccess.Read, tempDir)); - permissionSet.AddPermission(new UIPermission(PermissionState.None)); - //permissionSet.AddPermission(HostProtection); - - domainSetup.ApplicationBase = tempDir; - - domainSetup.ApplicationName = name; - //domainSetup.SandboxInterop = true; - domainSetup.DisallowBindingRedirects = true; - domainSetup.DisallowCodeDownload = true; - domainSetup.DisallowPublisherPolicy = true; - domainSetup.AppDomainInitializer = AppDomainSeed.Load; - - - domain = AppDomain.CreateDomain(name, securityInfo, domainSetup, permissionSet, trustAssemblies); - domain.SetData("fullBind", fullBind); - domain.SetData("JavaHome", Bridge.Setup.JavaHome); - domain.DoCallBack(AppDomainSeed.Bind); - } - - public void Open(string dllName) - { - robotAssemblyFileName = Path.GetFullPath(dllName); - robotShadow = Path.Combine(tempDir, Path.GetFileName(robotAssemblyFileName)); - if (!File.Exists(robotShadow)) - { - File.Copy(robotAssemblyFileName, robotShadow); - } - domain.SetData("robotAssemblyFileName", robotAssemblyFileName); - domain.SetData("robotAssemblyShadowFileName", robotShadow); - domain.DoCallBack(AppDomainSeed.Open); - } - - - public string[] FindRobots() - { - domain.DoCallBack(AppDomainSeed.FindRobots); - object data = domain.GetData("robotsFound"); - string[] robotsFound = data == null ? new string[] {} : ((string) data).Split(';'); - return robotsFound; - } - - public RobotType GetRobotType(string typeFullName) - { - domain.SetData("loadRobot", typeFullName); - domain.DoCallBack(AppDomainSeed.GetRobotType); - object data = domain.GetData("robotLoaded"); - if (data==null) - { - return RobotType.Invalid; - } - var type = (int) data; - if (type == 0) - { - return RobotType.Invalid; - } - return new RobotType(type); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/HostingSeed.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/HostingSeed.cs deleted file mode 100644 index b4e6c69..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/HostingSeed.cs +++ /dev/null @@ -1,183 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Globalization; -using System.Reflection; -using System.Security.Permissions; -using System.Threading; -using net.sf.jni4net; -using net.sf.jni4net.jni; -using net.sf.jni4net.utils; -using net.sf.robocode.dotnet.host.proxies; -using net.sf.robocode.dotnet.nhost; -using net.sf.robocode.dotnet.peer; -using net.sf.robocode.dotnet.utils; -using net.sf.robocode.host; -using net.sf.robocode.io; -using net.sf.robocode.peer; -using net.sf.robocode.repository; -using net.sf.robocode.security; -using Robocode; -using Thread = System.Threading.Thread; - -namespace net.sf.robocode.dotnet.host.seed -{ - [ReflectionPermission(SecurityAction.Assert, Unrestricted = true)] - [FileIOPermission(SecurityAction.Assert, Unrestricted = true)] - [SecurityPermission(SecurityAction.Assert, Unrestricted = true)] - public class HostingSeed : AppDomainSeed - { - private static IHostManager hostManager; - private static IRobotPeer robotPeer; - private static RobotStatics statics; - private static IRobotItem specification; - private static Type robotType; - private static Thread robotThread; - private static HostingRobotProxy robotProxy; - - public static void Construct() - { - try - { - ModuleN.InitN(); - - JNIEnv env = JNIEnv.ThreadEnv; - JniGlobalHandle hmHandle = env.NewGlobalRef((JniHandle)domain.GetData("hostManager")); - JniGlobalHandle peerHandle = env.NewGlobalRef((JniHandle)domain.GetData("peer")); - JniGlobalHandle itemHandle = env.NewGlobalRef((JniHandle)domain.GetData("item")); - hostManager = Bridge.CreateProxy(hmHandle); - robotPeer = Bridge.CreateProxy(peerHandle); - specification = Bridge.CreateProxy(itemHandle); - - statics = ((RobotStatics)domain.GetData("statics")); - CreateProxy(); - - Assembly assembly = Assembly.LoadFrom(robotAssemblyShadowFileName); - Reflection.CheckAssembly(assembly); - string robotFullName = specification.getFullClassName(); - robotType = assembly.GetType(robotFullName, false); - robotProxy.setRobotType(robotType); - } - catch (Exception ex) - { - LoggerN.logError(ex); - throw; - } - } - - public static void StartRound() - { - try - { - var commands = (ExecCommands) domain.GetData("commands"); - var status = (RobotStatus) domain.GetData("status"); - - robotProxy.initializeRound(commands, status); - - robotThread = new Thread(RobotMain); - robotThread.CurrentCulture = CultureInfo.InvariantCulture; - robotThread.CurrentUICulture = CultureInfo.InvariantCulture; - robotThread.Start(null); - robotThread.Name = "Robot: "+robotProxy.getStatics().getName(); - } - catch (Exception ex) - { - LoggerN.logError(ex); - throw; - } - } - - private static void RobotMain(object param) - { - try - { - robotPeer.setupThread(); - robotProxy.run(); - } - catch(Exception ex) - { - robotProxy.println(ex); - } - finally - { - JNIEnv.ThreadEnv.GetJavaVM().DetachCurrentThread(); - } - } - - public static void ForceStopThread() - { - try - { - LoggerN.logMessage(HiddenAccessN.GetRobotName() + " is not stopping. Forcing a stop."); - robotThread.Priority = ThreadPriority.Lowest; - robotThread.Abort(); - robotThread.Interrupt(); - } - catch (Exception ex) - { - LoggerN.logError(ex); - throw; - } - } - - public static void WaitForStopThread() - { - try - { - if (!robotThread.Join(1000)) - { - LoggerN.logError("Unable to stop thread for "+statics.getName()); - robotPeer.punishBadBehavior(BadBehavior.UNSTOPPABLE); - robotPeer.setRunning(false); - } - } - catch (Exception ex) - { - LoggerN.logError(ex); - throw; - } - } - - public static void Cleanup() - { - try - { - robotProxy.cleanup(); - } - catch (Exception ex) - { - LoggerN.logError(ex); - throw; - } - } - - private static void CreateProxy() - { - if (specification.isTeamRobot()) - { - robotProxy = new TeamRobotProxy(specification, hostManager, robotPeer, statics); - } - else if (specification.isAdvancedRobot()) - { - robotProxy = new AdvancedRobotProxy(specification, hostManager, robotPeer, statics); - } - else if (specification.isStandardRobot()) - { - robotProxy = new StandardRobotProxy(specification, hostManager, robotPeer, statics); - } - else if (specification.isJuniorRobot()) - { - robotProxy = new JuniorRobotProxy(specification, hostManager, robotPeer, statics); - } - else - { - throw new AccessViolationException("Unknown robot type"); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/HostingShell.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/HostingShell.cs deleted file mode 100644 index 3495893..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/host/seed/HostingShell.cs +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using java.lang; -using net.sf.jni4net.jni; -using net.sf.jni4net.utils; -using net.sf.robocode.dotnet.peer; -using net.sf.robocode.host; -using net.sf.robocode.host.proxies; -using net.sf.robocode.peer; -using net.sf.robocode.repository; -using net.sf.robocode.serialization; -using Robocode; - -namespace net.sf.robocode.dotnet.host.seed -{ - public class HostingShell : AppDomainShell, IHostingRobotProxy - { - private readonly RbSerializer serializer = new RbSerializer(); - - public HostingShell(IRobotItem itemSpecification, - IHostManager hostManager, IRobotPeer peer, - IRobotStatics jstatics, string dllFileName) - { - robotPeer = peer; - - Init(true); - Open(dllFileName); - JniGlobalHandle hmHandle = ((IJvmProxy) hostManager).JvmHandle; - JniGlobalHandle peerhandle = ((IJvmProxy)peer).JvmHandle; - JniGlobalHandle itemHandle = ((IJvmProxy)itemSpecification).JvmHandle; - - domain.SetData("hostManager", hmHandle.DangerousGetHandle()); - domain.SetData("peer", peerhandle.DangerousGetHandle()); - domain.SetData("item", itemHandle.DangerousGetHandle()); - - var statics = serializer.ConvertJ2C(RbSerializerN.RobotStatics_TYPE, (Object) jstatics); - domain.SetData("statics", statics); - domain.SetData("robotName", statics.getName()); - try - { - domain.DoCallBack(HostingSeed.Construct); - } - catch (Exception) - { - robotPeer.punishBadBehavior(BadBehavior.SECURITY_VIOLATION); - } - - hmHandle.HoldThisHandle(); - peerhandle.HoldThisHandle(); - itemHandle.HoldThisHandle(); - } - - #region IHostingRobotProxy Members - - public void startRound(Object aCommands, Object aStatus) - { - var commands = serializer.ConvertJ2C(RbSerializerN.ExecCommands_TYPE, aCommands); - var status = serializer.ConvertJ2C(RbSerializerN.RobotStatus_TYPE, aStatus); - - domain.SetData("commands", commands); - domain.SetData("status", status); - domain.DoCallBack(HostingSeed.StartRound); - } - - public void forceStopThread() - { - domain.DoCallBack(HostingSeed.ForceStopThread); - } - - public void waitForStopThread() - { - domain.DoCallBack(HostingSeed.WaitForStopThread); - } - - public void cleanup() - { - domain.DoCallBack(HostingSeed.Cleanup); - Dispose(); - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/io/Logger.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/io/Logger.cs deleted file mode 100644 index 5e64e0a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/io/Logger.cs +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using java.lang; - -namespace net.sf.robocode.io -{ - partial class Logger : ILoggerN - { - public Logger(bool fakeInstance) - { - } - - #region ILoggerN Members - - public void logMessage(string s, bool newline) - { - logMessage((String) s, newline); - } - - public void logError(string s) - { - logError((String) s); - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/mono/reflection/CILReader.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/mono/reflection/CILReader.cs deleted file mode 100644 index c864bdc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/mono/reflection/CILReader.cs +++ /dev/null @@ -1,419 +0,0 @@ -// -// MethodBaseRocks.cs -// -// Author: -// Jb Evain (jbevain@novell.com) -// -// (C) 2009 Novell, Inc. (http://www.novell.com) -// -// Permission is hereby granted, free of charge, to any person obtaining -// a copy of this software and associated documentation files (the -// "Software"), to deal in the Software without restriction, including -// without limitation the rights to use, copy, modify, merge, publish, -// distribute, sublicense, and/or sell copies of the Software, and to -// permit persons to whom the Software is furnished to do so, subject to -// the following conditions: -// -// The above copyright notice and this permission notice shall be -// included in all copies or substantial portions of the Software. -// -// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, -// EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF -// MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND -// NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE -// LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION -// OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION -// WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -// - -using System; -using System.Collections.Generic; -using System.Reflection; -using System.Reflection.Emit; - -namespace Mono.Reflection -{ - public sealed class Instruction - { - private readonly int offset; - private OpCode opcode; - private object operand; - - public int Offset - { - get { return offset; } - } - - public OpCode OpCode - { - get { return opcode; } - } - - public object Operand - { - get { return operand; } - internal set { operand = value; } - } - - public Instruction Previous { get; internal set; } - - public Instruction Next { get; internal set; } - - internal Instruction(int offset, OpCode opcode) - { - this.offset = offset; - this.opcode = opcode; - } - - public int GetSize() - { - int size = opcode.Size; - - switch (opcode.OperandType) - { - case OperandType.InlineSwitch: - size += (1 + ((int[]) operand).Length)*4; - break; - case OperandType.InlineI8: - case OperandType.InlineR: - size += 8; - break; - case OperandType.InlineBrTarget: - case OperandType.InlineField: - case OperandType.InlineI: - case OperandType.InlineMethod: - case OperandType.InlineString: - case OperandType.InlineTok: - case OperandType.InlineType: - case OperandType.ShortInlineR: - size += 4; - break; - case OperandType.InlineVar: - size += 2; - break; - case OperandType.ShortInlineBrTarget: - case OperandType.ShortInlineI: - case OperandType.ShortInlineVar: - size += 1; - break; - } - - return size; - } - - public override string ToString() - { - return opcode.Name; - } - } - - internal class MethodBodyReader - { - private static readonly OpCode[] one_byte_opcodes; - private static readonly OpCode[] two_bytes_opcodes; - - static MethodBodyReader() - { - one_byte_opcodes = new OpCode[0xe1]; - two_bytes_opcodes = new OpCode[0x1f]; - - var fields = GetOpCodeFields(); - - foreach (FieldInfo t in fields) - { - var opcode = (OpCode) t.GetValue(null); - if (opcode.OpCodeType == OpCodeType.Nternal) - continue; - - if (opcode.Size == 1) - one_byte_opcodes[opcode.Value] = opcode; - else - two_bytes_opcodes[opcode.Value & 0xff] = opcode; - } - } - - private static IEnumerable GetOpCodeFields() - { - return typeof (OpCodes).GetFields(BindingFlags.Public | BindingFlags.Static); - } - - private class ByteBuffer - { - internal readonly byte[] buffer; - internal int position; - - public ByteBuffer(byte[] buffer) - { - this.buffer = buffer; - } - - public byte ReadByte() - { - CheckCanRead(1); - return buffer[position++]; - } - - private byte[] ReadBytes(int length) - { - CheckCanRead(length); - var value = new byte[length]; - Buffer.BlockCopy(buffer, position, value, 0, length); - position += length; - return value; - } - - public short ReadInt16() - { - CheckCanRead(2); - short value = (short) (buffer[position] - | (buffer[position + 1] << 8)); - position += 2; - return value; - } - - public int ReadInt32() - { - CheckCanRead(4); - int value = buffer[position] - | (buffer[position + 1] << 8) - | (buffer[position + 2] << 16) - | (buffer[position + 3] << 24); - position += 4; - return value; - } - - public long ReadInt64() - { - CheckCanRead(8); - uint low = (uint) (buffer[position] - | (buffer[position + 1] << 8) - | (buffer[position + 2] << 16) - | (buffer[position + 3] << 24)); - - uint high = (uint) (buffer[position + 4] - | (buffer[position + 5] << 8) - | (buffer[position + 6] << 16) - | (buffer[position + 7] << 24)); - - long value = (((long) high) << 32) | low; - position += 8; - return value; - } - - public float ReadSingle() - { - if (!BitConverter.IsLittleEndian) - { - var bytes = ReadBytes(4); - Array.Reverse(bytes); - return BitConverter.ToSingle(bytes, 0); - } - - CheckCanRead(4); - float value = BitConverter.ToSingle(buffer, position); - position += 4; - return value; - } - - public double ReadDouble() - { - if (!BitConverter.IsLittleEndian) - { - var bytes = ReadBytes(8); - Array.Reverse(bytes); - return BitConverter.ToDouble(bytes, 0); - } - - CheckCanRead(8); - double value = BitConverter.ToDouble(buffer, position); - position += 8; - return value; - } - - private void CheckCanRead(int count) - { - if (position + count > buffer.Length) - throw new ArgumentOutOfRangeException(); - } - } - - private readonly MethodBase method; - private readonly MethodBody body; - private readonly Module module; - private readonly Type[] generic_type_arguments; - private readonly Type[] method_arguments; - private readonly ByteBuffer il; - private readonly ParameterInfo[] parameters; - private readonly IList locals; - private readonly List instructions = new List(); - - private MethodBodyReader(MethodBase method, MethodBody mb) - { - this.method = method; - - body = mb; - if (body == null) - throw new ArgumentException(); - - var bytes = body.GetILAsByteArray(); - if (bytes == null) - throw new ArgumentException(); - - if (!(method is ConstructorInfo)) - method_arguments = method.GetGenericArguments(); - - if (method.DeclaringType != null) - generic_type_arguments = method.DeclaringType.GetGenericArguments(); - - parameters = method.GetParameters(); - locals = body.LocalVariables; - module = method.Module; - il = new ByteBuffer(bytes); - } - - private void ReadInstructions() - { - Instruction previous = null; - - while (il.position < il.buffer.Length) - { - var instruction = new Instruction(il.position, ReadOpCode()); - - ReadOperand(instruction); - - if (previous != null) - { - instruction.Previous = previous; - previous.Next = instruction; - } - - instructions.Add(instruction); - previous = instruction; - } - } - - private void ReadOperand(Instruction instruction) - { - switch (instruction.OpCode.OperandType) - { - case OperandType.InlineNone: - break; - case OperandType.InlineSwitch: - int length = il.ReadInt32(); - int[] branches = new int[length]; - int[] offsets = new int[length]; - for (int i = 0; i < length; i++) - offsets[i] = il.ReadInt32(); - for (int i = 0; i < length; i++) - branches[i] = il.position + offsets[i]; - - instruction.Operand = branches; - break; - case OperandType.ShortInlineBrTarget: - instruction.Operand = (sbyte) (il.ReadByte() + il.position); - break; - case OperandType.InlineBrTarget: - instruction.Operand = il.ReadInt32() + il.position; - break; - case OperandType.ShortInlineI: - if (instruction.OpCode == OpCodes.Ldc_I4_S) - instruction.Operand = (sbyte) il.ReadByte(); - else - instruction.Operand = il.ReadByte(); - break; - case OperandType.InlineI: - instruction.Operand = il.ReadInt32(); - break; - case OperandType.ShortInlineR: - instruction.Operand = il.ReadSingle(); - break; - case OperandType.InlineR: - instruction.Operand = il.ReadDouble(); - break; - case OperandType.InlineI8: - instruction.Operand = il.ReadInt64(); - break; - case OperandType.InlineSig: - byte[] resolveSignature = module.ResolveSignature(il.ReadInt32()); - instruction.Operand = resolveSignature; - break; - case OperandType.InlineString: - string resolveString = module.ResolveString(il.ReadInt32()); - instruction.Operand = resolveString; - break; - case OperandType.InlineTok: - MemberInfo resolveMember = module.ResolveMember(il.ReadInt32(), generic_type_arguments, method_arguments); - instruction.Operand = resolveMember; - break; - case OperandType.InlineType: - Type resolveType = module.ResolveType(il.ReadInt32(), generic_type_arguments, method_arguments); - instruction.Operand = resolveType; - break; - case OperandType.InlineMethod: - MethodBase resolveMethod = module.ResolveMethod(il.ReadInt32(), generic_type_arguments, method_arguments); - instruction.Operand = resolveMethod; - break; - case OperandType.InlineField: - FieldInfo resolveField = module.ResolveField(il.ReadInt32(), generic_type_arguments, method_arguments); - instruction.Operand = resolveField; - break; - case OperandType.ShortInlineVar: - object variable = GetVariable(instruction, il.ReadByte()); - instruction.Operand = variable; - break; - case OperandType.InlineVar: - object operand = GetVariable(instruction, il.ReadInt16()); - instruction.Operand = operand; - break; - default: - throw new NotSupportedException(); - } - } - - private object GetVariable(Instruction instruction, int index) - { - if (TargetsLocalVariable(instruction.OpCode)) - return GetLocalVariable(index); - return GetParameter(index); - } - - private static bool TargetsLocalVariable(OpCode opcode) - { - return opcode.Name.Contains("loc"); - } - - private LocalVariableInfo GetLocalVariable(int index) - { - return locals[index]; - } - - private ParameterInfo GetParameter(int index) - { - if (!method.IsStatic) - index--; - - return parameters[index]; - } - - private OpCode ReadOpCode() - { - byte op = il.ReadByte(); - return op != 0xfe - ? one_byte_opcodes[op] - : two_bytes_opcodes[il.ReadByte()]; - } - - public static IList GetInstructions(MethodBase method) - { - var mb = method.GetMethodBody(); - if (mb == null) - { - return new List(); - } - var reader = new MethodBodyReader(method, mb); - reader.ReadInstructions(); - return reader.instructions; - } - - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/BulletCommand.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/BulletCommand.cs deleted file mode 100644 index 5784e15..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/BulletCommand.cs +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using net.sf.robocode.nio; -using net.sf.robocode.serialization; - -namespace net.sf.robocode.dotnet.peer -{ - [Serializable] - public class BulletCommand - { - private readonly int bulletId; - private readonly double fireAssistAngle; - private readonly bool fireAssistValid; - private readonly double power; - - public BulletCommand(double power, bool fireAssistValid, double fireAssistAngle, int bulletId) - { - this.fireAssistValid = fireAssistValid; - this.fireAssistAngle = fireAssistAngle; - this.bulletId = bulletId; - this.power = power; - } - - public bool isFireAssistValid() - { - return fireAssistValid; - } - - public int getBulletId() - { - return bulletId; - } - - public double getPower() - { - return power; - } - - public double getFireAssistAngle() - { - return fireAssistAngle; - } - - // ReSharper disable UnusedMember.Local - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - #region Nested type: SerializableHelper - - private class SerializableHelper : ISerializableHelperN - { - #region ISerializableHelperN Members - - public int sizeOf(RbSerializerN serializer, Object obje) - { - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_DOUBLE + RbSerializerN.SIZEOF_BOOL - + RbSerializerN.SIZEOF_DOUBLE + RbSerializerN.SIZEOF_INT; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje) - { - var obj = (BulletCommand) obje; - - serializer.serialize(buffer, obj.power); - serializer.serialize(buffer, obj.fireAssistValid); - serializer.serialize(buffer, obj.fireAssistAngle); - serializer.serialize(buffer, obj.bulletId); - } - - public Object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - double power = buffer.getDouble(); - bool fireAssistValid = serializer.deserializeBoolean(buffer); - double fireAssistAngle = buffer.getDouble(); - int bulletId = buffer.getInt(); - - return new BulletCommand(power, fireAssistValid, fireAssistAngle, bulletId); - } - - #endregion - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/BulletStatus.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/BulletStatus.cs deleted file mode 100644 index fa25dd9..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/BulletStatus.cs +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using net.sf.robocode.nio; -using net.sf.robocode.serialization; - -namespace net.sf.robocode.dotnet.peer -{ - public class BulletStatus - { - public readonly int bulletId; - public readonly bool isActive; - public readonly String victimName; - public readonly double x; - public readonly double y; - - public BulletStatus(int bulletId, double x, double y, String victimName, bool isActive) - { - this.bulletId = bulletId; - this.x = x; - this.y = y; - this.isActive = isActive; - this.victimName = victimName; - } - - // ReSharper disable UnusedMember.Local - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - #region Nested type: SerializableHelper - - private class SerializableHelper : ISerializableHelperN - { - #region ISerializableHelperN Members - - public int sizeOf(RbSerializerN serializer, Object obje) - { - var obj = (BulletStatus) obje; - - return RbSerializerN.SIZEOF_TYPEINFO + RbSerializerN.SIZEOF_INT + serializer.sizeOf(obj.victimName) - + RbSerializerN.SIZEOF_BOOL + 2*RbSerializerN.SIZEOF_DOUBLE; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje) - { - var obj = (BulletStatus) obje; - - serializer.serialize(buffer, obj.bulletId); - serializer.serialize(buffer, obj.victimName); - serializer.serialize(buffer, obj.isActive); - serializer.serialize(buffer, obj.x); - serializer.serialize(buffer, obj.y); - } - - public Object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - int bulletId = buffer.getInt(); - String victimName = serializer.deserializeString(buffer); - bool isActive = serializer.deserializeBoolean(buffer); - double x = buffer.getDouble(); - double y = buffer.getDouble(); - - return new BulletStatus(bulletId, x, y, victimName, isActive); - } - - #endregion - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/DebugProperty.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/DebugProperty.cs deleted file mode 100644 index 4366913..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/DebugProperty.cs +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using net.sf.robocode.nio; -using net.sf.robocode.serialization; - -namespace net.sf.robocode.dotnet.peer -{ - [Serializable] - public class DebugProperty - { - private String key; - private String value; - - public DebugProperty() - { - } - - public DebugProperty(String key, String value) - { - setKey(key); - setValue(value); - } - - - public String getKey() - { - return key; - } - - public void setKey(String key) - { - this.key = key; - } - - public String getValue() - { - return value; - } - - public void setValue(String value) - { - this.value = value; - } - - // ReSharper disable UnusedMember.Local - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - #region Nested type: SerializableHelper - - private class SerializableHelper : ISerializableHelperN - { - #region ISerializableHelperN Members - - public int sizeOf(RbSerializerN serializer, Object obje) - { - var obj = (DebugProperty) obje; - - return RbSerializerN.SIZEOF_TYPEINFO + serializer.sizeOf(obj.key) + serializer.sizeOf(obj.value); - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje) - { - var obj = (DebugProperty) obje; - - serializer.serialize(buffer, obj.key); - serializer.serialize(buffer, obj.value); - } - - public Object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - String key = serializer.deserializeString(buffer); - String value = serializer.deserializeString(buffer); - - return new DebugProperty(key, value); - } - - #endregion - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/ExecCommands.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/ExecCommands.cs deleted file mode 100644 index 263357e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/ExecCommands.cs +++ /dev/null @@ -1,490 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using net.sf.robocode.nio; -using net.sf.robocode.serialization; -using Robocode; - -namespace net.sf.robocode.dotnet.peer -{ - [Serializable] - public class ExecCommands - { - public const int defaultBodyColor = 0; //0xFF29298C; - public const int defaultGunColor = 0; //0xFF29298C; - public const int defaultRadarColor = 0; //0xFF29298C; - public const int defaultScanColor = 0; //0xFF0000FF; - public const int defaultBulletColor = 0; //0xFFFFFFFF; - private int bodyColor = defaultBodyColor; - - private double bodyTurnRemaining; - private int bulletColor = defaultBulletColor; - private List bullets = new List(); - private List debugProperties = new List(); - private double distanceRemaining; - [NonSerialized] private byte[] graphicsCalls; - private int gunColor = defaultGunColor; - private double gunTurnRemaining; - - private bool isAdjustGunForBodyTurn; - private bool isAdjustRadarForBodyTurn; - private bool isAdjustRadarForBodyTurnSet; - private bool isAdjustRadarForGunTurn; - private bool isIORobot; - private bool isTryingToPaint; - - private double maxTurnRate; - private double maxVelocity; - - private bool moved; - private String outputText; - private int radarColor = defaultRadarColor; - private double radarTurnRemaining; - private bool scan; - private int scanColor = defaultScanColor; - private List teamMessages = new List(); - - public ExecCommands() - { - setMaxVelocity(Double.MaxValue); - setMaxTurnRate(Double.MaxValue); - } - - public ExecCommands(ExecCommands origin, bool fromRobot) - { - bodyTurnRemaining = origin.bodyTurnRemaining; - radarTurnRemaining = origin.radarTurnRemaining; - gunTurnRemaining = origin.gunTurnRemaining; - distanceRemaining = origin.distanceRemaining; - isAdjustGunForBodyTurn = origin.isAdjustGunForBodyTurn; - isAdjustRadarForGunTurn = origin.isAdjustRadarForGunTurn; - isAdjustRadarForBodyTurn = origin.isAdjustRadarForBodyTurn; - isAdjustRadarForBodyTurnSet = origin.isAdjustRadarForBodyTurnSet; - maxTurnRate = origin.maxTurnRate; - maxVelocity = origin.maxVelocity; - copyColors(origin); - if (fromRobot) - { - debugProperties = origin.debugProperties; - bullets = origin.bullets; - scan = origin.scan; - moved = origin.moved; - graphicsCalls = origin.graphicsCalls; - outputText = origin.outputText; - teamMessages = origin.teamMessages; - isTryingToPaint = origin.isTryingToPaint; - } - } - - public void copyColors(ExecCommands origin) - { - if (origin != null) - { - bodyColor = origin.bodyColor; - gunColor = origin.gunColor; - radarColor = origin.radarColor; - bulletColor = origin.bulletColor; - scanColor = origin.scanColor; - } - } - - public int getBodyColor() - { - return bodyColor; - } - - public int getRadarColor() - { - return radarColor; - } - - public int getGunColor() - { - return gunColor; - } - - public int getBulletColor() - { - return bulletColor; - } - - public int getScanColor() - { - return scanColor; - } - - public void setBodyColor(int color) - { - bodyColor = color; - } - - public void setRadarColor(int color) - { - radarColor = color; - } - - public void setGunColor(int color) - { - gunColor = color; - } - - public void setBulletColor(int color) - { - bulletColor = color; - } - - public void setScanColor(int color) - { - scanColor = color; - } - - public double getBodyTurnRemaining() - { - return bodyTurnRemaining; - } - - public void setBodyTurnRemaining(double bodyTurnRemaining) - { - this.bodyTurnRemaining = bodyTurnRemaining; - } - - public double getRadarTurnRemaining() - { - return radarTurnRemaining; - } - - public void setRadarTurnRemaining(double radarTurnRemaining) - { - this.radarTurnRemaining = radarTurnRemaining; - } - - public double getGunTurnRemaining() - { - return gunTurnRemaining; - } - - public void setGunTurnRemaining(double gunTurnRemaining) - { - this.gunTurnRemaining = gunTurnRemaining; - } - - public double getDistanceRemaining() - { - return distanceRemaining; - } - - public void setDistanceRemaining(double distanceRemaining) - { - this.distanceRemaining = distanceRemaining; - } - - public bool IsAdjustGunForBodyTurn() - { - return isAdjustGunForBodyTurn; - } - - public void setAdjustGunForBodyTurn(bool adjustGunForBodyTurn) - { - isAdjustGunForBodyTurn = adjustGunForBodyTurn; - } - - public bool IsAdjustRadarForGunTurn() - { - return isAdjustRadarForGunTurn; - } - - public void setAdjustRadarForGunTurn(bool adjustRadarForGunTurn) - { - isAdjustRadarForGunTurn = adjustRadarForGunTurn; - } - - public bool IsAdjustRadarForBodyTurn() - { - return isAdjustRadarForBodyTurn; - } - - public void setAdjustRadarForBodyTurn(bool adjustRadarForBodyTurn) - { - isAdjustRadarForBodyTurn = adjustRadarForBodyTurn; - } - - public bool IsAdjustRadarForBodyTurnSet() - { - return isAdjustRadarForBodyTurnSet; - } - - public void setAdjustRadarForBodyTurnSet(bool adjustRadarForBodyTurnSet) - { - isAdjustRadarForBodyTurnSet = adjustRadarForBodyTurnSet; - } - - public double getMaxTurnRate() - { - return maxTurnRate; - } - - public void setMaxTurnRate(double maxTurnRate) - { - this.maxTurnRate = Math.Min(Math.Abs(maxTurnRate), Rules.MAX_TURN_RATE_RADIANS); - } - - public double getMaxVelocity() - { - return maxVelocity; - } - - public void setMaxVelocity(double maxVelocity) - { - this.maxVelocity = Math.Min(Math.Abs(maxVelocity), Rules.MAX_VELOCITY); - } - - public bool isMoved() - { - return moved; - } - - public void setMoved(bool moved) - { - this.moved = moved; - } - - public bool isScan() - { - return scan; - } - - public void setScan(bool scan) - { - this.scan = scan; - } - - public List getBullets() - { - return bullets; - } - - public Object getGraphicsCalls() - { - return graphicsCalls; - } - - public List getDebugProperties() - { - return debugProperties; - } - - public void setGraphicsCalls(byte[] graphicsCalls) - { - this.graphicsCalls = graphicsCalls; - } - - public string getOutputText() - { - return outputText; - } - - public void setOutputText(string output) - { - outputText = string.IsNullOrEmpty(output) ? null : output; - } - - public List getTeamMessages() - { - return teamMessages; - } - - public bool IsIORobot() - { - return isIORobot; - } - - public void setIORobot() - { - isIORobot = true; - } - - public void setDebugProperty(String key, String value) - { - debugProperties.Add(new DebugProperty(key, value)); - } - - public bool IsTryingToPaint() - { - return isTryingToPaint; - } - - public void setTryingToPaint(bool tryingToPaint) - { - isTryingToPaint = tryingToPaint; - } - - // ReSharper disable UnusedMember.Local - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - #region Nested type: SerializableHelper - - private class SerializableHelper : ISerializableHelperN - { - #region ISerializableHelperN Members - - public int sizeOf(RbSerializerN serializer, Object obje) - { - var obj = (ExecCommands) obje; - int size = RbSerializerN.SIZEOF_TYPEINFO + 4*RbSerializerN.SIZEOF_DOUBLE; - - size += 4*RbSerializerN.SIZEOF_BOOL; - size += 5*RbSerializerN.SIZEOF_INT; - size += 2*RbSerializerN.SIZEOF_DOUBLE; - size += 4*RbSerializerN.SIZEOF_BOOL; - size += serializer.sizeOf(obj.outputText); - - size += serializer.sizeOf(obj.graphicsCalls); - - // bullets - size += obj.bullets.Count*serializer.sizeOf(RbSerializerN.BulletCommand_TYPE, null); - size += 1; - - // messages - foreach (TeamMessage m in obj.teamMessages) - { - size += serializer.sizeOf(RbSerializerN.TeamMessage_TYPE, m); - } - size += 1; - - // properties - foreach (DebugProperty d in obj.debugProperties) - { - size += serializer.sizeOf(RbSerializerN.DebugProperty_TYPE, d); - } - size += 1; - - return size; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje) - { - var obj = (ExecCommands) obje; - - serializer.serialize(buffer, obj.bodyTurnRemaining); - serializer.serialize(buffer, obj.radarTurnRemaining); - serializer.serialize(buffer, obj.gunTurnRemaining); - serializer.serialize(buffer, obj.distanceRemaining); - - serializer.serialize(buffer, obj.isAdjustGunForBodyTurn); - serializer.serialize(buffer, obj.isAdjustRadarForGunTurn); - serializer.serialize(buffer, obj.isAdjustRadarForBodyTurn); - serializer.serialize(buffer, obj.isAdjustRadarForBodyTurnSet); - - serializer.serialize(buffer, obj.bodyColor); - serializer.serialize(buffer, obj.gunColor); - serializer.serialize(buffer, obj.radarColor); - serializer.serialize(buffer, obj.scanColor); - serializer.serialize(buffer, obj.bulletColor); - - serializer.serialize(buffer, obj.maxTurnRate); - serializer.serialize(buffer, obj.maxVelocity); - - serializer.serialize(buffer, obj.moved); - serializer.serialize(buffer, obj.scan); - serializer.serialize(buffer, obj.isIORobot); - serializer.serialize(buffer, obj.isTryingToPaint); - - serializer.serialize(buffer, obj.outputText); - - serializer.serialize(buffer, obj.graphicsCalls); - - foreach (BulletCommand bullet in obj.bullets) - { - serializer.serialize(buffer, RbSerializerN.BulletCommand_TYPE, bullet); - } - buffer.put(RbSerializerN.TERMINATOR_TYPE); - foreach (TeamMessage message in obj.teamMessages) - { - serializer.serialize(buffer, RbSerializerN.TeamMessage_TYPE, message); - } - buffer.put(RbSerializerN.TERMINATOR_TYPE); - foreach (DebugProperty prop in obj.debugProperties) - { - serializer.serialize(buffer, RbSerializerN.DebugProperty_TYPE, prop); - } - buffer.put(RbSerializerN.TERMINATOR_TYPE); - } - - public Object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - var res = new ExecCommands(); - - res.bodyTurnRemaining = buffer.getDouble(); - res.radarTurnRemaining = buffer.getDouble(); - res.gunTurnRemaining = buffer.getDouble(); - res.distanceRemaining = buffer.getDouble(); - - res.isAdjustGunForBodyTurn = serializer.deserializeBoolean(buffer); - res.isAdjustRadarForGunTurn = serializer.deserializeBoolean(buffer); - res.isAdjustRadarForBodyTurn = serializer.deserializeBoolean(buffer); - res.isAdjustRadarForBodyTurnSet = serializer.deserializeBoolean(buffer); - - res.bodyColor = buffer.getInt(); - res.gunColor = buffer.getInt(); - res.radarColor = buffer.getInt(); - res.scanColor = buffer.getInt(); - res.bulletColor = buffer.getInt(); - - res.maxTurnRate = buffer.getDouble(); - res.maxVelocity = buffer.getDouble(); - - res.moved = serializer.deserializeBoolean(buffer); - res.scan = serializer.deserializeBoolean(buffer); - res.isIORobot = serializer.deserializeBoolean(buffer); - res.isTryingToPaint = serializer.deserializeBoolean(buffer); - - res.outputText = serializer.deserializeString(buffer); - - res.graphicsCalls = serializer.deserializeBytes(buffer); - - Object item = serializer.deserializeAny(buffer); - - while (item != null) - { - if (item is BulletCommand) - { - res.bullets.Add((BulletCommand) item); - } - item = serializer.deserializeAny(buffer); - } - item = serializer.deserializeAny(buffer); - while (item != null) - { - if (item is TeamMessage) - { - res.teamMessages.Add((TeamMessage) item); - } - item = serializer.deserializeAny(buffer); - } - item = serializer.deserializeAny(buffer); - while (item != null) - { - if (item is DebugProperty) - { - res.debugProperties.Add((DebugProperty) item); - } - item = serializer.deserializeAny(buffer); - } - return res; - } - - #endregion - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/ExecResults.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/ExecResults.cs deleted file mode 100644 index 01bf7f0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/ExecResults.cs +++ /dev/null @@ -1,253 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using net.sf.robocode.nio; -using net.sf.robocode.serialization; -using Robocode; - -namespace net.sf.robocode.dotnet.peer -{ - [Serializable] - public class ExecResults - { - private const long serialVersionUID = 1L; - private List bulletUpdates; - private ExecCommands commands; - private List events; - private bool halt; - private bool paintEnabled; - private bool shouldWait; - private RobotStatus status; - private List teamMessages; - - public ExecResults(ExecCommands commands, RobotStatus status, List events, List teamMessages, - List bulletUpdates, bool halt, bool shouldWait, bool paintEnabled) - { - this.commands = commands; - this.status = status; - this.events = events; - this.teamMessages = teamMessages; - this.bulletUpdates = bulletUpdates; - this.halt = halt; - this.shouldWait = shouldWait; - this.paintEnabled = paintEnabled; - } - - private ExecResults() - { - } - - public static long getSerialVersionUID() - { - return serialVersionUID; - } - - public ExecCommands getCommands() - { - return commands; - } - - public void setCommands(ExecCommands commands) - { - this.commands = commands; - } - - public RobotStatus getStatus() - { - return status; - } - - public void setStatus(RobotStatus status) - { - this.status = status; - } - - public List getEvents() - { - return events; - } - - public void setEvents(List events) - { - this.events = events; - } - - public List getTeamMessages() - { - return teamMessages; - } - - public void setTeamMessages(List teamMessages) - { - this.teamMessages = teamMessages; - } - - public List getBulletUpdates() - { - return bulletUpdates; - } - - public void setBulletUpdates(List bulletUpdates) - { - this.bulletUpdates = bulletUpdates; - } - - public bool isHalt() - { - return halt; - } - - public void setHalt(bool halt) - { - this.halt = halt; - } - - public bool isShouldWait() - { - return shouldWait; - } - - public void setShouldWait(bool shouldWait) - { - this.shouldWait = shouldWait; - } - - public bool isPaintEnabled() - { - return paintEnabled; - } - - public void setPaintEnabled(bool paintEnabled) - { - this.paintEnabled = paintEnabled; - } - - // ReSharper disable UnusedMember.Local - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - #region Nested type: SerializableHelper - - private class SerializableHelper : ISerializableHelperN - { - #region ISerializableHelperN Members - - public int sizeOf(RbSerializerN serializer, Object obje) - { - var obj = (ExecResults) obje; - int size = RbSerializerN.SIZEOF_TYPEINFO + 3*RbSerializerN.SIZEOF_BOOL; - - size += serializer.sizeOf(RbSerializerN.ExecCommands_TYPE, obj.commands); - size += serializer.sizeOf(RbSerializerN.RobotStatus_TYPE, obj.status); - - // events - foreach (Event evnt in obj.events) - { - size += serializer.sizeOf(evnt); - } - size += 1; - - // messages - foreach (TeamMessage m in obj.teamMessages) - { - size += serializer.sizeOf(RbSerializerN.TeamMessage_TYPE, m); - } - size += 1; - - // bullets - foreach (BulletStatus b in obj.bulletUpdates) - { - size += serializer.sizeOf(RbSerializerN.BulletStatus_TYPE, b); - } - size += 1; - - return size; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje) - { - var obj = (ExecResults) obje; - - serializer.serialize(buffer, obj.halt); - serializer.serialize(buffer, obj.shouldWait); - serializer.serialize(buffer, obj.paintEnabled); - - serializer.serialize(buffer, RbSerializerN.ExecCommands_TYPE, obj.commands); - serializer.serialize(buffer, RbSerializerN.RobotStatus_TYPE, obj.status); - - foreach (Event evnt in obj.events) - { - serializer.serialize(buffer, evnt); - } - buffer.put(RbSerializerN.TERMINATOR_TYPE); - foreach (TeamMessage message in obj.teamMessages) - { - serializer.serialize(buffer, RbSerializerN.TeamMessage_TYPE, message); - } - buffer.put(RbSerializerN.TERMINATOR_TYPE); - foreach (BulletStatus bulletStatus in obj.bulletUpdates) - { - serializer.serialize(buffer, RbSerializerN.BulletStatus_TYPE, bulletStatus); - } - buffer.put(RbSerializerN.TERMINATOR_TYPE); - } - - public Object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - var res = new ExecResults(); - - res.halt = serializer.deserializeBoolean(buffer); - res.shouldWait = serializer.deserializeBoolean(buffer); - res.paintEnabled = serializer.deserializeBoolean(buffer); - - res.commands = (ExecCommands) serializer.deserializeAny(buffer); - res.status = (RobotStatus) serializer.deserializeAny(buffer); - - Object item = serializer.deserializeAny(buffer); - - res.events = new List(); - res.teamMessages = new List(); - res.bulletUpdates = new List(); - while (item != null) - { - if (item is Event) - { - res.events.Add((Event) item); - } - item = serializer.deserializeAny(buffer); - } - item = serializer.deserializeAny(buffer); - while (item != null) - { - if (item is TeamMessage) - { - res.teamMessages.Add((TeamMessage) item); - } - item = serializer.deserializeAny(buffer); - } - item = serializer.deserializeAny(buffer); - while (item != null) - { - if (item is BulletStatus) - { - res.bulletUpdates.Add((BulletStatus) item); - } - item = serializer.deserializeAny(buffer); - } - return res; - } - - #endregion - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/TeamMessage.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/TeamMessage.cs deleted file mode 100644 index 2f31f0e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/peer/TeamMessage.cs +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using net.sf.robocode.nio; -using net.sf.robocode.serialization; - -namespace net.sf.robocode.dotnet.peer -{ - [Serializable] - public class TeamMessage - { - public byte[] message; - public String recipient; - public String sender; - - public TeamMessage(String sender, String recipient, byte[] message) - { - this.sender = sender; - this.recipient = recipient; - this.message = message; - } - - // ReSharper disable UnusedMember.Local - private static ISerializableHelperN createHiddenSerializer() - { - return new SerializableHelper(); - } - - #region Nested type: SerializableHelper - - private class SerializableHelper : ISerializableHelperN - { - #region ISerializableHelperN Members - - public int sizeOf(RbSerializerN serializer, Object obje) - { - var obj = (TeamMessage) obje; - int s = serializer.sizeOf(obj.sender); - int r = serializer.sizeOf(obj.recipient); - int m = serializer.sizeOf(obj.message); - - return RbSerializerN.SIZEOF_TYPEINFO + s + r + m; - } - - public void serialize(RbSerializerN serializer, ByteBuffer buffer, Object obje) - { - var obj = (TeamMessage) obje; - - serializer.serialize(buffer, obj.sender); - serializer.serialize(buffer, obj.recipient); - serializer.serialize(buffer, obj.message); - } - - public Object deserialize(RbSerializerN serializer, ByteBuffer buffer) - { - String sender = serializer.deserializeString(buffer); - String recipient = serializer.deserializeString(buffer); - byte[] message = serializer.deserializeBytes(buffer); - - return new TeamMessage(sender, recipient, message); - } - - #endregion - } - - #endregion - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/repository/RobotType.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/repository/RobotType.cs deleted file mode 100644 index 3e68dd0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/repository/RobotType.cs +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; - -namespace net.sf.robocode.repository -{ - [Flags] - public enum RobotTypeN - { - INVALID = 0, - JUNIOR = 1, - STANDARD = 2, - ADVANCED = 4, - TEAM = 8, - DROID = 16, - INTERACTIVE = 32, - PAINTING = 64, - SENTRY = 128 - } - - partial class RobotType - { - private static RobotType _Invalid; - - public static RobotType Invalid - { - get - { - if (_Invalid == null) - { - _Invalid = INVALID; - } - return _Invalid; - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/repository/root/DllRootHelper.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/repository/root/DllRootHelper.cs deleted file mode 100644 index 6b00054..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/repository/root/DllRootHelper.cs +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.IO; -using System.Threading; -using System.Web; -using net.sf.robocode.dotnet.host.seed; -using net.sf.robocode.repository; - -namespace net.sf.robocode.dotnet.repository.root -{ - public static class DllRootHelper - { - private static AppDomainShell shell; - - public static void Open() - { - if (shell!=null) - { - shell.Dispose(); - } - shell = new AppDomainShell(); - shell.Init(false); - } - - public static void Close() - { - } - - public static string[] findItems(string dllPath) - { - string uriPath = dllPath.Replace("#", "%23"); // All '#' occurrences must be replaced - string file = new Uri(uriPath).LocalPath; - if (!File.Exists(file)) - { - throw new FileNotFoundException("File not found: " + dllPath); - } - - if (shell != null) - { - shell.Open(file); - return shell.FindRobots(); - } - using (AppDomainShell localshell = new AppDomainShell()) - { - localshell.Init(false); - localshell.Open(file); - return localshell.FindRobots(); - } - } - - public static RobotType GetRobotType(IRobotItem robotItem) - { - string file = GetDllFileName(robotItem); - if (!File.Exists(file)) - { - return RobotType.Invalid; - } - if (shell != null) - { - shell.Open(file); - return shell.GetRobotType(robotItem.getFullClassName()); - } - using (AppDomainShell localshell = new AppDomainShell()) - { - localshell.Init(false); - localshell.Open(file); - return localshell.GetRobotType(robotItem.getFullClassName()); - } - } - - public static string GetDllFileName(IRobotItem robotItem) - { - string uriString = robotItem.getClassPathURL().toURI().toString(); - string trim = uriString.Substring(0, uriString.LastIndexOf(".dll!/") + 4); - return new Uri(trim).LocalPath; - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/robocode.dotnet.nhost.csproj b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/robocode.dotnet.nhost.csproj deleted file mode 100644 index d9a87e7..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/robocode.dotnet.nhost.csproj +++ /dev/null @@ -1,187 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {674AED55-B9EC-4C7D-8E0B-1B2481C578B2} - Library - net.sf.robocode.dotnet - robocode.dotnet.nhost-1.9.2.4 - v3.5 - 512 - true - ..\..\tools\keys\robocode.snk - - - 3.5 - - - - true - full - false - ..\target\ - ..\target\obj\ - DEBUG;TRACE - prompt - 4 - false - true - - - pdbonly - true - ..\target\ - ..\target\obj\ - - - prompt - 4 - true - - - - False - ..\..\tools\lib\jni4net.n-0.8.7.0.dll - - - - - - - - - - - - generated\AssemblyInfo.cs - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - Code - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - {7E0900D3-6E8F-48EB-86DB-AA767AA90B84} - robocode.dotnet.api - - - {674AED55-B9EC-4C7D-8E0B-1B2471C578B2} - robocode.dotnet.control.api - - - - - - if not exist $(OutDir)\build-sources\generated-sources\META-INF mkdir $(OutDir)\build-sources\generated-sources\META-INF\ -echo [assembly: System.Reflection.AssemblyVersion("1.9.2.4")] > $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs - - copy "$(TargetPath)" "$(SolutionDir)\robocode.dotnet.host\target" -copy "$(SolutionDir)\tools\lib\*.dll" "$(TargetDir)" -copy "$(SolutionDir)\tools\lib\*.dll" "$(SolutionDir)\robocode.dotnet.host\target" - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/serialization/RbSerializer.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/serialization/RbSerializer.cs deleted file mode 100644 index c176eaf..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/serialization/RbSerializer.cs +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System.IO; -using java.lang; -using net.sf.jni4net.nio; -using ByteBuffer = net.sf.robocode.nio.ByteBuffer; - -namespace net.sf.robocode.serialization -{ - partial class RbSerializer - { - private const int byteOrder = -1059135839; //0xC0DEDEA1 - private static int currentVersion; - - public static void Init(int version) - { - if (currentVersion == 0) - { - currentVersion = version; - } - } - - public DirectByteBuffer serializeN(byte type, Object obj) - { - int length = sizeOf(type, obj); - - // header - int size = RbSerializerN.SIZEOF_INT*3 + length; - var sharedBuffer = new byte[size]; - var buffer = new DirectByteBuffer(sharedBuffer); - - buffer.putInt(byteOrder); - buffer.putInt(currentVersion); - buffer.putInt(length); - - // body - serialize(buffer, type, obj); - if (buffer.remaining() != 0) - { - throw new IOException("Serialization failed: bad size"); - } - return buffer; - } - - public T ConvertJ2C(byte type, Object javaObject) - { - DirectByteBuffer commandBuffer = serializeN(type, javaObject); - ByteBuffer byteBuffer = ByteBuffer.wrap(commandBuffer.GetSharedBuffer()); - return RbSerializerN.deserializeFromBuffer(byteBuffer); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/utils/Reflection.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/utils/Reflection.cs deleted file mode 100644 index 0f7e664..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/utils/Reflection.cs +++ /dev/null @@ -1,189 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections; -using System.Diagnostics; -using System.Reflection; -using System.Security; -using System.Security.Permissions; -using System.Security.Policy; -using net.sf.robocode.repository; -using Robocode; -using Robocode.RobotInterfaces; - -namespace net.sf.robocode.dotnet.utils -{ - internal partial class Reflection - { - public static PermissionSet GetNamedPermissionSet(string name) - { - IEnumerator policyEnumerator = SecurityManager.PolicyHierarchy(); - - // Move through the policy levels to the machine policy level. - while (policyEnumerator.MoveNext()) - { - var currentLevel = (PolicyLevel) policyEnumerator.Current; - - if (currentLevel.Label == "Machine") - { - return currentLevel.GetNamedPermissionSet(name); - } - } - return null; - } - - public static StrongName GetStrongName(Assembly assembly) - { - if (assembly == null) - throw new ArgumentNullException("assembly"); - - AssemblyName assemblyName = assembly.GetName(); - Debug.Assert(assemblyName != null, "Could not get assembly name"); - - // Get the public key blob. - byte[] publicKey = assemblyName.GetPublicKey(); - if (publicKey == null || publicKey.Length == 0) - throw new InvalidOperationException("Assembly is not strongly named"); - - var keyBlob = new StrongNamePublicKeyBlob(publicKey); - - // Return the strong name. - return new StrongName(keyBlob, assemblyName.Name, assemblyName.Version); - } - - public static RobotTypeN CheckInterfaces(Type robotClass) - { - if (robotClass == null || robotClass.IsAbstract) - { - // this class is not robot - return RobotTypeN.INVALID; - } - bool isJuniorRobot = false; - bool isStandardRobot = false; - bool isInteractiveRobot = false; - bool isPaintRobot = false; - bool isAdvancedRobot = false; - bool isTeamRobot = false; - bool isDroid = false; - bool isSentryRobot = false; - - if (typeof (IDroid).IsAssignableFrom(robotClass)) - { - isDroid = true; - } - - if (typeof(IBorderSentry).IsAssignableFrom(robotClass)) - { - isSentryRobot = true; - } - - if (typeof (ITeamRobot).IsAssignableFrom(robotClass)) - { - isTeamRobot = true; - } - - if (typeof (IAdvancedRobot).IsAssignableFrom(robotClass)) - { - isAdvancedRobot = true; - } - - if (typeof (IInteractiveRobot).IsAssignableFrom(robotClass)) - { - // in this case we make sure that robot don't waste time - if (checkMethodOverride(robotClass, typeof (Robot), "GetInteractiveEventListener") - || checkMethodOverride(robotClass, typeof (Robot), "OnKeyPressed", typeof (KeyEvent)) - || checkMethodOverride(robotClass, typeof (Robot), "OnKeyReleased", typeof (KeyEvent)) - || checkMethodOverride(robotClass, typeof (Robot), "OnKeyTyped", typeof (KeyEvent)) - || checkMethodOverride(robotClass, typeof (Robot), "OnMouseClicked", typeof (MouseEvent)) - || checkMethodOverride(robotClass, typeof (Robot), "OnMouseEntered", typeof (MouseEvent)) - || checkMethodOverride(robotClass, typeof (Robot), "OnMouseExited", typeof (MouseEvent)) - || checkMethodOverride(robotClass, typeof (Robot), "OnMousePressed", typeof (MouseEvent)) - || checkMethodOverride(robotClass, typeof (Robot), "OnMouseReleased", typeof (MouseEvent)) - || checkMethodOverride(robotClass, typeof (Robot), "OnMouseMoved", typeof (MouseEvent)) - || checkMethodOverride(robotClass, typeof (Robot), "OnMouseDragged", typeof (MouseEvent)) - || - checkMethodOverride(robotClass, typeof (Robot), "OnMouseWheelMoved", typeof (MouseWheelMovedEvent)) - ) - { - isInteractiveRobot = true; - } - } - - if (typeof (IPaintRobot).IsAssignableFrom(robotClass)) - { - if (checkMethodOverride(robotClass, typeof (Robot), "GetPaintEventListener") - || checkMethodOverride(robotClass, typeof (Robot), "OnPaint", typeof (IGraphics)) - ) - { - isPaintRobot = true; - } - } - - if (typeof (Robot).IsAssignableFrom(robotClass) && !isAdvancedRobot) - { - isStandardRobot = true; - } - - if (typeof (IJuniorRobot).IsAssignableFrom(robotClass)) - { - isJuniorRobot = true; - if (isAdvancedRobot) - { - throw new AccessViolationException(robotClass.Name + - ": Junior robot should not implement IAdvancedRobot interface."); - } - } - - if (typeof (IBasicRobot).IsAssignableFrom(robotClass)) - { - if (!(isAdvancedRobot || isJuniorRobot)) - { - isStandardRobot = true; - } - } - if (!isAdvancedRobot && !isStandardRobot && !isJuniorRobot) - { - return RobotTypeN.INVALID; - } - - RobotTypeN type=0; - - if (isJuniorRobot) type |= RobotTypeN.JUNIOR; - if (isStandardRobot) type |= RobotTypeN.STANDARD; - if (isInteractiveRobot) type |= RobotTypeN.INTERACTIVE; - if (isPaintRobot) type |= RobotTypeN.PAINTING; - if (isAdvancedRobot) type |= RobotTypeN.ADVANCED; - if (isTeamRobot) type |= RobotTypeN.TEAM; - if (isDroid) type |= RobotTypeN.DROID; - if (isSentryRobot) type |= RobotTypeN.SENTRY; - return type; - } - - private static bool checkMethodOverride(Type robotClass, Type knownBase, String name, - params Type[] parameterTypes) - { - if (knownBase.IsAssignableFrom(robotClass)) - { - MethodInfo method; - - method = robotClass.GetMethod(name, parameterTypes); - if (method == null) - { - return false; - } - - - if (method.DeclaringType.Equals(knownBase)) - { - return false; - } - } - return true; - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/utils/Reflection.security.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/utils/Reflection.security.cs deleted file mode 100644 index e0a4830..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.nhost/src/utils/Reflection.security.cs +++ /dev/null @@ -1,99 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Reflection; -using System.Security; -using System.Threading; -using Mono.Reflection; - -namespace net.sf.robocode.dotnet.utils -{ - partial class Reflection - { - private const BindingFlags nextedFlags = BindingFlags.NonPublic | BindingFlags.Public; - private const BindingFlags memberFlags = - BindingFlags.Static | BindingFlags.Instance | BindingFlags.NonPublic | BindingFlags.Public | - BindingFlags.CreateInstance | BindingFlags.GetProperty; - - public static void CheckAssembly(Assembly assembly) - { - foreach (Type type in assembly.GetTypes()) - { - CheckType(type); - } - } - - private static void CheckType(Type type) - { - foreach (MemberInfo member in type.GetMembers(memberFlags)) - { - MethodBase mb = member as MethodBase; - if (mb != null && member.DeclaringType == type) - { - CheckMethodBase(mb); - } - } - CheckUsedType(type.BaseType); - foreach (Type ifc in type.GetInterfaces()) - { - if (ifc.DeclaringType == type) - { - CheckUsedType(ifc); - } - } - foreach (Type nestedType in type.GetNestedTypes(nextedFlags)) - { - CheckType(nestedType); - } - } - - private static void CheckMethodBase(MethodBase methodBase) - { - foreach (Instruction i in MethodBodyReader.GetInstructions(methodBase)) - { - MethodBase mb = i.Operand as MethodBase; - MethodInfo mi = i.Operand as MethodInfo; - FieldInfo fi = i.Operand as FieldInfo; - - if (mb != null) - { - foreach (var parameter in mb.GetParameters()) - { - CheckUsedType(parameter.ParameterType); - } - CheckUsedType(mb.DeclaringType); - } - - if (mi != null) - { - CheckUsedType(mi.ReturnType); - } - - if (fi != null) - { - CheckUsedType(fi.FieldType); - } - - } - } - - private static void CheckUsedType(Type usedType) - { - if (typeof(Thread).IsAssignableFrom(usedType) || - typeof(ThreadPool).IsAssignableFrom(usedType) || - typeof(ThreadPriority).IsAssignableFrom(usedType) - ) - { - throw new SecurityException("System.Threading.Thread usage is banned here! Please use robocode.Thread instead"); - } - } - - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/.project deleted file mode 100644 index dc0a099..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/.project +++ /dev/null @@ -1,14 +0,0 @@ - - - robocode.dotnet.ntests - .NET ntests for Robocode. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.dotnet.api - robocode.dotnet.control.api - robocode.dotnet.nhost - robocode.dotnet.robotscs - robocode.dotnet.samples - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 6687c7a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,10 +0,0 @@ -#Tue Nov 27 22:34:11 CET 2012 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 -encoding/src/main/resources=8859_1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/test/resources=8859_1 -encoding/src=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/pom.xml deleted file mode 100644 index bc91d59..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/pom.xml +++ /dev/null @@ -1,70 +0,0 @@ - - - 4.0.0 - robocode.dotnet.ntests - dotnet:library - Robocode .NET nTests - .NET ntests for Robocode - - robocode.dotnet - net.sf.robocode - ${robocode.dotnet.version} - - - - net.sf.robocode - robocode.dotnet.api - ${project.version} - dotnet:library - - - net.sf.robocode - robocode.dotnet.control.api - ${project.version} - dotnet:library - - - net.sf.robocode - robocode.dotnet.nhost - ${project.version} - dotnet:library - - - net.sf.robocode - robocode.dotnet.robotscs - ${project.version} - dotnet:library - - - net.sf.robocode - robocode.dotnet.samples - ${project.version} - dotnet:library - - - org.nunit - nunit.framework - 2.4.3.0 - dotnet:library - - - net.sf.jni4net - jni4net.n - 0.8.7.0 - dotnet:library - - - - src - - - org.sonatype.nmaven.plugins - maven-dotnet-compiler-plugin - - /warn:0 - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/robocode.dotnet.ntests.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/robocode.dotnet.ntests.iml deleted file mode 100644 index 96d01fd..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/robocode.dotnet.ntests.iml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/AssemblyLoadTest.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/AssemblyLoadTest.cs deleted file mode 100644 index 6e7fdaa..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/AssemblyLoadTest.cs +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using net.sf.robocode.dotnet.host.seed; -using net.sf.robocode.dotnet.repository.root; -using net.sf.robocode.repository; -using NUnit.Framework; -using SampleCs; -using tested.robotscs; - -namespace net.sf.robocode.dotnet -{ - [TestFixture] - public class AssemblyLoadTest : TestBase - { - [Test] - public void testDomain() - { - string[] strings = DllRootHelper.findItems(@"file:/" + typeof(MyFirstRobot).Assembly.Location); - Assert.GreaterOrEqual(strings.Length, 5); - } - - [Test] - public void testType() - { - var shell = new AppDomainShell(); - shell.Init(false); - shell.Open(typeof(ThreadAttack).Assembly.Location); - RobotType robotType = shell.GetRobotType(typeof(ThreadAttack).FullName); - Assert.IsTrue(robotType.isAdvancedRobot()); - shell.Open(typeof(MyFirstRobot).Assembly.Location); - robotType = shell.GetRobotType(typeof(MyFirstRobot).FullName); - Assert.IsTrue(robotType.isStandardRobot()); - shell.Dispose(); - } - - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/SimpleTest.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/SimpleTest.cs deleted file mode 100644 index e1334fc..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/SimpleTest.cs +++ /dev/null @@ -1,125 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Drawing; -using System.IO; -using System.Reflection; -using net.sf.robocode.dotnet.host.proxies; -using net.sf.robocode.dotnet.host.security; -using NUnit.Framework; - -namespace net.sf.robocode.dotnet -{ - [TestFixture] - public class SimpleTest : TestBase - { - [Test] - public void Graphics() - { - var sg = new GraphicsProxy(); - sg.setPaintingEnabled(true); - /*sg.DrawArc(Pens.Red, new RectangleF(0,0,80,80),-30,10); - - GraphicsPath path = new GraphicsPath(); - path.AddLine(99,98,78,3); - sg.DrawPath(Pens.Blue, path); - sg.DrawRectangle(Pens.Yellow, 20,20,30,50); - - sg.DrawLine(Pens.Black, 99, 3, 78, 3); - sg.DrawRectangle(Pens.Black, 90, 20, 30, 50); - - Brush brush = new HatchBrush(HatchStyle.Vertical, Color.Cyan); - sg.FillRectangle(brush, new RectangleF(20, 70, 30, 50)); - sg.FillEllipse(brush, new RectangleF(70, 70, 30, 50 )); - */ - - sg.DrawEllipse(Pens.Red, (50), (50), 100, 100); - sg.FillEllipse(new SolidBrush(Color.FromArgb(0, 0xFF, 0, 30)), (100 - 60), (100 - 60), 120, - 120); - - - byte[] readoutQueuedCalls = sg.readoutQueuedCalls(); - Assert.Greater(readoutQueuedCalls.Length, 0); - } - - [Test] - [ExpectedException(typeof (AccessViolationException))] - public void StreamBig() - { - string tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - Directory.CreateDirectory(tempDir); - var m = new RobotFileSystemManager(null, 100, tempDir, tempDir); - - using (Stream dataFile = m.getDataFile("test.txt")) - { - dataFile.WriteByte(0xFF); - dataFile.Position = 98; - dataFile.WriteByte(0xFF); - dataFile.WriteByte(0xFF); - dataFile.WriteByte(0xFF); - } - } - - [Test] - [ExpectedException(typeof (AccessViolationException))] - public void StreamBig2() - { - string tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - Directory.CreateDirectory(tempDir); - var m = new RobotFileSystemManager(null, 100, tempDir, tempDir); - - using (Stream dataFile = m.getDataFile("test.txt")) - { - dataFile.WriteByte(0xFF); - dataFile.Position = 97; - dataFile.WriteByte(0xFF); - using (Stream dataFile2 = m.getDataFile("test.txt")) - { - dataFile2.WriteByte(0xFF); - dataFile2.Position = 98; - dataFile2.WriteByte(0xFF); - } - } - } - - [Test] - [ExpectedException(typeof (AccessViolationException))] - public void StreamBig3() - { - string tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - Directory.CreateDirectory(tempDir); - var m = new RobotFileSystemManager(null, 100, tempDir, tempDir); - - using (Stream dataFile = m.getDataFile("test.txt")) - { - dataFile.WriteByte(0xFF); - dataFile.Position = 97; - dataFile.WriteByte(0xFF); - dataFile.Write(new byte[] {0xFF, 0xFF, 0xFF}, 0, 3); - } - } - - [Test] - public void StreamOk() - { - string tempDir = Path.Combine(Path.GetTempPath(), Path.GetRandomFileName()); - Directory.CreateDirectory(tempDir); - var m = new RobotFileSystemManager(null, 100, tempDir, tempDir); - - using (Stream dataFile = m.getDataFile("test.txt")) - { - dataFile.WriteByte(0xFF); - dataFile.Position = 97; - dataFile.WriteByte(0xFF); - dataFile.Write(new byte[] {0xFF, 0xFF, 0xFF}, 0, 2); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/TestBase.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/TestBase.cs deleted file mode 100644 index 452858c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/TestBase.cs +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System; -using System.Globalization; -using System.Threading; -using net.sf.jni4net; -using net.sf.jni4net.jni; -using net.sf.robocode.dotnet.repository.root; -using NUnit.Framework; - -namespace net.sf.robocode.dotnet -{ - public abstract class TestBase - { - protected JNIEnv env; - - [TestFixtureSetUp] - public virtual void Setup() - { - Thread.CurrentThread.CurrentUICulture = CultureInfo.InvariantCulture; - Thread.CurrentThread.CurrentCulture = CultureInfo.InvariantCulture; - var setup = new BridgeSetup(false) { Verbose = true, Debug = true }; - string prefix; - if (Environment.CurrentDirectory.EndsWith("target")) - { - prefix = "../../"; - } - else - { - prefix = "../../../"; - } - string userHome = Environment.GetEnvironmentVariable("USERPROFILE"); - string version = typeof (BridgeSetup).Assembly.GetName().Version.ToString(); - setup.AddClassPath(userHome + @"/.m2/repository/org/picocontainer/picocontainer/2.14.2/picocontainer-2.14.2.jar"); - setup.AddClassPath(userHome + @"/.m2/repository/net/sf/jni4net/jni4net.j/" + version + "/jni4net.j-" + - version + ".jar"); - setup.AddClassPath(prefix + "../../robocode.api/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.api/target/classes"); - setup.AddClassPath(prefix + "../../robocode.battle/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.battle/target/classes"); - setup.AddClassPath(prefix + "../../robocode.core/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.core/target/classes"); - setup.AddClassPath(prefix + "../../robocode.host/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.host/target/classes"); - setup.AddClassPath(prefix + "../../robocode.repository/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.repository/target/classes"); - setup.AddClassPath(prefix + "../../robocode.roborumble/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.roborumble/target/classes"); - setup.AddClassPath(prefix + "../../robocode.samples/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.samples/target/classes"); - setup.AddClassPath(prefix + "../../robocode.sound/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.sound/target/classes"); - setup.AddClassPath(prefix + "../../robocode.tests/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.tests/target/classes"); - setup.AddClassPath(prefix + "../../robocode.ui/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.ui/target/classes"); - setup.AddClassPath(prefix + "../../robocode.ui.editor/target/Test-classes"); - setup.AddClassPath(prefix + "../../robocode.ui.editor/target/classes"); - setup.AddClassPath(prefix + "robocode.dotnet.api/target/Test-classes"); - setup.AddClassPath(prefix + "robocode.dotnet.api/target/classes"); - setup.AddClassPath(prefix + "robocode.dotnet.host/target/Test-classes"); - setup.AddClassPath(prefix + "robocode.dotnet.host/target/classes"); - setup.AddClassPath(prefix + "robocode.dotnet.nhost/target/Test-classes"); - setup.AddClassPath(prefix + "robocode.dotnet.nhost/target/classes"); - setup.AddClassPath(prefix + "robocode.dotnet.samples/target/Test-classes"); - setup.AddClassPath(prefix + "robocode.dotnet.samples/target/classes"); - setup.AddClassPath(prefix + "robocode.dotnet.tests/target/Test-classes"); - setup.AddClassPath(prefix + "robocode.dotnet.tests/target/classes"); - env = Bridge.CreateJVM(setup); - Bridge.RegisterAssembly(typeof (TestBase).Assembly); - Bridge.RegisterAssembly(typeof (DllRootHelper).Assembly); - } - - [TestFixtureTearDown] - public void TearDown() - { - //Assert.AreEqual(JNIResult.JNI_OK, vm.DestroyJavaVM()); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/robocode.dotnet.ntests.csproj b/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/robocode.dotnet.ntests.csproj deleted file mode 100644 index d0f9444..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.ntests/src/robocode.dotnet.ntests.csproj +++ /dev/null @@ -1,108 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {B3487E2D-2737-4C04-AA71-B9A726B3F781} - Library - net.sf.robocode.dotnet - robocode.dotnet.ntests-1.9.2.4 - v3.5 - 512 - false - ..\..\tools\keys\robocode.snk - - - - - 3.5 - - - - true - full - false - ..\target\ - ..\target\obj\ - DEBUG;TRACE - prompt - 4 - false - true - - - pdbonly - true - ..\target\ - ..\target\obj\ - - - prompt - 4 - true - - - - False - ..\..\tools\lib\jni4net.n-0.8.7.0.dll - - - False - ..\..\tools\lib\nunit.framework-2.4.3.0.dll - - - - - - - - - - - - - - {7E0900D3-6E8F-48EB-86DB-AA767AA90B84} - robocode.dotnet.api - - - {674AED55-B9EC-4C7D-8E0B-1B2471C578B2} - robocode.dotnet.control.api - - - {674AED55-B9EC-4C7D-8E0B-1B2481C578B2} - robocode.dotnet.nhost - - - {B3487E2D-2737-4C04-AA71-B9A726B3F787} - robocode.dotnet.robotscs - - - {80857B97-6397-487B-A9F5-B07026DCBB66} - robocode.dotnet.samples - - - - - - - - - - - if not exist $(OutDir)\build-sources\generated-sources\META-INF mkdir $(OutDir)\build-sources\generated-sources\META-INF\ -echo [assembly: System.Reflection.AssemblyVersion("0.0.0.0")] > $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs - - copy "$(SolutionDir)\tools\lib\*.dll" "$(TargetDir)" -copy "$(SolutionDir)\tools\lib\*.jar" "$(TargetDir)" - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/.project deleted file mode 100644 index 21402e0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/.project +++ /dev/null @@ -1,10 +0,0 @@ - - - robocode.dotnet.robotscs - .NET test robots for Robocode. NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.dotnet.api - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 6687c7a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,10 +0,0 @@ -#Tue Nov 27 22:34:11 CET 2012 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 -encoding/src/main/resources=8859_1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/test/resources=8859_1 -encoding/src=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/pom.xml deleted file mode 100644 index ba58d91..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - robocode.dotnet.robotscs - dotnet:library - Robocode .NET Test Robots - .NET test robots for Robocode - - robocode.dotnet - net.sf.robocode - ${robocode.dotnet.version} - - - - net.sf.robocode - robocode.dotnet.api - ${project.version} - dotnet:library - - - - src - - - org.sonatype.nmaven.plugins - maven-dotnet-compiler-plugin - - /warn:0 - - - - org.jvnet.maven-antrun-extended-plugin - maven-antrun-extended-plugin - - - process-classes - - - - - - - run - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/robocode.dotnet.robotscs.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/robocode.dotnet.robotscs.iml deleted file mode 100644 index 3d67425..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/robocode.dotnet.robotscs.iml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/NoPackageButReallyLongNameIWouldSayTooLongMaybeEventLongerCs.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/NoPackageButReallyLongNameIWouldSayTooLongMaybeEventLongerCs.cs deleted file mode 100644 index 4f690cf..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/NoPackageButReallyLongNameIWouldSayTooLongMaybeEventLongerCs.cs +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -public class NoPackageButReallyLongNameIWouldSayTooLongMaybeEventLongerCs : Robot -{ - public override void Run() - { - while (true) - { - Ahead(1); // Move ahead 100 - TurnGunRight(360); // Spin gun around - Back(1); // Move back 100 - TurnGunRight(360); // Spin gun around - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/NoPackageShortNameCs.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/NoPackageShortNameCs.cs deleted file mode 100644 index 0d79f89..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/NoPackageShortNameCs.cs +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -public class NoPackageShortNameCs : Robot -{ - public override void Run() - { - while (true) - { - Ahead(1); // Move ahead 100 - TurnGunRight(360); // Spin gun around - Back(1); // Move back 100 - TurnGunRight(360); // Spin gun around - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/SampleCs.csproj b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/SampleCs.csproj deleted file mode 100644 index 478e6ae..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/SampleCs.csproj +++ /dev/null @@ -1,91 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {80857B97-6397-487B-A9F5-B07026DCB666} - Library - SampleCs - samplescs-1.9.2.4 - v4.0 - 512 - - - 3.5 - - - - true - full - false - .\ - obj\ - DEBUG;TRACE - prompt - 4 - false - false - - - pdbonly - true - .\ - obj\ - - - prompt - 4 - true - - - - False - ..\libs\robocode.dll - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/SampleCs.sln b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/SampleCs.sln deleted file mode 100644 index 66ab900..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/SampleCs.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C# Express 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleCs", "SampleCs.csproj", "{80857B97-6397-487B-A9F5-B07026DCB666}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {80857B97-6397-487B-A9F5-B07026DCB666}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {80857B97-6397-487B-A9F5-B07026DCB666}.Debug|Any CPU.Build.0 = Debug|Any CPU - {80857B97-6397-487B-A9F5-B07026DCB666}.Release|Any CPU.ActiveCfg = Release|Any CPU - {80857B97-6397-487B-A9F5-B07026DCB666}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/robocode.dotnet.robotscs.csproj b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/robocode.dotnet.robotscs.csproj deleted file mode 100644 index 9405ace..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/robocode.dotnet.robotscs.csproj +++ /dev/null @@ -1,114 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {B3487E2D-2737-4C04-AA71-B9A726B3F787} - Library - net.sf.robocode.dotnet - robocode.dotnet.robotscs-1.9.2.4 - v3.5 - 512 - false - ..\..\tools\keys\robocode.snk - - - 3.5 - - - - true - full - false - ..\target\ - ..\target\obj\ - DEBUG;TRACE - prompt - 4 - false - false - - - pdbonly - true - ..\target\ - ..\target\obj\ - - - prompt - 4 - true - - - - False - ..\..\robocode.dotnet.api\target\robocode.dll - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - - if not exist $(OutDir)\build-sources\generated-sources\META-INF mkdir $(OutDir)\build-sources\generated-sources\META-INF\ -echo [assembly: System.Reflection.AssemblyVersion("0.0.0.0")] > $(OutDir)\build-sources\generated-sources\META-INF\AssemblyInfo.cs - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/robocode/BadNamespaceCs.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/robocode/BadNamespaceCs.cs deleted file mode 100644 index 9e3711d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/robocode/BadNamespaceCs.cs +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -namespace Robocode -{ - public class BadNamespaceCs : Robot - { - public override void Run() - { - while (true) - { - Ahead(1); // Move ahead 100 - TurnGunRight(360); // Spin gun around - Back(1); // Move back 100 - TurnGunRight(360); // Spin gun around - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/Ahead.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/Ahead.cs deleted file mode 100644 index e8e1c62..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/Ahead.cs +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - /** - * @author Pavel Savara (original) - */ - - public class Ahead : AdvancedRobot - { - public override void Run() - { - Ahead(100); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BadFirePower.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BadFirePower.cs deleted file mode 100644 index ae07ab0..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BadFirePower.cs +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - /** - * @author Pavel Savara (original) - */ - - public class BadFirePower : AdvancedRobot - { - public override void Run() - { - while (true) - { - Bullet bullet = SetFireBullet(Time - 12.0); - - if (bullet != null) - { - Out.WriteLine(Time + " Bullet power: " + bullet.Power); - } - else - { - Out.WriteLine(Time + " No bullet"); - } - Execute(); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BattleLost.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BattleLost.cs deleted file mode 100644 index 3fda29b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BattleLost.cs +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - public class BattleLost : Robot - { - public override void Run() - { - while (true) - { - Ahead(1); // Move ahead 100 - TurnGunRight(360); // Spin gun around - Back(1); // Move back 100 - TurnGunRight(360); // Spin gun around - } - } - - - public override void OnWin(WinEvent e) - { - Out.WriteLine("Win!"); - } - - public override void OnDeath(DeathEvent e) - { - Out.WriteLine("Death!"); - } - - public override void OnBattleEnded(BattleEndedEvent evnt) - { - Out.WriteLine("BattleEnded!"); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BattleWin.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BattleWin.cs deleted file mode 100644 index 64115f4..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BattleWin.cs +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - public class BattleWin : Robot - { - public override void Run() - { - while (true) - { - Ahead(100); // Move ahead 100 - TurnGunRight(360); // Spin gun around - Back(100); // Move back 100 - TurnGunRight(360); // Spin gun around - } - } - - - public override void OnScannedRobot(ScannedRobotEvent e) - { - Fire(1); - } - - - public override void OnHitByBullet(HitByBulletEvent e) - { - TurnLeft(90 - e.Bearing); - } - - - public override void OnWin(WinEvent e) - { - Out.WriteLine("Win!"); - } - - - public override void OnDeath(DeathEvent e) - { - Out.WriteLine("Death!"); - } - - - public override void OnBattleEnded(BattleEndedEvent evnt) - { - Out.WriteLine("BattleEnded!"); - } - - public override void OnRoundEnded(RoundEndedEvent evnt) - { - Out.WriteLine("RoundEnded!"); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BodyTurnRate.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BodyTurnRate.cs deleted file mode 100644 index 1ab0988..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/BodyTurnRate.cs +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; -using Robocode.Util; - -namespace tested.robotscs -{ - /** - * @author Flemming N. Larsen (original) - */ - - public class BodyTurnRate : AdvancedRobot - { - public override void Run() - { - // Test turn rate at all speed moving ahead and turning left - - SetAhead(1000); - SetTurnLeft(360); - executeAndDumpTurnRate9turns(); - - stopMoving(); - - // Test turn rate at all speed moving ahead and turning right - - SetAhead(1000); - SetTurnRight(360); - executeAndDumpTurnRate9turns(); - - stopMoving(); - - // Test turn rate at all speed moving back and turning right - - SetBack(1000); - SetTurnRight(360); - executeAndDumpTurnRate9turns(); - - stopMoving(); - - // Test turn rate at all speed moving back and turning left - - SetBack(1000); - SetTurnLeft(360); - executeAndDumpTurnRate9turns(); - - stopMoving(); - } - - private void executeAndDumpTurnRate9turns() - { - for (int i = 0; i < 9; i++) - { - executeAndDumpTurnRate(); - } - } - - private void executeAndDumpTurnRate() - { - double lastHeading = Heading; - double lastVelocity = Velocity; - - Execute(); - - double turnRate = Utils.NormalRelativeAngleDegrees(Heading - lastHeading); - - lastHeading = Heading; - - Out.WriteLine(Time + ": " + lastVelocity + ", " + turnRate); - } - - private void stopMoving() - { - SetAhead(0); - SetTurnLeft(0); - - for (int i = 0; i < 6; i++) - { - executeAndDumpTurnRate(); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/CustomEvents.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/CustomEvents.cs deleted file mode 100644 index 3557f26..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/CustomEvents.cs +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - public class CustomEvents : AdvancedRobot - { - public override void Run() - { - AddCustomEvent("onTick99", 99, c => true); - AddCustomEvent("onTick30", 30, c => true); - - AddCustomEvent("onLowEnergy98", 98, c => Energy < 20); - - while (true) - { - Ahead(100); // Move ahead 100 - TurnGunRight(360); // Spin gun around - Back(100); // Move back 100 - TurnGunRight(360); // Spin gun around - } - } - - public override void OnCustomEvent(CustomEvent e) - { - Out.WriteLine(Time + " " + e.Condition.Name); - } - - public override void OnScannedRobot(ScannedRobotEvent e) - { - Out.WriteLine(Time + " onScannedRobot10"); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/DieFast.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/DieFast.cs deleted file mode 100644 index d660e5d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/DieFast.cs +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; -using Robocode.Exception; - -namespace tested.robotscs -{ - public class DieFast : Robot - { - public override void Run() - { - throw new RobotException(); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/EnvAttack.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/EnvAttack.cs deleted file mode 100644 index b7595f5..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/EnvAttack.cs +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using Robocode; - -namespace tested.robotscs -{ - public class EnvAttack : AdvancedRobot - { - public override void Run() - { - // attack - Environment.SetEnvironmentVariable("NOSECURITY", "true"); - - // noinspection InfiniteLoopStatement - for (;;) - { - TurnLeft(100); - Ahead(10); - TurnLeft(100); - Back(10); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/EventPriorityFilter.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/EventPriorityFilter.cs deleted file mode 100644 index cc8f570..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/EventPriorityFilter.cs +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - public class EventPriorityFilter : AdvancedRobot - { - public override void Run() - { - // noinspection InfiniteLoopStatement - for (;;) - { - Ahead(10); // make sure we eventually hits a wall to receive onHitWall - } - } - - - public override void OnScannedRobot(ScannedRobotEvent evnt) - { - Out.WriteLine("Scanned!!!"); // a robot was Scanned -> problem! - } - - - public override void OnHitWall(HitWallEvent e) - { - // when the radar is turned here, at least another robot should be Scanned - // but Event should not be dispatched because we are in handler with higher priority - TurnRadarRight(360); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FairPlay.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FairPlay.cs deleted file mode 100644 index bfceb70..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FairPlay.cs +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; -using Robocode.Util; - -namespace tested.robotscs -{ - public class FairPlay : AdvancedRobot - { - public override void Run() - { - SetTurnRadarRightRadians(1d/0d); - } - - public override void OnScannedRobot(ScannedRobotEvent e) - { - SetTurnRadarLeft(RadarTurnRemaining); - SetTurnGunRightRadians( - Utils.NormalRelativeAngle(e.BearingRadians + HeadingRadians - GunHeadingRadians)); - SetFire(3); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FileAttack.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FileAttack.cs deleted file mode 100644 index b7ddd28..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FileAttack.cs +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.IO; -using Robocode; - -namespace tested.robotscs -{ - public class FileAttack : AdvancedRobot - { - public override void Run() - { - for (;;) - { - TurnLeft(100); - Ahead(10); - TurnLeft(100); - Back(10); - } - } - - - public override void OnScannedRobot(ScannedRobotEvent evnt) - { - readAttack(); - writeAttack(); - } - - private void readAttack() - { - try - { - FileStream fs = new FileStream(@"C:\MSDOS.SYS", FileMode.OpenOrCreate, FileAccess.Read); - - Out.WriteLine(fs.ReadByte()); - Out.WriteLine(fs.ReadByte()); - Out.WriteLine(fs.ReadByte()); - Out.WriteLine(fs.ReadByte()); - fs.Close(); - } - catch (Exception e) - { - Out.WriteLine(e); - } - } - - private void writeAttack() - { - try - { - FileStream fs = new FileStream(@"C:\MSDOS.SYS", FileMode.OpenOrCreate, FileAccess.ReadWrite); - fs.WriteByte(0xBA); - fs.WriteByte(0xDF); - fs.WriteByte(0x00); - fs.WriteByte(0xD0); - fs.Close(); - } - catch (Exception e) - { - Out.WriteLine(e); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FileWriteSize.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FileWriteSize.cs deleted file mode 100644 index 79fd89b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FileWriteSize.cs +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.IO; -using Robocode; - -namespace tested.robotscs -{ - public class FileWriteSize : AdvancedRobot - { - public override void Run() - { - Out.WriteLine("Data quota: " + DataQuotaAvailable); - Out.WriteLine("Data directory: " + GetDataDirectory()); - - using (Stream dataFile = GetDataFile("test.txt")) - { - byte[] buf = new byte[100000]; - for (int i = 0; i < 3; i++) - { - dataFile.Write(buf, 0, buf.Length); - } - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FormsAttack.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FormsAttack.cs deleted file mode 100644 index 90419d4..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/FormsAttack.cs +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.IO; -using System.Windows.Forms; -using Robocode; - -namespace tested.robotscs -{ - public class FormsAttack : AdvancedRobot - { - public override void Run() - { - for (;;) - { - TurnLeft(100); - Ahead(10); - TurnLeft(100); - Back(10); - } - } - - private Form f; - - public override void OnScannedRobot(ScannedRobotEvent evnt) - { - f = new Form(); - f.Show(); - f.Shown += f_Shown; - } - - private void f_Shown(object sender, EventArgs e) - { - f.Invoke(new Action(writeAttack)); - } - - private void writeAttack(int i) - { - try - { - FileStream fs = new FileStream(@"C:\MSDOS.SYS", FileMode.OpenOrCreate, FileAccess.ReadWrite); - fs.WriteByte(0xBA); - fs.WriteByte(0xDF); - fs.WriteByte(0x00); - fs.WriteByte(0xD0); - fs.Close(); - } - catch (Exception e) - { - Out.WriteLine(e); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/GunHeat.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/GunHeat.cs deleted file mode 100644 index 05b10c6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/GunHeat.cs +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - public class GunHeat : AdvancedRobot - { - public override void Run() - { - while (true) - { - SetFireBullet(3.0); - Out.WriteLine(Time + " gunHeat after fire: " + GunHeat); - Execute(); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/GunTurnRate.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/GunTurnRate.cs deleted file mode 100644 index 48cbc6c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/GunTurnRate.cs +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using Robocode; -using Robocode.Util; - -namespace tested.robotscs -{ - /** - * @author Flemming N. Larsen (original) - */ - - public class GunTurnRate : AdvancedRobot - { - public override void Run() - { - MaxTurnRate = (5); - - SetTurnGunLeft(Double.PositiveInfinity); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - SetTurnGunRight(Double.PositiveInfinity); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - SetTurnLeft(Double.PositiveInfinity); - SetTurnGunLeft(Double.PositiveInfinity); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - SetTurnRight(Double.PositiveInfinity); - SetTurnGunRight(Double.PositiveInfinity); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - MaxTurnRate = (20); - - SetTurnLeft(Double.PositiveInfinity); - SetTurnGunLeft(Double.PositiveInfinity); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - SetTurnRight(Double.PositiveInfinity); - SetTurnGunRight(Double.PositiveInfinity); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - IsAdjustGunForRobotTurn = (false); - - SetTurnRight(Double.PositiveInfinity); - SetTurnGunLeft(Double.PositiveInfinity); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - SetTurnLeft(Double.PositiveInfinity); - SetTurnGunRight(Double.PositiveInfinity); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - } - - private void executeAndDumpTurnRate() - { - double lastHeading = GunHeading; - - Execute(); - - double turnRate = Utils.NormalRelativeAngleDegrees(GunHeading - lastHeading); - - Out.WriteLine(Time + ": " + turnRate); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/HttpAttack.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/HttpAttack.cs deleted file mode 100644 index 18fd910..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/HttpAttack.cs +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Net; -using Robocode; - -namespace tested.robotscs -{ - public class HttpAttack : AdvancedRobot - { - private static string HTTP_ADDR = "http://robocode.sourceforge.net/"; - - public override void Run() - { - WebClient req = new WebClient(); - using (var res = req.OpenRead(HTTP_ADDR)) - { - res.Read(new byte[100000], 0, 100000); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/InteruptibleEvent.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/InteruptibleEvent.cs deleted file mode 100644 index 5c07a3a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/InteruptibleEvent.cs +++ /dev/null @@ -1,36 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - public class InteruptibleEvent : AdvancedRobot - { - public override void Run() - { - SetEventPriority("HitWallEvent", GetEventPriority("ScannedRobotEvent")); // make same as scan - - // noinspection InfiniteLoopStatement - for (;;) - { - Ahead(10); // make sure we eventually hits a wall to receive onHitWall - } - } - - public override void OnScannedRobot(ScannedRobotEvent evnt) - { - Out.WriteLine("Scanned!!!"); // a robot was Scanned -> success! - } - - public override void OnHitWall(HitWallEvent e) - { - IsInterruptible = (true); // make sure that the Event handler can be interrupted and restarted - TurnRadarRight(360); // when the radar is turned here, at least another robot should be Scanned - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/JuniorEvents.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/JuniorEvents.cs deleted file mode 100644 index 5df75fb..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/JuniorEvents.cs +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using System.Drawing; -using System.IO; -using Robocode; -using Robocode.RobotInterfaces; -using Robocode.RobotInterfaces.Peer; -using Robocode.Util; - -namespace tested.robotscs -{ - public class JuniorEvents : IJuniorRobot, IBasicEvents, IRunnable - { - private IBasicRobotPeer peer; - private TextWriter Out; - private readonly Dictionary counts = new Dictionary(); - private Bullet bullet; - - public void Run() - { - // noinspection InfiniteLoopStatement - while (true) - { - peer.Move(100); // Move ahead 100 - peer.TurnGun(Math.PI*2); // Spin gun around - peer.Move(-100); // Move back 100 - peer.TurnGun(Math.PI*2); // Spin gun around - } - } - - public IRunnable GetRobotRunnable() - { - return this; - } - - public IBasicEvents GetBasicEventListener() - { - return this; - } - - public void SetPeer(IBasicRobotPeer peer) - { - this.peer = peer; - } - - public void SetOut(TextWriter output) - { - Out = output; - } - - public void OnStatus(StatusEvent evnt) - { - count(evnt); - IGraphics g = peer.GetGraphics(); - - g.DrawEllipse(Pens.Orange, (int) (peer.GetX() - 55), (int) (peer.GetY() - 55), 110, 110); - } - - public void OnBulletHit(BulletHitEvent evnt) - { - count(evnt); - } - - public void OnBulletHitBullet(BulletHitBulletEvent evnt) - { - count(evnt); - } - - public void OnBulletMissed(BulletMissedEvent evnt) - { - count(evnt); - } - - public void OnDeath(DeathEvent evnt) - { - count(evnt); - } - - public void OnHitByBullet(HitByBulletEvent evnt) - { - count(evnt); - } - - public void OnHitRobot(HitRobotEvent evnt) - { - count(evnt); - } - - public void OnHitWall(HitWallEvent evnt) - { - count(evnt); - } - - public void OnRobotDeath(RobotDeathEvent evnt) - { - count(evnt); - } - - public void OnWin(WinEvent evnt) - { - count(evnt); - - // this is tested output - foreach (KeyValuePair s in counts) - { - Out.WriteLine(s.Key + " " + s.Value); - } - - Out.WriteLine("last bullet heading " + bullet.HeadingRadians.ToString("F5")); - } - - public void OnScannedRobot(ScannedRobotEvent evnt) - { - count(evnt); - - // Turn gun to point at the Scanned robot - peer.TurnGun(Utils.NormalAbsoluteAngle(peer.GetBodyHeading() + evnt.BearingRadians - peer.GetGunHeading())); - // - - // Fire! - const double power = 1; - - Bullet firedBullet = peer.Fire(power); - - if (firedBullet != null) - { - bullet = firedBullet; - } - } - - private void count(Event evnt) - { - String name = evnt.GetType().FullName; - object curr; - - if (!counts.TryGetValue(name, out curr)) - { - curr = 0; - } - counts[name] = ((int) curr) + 1; - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/MaxTurnRate.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/MaxTurnRate.cs deleted file mode 100644 index 80f7e04..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/MaxTurnRate.cs +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using Robocode; -using Robocode.Util; - -namespace tested.robotscs -{ - public class MaxTurnRate : AdvancedRobot - { - public override void Run() - { - SetTurnLeft(Double.PositiveInfinity); - - for (int i = 0; i < 13; i++) - { - MaxTurnRate = (i); - executeAndDumpTurnRate(); - } - - SetTurnRight(Double.PositiveInfinity); - - for (int i = 0; i < 13; i++) - { - MaxTurnRate = (i); - executeAndDumpTurnRate(); - } - } - - private void executeAndDumpTurnRate() - { - double lastHeading = Heading; - - Execute(); - - double turnRate = Utils.NormalRelativeAngleDegrees(Heading - lastHeading); - - Out.WriteLine(Time + ": " + Velocity.ToString("F1") + ", " + turnRate.ToString("F1")); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/MaxVelocity.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/MaxVelocity.cs deleted file mode 100644 index 0faa940..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/MaxVelocity.cs +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - public class MaxVelocity : AdvancedRobot - { - public override void Run() - { - for (;;) - { - int time = (int) Time; - - if (time < 200) - { - Out.WriteLine(time + ": " + Velocity); - } - - switch (time) - { - case 1: - SetAhead(1000); - break; - - case 20: - SetBack(1000); - break; - - case 40: - MaxVelocity = (4.2); - SetAhead(1000); - break; - - case 60: - SetBack(1000); - break; - - case 80: - MaxVelocity = (100); - SetAhead(1000); - break; - - case 100: - SetBack(1000); - break; - - case 120: - MaxVelocity = (-2); - SetAhead(1000); - break; - - case 140: - SetBack(1000); - break; - - case 160: - MaxVelocity = (0); - SetAhead(1000); - break; - - case 180: - SetBack(1000); - break; - } - Execute(); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/PrivateConstructor.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/PrivateConstructor.cs deleted file mode 100644 index 976b31f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/PrivateConstructor.cs +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - public class PrivateConstructor : Robot - { - private PrivateConstructor() - { - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/RadarTurnRateAndSetAdjust.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/RadarTurnRateAndSetAdjust.cs deleted file mode 100644 index d9f578d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/RadarTurnRateAndSetAdjust.cs +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using Robocode; -using Robocode.Util; - -namespace tested.robotscs -{ - public class RadarTurnRateAndIsAdjust : AdvancedRobot - { - public override void Run() - { - // -- Turn 1 -- - SetTurnRadarRight(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. radar turn rate = 45 - - // -- Turn 2 -- - SetTurnGunRight(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. gun + radar turn rate = 20 + 45 = 65 - - // -- Turn 3 -- - SetTurnRight(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. robot + gun + radar turn rate = 10 + 20 + 45 = 75 - - // -- Turn 4 -- - SetTurnRadarLeft(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. robot + gun - radar turn rate = 10 + 20 - 45 = -15 - - // -- Turn 5 -- - SetTurnGunLeft(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. robot + gun - radar turn rate = 10 - 20 - 45 = -55 - - // -- Turn 6 -- - SetTurnLeft(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. robot + gun - radar turn rate = -10 - 20 - 45 = -75 - - // -- Turn 7 -- - IsAdjustRadarForGunTurn = (false); - SetTurnRight(14); - SetTurnGunRight(15); - SetTurnRadarRight(7); - executeAndDumpTurnRate(); - // Expected turn rate: robot + gun + radar turn rate = 14 + 15 + 7 = 32 - - // -- Turn 8 -- - IsAdjustGunForRobotTurn = (false); - IsAdjustRadarForRobotTurn = (false); - IsAdjustRadarForGunTurn = (true); - SetTurnRight(14); - SetTurnGunLeft(15); - SetTurnRadarRight(7); - executeAndDumpTurnRate(); - // Expected turn rate: robot (max) + radar turn rate (ignoring gun turn rate, but not robot turn rate) = 10 + 7 = 17 - - // -- Turn 9 -- - IsAdjustGunForRobotTurn = (false); - IsAdjustRadarForRobotTurn = (true); - IsAdjustRadarForGunTurn = (true); - SetTurnRight(14); - SetTurnGunLeft(15); - SetTurnRadarRight(35); - executeAndDumpTurnRate(); - // Expected turn rate: robot turn rate (ignoring both gun and body turn rate) = 35 - - // -- Turn 10 -- - IsAdjustGunForRobotTurn = (false); - IsAdjustRadarForRobotTurn = (false); - IsAdjustRadarForGunTurn = (true); - SetTurnRight(14); - SetTurnGunLeft(15); - SetTurnRadarLeft(7); - executeAndDumpTurnRate(); - // Expected turn rate: robot (max) + radar turn rate (ignoring gun turn rate, but not robot turn rate) = 10 - 7 = 3 - - // -- Turn 11 -- - IsAdjustGunForRobotTurn = (false); - IsAdjustRadarForRobotTurn = (true); - IsAdjustRadarForGunTurn = (true); - SetTurnRight(4); - SetTurnGunRight(60); - SetTurnRadarLeft(100); - executeAndDumpTurnRate(); - // Expected turn rate: robot (max) turn rate (ignoring both gun and body turn rate) = -20 - - // -- Turn 12 -- - IsAdjustGunForRobotTurn = (false); - IsAdjustRadarForRobotTurn = (false); - IsAdjustRadarForGunTurn = (true); - SetTurnRight(Double.PositiveInfinity); - SetTurnGunRight(Double.PositiveInfinity); - SetTurnRadarRight(Double.PositiveInfinity); - executeAndDumpTurnRate(); - // Expected turn rate: IsAdjusts are all ignored, max. robot + gun + radar turn rate = 10 + 20 + 45 = 75 - - // -- Turn 13 -- - IsAdjustGunForRobotTurn = (true); - IsAdjustRadarForRobotTurn = (false); - IsAdjustRadarForGunTurn = (true); - SetTurnRight(Double.NegativeInfinity); - SetTurnGunRight(Double.NegativeInfinity); - SetTurnRadarRight(Double.NegativeInfinity); - executeAndDumpTurnRate(); - // Expected turn rate: IsAdjusts are all ignored, max. robot + gun + radar turn rate = -10 - 20 - 45 = -75 - - // -- Turn 14 -- - IsAdjustGunForRobotTurn = (true); - IsAdjustRadarForRobotTurn = (true); - IsAdjustRadarForGunTurn = (true); - SetTurnLeft(Double.NegativeInfinity); - SetTurnGunLeft(Double.NegativeInfinity); - SetTurnRadarLeft(Double.NegativeInfinity); - executeAndDumpTurnRate(); - // Expected turn rate: IsAdjusts are all ignored, max. robot + gun + radar turn rate = -(-10) - (-20) - 45 = -15 - } - - private void executeAndDumpTurnRate() - { - double lastHeading = RadarHeading; - - Execute(); - - double turnRate = Utils.NormalRelativeAngleDegrees(RadarHeading - lastHeading); - - Out.WriteLine(Time + ": " + turnRate); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/Random.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/Random.cs deleted file mode 100644 index d8bc2d3..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/Random.cs +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; -using Robocode.Util; - -namespace tested.robotscs -{ - public class Random : Robot - { - private readonly System.Random random = Utils.GetRandom(); - - public override void Run() - { - while (true) - { - Ahead(100*random.Next()); - TurnRight(180*random.Next()); - Back(100*random.Next()); - TurnLeft(360*random.Next()); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/RateControl.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/RateControl.cs deleted file mode 100644 index 1703a4a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/RateControl.cs +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - public class RateControl : RateControlRobot - { - public override void Run() - { - for (int turnNumber = 0; turnNumber < 80; turnNumber++) - { - if (turnNumber == 0) - { - TurnRate = (4.5); - } - else if (turnNumber == 10) - { - TurnRate = (-9); - } - else if (turnNumber == 20) - { - TurnRate = (0); - VelocityRate = (2); - } - else if (turnNumber == 25) - { - VelocityRate = (-8); - } - else if (turnNumber == 35) - { - VelocityRate = (0); - GunRotationRate = (9); - } - else if (turnNumber == 45) - { - GunRotationRate = (-4.5); - } - else if (turnNumber == 55) - { - GunRotationRate = (0); - RadarRotationRate = (9); - } - else if (turnNumber == 65) - { - RadarRotationRate = (-4.5); - } - else if (turnNumber == 75) - { - RadarRotationRate = (0); - } - Execute(); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/ReflectionAttack.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/ReflectionAttack.cs deleted file mode 100644 index 4ba2594..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/ReflectionAttack.cs +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Reflection; -using Robocode; - -namespace tested.robotscs -{ - public class ReflectionAttack : AdvancedRobot - { - public override void Run() - { - FieldInfo fieldInfo = typeof(Console).GetField("_out", BindingFlags.Static | BindingFlags.NonPublic); - object obj = fieldInfo.GetValue(null); - fieldInfo.SetValue(null, null); - - MethodInfo method = obj.GetType().GetMethod("Write", new[] { typeof(string) }); - method.Invoke(obj, new Object[] { "Hello World" }); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/RobotDeathEvents.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/RobotDeathEvents.cs deleted file mode 100644 index eed772e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/RobotDeathEvents.cs +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; -using Robocode.Exception; - -namespace tested.robotscs -{ - public class RobotDeathEvents : AdvancedRobot - { - private bool dead; - private long enemyCount; - - public override void Run() - { - enemyCount = Others; - while (!dead) - { - if (enemyCount != Others) - { - throw new RobotException("enemyCount != GetOthers()"); - } - Execute(); - } - } - - public override void OnRobotDeath(RobotDeathEvent e) - { - enemyCount--; - } - - public override void OnDeath(DeathEvent e) - { - dead = true; - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/SkipTurns.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/SkipTurns.cs deleted file mode 100644 index 582530b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/SkipTurns.cs +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Threading; -using Robocode; -using Robocode.Exception; -using Thread = Robocode.Thread; - -namespace tested.robotscs -{ - public class SkipTurns : AdvancedRobot - { - private volatile int skipped = 0; - - private const int limit = 5; - - public override void Run() - { - // noinspection InfiniteLoopStatement - for (;;) - { - if (skipped > limit) - { - throw new RobotException("satisfied, end battle please"); - } - TurnLeft(10); - if (skipped > limit) - { - // satisfied, end battle please - throw new RobotException(); - } - Ahead(1); - if (skipped > limit) - { - // satisfied, end battle please - throw new RobotException(); - } - TurnLeft(10); - if (skipped > limit) - { - // satisfied, end battle please - throw new RobotException(); - } - Back(1); - } - } - - - public override void OnStatus(StatusEvent e) - { - Out.WriteLine("live"); - slowResponse(); - } - - - public override void OnSkippedTurn(SkippedTurnEvent evnt) - { - Out.WriteLine("Skipped!!!"); - - skipped++; - } - - private void slowResponse() - { - try - { - if (skipped > 3) - { - Thread.Sleep(3000); - } - else - { - Thread.Sleep(100); - } - } - catch (Exception ex) - { - // eat interrupt - Out.WriteLine(ex); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/TestTeam.team b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/TestTeam.team deleted file mode 100644 index 69457ad..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/TestTeam.team +++ /dev/null @@ -1,7 +0,0 @@ -#Robocode robot CS team -#Sat Oct 25 22:23:58 CEST 2008 -team.members=SampleCsTeam.MyFirstLeader,SampleCsTeam.MyFirstDroid,SampleCs.Fire -team.author.name= -robocode.version=unknown -uuid=8abd63e8-1156-4fb4-a81f-eb10fca9596d -team.description=testteam diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/ThreadAttack.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/ThreadAttack.cs deleted file mode 100644 index 9cdce98..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/ThreadAttack.cs +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Threading; -using Robocode; -using Thread = Robocode.Thread; - -namespace tested.robotscs -{ - public class ThreadAttack : AdvancedRobot - { - public override void Run() - { - // noinspection InfiniteLoopStatement - for (;;) - { - TurnLeft(100); - Ahead(10); - TurnLeft(100); - Back(10); - } - } - - - public override void OnScannedRobot(ScannedRobotEvent evnt) - { - runAttack(); - } - - private void runAttack() - { - Thread t2 = new Thread(attack); - t2.Start(); - } - - private readonly Semaphore s = new Semaphore(0, 1); - - private int counter; - - public void attack() - { - int id = counter++; - - Out.WriteLine("Running id:" + id); - - try - { - s.WaitOne(); - } - catch (Exception e) - { - Out.WriteLine("Interrupted id:" + id + e.Message); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/TooLongNameThisIsReallyTooLongNameCs.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/TooLongNameThisIsReallyTooLongNameCs.cs deleted file mode 100644 index 6f30aed..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/TooLongNameThisIsReallyTooLongNameCs.cs +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tested.robotscs -{ - public class TooLongNameThisIsReallyTooLongNameCs : Robot - { - public override void Run() - { - while (true) - { - Ahead(1); // Move ahead 100 - TurnGunRight(360); // Spin gun around - Back(1); // Move back 100 - TurnGunRight(360); // Spin gun around - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/UndeadThread.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/UndeadThread.cs deleted file mode 100644 index 4c05a89..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/UndeadThread.cs +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using Robocode; - -namespace tested.robotscs -{ - /** - * @author Pavel Savara (original) - */ - - public class UndeadThread : AdvancedRobot - { - public override void Run() - { - Out.WriteLine("I will live forever!"); - // noinspection InfiniteLoopStatement - while (true) - { - body(); - } - } - - private void body() - { - bool normal=false; - try - { - loop(); - } - catch(Exception) - { - Out.WriteLine("that's my time"); - normal = true; - } - finally - { - if (!normal) - { - // spamming the console - Out.WriteLine("Swalowed it, HA HA HA HA HAAAAA !!!!!"); - loop(); - body(); - } - } - } - - private void loop() - { - while (true) - { - TurnLeft(100); - Ahead(10); - TurnLeft(100); - Back(10); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/WatchBullets.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/WatchBullets.cs deleted file mode 100644 index c096e60..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tested/robotscs/WatchBullets.cs +++ /dev/null @@ -1,93 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Globalization; -using Robocode; -using Robocode.Util; - -namespace tested.robotscs -{ - /* - * @author Pavel Savara (original) - */ - - public class WatchBullets : AdvancedRobot - { - public override void Run() - { - while (true) - { - Ahead(100); - TurnGunRight(360); - Back(100); - TurnGunRight(360); - } - } - - private Bullet bullet; - - public override void OnStatus(StatusEvent evnt) - { - dump(); - } - - - public override void OnBulletHit(BulletHitEvent evnt) - { - if (bullet != evnt.Bullet) - { - Out.WriteLine("Failed bullet identity"); - } - } - - - public override void OnScannedRobot(ScannedRobotEvent e) - { - // Calculate exact location of the robot - double absoluteBearing = Heading + e.Bearing; - double bearingFromGun = Utils.NormalRelativeAngle(absoluteBearing - GunHeading); - - // If it's close enough, fire! - if (Math.Abs(bearingFromGun) <= 3) - { - TurnGunRight(bearingFromGun); - // We check gun heat here, because calling Fire() - // uses a turn, which could cause us to lose track - // of the other robot. - if (GunHeat == 0 && bullet == null) - { - Bullet lbullet = FireBullet(Math.Min(3 - Math.Abs(bearingFromGun), Energy - .1)); - - bullet = lbullet; - } - } // otherwise just set the gun to turn. - // Note: This will have no effect until we call Scan() - else - { - TurnGunRight(bearingFromGun); - } - // Generates another scan event if we see a robot. - // We only need to call this if the gun (and therefore radar) - // are not turning. Otherwise, scan is called automatically. - if (bearingFromGun == 0) - { - Scan(); - } - } - - private void dump() - { - if (bullet != null) - { - Out.WriteLine( - Time + " " + bullet.X.ToString("F5", CultureInfo.InvariantCulture) + " " + bullet.Y.ToString("F5", CultureInfo.InvariantCulture) + " " + bullet.Heading.ToString("F5", CultureInfo.InvariantCulture) + " " - + bullet.IsActive); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tooLongNamespaceThisIsReallyTooLongNamespace/TooLongNamespaceCs.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tooLongNamespaceThisIsReallyTooLongNamespace/TooLongNamespaceCs.cs deleted file mode 100644 index 4279c08..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.robotscs/src/tooLongNamespaceThisIsReallyTooLongNamespace/TooLongNamespaceCs.cs +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace tooLongNamespaceThisIsReallyTooLongNamespace -{ - public class TooLongNamespaceCs : Robot - { - public override void Run() - { - while (true) - { - Ahead(1); // Move ahead 100 - TurnGunRight(360); // Spin gun around - Back(1); // Move back 100 - TurnGunRight(360); // Spin gun around - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/.project deleted file mode 100644 index 350b981..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/.project +++ /dev/null @@ -1,10 +0,0 @@ - - - robocode.dotnet.samples - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.dotnet.api - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 554237f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,8 +0,0 @@ -#Tue Nov 27 22:34:11 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/pom.xml deleted file mode 100644 index 31a2de2..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/pom.xml +++ /dev/null @@ -1,50 +0,0 @@ - - - 4.0.0 - robocode.dotnet.samples - Robocode .NET Samples - dotnet:library - - robocode.dotnet - net.sf.robocode - ${robocode.dotnet.version} - - - - net.sf.robocode - robocode.dotnet.api - ${project.version} - dotnet:library - - - - samplescs-${project.version} - src - - - org.sonatype.nmaven.plugins - maven-dotnet-compiler-plugin - - /warn:0 - samplescs-${project.version}.dll - - - - - - src - false - - **/*.vb - **/*.cs - **/*.fs - **/*.fsproj - **/*.properties - **/*.team - **/*.html - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/robocode.dotnet.samples.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/robocode.dotnet.samples.iml deleted file mode 100644 index e5ededf..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/robocode.dotnet.samples.iml +++ /dev/null @@ -1,68 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs.csproj b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs.csproj deleted file mode 100644 index 478e6ae..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs.csproj +++ /dev/null @@ -1,91 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {80857B97-6397-487B-A9F5-B07026DCB666} - Library - SampleCs - samplescs-1.9.2.4 - v4.0 - 512 - - - 3.5 - - - - true - full - false - .\ - obj\ - DEBUG;TRACE - prompt - 4 - false - false - - - pdbonly - true - .\ - obj\ - - - prompt - 4 - true - - - - False - ..\libs\robocode.dll - False - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs.sln b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs.sln deleted file mode 100644 index 66ab900..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs.sln +++ /dev/null @@ -1,20 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C# Express 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "SampleCs", "SampleCs.csproj", "{80857B97-6397-487B-A9F5-B07026DCB666}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {80857B97-6397-487B-A9F5-B07026DCB666}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {80857B97-6397-487B-A9F5-B07026DCB666}.Debug|Any CPU.Build.0 = Debug|Any CPU - {80857B97-6397-487B-A9F5-B07026DCB666}.Release|Any CPU.ActiveCfg = Release|Any CPU - {80857B97-6397-487B-A9F5-B07026DCB666}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Corners.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Corners.cs deleted file mode 100644 index f4d4a97..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Corners.cs +++ /dev/null @@ -1,155 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Drawing; -using Robocode; -using Robocode.Util; - -namespace SampleCs -{ - /// - /// Corners - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - ///

- /// This robot moves to a corner, then swings the gun back and forth. - /// If it dies, it tries a new corner in the next round. - ///

- public class Corners : Robot - { - private int others; // Number of other robots in the game - private static int corner; // Which corner we are currently using - // static so that it keeps it between rounds. - private bool stopWhenSeeRobot; // See goCorner() - - /// - /// run: Corners' main run function. - /// - public override void Run() - { - // Set colors - BodyColor = (Color.Red); - GunColor = (Color.Black); - RadarColor = (Color.Yellow); - BulletColor = (Color.Green); - ScanColor = (Color.Green); - - // Save # of other bots - others = Others; - - // Move to a corner - goCorner(); - - // Initialize gun turn speed to 3 - int gunIncrement = 3; - - // Spin gun back and forth - while (true) - { - for (int i = 0; i < 30; i++) - { - TurnGunLeft(gunIncrement); - } - gunIncrement *= -1; - } - } - - /// - /// goCorner: A very inefficient way to get to a corner. Can you do better? - /// - public void goCorner() - { - // We don't want to stop when we're just turning... - stopWhenSeeRobot = false; - // turn to face the wall to the "right" of our desired corner. - TurnRight(Utils.NormalRelativeAngleDegrees(corner - Heading)); - // Ok, now we don't want to crash into any robot in our way... - stopWhenSeeRobot = true; - // Move to that wall - Ahead(5000); - // Turn to face the corner - TurnLeft(90); - // Move to the corner - Ahead(5000); - // Turn gun to starting point - TurnGunLeft(90); - } - - /// - /// onScannedRobot: Stop and Fire! - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - // Should we stop, or just Fire? - if (stopWhenSeeRobot) - { - // Stop everything! You can safely call stop multiple times. - Stop(); - // Call our custom firing method - smartFire(e.Distance); - // Look for another robot. - // NOTE: If you call scan() inside onScannedRobot, and it sees a robot, - // the game will interrupt the event handler and start it over - Scan(); - // We won't get here if we saw another robot. - // Okay, we didn't see another robot... start moving or turning again. - Resume(); - } - else - { - smartFire(e.Distance); - } - } - - /// - /// smartFire: Custom Fire method that determines firepower based on distance. - /// - /// - /// the distance to the robot to Fire at - /// - public void smartFire(double robotDistance) - { - if (robotDistance > 200 || Energy < 15) - { - Fire(1); - } - else if (robotDistance > 50) - { - Fire(2); - } - else - { - Fire(3); - } - } - - /// - /// onDeath: We died. Decide whether to try a different corner next game. - /// - public override void OnDeath(DeathEvent e) - { - // Well, others should never be 0, but better safe than sorry. - if (others == 0) - { - return; - } - - // If 75% of the robots are still alive when we die, we'll switch corners. - if ((others - Others)/(double) others < .75) - { - corner += 90; - if (corner == 270) - { - corner = -90; - } - Out.WriteLine("I died and did poorly... switching corner to " + corner); - } - else - { - Out.WriteLine("I died but did well. I will still use corner " + corner); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Crazy.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Crazy.cs deleted file mode 100644 index 69df1b8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Crazy.cs +++ /dev/null @@ -1,107 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Drawing; -using Robocode; - -namespace SampleCs -{ - /// - /// Crazy - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - /// This robot moves around in a crazy pattern - /// - public class Crazy : AdvancedRobot - { - private bool movingForward; - - /// - /// run: Crazy's main run function - /// - public override void Run() - { - BodyColor = (Color.FromArgb(0, 200, 0)); - GunColor = (Color.FromArgb(0, 150, 50)); - RadarColor = (Color.FromArgb(0, 100, 100)); - BulletColor = (Color.FromArgb(255, 255, 100)); - ScanColor = (Color.FromArgb(255, 200, 200)); - - // Loop forever - while (true) - { - // Tell the game we will want to move ahead 40000 -- some large number - SetAhead(40000); - movingForward = true; - // Tell the game we will want to turn right 90 - SetTurnRight(90); - // At this point, we have indicated to the game that *when we do something*, - // we will want to move ahead and turn right. That's what "set" means. - // It is important to realize we have not done anything yet! - // In order to actually move, we'll want to call a method that - // takes real time, such as WaitFor. - // WaitFor actually starts the action -- we start moving and turning. - // It will not return until we have finished turning. - WaitFor(new TurnCompleteCondition(this)); - // Note: We are still moving ahead now, but the turn is complete. - // Now we'll turn the other way... - SetTurnLeft(180); - // ... and wait for the turn to finish ... - WaitFor(new TurnCompleteCondition(this)); - // ... then the other way ... - SetTurnRight(180); - // .. and wait for that turn to finish. - WaitFor(new TurnCompleteCondition(this)); - // then back to the top to do it all again - } - } - - /// - /// onHitWall: Handle collision with wall. - /// - public override void OnHitWall(HitWallEvent e) - { - // Bounce off! - reverseDirection(); - } - - /// - /// reverseDirection: Switch from ahead to back & vice versa - /// - public void reverseDirection() - { - if (movingForward) - { - SetBack(40000); - movingForward = false; - } - else - { - SetAhead(40000); - movingForward = true; - } - } - - /// - /// onScannedRobot: Fire! - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - Fire(1); - } - - /// - /// onHitRobot: Back up! - /// - public override void OnHitRobot(HitRobotEvent e) - { - // If we're moving the other robot, reverse! - if (e.IsMyFault) - { - reverseDirection(); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Fire.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Fire.cs deleted file mode 100644 index 205454a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Fire.cs +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Drawing; -using Robocode; -using Robocode.Util; - -namespace SampleCs -{ - /// - /// Fire - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - /// Sits still. Spins gun around. Moves when hit. - /// - public class Fire : Robot - { - private int dist = 50; // distance to move when we're hit - - /// - /// run: Fire's main run function - /// - public override void Run() - { - // Set colors - BodyColor = (Color.Orange); - GunColor = (Color.Orange); - RadarColor = (Color.Red); - ScanColor = (Color.Red); - BulletColor = (Color.Red); - - // Spin the gun around slowly... forever - while (true) - { - TurnGunRight(5); - } - } - - /// - /// onScannedRobot: Fire! - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - // If the other robot is close by, and we have plenty of life, - // Fire hard! - if (e.Distance < 50 && Energy > 50) - { - Fire(3); - } // otherwise, Fire 1. - else - { - Fire(1); - } - // Call scan again, before we turn the gun - Scan(); - } - - /// - /// onHitByBullet: Turn perpendicular to the bullet, and move a bit. - /// - public override void OnHitByBullet(HitByBulletEvent e) - { - TurnRight(Utils.NormalRelativeAngleDegrees(90 - (Heading - e.Heading))); - - Ahead(dist); - dist *= -1; - Scan(); - } - - /// - /// onHitRobot: Aim at it. Fire Hard! - /// - public override void OnHitRobot(HitRobotEvent e) - { - double turnGunAmt = Utils.NormalRelativeAngleDegrees(e.Bearing + Heading - GunHeading); - - TurnGunRight(turnGunAmt); - Fire(3); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Interactive.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Interactive.cs deleted file mode 100644 index eaa38ef..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Interactive.cs +++ /dev/null @@ -1,218 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using Robocode; -using Robocode.Util; - -namespace SampleCs -{ - /// - /// Interactive - a sample robot by Flemming N. Larsen. - ///

- /// This is a robot that is controlled using the arrow keys and mouse only. - ///

- /// Keys: - /// - Arrow up: Move forward - /// - Arrow down: Move backward - /// - Arrow right: Turn right - /// - Arrow left: Turn left - /// Mouse: - /// - Moving: Moves the aim, which the gun will follow - /// - Wheel up: Move forward - /// - Wheel down: Move backward - /// - Button 1: Fire a bullet with power = 1 - /// - Button 2: Fire a bullet with power = 2 - /// - Button 3: Fire a bullet with power = 3 - ///

- /// The bullet color depends on the Fire power: - /// - Power = 1: Yellow - /// - Power = 2: Orange - /// - Power = 3: Red - ///

- /// Note that the robot will continue firing as long as the mouse button is - /// pressed down. - ///

- /// By enabling the "Paint" button on the robot console window for this robot, - /// a cross hair will be painted for the robots current aim (controlled by the - /// mouse). - ///

- public class Interactive : AdvancedRobot - { - // Move direction: 1 = move forward, 0 = stand still, -1 = move backward - private int moveDirection; - - // Turn direction: 1 = turn right, 0 = no turning, -1 = turn left - private int turnDirection; - - // Amount of pixels/units to move - private double moveAmount; - - // The coordinate of the aim (x,y) - private int aimX, aimY; - - // Fire power, where 0 = don't Fire - private int firePower; - - // Called when the robot must run - public override void Run() - { - // Sets the colors of the robot - // body = black, gun = white, radar = red - SetColors(Color.Black, Color.White, Color.Red); - - // Loop forever - for (;;) - { - // Sets the robot to move forward, backward or stop moving depending - // on the move direction and amount of pixels to move - SetAhead(moveAmount*moveDirection); - - // Decrement the amount of pixels to move until we reach 0 pixels - // This way the robot will automatically stop if the mouse wheel - // has stopped it's rotation - moveAmount = Math.Max(0, moveAmount - 1); - - // Sets the robot to turn right or turn left (at maximum speed) or - // stop turning depending on the turn direction - SetTurnRight(45*turnDirection); // degrees - - // Turns the gun toward the current aim coordinate (x,y) controlled by - // the current mouse coordinate - double angle = Utils.NormalAbsoluteAngle(Math.Atan2(aimX - X, aimY - Y)); - - SetTurnGunRightRadians(Utils.NormalRelativeAngle(angle - GunHeadingRadians)); - - // Fire the gun with the specified Fire power, unless the Fire power = 0 - if (firePower > 0) - { - SetFire(firePower); - } - - // Execute all pending set-statements - Execute(); - - // Next turn is processed in this loop.. - } - } - - // Called when a key has been pressed - public override void OnKeyPressed(KeyEvent e) - { - switch (e.KeyCode) - { - case Keys.VK_UP: - // Arrow up key: move direction = forward (infinitely) - moveDirection = 1; - moveAmount = Double.PositiveInfinity; - break; - - case Keys.VK_DOWN: - // Arrow down key: move direction = backward (infinitely) - moveDirection = -1; - moveAmount = Double.PositiveInfinity; - break; - - case Keys.VK_RIGHT: - // Arrow right key: turn direction = right - turnDirection = 1; - break; - - case Keys.VK_LEFT: - // Arrow left key: turn direction = left - turnDirection = -1; - break; - } - } - - // Called when a key has been released (after being pressed) - public override void OnKeyReleased(KeyEvent e) - { - switch (e.KeyCode) - { - case Keys.VK_UP: - case Keys.VK_DOWN: - // Arrow up and down keys: move direction = stand still - moveDirection = 0; - moveAmount = 0; - break; - - case Keys.VK_RIGHT: - case Keys.VK_LEFT: - // Arrow right and left keys: turn direction = stop turning - turnDirection = 0; - break; - } - } - - // Called when the mouse wheel is rotated - public override void OnMouseWheelMoved(MouseWheelMovedEvent e) - { - // If the wheel rotation is negative it means that it is moved forward. - // Set move direction = forward, if wheel is moved forward. - // Otherwise, set move direction = backward - moveDirection = (e.WheelRotation < 0) ? 1 : -1; - - // Set the amount to move = absolute wheel rotation amount * 5 (speed) - // Here 5 means 5 pixels per wheel rotation step. The higher value, the - // more speed - moveAmount += Math.Abs(e.WheelRotation)*5; - } - - // Called when the mouse has been moved - public override void OnMouseMoved(MouseEvent e) - { - // Set the aim coordinate = the mouse pointer coordinate - aimX = e.X; - aimY = e.Y; - } - - // Called when a mouse button has been pressed - public override void OnMousePressed(MouseEvent e) - { - if (e.Button == Keys.BUTTON3) - { - // Button 3: Fire power = 3 energy points, bullet color = red - firePower = 3; - BulletColor = (Color.Red); - } - else if (e.Button == Keys.BUTTON2) - { - // Button 2: Fire power = 2 energy points, bullet color = orange - firePower = 2; - BulletColor = (Color.Orange); - } - else - { - // Button 1 or unknown button: - // Fire power = 1 energy points, bullet color = yellow - firePower = 1; - BulletColor = (Color.Yellow); - } - } - - // Called when a mouse button has been released (after being pressed) - public override void OnMouseReleased(MouseEvent e) - { - // Fire power = 0, which means "don't Fire" - firePower = 0; - } - - // Called in order to paint graphics for this robot. - // "Paint" button on the robot console window for this robot must be - // enabled in order to see the paintings. - public override void OnPaint(IGraphics g) - { - // Draw a red cross hair with the center at the current aim - // coordinate (x,y) - g.DrawEllipse(Pens.Red, aimX - 15, aimY - 15, 30, 30); - g.DrawLine(Pens.Red, aimX, aimY - 4, aimX, aimY + 4); - g.DrawLine(Pens.Red, aimX - 4, aimY, aimX + 4, aimY); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/MyFirstJuniorRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/MyFirstJuniorRobot.cs deleted file mode 100644 index 2cd6050..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/MyFirstJuniorRobot.cs +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace SampleCs -{ - /// - /// MyFirstJuniorRobot - a sample robot by Flemming N. Larsen - ///

- /// Moves in a seesaw motion, and spins the gun around at each end - /// when it cannot see any enemy robot. When the robot sees and enemy - /// robot, it will immediately turn the gun and Fire at it. - ///

- public class MyFirstJuniorRobot : JuniorRobot - { - /// - /// MyFirstJuniorRobot's run method - Seesaw as default - /// - public override void Run() - { - // Set robot colors - SetColors(GREEN, BLACK, BLUE); - - // Seesaw forever - while (true) - { - Ahead(100); // Move ahead 100 - TurnGunRight(360); // Spin gun around - Back(100); // Move back 100 - TurnGunRight(360); // Spin gun around - } - } - - /// - /// When we see a robot, turn the gun towards it and Fire - /// - public override void OnScannedRobot() - { - // Turn gun to point at the scanned robot - TurnGunTo(ScannedAngle); - - // Fire! - Fire(1); - } - - /// - /// We were hit! Turn and move perpendicular to the bullet, - /// so our seesaw might avoid a future shot. - /// - public override void OnHitByBullet() - { - // Move ahead 100 and in the same time turn left papendicular to the bullet - TurnAheadLeft(100, 90 - HitByBulletBearing); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/MyFirstRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/MyFirstRobot.cs deleted file mode 100644 index a79a791..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/MyFirstRobot.cs +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace SampleCs -{ - /// - /// MyFirstRobot - a sample robot by Mathew Nelson - ///

- /// Moves in a seesaw motion, and spins the gun around at each end - ///

- public class MyFirstRobot : Robot - { - /// - /// MyFirstRobot's run method - Seesaw - /// - public override void Run() - { - while (true) - { - Ahead(100); // Move ahead 100 - TurnGunRight(360); // Spin gun around - Back(100); // Move back 100 - TurnGunRight(360); // Spin gun around - } - } - - /// - /// Fire when we see a robot - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - Fire(1); - } - - /// - /// We were hit! Turn perpendicular to the bullet, - /// so our seesaw might avoid a future shot. - /// - public override void OnHitByBullet(HitByBulletEvent e) - { - TurnLeft(90 - e.Bearing); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/PaintingRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/PaintingRobot.cs deleted file mode 100644 index c6822ef..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/PaintingRobot.cs +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Drawing; -using Robocode; - -namespace SampleCs -{ - /// - /// PaintingRobot - a sample robot that demonstrates the OnPaint() and - /// GetGraphics() methods. - /// Also demonstrate feature of debugging properties on RobotDialog - ///

- /// Moves in a seesaw motion, and spins the gun around at each end. - /// When painting is enabled for this robot, a red circle will be painted - /// around this robot. - ///

- public class PaintingRobot : Robot - { - /// - /// PaintingRobot's Run method - Seesaw - /// - public override void Run() - { - while (true) - { - Ahead(100); - TurnGunRight(360); - Back(100); - TurnGunRight(360); - } - } - - /// - /// Fire when we see a robot - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - // demonstrate feature of debugging properties on RobotDialog - DebugProperty["lastScannedRobot"] = e.Name + " at " + e.Bearing + " degrees at time " + Time; - - Fire(1); - } - - /// - /// We were hit! Turn perpendicular to the bullet, - /// so our seesaw might avoid a future shot. - /// In addition, draw orange circles where we were hit. - /// - public override void OnHitByBullet(HitByBulletEvent e) - { - // demonstrate feature of debugging properties on RobotDialog - DebugProperty["lastHitBy"] = e.Name + " with power of bullet " + e.Power + " at time " + Time; - - // show how to remove debugging property - DebugProperty["lastScannedRobot"] = null; - - // gebugging by painting to battle view - IGraphics g = Graphics; - - g.DrawEllipse(Pens.Orange, (int) (X - 55), (int) (Y - 55), 110, 110); - g.DrawEllipse(Pens.Orange, (int) (X - 56), (int) (Y - 56), 112, 112); - g.DrawEllipse(Pens.Orange, (int) (X - 59), (int) (Y - 59), 118, 118); - g.DrawEllipse(Pens.Orange, (int) (X - 60), (int) (Y - 60), 120, 120); - - TurnLeft(90 - e.Bearing); - } - - /// - /// Paint a red circle around our PaintingRobot - /// - public override void OnPaint(IGraphics graphics) - { - var transparentGreen = new SolidBrush(Color.FromArgb(30, 0, 0xFF, 0)); - graphics.FillEllipse(transparentGreen, (int) (X - 60), (int) (Y - 60), 120, 120); - graphics.DrawEllipse(Pens.Red, (int) (X - 50), (int) (Y - 50), 100, 100); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/PointD.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/PointD.cs deleted file mode 100644 index 433242d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/PointD.cs +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Collections.Generic; -using System.Text; - -namespace SampleCs -{ - [Serializable] - public class PointD - { - public PointD(double x, double y) - { - X = x; - Y = y; - } - - public double X { get; set; } - - public double Y { get; set; } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/RamFire.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/RamFire.cs deleted file mode 100644 index f847cb9..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/RamFire.cs +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Drawing; -using Robocode; - -namespace SampleCs -{ - /// - /// RamFire - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - ///

- /// Drives at robots trying to ram them. - /// Fires when it hits them. - ///

- public class RamFire : Robot - { - private int turnDirection = 1; // Clockwise or counterclockwise - - /// - /// run: Spin around looking for a target - /// - public override void Run() - { - // Set colors - BodyColor = (Color.LightGray); - GunColor = (Color.Gray); - RadarColor = (Color.DarkGray); - - while (true) - { - TurnRight(5*turnDirection); - } - } - - /// - /// onScannedRobot: We have a target. Go get it. - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - if (e.Bearing >= 0) - { - turnDirection = 1; - } - else - { - turnDirection = -1; - } - - TurnRight(e.Bearing); - Ahead(e.Distance + 5); - Scan(); // Might want to move ahead again! - } - - /// - /// onHitRobot: Turn to face robot, fire hard, and ram him again! - /// - public override void OnHitRobot(HitRobotEvent e) - { - if (e.Bearing >= 0) - { - turnDirection = 1; - } - else - { - turnDirection = -1; - } - TurnRight(e.Bearing); - - // Determine a shot that won't kill the robot... - // We want to ram him instead for bonus points - if (e.Energy > 16) - { - Fire(3); - } - else if (e.Energy > 10) - { - Fire(2); - } - else if (e.Energy > 4) - { - Fire(1); - } - else if (e.Energy > 2) - { - Fire(.5); - } - else if (e.Energy > .4) - { - Fire(.1); - } - Ahead(40); // Ram him again! - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/RobotColors.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/RobotColors.cs deleted file mode 100644 index 40c1d1d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/RobotColors.cs +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; - -namespace SampleCs -{ - [Serializable] - public class RobotColors - { - public Color bodyColor; - public Color bulletColor; - public Color gunColor; - public Color radarColor; - public Color scanColor; - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/SittingDuck.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/SittingDuck.cs deleted file mode 100644 index aecf108..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/SittingDuck.cs +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using System.IO; -using Robocode; - -namespace SampleCs -{ - /// - /// SittingDuck - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - ///

- /// Along with sitting still doing nothing, this robot demonstrates persistency. - ///

- public class SittingDuck : AdvancedRobot - { - private static bool incrementedBattles; - - public override void Run() - { - BodyColor = (Color.Yellow); - GunColor = (Color.Yellow); - - int roundCount = 0; - int battleCount = 0; - - // Read file "count.dat" which contains 2 integers, - try - { - using (Stream count = GetDataFile("count.dat")) - { - if (count.Length != 0) - { - using (TextReader tr = new StreamReader(count)) - { - roundCount = int.Parse(tr.ReadLine()); - battleCount = int.Parse(tr.ReadLine()); - } - } - } - } - catch (Exception) - { - // Something went wrong reading the file, reset to 0. - roundCount = 0; - battleCount = 0; - } - - // Increment the # of rounds - roundCount++; - // If we haven't incremented # of battles already, - // (Note: Because robots are only instantiated once per battle, - // member variables remain valid throughout it. - if (!incrementedBattles) - { - // Increment # of battles - battleCount++; - incrementedBattles = true; - } - - try - { - using (Stream count = GetDataFile("count.dat")) - { - count.SetLength(0); - using (TextWriter tw = new StreamWriter(count)) - { - tw.WriteLine(roundCount); - tw.WriteLine(battleCount); - } - } - } - catch (Exception) - { - Out.WriteLine("I could not write the count!"); - } - - Out.WriteLine("I have been a sitting duck for " + roundCount + " rounds, in " + battleCount + " battles."); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/SpinBot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/SpinBot.cs deleted file mode 100644 index 0939278..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/SpinBot.cs +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System.Drawing; -using Robocode; - -namespace SampleCs -{ - /// - /// SpinBot - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - ///

- /// Moves in a circle, firing hard when an enemy is detected - ///

- public class SpinBot : AdvancedRobot - { - /// - /// SpinBot's run method - Circle - /// - public override void Run() - { - // Set colors - BodyColor = (Color.Blue); - GunColor = (Color.Blue); - RadarColor = (Color.Black); - ScanColor = (Color.Yellow); - - // Loop forever - while (true) - { - // Tell the game that when we take move, - // we'll also want to turn right... a lot. - SetTurnRight(10000); - // Limit our speed to 5 - MaxVelocity = 5; - // Start moving (and turning) - Ahead(10000); - // Repeat. - } - } - - /// - /// onScannedRobot: Fire hard! - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - Fire(3); - } - - /// - /// - /// onHitRobot: If it's our fault, we'll stop turning and moving, - /// so we need to turn again to keep spinning. - /// - public override void OnHitRobot(HitRobotEvent e) - { - if (e.Bearing > -10 && e.Bearing < 10) - { - Fire(3); - } - if (e.IsMyFault) - { - TurnRight(10); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Target.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Target.cs deleted file mode 100644 index 2079950..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Target.cs +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - - -using System.Drawing; -using Robocode; - -namespace SampleCs -{ - /// - /// Target - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - ///

- /// Sits still. Moves every time energy drops by 20. - /// This Robot demonstrates custom events. - ///

- public class Target : AdvancedRobot - { - private int trigger; // Keeps track of when to move - - /// - /// TrackFire's run method - /// - public override void Run() - { - // Set colors - BodyColor = (Color.White); - GunColor = (Color.White); - RadarColor = (Color.White); - - // Initially, we'll move when life hits 80 - trigger = 80; - // Add a custom event named "trigger hit", - AddCustomEvent( - new Condition("triggerhit", - (c) => - { - return Energy <= trigger; - })); - } - - /// - /// onCustomEvent handler - /// - public override void OnCustomEvent(CustomEvent e) - { - // If our custom event "triggerhit" went off, - if (e.Condition.Name == "triggerhit") - { - // Adjust the trigger value, or - // else the event will fire again and again and again... - trigger -= 20; - Out.WriteLine("Ouch, down to " + (int) (Energy + .5) + " energy."); - // move around a bit. - TurnLeft(65); - Ahead(100); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/TrackFire.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/TrackFire.cs deleted file mode 100644 index 25ad660..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/TrackFire.cs +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using Robocode; -using Robocode.Util; - -namespace SampleCs -{ - /// - /// TrackFire - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - ///

- /// Sits still. Tracks and fires at the nearest robot it sees - ///

- public class TrackFire : Robot - { - /// - /// TrackFire's run method - /// - public override void Run() - { - // Set colors - BodyColor = (Color.Pink); - GunColor = (Color.Pink); - RadarColor = (Color.Pink); - ScanColor = (Color.Pink); - BulletColor = (Color.Pink); - - // Loop forever - while (true) - { - TurnGunRight(10); // Scans automatically - } - } - - /// - /// onScannedRobot: We have a target. Go get it. - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - // Calculate exact location of the robot - double absoluteBearing = Heading + e.Bearing; - double bearingFromGun = Utils.NormalRelativeAngleDegrees(absoluteBearing - GunHeading); - - // If it's close enough, fire! - if (Math.Abs(bearingFromGun) <= 3) - { - TurnGunRight(bearingFromGun); - // We check gun heat here, because calling Fire() - // uses a turn, which could cause us to lose track - // of the other robot. - if (GunHeat == 0) - { - Fire(Math.Min(3 - Math.Abs(bearingFromGun), Energy - .1)); - } - } - else - { - // otherwise just set the gun to turn. - // Note: This will have no effect until we call scan() - TurnGunRight(bearingFromGun); - } - // Generates another scan event if we see a robot. - // We only need to call this if the gun (and therefore radar) - // are not turning. Otherwise, scan is called automatically. - if (bearingFromGun == 0) - { - Scan(); - } - } - - public override void OnWin(WinEvent e) - { - // Victory dance - TurnRight(36000); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Tracker.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Tracker.cs deleted file mode 100644 index 5396b95..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Tracker.cs +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using Robocode; -using Robocode.Util; - -namespace SampleCs -{ - /// - /// Tracker - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - ///

- /// Locks onto a robot, moves close, fires when close. - ///

- public class Tracker : Robot - { - private int count; // Keeps track of how long we've - // been searching for our target - private double gunTurnAmt; // How much to turn our gun when searching - private String trackName; // Name of the robot we're currently tracking - - /// - /// run: Tracker's main run function - /// - public override void Run() - { - // Set colors - BodyColor = (Color.FromArgb(128, 128, 50)); - GunColor = (Color.FromArgb(50, 50, 20)); - RadarColor = (Color.FromArgb(200, 200, 70)); - ScanColor = (Color.White); - BulletColor = (Color.Blue); - - // Prepare gun - trackName = null; // Initialize to not tracking anyone - IsAdjustGunForRobotTurn = (true); // Keep the gun still when we turn - gunTurnAmt = 10; // Initialize gunTurn to 10 - - // Loop forever - while (true) - { - // turn the Gun (looks for enemy) - TurnGunRight(gunTurnAmt); - // Keep track of how long we've been looking - count++; - // If we've haven't seen our target for 2 turns, look left - if (count > 2) - { - gunTurnAmt = -10; - } - // If we still haven't seen our target for 5 turns, look right - if (count > 5) - { - gunTurnAmt = 10; - } - // If we *still* haven't seen our target after 10 turns, find another target - if (count > 11) - { - trackName = null; - } - } - } - - /// - /// onScannedRobot: Here's the good stuff - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - // If we have a target, and this isn't it, return immediately - // so we can get more ScannedRobotEvents. - if (trackName != null && e.Name != trackName) - { - return; - } - - // If we don't have a target, well, now we do! - if (trackName == null) - { - trackName = e.Name; - Out.WriteLine("Tracking " + trackName); - } - // This is our target. Reset count (see the run method) - count = 0; - // If our target is too far away, turn and move toward it. - if (e.Distance > 150) - { - gunTurnAmt = Utils.NormalRelativeAngleDegrees(e.Bearing + (Heading - RadarHeading)); - - TurnGunRight(gunTurnAmt); // Try changing these to setTurnGunRight, - TurnRight(e.Bearing); // and see how much Tracker improves... - // (you'll have to make Tracker an AdvancedRobot) - Ahead(e.Distance - 140); - return; - } - - // Our target is close. - gunTurnAmt = Utils.NormalRelativeAngleDegrees(e.Bearing + (Heading - RadarHeading)); - TurnGunRight(gunTurnAmt); - Fire(3); - - // Our target is too close! Back up. - if (e.Distance < 100) - { - if (e.Bearing > -90 && e.Bearing <= 90) - { - Back(40); - } - else - { - Ahead(40); - } - } - Scan(); - } - - /// - /// onHitRobot: Set him as our new target - /// - public override void OnHitRobot(HitRobotEvent e) - { - // Only print if he's not already our target. - if (trackName != null && trackName != e.Name) - { - Out.WriteLine("Tracking " + e.Name + " due to collision"); - } - // Set the target - trackName = e.Name; - // Back up a bit. - // Note: We won't get scan events while we're doing this! - // An AdvancedRobot might use setBack(); Execute(); - gunTurnAmt = Utils.NormalRelativeAngleDegrees(e.Bearing + (Heading - RadarHeading)); - TurnGunRight(gunTurnAmt); - Fire(3); - Back(50); - } - - /// - /// onWin: Do a victory dance - /// - public override void OnWin(WinEvent e) - { - for (int i = 0; i < 50; i++) - { - TurnRight(30); - TurnLeft(30); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/VelociRobot.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/VelociRobot.cs deleted file mode 100644 index e5e70d8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/VelociRobot.cs +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using Robocode; - -namespace SampleCs -{ - /// - /// This is a sample of a robot using the RateControlRobot class by Joshua Galecki - /// - public class VelociRobot : RateControlRobot - { - private int turnCounter; - - public override void Run() - { - turnCounter = 0; - GunRotationRate = (15); - - while (true) - { - if (turnCounter%64 == 0) - { - // Straighten out, if we were hit by a bullet and are turning - TurnRate = 0; - // Go forward with a velocity of 4 - VelocityRate = 4; - } - if (turnCounter%64 == 32) - { - // Go backwards, faster - VelocityRate = -6; - } - turnCounter++; - Execute(); - } - } - - public override void OnScannedRobot(ScannedRobotEvent e) - { - Fire(1); - } - - public override void OnHitByBullet(HitByBulletEvent e) - { - // Turn to confuse the other robot - TurnRate = 5; - } - - public override void OnHitWall(HitWallEvent e) - { - // Move away from the wall - VelocityRate = (-1*VelocityRate); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Walls.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Walls.cs deleted file mode 100644 index 988a5da..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCs/Walls.cs +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using Robocode; - -namespace SampleCs -{ - /// - /// Walls - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - ///

- /// Moves around the outer edge with the gun facing in. - ///

- public class Walls : Robot - { - private bool peek; // Don't turn if there's a robot there - private double moveAmount; // How much to move - - /// - /// run: Move around the walls - /// - public override void Run() - { - // Set colors - BodyColor = (Color.Black); - GunColor = (Color.Black); - RadarColor = (Color.Orange); - BulletColor = (Color.Cyan); - ScanColor = (Color.Cyan); - - // Initialize moveAmount to the maximum possible for this battlefield. - moveAmount = Math.Max(BattleFieldWidth, BattleFieldHeight); - // Initialize peek to false - peek = false; - - // turnLeft to face a wall. - // getHeading() % 90 means the remainder of - // getHeading() divided by 90. - TurnLeft(Heading%90); - Ahead(moveAmount); - // Turn the gun to turn right 90 degrees. - peek = true; - TurnGunRight(90); - TurnRight(90); - - while (true) - { - // Look before we turn when ahead() completes. - peek = true; - // Move up the wall - Ahead(moveAmount); - // Don't look now - peek = false; - // Turn to the next wall - TurnRight(90); - } - } - - /// - /// onHitRobot: Move away a bit. - /// - public override void OnHitRobot(HitRobotEvent e) - { - // If he's in front of us, set back up a bit. - if (e.Bearing > -90 && e.Bearing < 90) - { - Back(100); - } // else he's in back of us, so set ahead a bit. - else - { - Ahead(100); - } - } - - /// - /// onScannedRobot: Fire! - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - Fire(2); - // Note that scan is called automatically when the robot is moving. - // By calling it manually here, we make sure we generate another scan event if there's a robot on the next - // wall, so that we do not start moving up it until it's gone. - if (peek) - { - Scan(); - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsSentry/BorderGuard.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsSentry/BorderGuard.cs deleted file mode 100644 index b2cec54..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsSentry/BorderGuard.cs +++ /dev/null @@ -1,763 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using System.Collections.Generic; -using System.Collections.ObjectModel; -using Robocode; -using Robocode.Util; - -namespace SampleCsSentry -{ - /// - /// BorderGuard - is a sample robot that demonstrates how the BorderSentry interface can be used for - /// creating a robot that guards the border area of the battle field, and which is efficient against - /// robots trying to hide at corners and robots sneaking around near the borders. - ///

- /// This robot is somewhat advanced due to:
- /// 1) it uses linear targeting for predicting how to hit robots that moves in straight lines.
- /// 2) it will only fire at a robot, if it figures out that its bullets will do damage to that - /// particular robot, e.g. when the robots predicted future position will be within the sentry border - /// attack range.
- /// 3) it has an efficient scanner that keeps the scan angle as little as possible to get as new - /// scanned data for enemy robots as possible.
- /// 4) it picks a target robot to fire at, which is the nearest robot our robot will be able to - /// damage (by predicting its future position using linear targeting).
- /// 5) it only moves along the borders of the battle field and constantly changes its direction, so - /// it is not an easy target, and it will try to get as close to its target robot as possible.
- ///

- /// Lots of improvements can be made to this robot by copying it - making it even stronger. The - /// intention with of this sample robot is to serve as a more advanced example of how a AdvancedRobot - /// can be made, and how it can be structured as most sample robots are far simpler. - ///

- /// - /// Credits goes to the hard working Robocoders at the RoboWiki. :-) - ///

- /// - /// This robot makes use of the Oldest Scanned melee scanner from the RoboWiki:
- /// http://robowiki.net/wiki/Melee_Radar - ///

- /// - /// In addition, it makes use of the Exact Non-iterative Solution for Linear Targeting from the - /// RoboWiki:
- /// http://robowiki.net/wiki/Linear_Targeting - ///

- /// - /// Author: Flemming N. Larsen - ///

- /// Version: 1.0 - ///

- /// Since 1.9.2.4 - ///

- public class BorderGuard - : AdvancedRobot, IBorderSentry - { - // Constants - const double FIREPOWER = 3; // Max. power => violent as this robot can afford it! - const double HALF_ROBOT_SIZE = 18; // Robot size is 36x36 units, so the half size is 18 units - - // Dictionary containing data for all scanned robots. - // The key to the dictionary is a robot name and the value is an object containing robot data. - IDictionary enemyDictionary; - // List containing robot names where the order of names reflects the when these names was accessed the last time - // within the enemy dictionary. The first in the list is the name of the robot that was accessed the last time, - // and the last in the list is the oldest one. - IList accessedEnemyList; - - // Scanning direction, where the radar turns to the right with positive values, and turns - // to the left with negative values. - double scanDir = 1; - - // Oldest scanned robot. Can be null. - RobotData oldestScanned; - - // Target robot for the gun. Can be null meaning that there is currently no target robot. - RobotData target; - - // Last time when the robot shifted its direction - long lastDirectionShift; - - // Current direction, where 1 means ahead (forward) and -1 means back - int direction = 1; - - /// - /// Constructs this robot. - /// - public BorderGuard() - { - // We initialize a Dictionary containing robot data for each scanned robot, and also a - // List keeping track of the access order for the enemy dictionary. The last accessed robot - // entry is listed first in the List. - // This robot always sweep the radar towards the oldest scanned robot. - enemyDictionary = new Dictionary(); - accessedEnemyList = new List(); - } - - /// - /// Main method that is called by the game when the robot engage in the next round of a battle. - /// - public override void Run() - { - // Do initialization stuff here before the loop - Initialize(); - - // Loop forever. If the robot does not take action, the game will disable our robot! - while (true) - { - // Handle a single turn... - - // Handle the radar that scans enemy robots - HandleRadar(); - // Handle the gun by turning it and fire at our target - HandleGun(); - // Move the robot around on the battlefield - MoveRobot(); - - // Scan for other robots. Note that this method will execute all pending commands for - // the next turn. Hence, scan() ends the turn for our robot. - Scan(); - } - } - - /// - /// This method is called by the game when your robot sees another robot, i.e. when the robot's - /// radar scan "hits" another robot. - /// - /// The scanned robot event containing data about the scanned robot. - public override void OnScannedRobot(ScannedRobotEvent scannedRobotEvent) - { - // Check that the scanned robot is not a sentry robot - if (!scannedRobotEvent.IsSentryRobot) - { - // The scanned robot is not a sentry robot... - - // Update the enemy dictionary - UpdateEnemyDictionary(scannedRobotEvent); - - // Update the scan direction - UpdateScanDirection(scannedRobotEvent); - - // Update enemy target positions - UpdateEnemyTargetPositions(); - } - } - - /// - /// This method is called by the game when another robot dies. - /// - /// The robot death event containing data about the robot that died. - public override void OnRobotDeath(RobotDeathEvent robotDeathEvent) - { - // Gets the name of the robot that died - var deadRobotName = robotDeathEvent.Name; - - // Remove the robot data for the robot that died from the enemy dictionary and access list - enemyDictionary.Remove(deadRobotName); - accessedEnemyList.Remove(deadRobotName); - - // Remove the data entry for the oldest scanned robot, if we have such an entry - if (oldestScanned != null && oldestScanned.name.Equals(deadRobotName)) - { - oldestScanned = null; - } - if (target != null && target.name.Equals(deadRobotName)) - { - target = null; - } - } - - /// - /// This method is called by the every time the robot is painted. - /// - /// - /// In order to see the painting, make sure to enable the Paint button on the robot console for this robot. - /// - /// - /// The graphics context used for painting various shapes like rectangles, circles, lines etc. - /// on top of the battlefield for debugging graphics. - /// - public override void OnPaint(IGraphics g) - { - // Prepare colors for painting the scanned coordinate and target coordinate - var color1 = Color.FromArgb(0x40, 0x00, 0xFF, 0x00); // Green with 25% alpha blending - var color2 = Color.FromArgb(0x40, 0xFF, 0x00, 0x40); // Yellow with 25% alhpa blending - - // Prepare pen with color 1 and a width of 2 pixels - var pen = new Pen(color1, 2); - - // Paint a two circles for each robot in the enemy dictionary. One circle where the robot was - // scanned the last time, and another circle where our robot must point the gun in order to - // hit it (target coordinate). In addition, a line is drawn between these circles. - foreach (RobotData robot in enemyDictionary.Values) - { - // Paint the two circles and a line - FillCircle(g, robot.scannedX, robot.scannedY, color1); // scanned coordinate - FillCircle(g, robot.targetX, robot.targetY, color2); // target coordinate - g.DrawLine(pen, (float)robot.scannedX, (float)robot.scannedY, - (float)robot.targetX, (float)robot.targetY); - } - - // Paint a two circles for the target robot. One circle where the robot was - // scanned the last time, and another circle where our robot must point the gun in order to - // hit it (target coordinate). In addition, a line is drawn between these circles. - if (target != null) - { - // Prepare colors for painting the scanned coordinate and target coordinate - color1 = Color.FromArgb(0x40, 0xFF, 0x7F, 0x00); // Orange with 25% alpha blending - color2 = Color.FromArgb(0x80, 0xFF, 0x00, 0x00); // Red with 50% alpha blending - - // Prepare pen with color 1 and a width of 2 pixels - pen = new Pen(color1, 2); - - // Paint the two circles and a line - FillCircle(g, target.scannedX, target.scannedY, color1); // scanned coordinate - FillCircle(g, target.targetX, target.targetY, color2); // target coordinate - g.DrawLine(pen, (float)target.scannedX, (float)target.scannedY, - (float)target.targetX, (float)target.targetY); - } - } - - /// - /// Initializes this robot before a new round in a battle. - /// - private void Initialize() - { - // Let the robot body, gun, and radar turn independently of each other - IsAdjustRadarForGunTurn = true; - IsAdjustGunForRobotTurn = true; - - // Set robot colors - BodyColor = Color.FromArgb(0x5C, 0x33, 0x17); // Chocolate Brown - GunColor = Color.FromArgb(0x45, 0x8B, 0x74); // Aqua Marine - RadarColor = Color.FromArgb(0xD2, 0x69, 0x1E); // Orange Chocolate - BulletColor = Color.FromArgb(0xFF, 0xD3, 0x9B); // Burly wood - ScanColor = Color.FromArgb(0xCA, 0xFF, 0x70); // Olive Green - } - - /// - /// This method handles the radar that scans for enemy robots. - /// - private void HandleRadar() - { - // Set the radar to turn infinitely to the right if the scan direction is positive; - // otherwise the radar is moved to the left, if the scan direction is negative. - // Notice that onScannedRobot(ScannedRobotEvent) is responsible for determining the scan - // direction. - SetTurnRadarRightRadians(scanDir * Double.PositiveInfinity); - } - - /// - /// Method that handles the gun be turning it and fire at a target. - /// - private void HandleGun() - { - // Update our target robot to fire at - UpdateTarget(); - // Update the gun direction - UpdateGunDirection(); - // Fires the gun, when it is ready - FireGunWhenReady(); - } - - /// - /// Method that moves our robot around the battlefield. - /// - private void MoveRobot() - { - // The movement strategy is to move as close to our target robot as possible. - // Our robot should move along the borders all the time, vertically or horizontally. - // When we get close to our target, or have no where to go, our robot should shift its - // direction from side to side so it does not stand still at any time. - // If the robot stands still, it will be an easy target for enemy robots. - - int newDirection = direction; - - // Get closer to our target if we have a target robot - if (target != null) - { - // Calculate the range from the walls/borders, our robot should keep within - int borderRange = SentryBorderSize - 20; - - // The horizontal and vertical flags are used for determining, if our robot should - // move horizontal or vertical. - bool horizontal = false; - bool vertical = false; - - // Initialize the new heading of the robot to the current heading of the robot - double newHeading = HeadingRadians; - - // Check if our robot is at the upper or lower border and hence should move horizontally - if (X < borderRange || Y > BattleFieldHeight - borderRange) - { - horizontal = true; - } - // Check if our robot is at the left or right border and hence should move vertically - if (X < borderRange || X > BattleFieldWidth - borderRange) - { - vertical = true; - } - - // If we are in one of the corners of the battlefield, we could move both horizontally - // or vertically. - // In this situation, we need to choose one of the two directions. - if (horizontal && vertical) - { - // If the horizontal distance to our target is lesser than the vertical distance, - // then we choose to move vertically, and hence we clear the horizontal flag. - if (Math.Abs(target.targetX - X) <= Math.Abs(target.targetY - Y)) - { - horizontal = false; // Do not move horizontally => move vertically - } - } - // Adjust the heading of our robot with 90 degrees, if it must move horizontally. - // Otherwise the calculated heading is towards moving vertically. - if (horizontal) - { - newHeading -= Math.PI / 2; - } - // Set the robot to turn left the amount of radians we have just calculated - SetTurnLeftRadians(Utils.NormalRelativeAngle(newHeading)); - - // Check if our robot has finished turning, i.e. has less than 1 degrees left to turn - if (Math.Abs(TurnRemaining) < 1 || Math.Abs(Velocity) < 0.01) - { - // If we should move horizontally, the set the robot to move ahead with the - // horizontal distance to the target robot. Otherwise, use the vertical distance. - double delta; // delta is the delta distance to move - if (horizontal) - { - delta = target.targetX - X; - } - else - { - delta = target.targetY - Y; - } - SetAhead(delta); - - // Set the new direction of our robot to 1 (meaning move forward) if the delta - // distance is positive; otherwise it is set to -1 (meaning move backward). - newDirection = delta > 0 ? 1 : -1; - - // Check if more than 10 turns have past since we changed the direction the last - // time - if (Time - lastDirectionShift > 10) - { - // If so, set the new direction to be the reverse direction if the velocity < 1 - if (Math.Abs(Velocity) < 1) - { - newDirection = direction * -1; - } - // Check if the direction really changed - if (newDirection != direction) - { - // If the new direction != current direction, then set the current direction - // to be the new direction and save the current time so we know when we - // changed the direction the last time. - direction = newDirection; - lastDirectionShift = Time; - } - } - } - } - // Set ahead 100 units forward or backward depending on the direction - SetAhead(100 * direction); - } - - /// - /// Method the updates the enemy dictionary based on new scan data for a scanned robot. - /// - /// The scanned robot event containing data about the scanned robot. - private void UpdateEnemyDictionary(ScannedRobotEvent scannedRobotEvent) - { - var name = scannedRobotEvent.Name; - - // Check if data entry exists for the scanned robot - if (enemyDictionary.ContainsKey(name)) - { - // Data entry exists => Update the current entry with new scanned data - RobotData scannedRobot = enemyDictionary[name]; - scannedRobot.Update(scannedRobotEvent, this); - } - else - { - // No data entry exists => Create a new data entry for the scanned robot - RobotData scannedRobot = new RobotData(scannedRobotEvent, this); - // Put the new data entry into the enemy dictionary - enemyDictionary.Add(name, scannedRobot); - } - // Change the access order for the robot name, so the name is moved to, or added as the last entry - if (accessedEnemyList.Contains(name)) - { - accessedEnemyList.Remove(name); - } - accessedEnemyList.Add(name); - } - - /// - /// Method that updates the direction of the radar based on new scan data for a scanned robot. - /// - /// The scanned robot event containing data about the scanned robot. - private void UpdateScanDirection(ScannedRobotEvent scannedRobotEvent) - { - // Gets the name of the scanned robot - var scannedRobotName = scannedRobotEvent.Name; - - // Change the scanning direction if and only if we have no record for the oldest scanned - // robot or the scanned robot IS the oldest scanned robot (based on the name) AND the enemy - // dictionary contains scanned data entries for ALL robots (the size of the enemy dictionary is equal to - // the number of opponent robots found by calling the getOthers() method). - if ((oldestScanned == null || scannedRobotName.Equals(oldestScanned.name)) && accessedEnemyList.Count == Others) - { - // Get the oldest scanned robot data from our LinkedHashMap, where the first value - // contains the oldest accessed entry, which is the robot we need to get. - string oldestScannedName = accessedEnemyList[0]; - RobotData oldestScannedRobot = enemyDictionary[oldestScannedName]; - - // Get the recent scanned position (x,y) of the oldest scanned robot - double x = oldestScannedRobot.scannedX; - double y = oldestScannedRobot.scannedY; - - // Get the heading of our robot - double ourHeading = RadarHeadingRadians; - - // Calculate the bearing to the oldest scanned robot. - // The bearing is the delta angle between the heading of our robot and the other robot, - // which can be a positive or negative angle. - double bearing = BearingTo(ourHeading, x, y); - - // Update the scan direction based on the bearing. - // If the bearing is positive, the radar will be moved to the right. - // If the bearing is negative, the radar will be moved to the left. - scanDir = bearing; - } - } - - /// - /// Updates the target positions for all enemies. The target position is the position our robot - /// must fire at in order to hit the target robot. - /// - /// - /// This robot uses Linear Targeting (Exact Non-iterative Solution) as described on the RoboWiki here: - /// http://robowiki.net/wiki/Linear_Targeting - /// - private void UpdateEnemyTargetPositions() - { - // Go thru all robots in the enemy dictionary - foreach (RobotData enemy in enemyDictionary.Values) - { - // Variables prefixed with e- refer to enemy and b- refer to bullet - double bV = Rules.GetBulletSpeed(FIREPOWER); - double eX = enemy.scannedX; - double eY = enemy.scannedY; - double eV = enemy.scannedVelocity; - double eH = enemy.scannedHeading; - - // These constants make calculating the quadratic coefficients below easier - double A = (eX - X) / bV; - double B = (eY - Y) / bV; - double C = eV / bV * Math.Sin(eH); - double D = eV / bV * Math.Cos(eH); - - // Quadratic coefficients: a*(1/t)^2 + b*(1/t) + c = 0 - double a = A * A + B * B; - double b = 2 * (A * C + B * D); - double c = (C * C + D * D - 1); - - // If the discriminant of the quadratic formula is >= 0, we have a solution meaning that - // at some time, t, the bullet will hit the enemy robot if we fire at it now. - double discrim = b * b - 4 * a * c; - if (discrim >= 0) - { - // Reciprocal of quadratic formula. Calculate the two possible solution for the - // time, t - double t1 = 2 * a / (-b - Math.Sqrt(discrim)); - double t2 = 2 * a / (-b + Math.Sqrt(discrim)); - - // Choose the minimum positive time or select the one closest to 0, if the time is - // negative - double t = Math.Min(t1, t2) >= 0 ? Math.Min(t1, t2) : Math.Max(t1, t2); - - // Calculate the target position (x,y) for the enemy. That is the point that our gun - // should point at in order to hit the enemy at the time, t. - double targetX = eX + eV * t * Math.Sin(eH); - double targetY = eY + eV * t * Math.Cos(eH); - - // Assume enemy stops at walls. Hence, we limit that target position at the walls. - double minX = HALF_ROBOT_SIZE; - double minY = HALF_ROBOT_SIZE; - double maxX = BattleFieldWidth - HALF_ROBOT_SIZE; - double maxY = BattleFieldHeight - HALF_ROBOT_SIZE; - - enemy.targetX = Limit(targetX, minX, maxX); - enemy.targetY = Limit(targetY, minY, maxY); - } - } - } - - /// - /// Updates which enemy robot from the enemy dictionary that should be our current target. - /// - private void UpdateTarget() - { - // Set target to null, meaning that we have no target robot yet - target = null; - - // Create a list over possible target robots that is a copy of robot data from the enemy dictionary - List targets = new List(enemyDictionary.Values); - - // Run thru all the possible target robots and remove those that are outside the attack - // range for this border sentry robot as our robot cannot do harm to robots outside its - // range. - for (int i = targets.Count - 1; i >= 0; i--) // avoids error "Collection was modified" - { - RobotData robot = targets[i]; - if (IsOutsideAttackRange(robot.targetX, robot.targetY)) - { - targets.Remove(robot); - } - } - - // Set the target robot to be the one among all possible target robots that is closest to - // our robot. - double minDist = Double.PositiveInfinity; - foreach (RobotData robot in targets) - { - double dist = DistanceTo(robot.targetX, robot.targetY); - if (dist < minDist) - { - minDist = dist; - target = robot; - } - } - - // If we still haven't got a target robot, then take the first one from our list of target - // robots if the list is not empty. - if (target == null && targets.Count > 0) - { - target = targets[0]; - } - } - - /// - /// Method that updates the gun direction to point at the current target. - /// - private void UpdateGunDirection() - { - // Only update the gun direction, if we have a current target - if (target != null) - { - // Calculate the bearing between the gun and the target, which can be positive or - // negative - double targetBearing = BearingTo(GunHeadingRadians, target.targetX, target.targetY); - // Set the gun to turn right the amount of radians defined by the bearing to the target - SetTurnGunRightRadians(targetBearing); // positive => turn right, negative => turn left - } - } - - /// - /// Method that fires a bullet when the gun is ready to fire. - /// - private void FireGunWhenReady() - { - // We only fire the fun, when we have a target robot - if (target != null) - { - // Only fire when the angle of the gun is pointing at our (virtual) target robot - - // Calculate the distance between between our robot and the target robot - double dist = DistanceTo(target.targetX, target.targetY); - // Angle that "covers" the the target robot from its center to its edge - double angle = Math.Atan(HALF_ROBOT_SIZE / dist); - - // Check if the remaining angle (turn) to move the gun is less than our calculated cover - // angle - if (Math.Abs(GunTurnRemaining) < angle) - { - // If so, our gun should be pointing at our target so we can hit it => fire!! - SetFire(FIREPOWER); - } - } - } - - /// - /// Method that checks if a coordinate (x,y) is outside the Border Sentry's attack range. - /// - /// X coordinate. - /// Y coordinate. - /// true if the coordinate is outside the attack range; false otherwise. - private bool IsOutsideAttackRange(double x, double y) - { - double minBorderX = SentryBorderSize; - double minBorderY = SentryBorderSize; - double maxBorderX = BattleFieldWidth - SentryBorderSize; - double maxBorderY = BattleFieldHeight - SentryBorderSize; - - return (x > minBorderX) && (y > minBorderY) && (x < maxBorderX) && (y < maxBorderY); - } - - /// - /// Method that returns a value that is guaranteed to be within a value range defined by a - /// minimum and maximum value based on an input value.
- /// If the input value is lesser than the minimum value, the returned value will be set to the - /// minimum value.
- /// If the input value is greater than the maximum value, the returned value will be set to the - /// maximum value.
- /// Otherwise the returned value will be equal to the input value. - ///
- /// Input value to limit. - /// Allowed minimum value. - /// Allowed maximum value. - /// - /// The limited input value that is guaranteed to be within the specified minimum and maximum range. - /// - private double Limit(double value, double min, double max) - { - return Math.Min(max, Math.Max(min, value)); - } - - /// - /// Methods that returns the distance to a coordinate (x,y) from our robot. - /// - /// X coordinate. - /// Y coordinate. - /// - /// The distance to the coordinate (x,y). - /// - private double DistanceTo(double x, double y) - { - double dx = X - x; - double dy = Y - y; - return Math.Sqrt(dx * dx + dy * dy); - } - - /// - /// Method that returns the angle to a coordinate (x,y) from our robot. - /// - /// X coordinate. - /// Y coordinate. - /// - /// The angle to the coordinate (x,y). - /// - private double AngleTo(double x, double y) - { - return Math.Atan2(x - X, y - Y); - } - - /// - /// Method that returns the bearing to a coordinate (x,y) from the position and heading of our - /// robot. The bearing is the delta angle between the heading of our robot and the angle of the - /// specified coordinate. - /// - /// X coordinate. - /// Y coordinate. - /// - /// The angle to the coordinate (x,y). - /// - private double BearingTo(double heading, double x, double y) - { - return Utils.NormalRelativeAngle(AngleTo(x, y) - heading); - } - - /// - /// Method that paints a filled circle at the specified coordinate (x,y) and given color. The - /// circle will have a radius of 20 pixels (meaning that the diameter will be 40 pixels). - /// - /// X coordinate. - /// X coordinate for the center of the circle. - /// Y coordinate for the center of the circle. - /// Color of the filled circle. - private void FillCircle(IGraphics gfx, double x, double y, Color color) - { - // Prepare brush - Brush brush = new SolidBrush(color); - // Paint a filled circle (oval) that has a radius of 20 pixels with a center at the input - // coordinates. - gfx.FillEllipse(brush, (float)x - 20, (float)y - 20, 40f, 40f); - } - - /// - /// This class is used for storing data about a robot that has been scanned.
- /// The data is mainly a snapshot of specific scanned data like the scanned position (x,y), - /// velocity and heading, put also the calculated predicted target position of the robot when our - /// robot needs to fire at the scanned robot.
- /// Note that this class calculates the position (x,y) of the scanned robot as our robot moves, - /// and hence data like the angle and distance to the scanned robot will change over time. by - /// using the position, it is easy to calculate a new angle and distance to the robot. - ///
- internal class RobotData - { - internal string name; // name of the scanned robot - internal double scannedX; // x coordinate of the scanned robot based on the last update - internal double scannedY; // y coordinate of the scanned robot based on the last update - internal double scannedVelocity; // velocity of the scanned robot from the last update - internal double scannedHeading; // heading of the scanned robot from the last update - internal double targetX; // predicated x coordinate to aim our gun at, when firing at the robot - internal double targetY; // predicated y coordinate to aim our gun at, when firing at the robot - - /// - /// Creates a new robot data entry based on new scan data for a scanned robot. - /// - /// - /// A ScannedRobotEvent event containing data about a scanned robot. - /// - /// Robot that creates this data entry. - public RobotData(ScannedRobotEvent scannedRobotEvent, AdvancedRobot robot) - { - // Store the name of the scanned robot - name = scannedRobotEvent.Name; - // Updates all scanned facts like position, velocity, and heading - Update(scannedRobotEvent, robot); - // Initialize the coordinates (x,y) to fire at to the updated scanned position - targetX = scannedX; - targetY = scannedY; - } - - /// - /// Updates the scanned data based on new scan data for a scanned robot. - /// - /// - /// A ScannedRobotEvent event containing data about a scanned robot. - /// - /// Robot that calls this method. - public void Update(ScannedRobotEvent scannedRobotEvent, AdvancedRobot robot) - { - // Get the position of the scanned robot based on the ScannedRobotEvent - PointF pos = GetPosition(scannedRobotEvent, robot); - // Store the scanned position (x,y) - scannedX = pos.X; - scannedY = pos.Y; - // Store the scanned velocity and heading - scannedVelocity = scannedRobotEvent.Velocity; - scannedHeading = scannedRobotEvent.HeadingRadians; - } - - /// - /// Returns the position of the scanned robot based on new scan data for a scanned robot. - /// - /// - /// A ScannedRobotEvent event containing data about a scanned robot. - /// - /// Robot that calls this method. - /// The position (x,y) of the scanned robot. - private PointF GetPosition(ScannedRobotEvent scannedRobotEvent, AdvancedRobot robot) - { - // Gets the distance to the scanned robot - double distance = scannedRobotEvent.Distance; - // Calculate the angle to the scanned robot (our robot heading + bearing to scanned robot) - double angle = robot.HeadingRadians + scannedRobotEvent.BearingRadians; - - // Calculate the coordinates (x,y) of the scanned robot - double x = robot.X + Math.Sin(angle) * distance; - double y = robot.Y + Math.Cos(angle) * distance; - - // Return the position as a point (x,y) - return new PointF((float)x, (float)y); - } - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsTeam/MyCsTeam.team b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsTeam/MyCsTeam.team deleted file mode 100644 index 057b59d..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsTeam/MyCsTeam.team +++ /dev/null @@ -1,7 +0,0 @@ -#Robocode robot team -#Sun Aug 20 23:26:53 EST 2006 -team.members=SampleCsTeam.MyFirstLeader,SampleCsTeam.MyFirstDroid,SampleCsTeam.MyFirstDroid,SampleCsTeam.MyFirstDroid,SampleCsTeam.MyFirstDroid -team.author.name=Pavel Savara -robocode.version=1.7.3 -team.webpage= -team.description=\ A sample team.\n MyFirstLeader scans for enemies,\n and orders the 4 droids to fire. diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsTeam/MyFirstDroid.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsTeam/MyFirstDroid.cs deleted file mode 100644 index d92b945..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsTeam/MyFirstDroid.cs +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using Robocode; -using Robocode.Util; -using SampleCs; - -namespace SampleCsTeam -{ - /// - /// SimpleDroid - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - ///

- /// Follows orders of team leader - ///

- public class MyFirstDroid : TeamRobot, IDroid - { - /// - /// Droid's default behavior - /// - public override void Run() - { - Out.WriteLine("MyFirstDroid ready."); - } - - /// - /// OnMessageReceived: What to do when our leader sends a message - /// - public override void OnMessageReceived(MessageEvent e) - { - // Fire at a point - if (e.Message is PointD) - { - var p = (PointD)e.Message; - // Calculate x and y to target - double dx = p.X - X; - double dy = p.Y - Y; - // Calculate angle to target - double theta = Utils.ToDegrees(Math.Atan2(dx, dy)); - - // Turn gun to target - TurnGunRight(Utils.NormalRelativeAngleDegrees(theta - GunHeading)); - // Fire hard! - Fire(3); - } - else if (e.Message is RobotColors) - { - // Set our colors - var c = (RobotColors) e.Message; - - BodyColor = c.bodyColor; - GunColor = c.gunColor; - RadarColor = c.radarColor; - ScanColor = c.scanColor; - BulletColor = c.bulletColor; - } - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsTeam/MyFirstLeader.cs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsTeam/MyFirstLeader.cs deleted file mode 100644 index ccbf3f9..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleCsTeam/MyFirstLeader.cs +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -using System; -using System.Drawing; -using Robocode; -using Robocode.Util; -using SampleCs; - -namespace SampleCsTeam -{ - /// - /// MyFirstLeader - a sample team robot by Mathew Nelson, and maintained by Flemming N. Larsen - ///

- /// Looks around for enemies, and orders teammates to Fire - ///

- public class MyFirstLeader : TeamRobot - { - /// - /// Run: Leader's default behavior - /// - public override void Run() - { - // Prepare RobotColors object - var c = new RobotColors(); - - c.bodyColor = Color.Red; - c.gunColor = Color.Red; - c.radarColor = Color.Red; - c.scanColor = Color.Yellow; - c.bulletColor = Color.Yellow; - - // Set the color of this robot containing the RobotColors - BodyColor = c.bodyColor; - GunColor = c.gunColor; - RadarColor = c.radarColor; - ScanColor = c.scanColor; - BulletColor = c.bulletColor; - try - { - // Send RobotColors object to our entire team - BroadcastMessage(c); - } - catch (Exception) - { - } - - // Normal behavior - while (true) - { - SetTurnRadarRight(10000); - Ahead(100); - Back(100); - } - } - - - /// - /// OnScannedRobot: What to do when you see another robot - /// - public override void OnScannedRobot(ScannedRobotEvent e) - { - // Don't Fire on teammates - if (IsTeammate(e.Name)) - { - return; - } - // Calculate enemy bearing - double enemyBearing = Heading + e.Bearing; - // Calculate enemy's position - double enemyX = X + e.Distance*Math.Sin(Utils.ToRadians(enemyBearing)); - double enemyY = Y + e.Distance*Math.Cos(Utils.ToRadians(enemyBearing)); - - try - { - // Send enemy position to teammates - BroadcastMessage(new PointD(enemyX, enemyY)); - } - catch (Exception ex) - { - Out.WriteLine("Unable to send order: "); - Out.WriteLine(ex); - } - } - - /// - /// OnHitByBullet: Turn perpendicular to bullet path - /// - public override void OnHitByBullet(HitByBulletEvent e) - { - TurnLeft(90 - e.Bearing); - } - } -} \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleFs/MyFirstRobot.fs b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleFs/MyFirstRobot.fs deleted file mode 100644 index 1ce76a9..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleFs/MyFirstRobot.fs +++ /dev/null @@ -1,23 +0,0 @@ -// Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -// All rights reserved. This program and the accompanying materials -// are made available under the terms of the Eclipse Public License v1.0 -// which accompanies this distribution, and is available at -// http://robocode.sourceforge.net/license/epl-v10.html - -namespace SampleFs - -open Robocode - -type MyFirstRobot() = - inherit Robot() - - override robot.Run() = - while true do - robot.TurnLeft(40.0) - robot.Ahead(20.0) - - override robot.OnScannedRobot(evnt : ScannedRobotEvent) = - robot.Fire(1.0) - - override robot.OnHitByBullet(evnt : HitByBulletEvent) = - robot.TurnLeft(90.0 - evnt.Bearing) diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleFs/robocode.dotnet.samplesfs.fsproj b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleFs/robocode.dotnet.samplesfs.fsproj deleted file mode 100644 index 2259662..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/SampleFs/robocode.dotnet.samplesfs.fsproj +++ /dev/null @@ -1,57 +0,0 @@ - - - - Debug - AnyCPU - 8.0.30703 - 2.0 - {f9be3471-d2fd-4d58-9991-7ad8ae7bd015} - Library - func - SampleFs - v3.5 - robocode.dotnet.samplesfs - - - true - full - false - false - bin\Debug\ - DEBUG;TRACE - 3 - bin\Debug\func.XML - - - pdbonly - true - true - bin\Release\ - TRACE - 3 - bin\Release\func.XML - - - - - - - - C:\robocode\libs\robocode.dll - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.csproj b/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.csproj deleted file mode 100644 index a2f4302..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.samples/src/robocode.dotnet.samples.csproj +++ /dev/null @@ -1,93 +0,0 @@ - - - - Debug - AnyCPU - 9.0.30729 - 2.0 - {80857B97-6397-487B-A9F5-B07026DCBB66} - Library - samplecs - samplescs-1.9.2.4 - v3.5 - 512 - - - 3.5 - - - - true - full - false - ..\target\ - ..\target\obj\ - DEBUG;TRACE - prompt - 4 - false - false - - - pdbonly - true - ..\target\ - ..\target\obj\ - - - prompt - 4 - true - - - - - - - - - - - - - - {7E0900D3-6E8F-48EB-86DB-AA767AA90B84} - robocode.dotnet.api - - - - - - - - - - - - - - - - - - - - - - - - - - - PreserveNewest - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.sln b/workspace_robo/plugins/dotnet/robocode.dotnet.sln deleted file mode 100644 index e47c09c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.sln +++ /dev/null @@ -1,50 +0,0 @@ - -Microsoft Visual Studio Solution File, Format Version 11.00 -# Visual C# Express 2010 -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "robocode.dotnet.nhost", "robocode.dotnet.nhost\src\robocode.dotnet.nhost.csproj", "{674AED55-B9EC-4C7D-8E0B-1B2481C578B2}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "robocode.dotnet.samples", "robocode.dotnet.samples\src\robocode.dotnet.samples.csproj", "{80857B97-6397-487B-A9F5-B07026DCBB66}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "robocode.dotnet.api", "robocode.dotnet.api\src\robocode.dotnet.api.csproj", "{7E0900D3-6E8F-48EB-86DB-AA767AA90B84}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "robocode.dotnet.ntests", "robocode.dotnet.ntests\src\robocode.dotnet.ntests.csproj", "{B3487E2D-2737-4C04-AA71-B9A726B3F781}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "robocode.dotnet.robotscs", "robocode.dotnet.robotscs\src\robocode.dotnet.robotscs.csproj", "{B3487E2D-2737-4C04-AA71-B9A726B3F787}" -EndProject -Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "robocode.dotnet.control.api", "robocode.dotnet.control.api\src\robocode.dotnet.control.api.csproj", "{674AED55-B9EC-4C7D-8E0B-1B2471C578B2}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Any CPU = Debug|Any CPU - Release|Any CPU = Release|Any CPU - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {674AED55-B9EC-4C7D-8E0B-1B2481C578B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {674AED55-B9EC-4C7D-8E0B-1B2481C578B2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {674AED55-B9EC-4C7D-8E0B-1B2481C578B2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {674AED55-B9EC-4C7D-8E0B-1B2481C578B2}.Release|Any CPU.Build.0 = Release|Any CPU - {80857B97-6397-487B-A9F5-B07026DCBB66}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {80857B97-6397-487B-A9F5-B07026DCBB66}.Debug|Any CPU.Build.0 = Debug|Any CPU - {80857B97-6397-487B-A9F5-B07026DCBB66}.Release|Any CPU.ActiveCfg = Release|Any CPU - {80857B97-6397-487B-A9F5-B07026DCBB66}.Release|Any CPU.Build.0 = Release|Any CPU - {7E0900D3-6E8F-48EB-86DB-AA767AA90B84}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {7E0900D3-6E8F-48EB-86DB-AA767AA90B84}.Debug|Any CPU.Build.0 = Debug|Any CPU - {7E0900D3-6E8F-48EB-86DB-AA767AA90B84}.Release|Any CPU.ActiveCfg = Release|Any CPU - {7E0900D3-6E8F-48EB-86DB-AA767AA90B84}.Release|Any CPU.Build.0 = Release|Any CPU - {B3487E2D-2737-4C04-AA71-B9A726B3F781}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B3487E2D-2737-4C04-AA71-B9A726B3F781}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B3487E2D-2737-4C04-AA71-B9A726B3F781}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B3487E2D-2737-4C04-AA71-B9A726B3F781}.Release|Any CPU.Build.0 = Release|Any CPU - {B3487E2D-2737-4C04-AA71-B9A726B3F787}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {B3487E2D-2737-4C04-AA71-B9A726B3F787}.Debug|Any CPU.Build.0 = Debug|Any CPU - {B3487E2D-2737-4C04-AA71-B9A726B3F787}.Release|Any CPU.ActiveCfg = Release|Any CPU - {B3487E2D-2737-4C04-AA71-B9A726B3F787}.Release|Any CPU.Build.0 = Release|Any CPU - {674AED55-B9EC-4C7D-8E0B-1B2471C578B2}.Debug|Any CPU.ActiveCfg = Debug|Any CPU - {674AED55-B9EC-4C7D-8E0B-1B2471C578B2}.Debug|Any CPU.Build.0 = Debug|Any CPU - {674AED55-B9EC-4C7D-8E0B-1B2471C578B2}.Release|Any CPU.ActiveCfg = Release|Any CPU - {674AED55-B9EC-4C7D-8E0B-1B2471C578B2}.Release|Any CPU.Build.0 = Release|Any CPU - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/.classpath b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/.classpath deleted file mode 100644 index 211ea34..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/.classpath +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/.project b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/.project deleted file mode 100644 index ab0fc6b..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/.project +++ /dev/null @@ -1,21 +0,0 @@ - - - robocode.dotnet.tests - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.dotnet.host - robocode.dotnet.nhost - robocode.dotnet.api - robocode.dotnet.control.api - robocode.dotnet.samples - robocode.dotnet.robotscs - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 764c3ab..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:34:11 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/test/java=8859_1 -encoding/src/main/resources=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/config/robocode.properties b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/config/robocode.properties deleted file mode 100644 index cfebed7..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/config/robocode.properties +++ /dev/null @@ -1,34 +0,0 @@ -#Robocode Properties -#Mon Aug 17 23:43:36 CEST 2009 -robocode.cpu.constant=9994115 -robocode.options.battle.desiredTPS=30 -robocode.options.common.appendWhenSavingResults=true -robocode.options.common.dontHideRankings=true -robocode.options.common.enableReplayRecording=false -robocode.options.common.showResults=true -robocode.options.development.path=..\\robocode.dotnet.samples\\target; -robocode.options.rendering.antialiasing=0 -robocode.options.rendering.bufferImages=true -robocode.options.rendering.forceBulletColor=false -robocode.options.rendering.method=0 -robocode.options.rendering.noBuffers=2 -robocode.options.rendering.text.antialiasing=0 -robocode.options.sound.enableBulletHit=true -robocode.options.sound.enableGunshot=true -robocode.options.sound.enableMixerPan=true -robocode.options.sound.enableMixerVolume=true -robocode.options.sound.enableRobotCollision=true -robocode.options.sound.enableRobotDeath=true -robocode.options.sound.enableSound=false -robocode.options.sound.enableWallCollision=true -robocode.options.sound.mixer=DirectAudioDevice -robocode.options.view.FPS=true -robocode.options.view.TPS=true -robocode.options.view.explosionDebris=true -robocode.options.view.explosions=true -robocode.options.view.ground=true -robocode.options.view.robotEnergy=true -robocode.options.view.robotNames=true -robocode.options.view.scanArcs=false -robocode.version.lastrun=\ 1.7.1.3 -robocode.versionchecked=08/17/2009 23\:11\:46 diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/pom.xml b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/pom.xml deleted file mode 100644 index 80c3e85..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/pom.xml +++ /dev/null @@ -1,71 +0,0 @@ - - - 4.0.0 - robocode.dotnet.tests - Robocode .NET Tests - - robocode.dotnet - net.sf.robocode - ${robocode.dotnet.version} - - - - net.sf.robocode - robocode.core - ${robocode.version} - - - net.sf.robocode - robocode.host - ${robocode.version} - - - net.sf.robocode - robocode.battle - ${robocode.version} - - - net.sf.robocode - robocode.repository - ${robocode.version} - - - net.sf.robocode - robocode.samples - ${robocode.version} - - - net.sf.robocode - robocode.tests - ${robocode.version} - - - net.sf.robocode - robocode.tests.robots - ${robocode.version} - - - net.sf.robocode - robocode.dotnet.host - ${robocode.version} - - - net.sf.robocode - robocode.dotnet.samples - ${project.version} - dotnet:library - - - net.sf.robocode - robocode.dotnet.robotscs - ${project.version} - dotnet:library - - - junit - junit - 4.11 - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/robocode.dotnet.tests.iml b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/robocode.dotnet.tests.iml deleted file mode 100644 index cf654ee..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/robocode.dotnet.tests.iml +++ /dev/null @@ -1,200 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestCustomEvents.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestCustomEvents.java deleted file mode 100644 index 828188c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestCustomEvents.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import org.junit.Test; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import net.sf.robocode.test.helpers.Assert; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestCustomEvents extends RobocodeTestBed { - - @Test - public void run() { - super.run(); - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - IRobotSnapshot gh = event.getTurnSnapshot().getRobots()[1]; - - switch (event.getTurnSnapshot().getTurn()) { - case 130: - test(gh, "130 onTick99\r\n130 onTick30"); - break; - - case 1451: - test(gh, "1451 onTick99\r\n1451 onLowEnergy98\r\n1451 onTick30\r\n1451 onScannedRobot10"); - - break; - - default: - break; - } - } - - private void test(IRobotSnapshot gh, String s) { - Assert.assertTrue("got: " + gh.getOutputStreamSnapshot() + ", expected: " + s, - gh.getOutputStreamSnapshot().contains(s)); - } - - @Override - public String getRobotNames() { - return "SampleCs.Target,tested.robotscs.CustomEvents"; - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestDuplicatesAndScore.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestDuplicatesAndScore.java deleted file mode 100644 index 2713b51..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestDuplicatesAndScore.java +++ /dev/null @@ -1,172 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import static org.hamcrest.CoreMatchers.is; -import org.junit.Assert; -import org.junit.Test; -import org.junit.Ignore; -import robocode.BattleResults; -import robocode.control.events.BattleCompletedEvent; -import robocode.control.events.BattleFinishedEvent; -import robocode.control.events.RoundStartedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -@Ignore(".NET is little bit slow, so it gives skipped turns for battles with many robots sometimes") -public class TestDuplicatesAndScore extends RobocodeTestBed { - private IRobotSnapshot[] robots; - private BattleResults[] results; - - @Test - public void run() { - super.run(); - } - - @Override - public int getExpectedRobotCount(String list) { - return 8; - } - - @Override - public String getRobotNames() { - return "SampleCs.Fire,tested.robotscs.TestTeam,tested.robotscs.TestTeam,SampleCs.Crazy"; - } - - @Override - public void onRoundStarted(final RoundStartedEvent event) { - super.onRoundStarted(event); - if (event.getRound() == 0) { - robots = event.getStartSnapshot().getRobots(); - Assert.assertEquals(8, robots.length); - - net.sf.robocode.test.helpers.Assert.assertNear(566.2968069, robots[0].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(436.3146436, robots[1].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(317.3362130, robots[2].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(717.6994092, robots[3].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(145.5531935, robots[4].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(734.4305396, robots[5].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(335.7732607, robots[6].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(390.8076498, robots[7].getX()); - - net.sf.robocode.test.helpers.Assert.assertNear(100.000, robots[0].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(200.000, robots[1].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(120.000, robots[2].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(100.000, robots[3].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(200.000, robots[4].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(120.000, robots[5].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(100.000, robots[6].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(100.000, robots[7].getEnergy()); - } - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - int lastTurn = event.getTurnSnapshot().getTurn(); - - robots = event.getTurnSnapshot().getRobots(); - - if (lastTurn == 1) { - net.sf.robocode.test.helpers.Assert.assertNear(566.2968069, robots[0].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(437.1810299, robots[1].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(317.3362130, robots[2].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(717.6994092, robots[3].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(145.2637220, robots[4].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(734.4305396, robots[5].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(335.7732607, robots[6].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(389.8100070, robots[7].getX()); - } - - if (lastTurn == 1365) { - net.sf.robocode.test.helpers.Assert.assertNear(563.1336824, robots[0].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(572.9500601, robots[1].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(317.3362130, robots[2].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(578.2231942, robots[3].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(120.3355009, robots[4].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(734.4305396, robots[5].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(244.9583274, robots[6].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(333.1785378, robots[7].getX()); - } - - Assert.assertFalse("skipped", robots[0].getOutputStreamSnapshot().contains("skipped")); - Assert.assertFalse("skipped", robots[1].getOutputStreamSnapshot().contains("skipped")); - Assert.assertFalse("skipped", robots[2].getOutputStreamSnapshot().contains("skipped")); - Assert.assertFalse("skipped", robots[3].getOutputStreamSnapshot().contains("skipped")); - Assert.assertFalse("skipped", robots[4].getOutputStreamSnapshot().contains("skipped")); - Assert.assertFalse("skipped", robots[5].getOutputStreamSnapshot().contains("skipped")); - Assert.assertFalse("skipped", robots[6].getOutputStreamSnapshot().contains("skipped")); - Assert.assertFalse("skipped", robots[7].getOutputStreamSnapshot().contains("skipped")); - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - if (event.isAborted()) { - results = null; - } - } - - @Override - public void onBattleCompleted(BattleCompletedEvent event) { - results = event.getSortedResults(); - } - - @Override - protected void runTeardown() { - Assert.assertNotNull(results); - Assert.assertNotNull(robots); - Assert.assertThat(robots[0].getName(), is("SampleCs.Fire (1)")); - Assert.assertThat(robots[1].getName(), is("SampleCsTeam.MyFirstLeader (1)")); - Assert.assertThat(robots[2].getName(), is("SampleCsTeam.MyFirstDroid (1)")); - Assert.assertThat(robots[3].getName(), is("SampleCs.Fire (2)")); - Assert.assertThat(robots[4].getName(), is("SampleCsTeam.MyFirstLeader (2)")); - Assert.assertThat(robots[5].getName(), is("SampleCsTeam.MyFirstDroid (2)")); - Assert.assertThat(robots[6].getName(), is("SampleCs.Fire (3)")); - Assert.assertThat(robots[7].getName(), is("SampleCs.Crazy")); - - // the results are different from Java version because of strictfp in Java Math - // as oposed to FPU driven .NET, which gives better precision. - // difference acumulates to make big difference in results - Assert.assertThat(results[0].getTeamLeaderName(), is("tested.robotscs.TestTeam (2)")); - Assert.assertThat(results[1].getTeamLeaderName(), is("tested.robotscs.TestTeam (1)")); - Assert.assertThat(results[2].getTeamLeaderName(), is("SampleCs.Crazy")); - Assert.assertThat(results[3].getTeamLeaderName(), is("SampleCs.Fire (1)")); - - Assert.assertThat(results[0].getLastSurvivorBonus(), is(0)); - Assert.assertThat(results[1].getLastSurvivorBonus(), is(50)); - Assert.assertThat(results[2].getLastSurvivorBonus(), is(0)); - Assert.assertThat(results[3].getLastSurvivorBonus(), is(0)); - - Assert.assertThat(results[0].getRamDamage(), is(0)); - Assert.assertThat(results[1].getRamDamage(), is(5)); - Assert.assertThat(results[2].getRamDamage(), is(14)); - Assert.assertThat(results[3].getRamDamage(), is(1)); - - Assert.assertThat(results[0].getBulletDamageBonus(), is(55)); - Assert.assertThat(results[1].getBulletDamageBonus(), is(0)); - Assert.assertThat(results[2].getBulletDamageBonus(), is(0)); - Assert.assertThat(results[3].getBulletDamageBonus(), is(0)); - - Assert.assertThat(results[0].getBulletDamage(), is(480)); - Assert.assertThat(results[1].getBulletDamage(), is(124)); - Assert.assertThat(results[2].getBulletDamage(), is(148)); - Assert.assertThat(results[3].getBulletDamage(), is(152)); - - Assert.assertThat(results[0].getScore(), is(1135)); - Assert.assertThat(results[1].getScore(), is(434)); - Assert.assertThat(results[2].getScore(), is(312)); - Assert.assertThat(results[3].getScore(), is(253)); - - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestEnvAttack.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestEnvAttack.java deleted file mode 100644 index f479d00..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestEnvAttack.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Pavel Savara (original) - */ -public class TestEnvAttack extends RobocodeTestBed { - boolean messagedAttack; - - @Test - public void run() { - super.run(); - } - - @Override - public String getRobotNames() { - return "tested.robotscs.BattleLost,tested.robotscs.EnvAttack"; - } - - @Override - protected int getExpectedErrors() { - return 1; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("System.Security.Permissions.EnvironmentPermission")) { - messagedAttack = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedAttack); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestEventPriorityFilter.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestEventPriorityFilter.java deleted file mode 100644 index 578eb12..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestEventPriorityFilter.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Pavel Savara (original) - */ -public class TestEventPriorityFilter extends RobocodeTestBed { - boolean messagedScanned; - - @Test - public void run() { - super.run(); - } - - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("Scanned!!!")) { - messagedScanned = true; - } - } - - @Override - public String getRobotNames() { - return "tested.robotscs.EventPriorityFilter,tested.robotscs.EventPriorityFilter"; - } - - @Override - protected void runTeardown() { - Assert.assertFalse(messagedScanned); - } -} - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFileAttack.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFileAttack.java deleted file mode 100644 index 5f45c26..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFileAttack.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; - -import java.io.File; - - -/** - * @author Pavel Savara (original) - */ -public class TestFileAttack extends RobocodeTestBed { - boolean messaged; - - @Test - public void run() { - super.run(); - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("System.Security.SecurityException")) { - messaged = true; - } - } - - @Override - public String getRobotNames() { - return "SampleCs.Fire,tested.robotscs.FileAttack"; - } - - @Override - protected void runSetup() { - File attack = new File("C:\\Robocode.attack"); - - if (attack.exists()) { - Assert.assertTrue(attack.delete()); - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("Didn't seen preventing read", messaged); - Assert.assertFalse("Found attack file", new File("C:\\Robocode.attack").exists()); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFileWrite.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFileWrite.java deleted file mode 100644 index 27293d6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFileWrite.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import org.junit.Test; - -import java.io.File; - - -/** - * @author Pavel Savara (original) - */ -public class TestFileWrite extends RobocodeTestBed { - - @Test - public void run() { - super.run(); - } - File file; - - public String getRobotNames() { - return "SampleCs.Walls,SampleCs.SittingDuck"; - } - - @Override - protected void runSetup() { - file = new File("../../../robocode.tests.robots/target/classes/.data/SampleCs/count.dat"); - if (file.exists()) { - if (!file.delete()) { - Logger.logError("Can't delete" + file); - } - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue(file.exists()); - if (!file.delete()) { - Logger.logError("Can't delete" + file); - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFileWriteSize.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFileWriteSize.java deleted file mode 100644 index a47500f..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFileWriteSize.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; - -import java.io.File; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestFileWriteSize extends RobocodeTestBed { - - boolean messagedDataQuota; - boolean messagedDataDirectory; - boolean messageQuotaReached; - boolean robotTerminated; - - @Test - public void run() { - super.run(); - } - - @Override - public String getRobotNames() { - return "tested.robotscs.FileWriteSize,SampleCs.Target"; - } - - File file; - @Override - protected void runSetup() { - file = new File(robotsPath + "\\target\\classes\\.data\\tested\\robotscs\\test.txt"); - if (file.exists()) { - if (!file.delete()) { - Logger.logError("Can't delete" + file); - } - } - } - - @Override - protected int getExpectedErrors() { - return 1; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("Data quota: 200000\r\n")) { - messagedDataQuota = true; - } - - if (out.contains("Data directory: " + robotsPath + "\\target\\classes\\.data\\tested\\robotscs")) { - messagedDataDirectory = true; - } - - if (out.contains("You have reached your filesystem quota: 200000 bytes per robot")) { - messageQuotaReached = true; - } - - if (event.getTurnSnapshot().getRobots()[0].getEnergy() == 0) { - robotTerminated = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("Data quota must be 200000", messagedDataQuota); - Assert.assertTrue("Data directory path is wrong", messagedDataDirectory); - Assert.assertTrue("Error must be output that file quota has been exceeded", messageQuotaReached); - Assert.assertTrue("Game must terminate the robot", robotTerminated); - Assert.assertTrue(file.exists()); - if (!file.delete()) { - Logger.logError("Can't delete" + file); - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFormsAttack.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFormsAttack.java deleted file mode 100644 index 58cb00c..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestFormsAttack.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Pavel Savara (original) - */ -public class TestFormsAttack extends RobocodeTestBed { - // in case: boolean messagedAttack; - boolean messagedViolation; - - @Test - public void run() { - super.run(); - } - - @Override - public String getRobotNames() { - return "tested.robotscs.BattleLost,tested.robotscs.FormsAttack"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("System.Security.Permissions.UIPermission")) { - messagedViolation = true; - } - } - - @Override - protected int getExpectedErrors() { - return 2; - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedViolation); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestHttpAttack.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestHttpAttack.java deleted file mode 100644 index 5b4e7f8..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestHttpAttack.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestHttpAttack extends RobocodeTestBed { - - private boolean messagedAccessDenied; - - @Override - public String getRobotNames() { - return "tested.robotscs.HttpAttack,SampleCs.Target"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("System.Net.WebPermission")) { - messagedAccessDenied = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("HTTP connection is not allowed", messagedAccessDenied); - } - - @Override - protected int getExpectedErrors() { - return 1; // Security error must be reported as an error - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestInteruptibleEvent.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestInteruptibleEvent.java deleted file mode 100644 index 6527e63..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestInteruptibleEvent.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; - - -/** - * Test if onScannedRobot() is called when the radar is turned from within a onHitWall() event. - * - * @author Flemming N. Larsen (original) - */ -public class TestInteruptibleEvent extends RobocodeTestBed { - boolean messagedScanned; - - @Test - public void run() { - super.run(); - } - - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("Scanned!!!")) { - messagedScanned = true; - } - } - - @Override - public String getRobotNames() { - return "tested.robotscs.InteruptibleEvent,tested.robotscs.InteruptibleEvent"; - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedScanned); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestJunior.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestJunior.java deleted file mode 100644 index ff12857..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestJunior.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import org.junit.Assert; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestJunior extends RobocodeTestBed { - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "tested.robotscs.JuniorEvents,SampleCs.SittingDuck"; - } - - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[0]; - - if (event.getTurnSnapshot().getTurn() == 590) { - String out = robot.getOutputStreamSnapshot(); - - test(out, "Robocode.BulletMissedEvent 5"); - test(out, "Robocode.ScannedRobotEvent 100"); - test(out, "Robocode.BulletHitEvent 24"); - test(out, "Robocode.StatusEvent 590"); - test(out, "Robocode.WinEvent 1"); - test(out, "last bullet heading 6.06794"); - } - } - - private void test(String out, String in) { - Assert.assertTrue(in, out.contains(in)); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestLost.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestLost.java deleted file mode 100644 index 557425a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestLost.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import static org.hamcrest.CoreMatchers.is; -import org.junit.Assert; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestLost extends RobocodeTestBed { - private int lost = 0; - private int end = 0; - - @Test - public void run() { - super.run(); - } - - @Override - public int getNumRounds() { - return 5; - } - - @Override - public String getRobotNames() { - return "SampleCs.Fire,tested.robotscs.BattleLost"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1]; - final String streamSnapshot = robot.getOutputStreamSnapshot(); - - if (streamSnapshot.contains("Death!")) { - lost++; - } - if (streamSnapshot.contains("BattleEnded!")) { - end++; - } - } - - @Override - protected void runTeardown() { - Assert.assertThat("always should loose", lost, is(getNumRounds())); - Assert.assertThat("should get BattleEnded event", end, is(1)); - } - -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestMaxTurnRate.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestMaxTurnRate.java deleted file mode 100644 index 551fac3..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestMaxTurnRate.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestMaxTurnRate extends RobocodeTestBed { - - StringBuffer buf = new StringBuffer(); - - @Override - public String getRobotNames() { - return "tested.robotscs.MaxTurnRate,SampleCs.Target"; - } - - @Override - public String getInitialPositions() { - return "(50,50,0), (150,50,0)"; // Make sure the robots do not collide! - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - buf.append(event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot()); - - if (event.getTurnSnapshot().getTurn() == 26) { - final String out = buf.toString(); - - Assert.assertTrue(out.contains("1: 0.0, 0.0") | out.contains("1: 0.0, -0.0")); - Assert.assertTrue(out.contains("2: 0.0, -1.0") | out.contains("2: 0.0, -0.999999999")); - Assert.assertTrue(out.contains("3: 0.0, -2.0") | out.contains("3: 0.0, -1.999999999")); - Assert.assertTrue(out.contains("4: 0.0, -3.0") | out.contains("4: 0.0, -2.999999999")); - Assert.assertTrue(out.contains("5: 0.0, -4.0") | out.contains("5: 0.0, -3.999999999")); - Assert.assertTrue(out.contains("6: 0.0, -5.0") | out.contains("6: 0.0, -4.999999999")); - Assert.assertTrue(out.contains("7: 0.0, -6.0") | out.contains("7: 0.0, -5.999999999")); - Assert.assertTrue(out.contains("8: 0.0, -7.0") | out.contains("8: 0.0, -6.999999999")); - Assert.assertTrue(out.contains("9: 0.0, -8.0") | out.contains("9: 0.0, -7.999999999")); - Assert.assertTrue(out.contains("10: 0.0, -9.0") | out.contains("10: 0.0, -8.999999999")); - Assert.assertTrue(out.contains("11: 0.0, -10.0") | out.contains("11: 0.0, -9.999999999")); - Assert.assertTrue(out.contains("12: 0.0, -10.0") | out.contains("12: 0.0, -9.999999999")); - Assert.assertTrue(out.contains("13: 0.0, -10.0") | out.contains("13: 0.0, -9.999999999")); - - Assert.assertTrue(out.contains("14: 0.0, 0.0") | out.contains("14: 0.0, -0.0")); - Assert.assertTrue(out.contains("15: 0.0, 1.0") | out.contains("15: 0.0, 0.999999999")); - Assert.assertTrue(out.contains("16: 0.0, 2.0") | out.contains("16: 0.0, 1.999999999")); - Assert.assertTrue(out.contains("17: 0.0, 3.0") | out.contains("17: 0.0, 2.999999999")); - Assert.assertTrue(out.contains("18: 0.0, 4.0") | out.contains("18: 0.0, 3.999999999")); - Assert.assertTrue(out.contains("19: 0.0, 5.0") | out.contains("19: 0.0, 4.999999999")); - Assert.assertTrue(out.contains("20: 0.0, 6.0") | out.contains("20: 0.0, 5.999999999")); - Assert.assertTrue(out.contains("21: 0.0, 7.0") | out.contains("21: 0.0, 6.999999999")); - Assert.assertTrue(out.contains("22: 0.0, 8.0") | out.contains("22: 0.0, 7.999999999")); - Assert.assertTrue(out.contains("23: 0.0, 9.0") | out.contains("23: 0.0, 8.999999999")); - Assert.assertTrue(out.contains("24: 0.0, 10.0") | out.contains("24: 0.0, 9.999999999")); - Assert.assertTrue(out.contains("25: 0.0, 10.0") | out.contains("25: 0.0, 9.999999999")); - Assert.assertTrue(out.contains("26: 0.0, 10.0") | out.contains("26: 0.0, 9.999999999")); - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestMaxVelocity.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestMaxVelocity.java deleted file mode 100644 index c888f57..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestMaxVelocity.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import robocode.control.events.TurnEndedEvent; -import robocode.util.Utils; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestMaxVelocity extends RobocodeTestBed { - - @Override - public String getRobotNames() { - return "tested.robotscs.MaxVelocity,SampleCs.Target"; - } - - @Override - public String getInitialPositions() { - return "(50,50,0), (600,50,0)"; // Make sure the robots do not collide! - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final int time = (int) event.getTurnSnapshot().getTurn(); - final double velocity = event.getTurnSnapshot().getRobots()[0].getVelocity(); - - switch (time) { - case 10: - case 20: - case 100: - Assert.assertTrue(Utils.isNear(velocity, 8)); - break; - - case 32: - case 40: - case 120: - Assert.assertTrue(Utils.isNear(velocity, -8)); - break; - - case 50: - case 60: - Assert.assertTrue(Utils.isNear(velocity, 4.2)); - break; - - case 70: - case 80: - Assert.assertTrue(Utils.isNear(velocity, -4.2)); - break; - - case 130: - case 140: - Assert.assertTrue(Utils.isNear(velocity, 2)); - break; - - case 150: - case 160: - Assert.assertTrue(Utils.isNear(velocity, -2)); - break; - - case 170: - case 180: - case 190: - case 199: - Assert.assertTrue(Utils.isNear(velocity, 0)); - break; - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestNames.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestNames.java deleted file mode 100644 index 90978c6..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestNames.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; - - -/** - * @author Pavel Savara (original) - */ -public class TestNames extends RobocodeTestBed { - @Test - public void run() { - super.run(); - } - - @Override - protected int getExpectedErrors() { - return 4; - } - - @Override - public int getExpectedRobotCount(String list) { - return 2; - } - - @Override - public String getRobotNames() { - return "SampleCs.Fire,robocode.BadNamespace,tested.robotscs.TooLongNameThisIsReallyTooLongName,tooLongNamespaceThisIsReallyTooLongNamespace.TooLongNamespace,NoPackageButReallyLongNameIWouldSayTooLongMaybeEventLonger,NoPackageShortName"; - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestPosition.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestPosition.java deleted file mode 100644 index 8cd2571..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestPosition.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.RoundStartedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * Repeatable robot possition test - * - * @author Pavel Savara (original) - */ -public class TestPosition extends RobocodeTestBed { - int lastTurn; - - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "SampleCs.Crazy,SampleCs.Target"; - } - - @Override - public void onRoundStarted(final RoundStartedEvent event) { - super.onRoundStarted(event); - if (event.getRound() == 0) { - IRobotSnapshot crazy = event.getStartSnapshot().getRobots()[0]; - IRobotSnapshot target = event.getStartSnapshot().getRobots()[1]; - - Assert.assertNear(568.1445492, crazy.getX()); - Assert.assertNear(163.0032275, crazy.getY()); - Assert.assertNear(436.7181397, target.getX()); - Assert.assertNear(351.5039067, target.getY()); - } - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - lastTurn = event.getTurnSnapshot().getTurn(); - - IRobotSnapshot crazy = event.getTurnSnapshot().getRobots()[0]; - IRobotSnapshot target = event.getTurnSnapshot().getRobots()[1]; - - if (lastTurn == 1) { - Assert.assertNear(567.2831835, crazy.getX()); - Assert.assertNear(162.4952421, crazy.getY()); - Assert.assertNear(436.7181397, target.getX()); - Assert.assertNear(351.5039067, target.getY()); - } - - if (lastTurn == 1700) { - Assert.assertNear(373.9958377, crazy.getX()); - Assert.assertNear(196.1380677, crazy.getY()); - Assert.assertNear(340.3212984, target.getX()); - Assert.assertNear(456.5502002, target.getY()); - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue(lastTurn == 2080 || lastTurn == 2296); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestPrivateConstructor.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestPrivateConstructor.java deleted file mode 100644 index 2f37039..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestPrivateConstructor.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestPrivateConstructor extends RobocodeTestBed { - boolean messaged; - - @Test - public void run() { - super.run(); - } - - public void onTurnEnded(final TurnEndedEvent event) { - super.onTurnEnded(event); - final IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1]; - - if (robot.getOutputStreamSnapshot().contains( - "tested.robotscs.PrivateConstructor No parameterless constructor defined for this object.")) { - messaged = true; - } - Assert.assertNear(0, robot.getEnergy()); - } - - @Override - public String getRobotNames() { - return "SampleCs.Fire,tested.robotscs.PrivateConstructor"; - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messaged); - } - - @Override - protected int getExpectedErrors() { - return 1; // Security error must be reported as an error - } -} - diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestRandom.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestRandom.java deleted file mode 100644 index eb22120..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestRandom.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * Repeatable random test - * - * @author Pavel Savara (original) - */ -public class TestRandom extends RobocodeTestBed { - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "SampleCs.Fire,tested.robotscs.Random"; - } - - @Override - public boolean isCheckOnBattleStart() { - return true; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - Assert.assertTrue(event.getTurnSnapshot().getTurn() <= 1407); - IRobotSnapshot fire = event.getTurnSnapshot().getRobots()[0]; - IRobotSnapshot random = event.getTurnSnapshot().getRobots()[1]; - - if (event.getTurnSnapshot().getTurn() == 1241) { - Assert.assertNear(213.18621928, fire.getX()); - Assert.assertNear(371.45706118, fire.getY()); - Assert.assertNear(782.0, random.getX()); - Assert.assertNear(230.95479253, random.getY()); - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestReflectionAttack.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestReflectionAttack.java deleted file mode 100644 index 06f50e7..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestReflectionAttack.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestReflectionAttack extends RobocodeTestBed { - - private boolean securityException; - private boolean fieldAccessException; - - @Override - public String getRobotNames() { - return "tested.robotscs.ReflectionAttack,SampleCs.Target"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("System.Security.SecurityException")) { - securityException = true; - } else if (out.contains("System.FieldAccessException")) { - fieldAccessException = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("Reflection is not allowed", securityException || fieldAccessException); - } - - @Override - protected int getExpectedErrors() { - return securityException ? 1 : 0; // Security error must be reported as an error - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestRobotDeathEvents.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestRobotDeathEvents.java deleted file mode 100644 index d8bb60e..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestRobotDeathEvents.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestRobotDeathEvents extends RobocodeTestBed { - - @Override - public String getRobotNames() { - return "tested.robotscs.RobotDeathEvents,SampleCs.Crazy,SampleCs.Target,SampleCs.Target,SampleCs.Target"; - } - - @Override - public int getNumRounds() { - return 5; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("enemyCount != getOthers()")) { - Assert.fail("Robot is missing RobotDeathEvent"); - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestScoring.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestScoring.java deleted file mode 100644 index f269e0a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestScoring.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import static org.hamcrest.CoreMatchers.is; -import org.junit.Assert; -import robocode.control.events.BattleFinishedEvent; -import robocode.control.events.RoundEndedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IScoreSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - - -/** - * This test is used for testing if the current scores and total scores are - * calculated correctly. Current scores are tested at each turn, and the total - * scores are tested per round and per battle. - * - * @author Flemming N. Larsen (original) - */ -public class TestScoring extends RobocodeTestBed { - - ITurnSnapshot lastTurnSnapshot; - - @Override - public String getRobotNames() { - return "SampleCs.Corners,SampleCs.Crazy,SampleCs.Fire,SampleCs.RamFire,SampleCs.SittingDuck,SampleCs.SpinBot,SampleCs.Tracker,SampleCs.TrackFire,SampleCs.Walls"; - } - - @Override - public int getNumRounds() { - return 10; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - lastTurnSnapshot = event.getTurnSnapshot(); - - for (IScoreSnapshot score : lastTurnSnapshot.getSortedTeamScores()) { - // Notice that the is no such thing as a 'current total last - // survivor bonus' - int currentScore = (int) (0.5 + score.getCurrentSurvivalScore() + score.getCurrentBulletDamageScore() - + score.getCurrentBulletKillBonus() + score.getCurrentRammingDamageScore() - + score.getCurrentRammingKillBonus() + score.getCurrentSurvivalBonus()); - - Assert.assertThat(score.getName(), currentScore, is((int) (0.5 + score.getCurrentScore()))); - } - } - - @Override - public void onRoundEnded(RoundEndedEvent event) { - super.onRoundEnded(event); - - for (IScoreSnapshot score : lastTurnSnapshot.getSortedTeamScores()) { - - int totalScore = (int) (0.5 + score.getTotalSurvivalScore() + score.getTotalLastSurvivorBonus() - + score.getTotalBulletDamageScore() + score.getTotalBulletKillBonus() + score.getTotalRammingDamageScore() - + score.getTotalRammingKillBonus()); - - Assert.assertThat(score.getName(), totalScore, is((int) (0.5 + score.getTotalScore()))); - } - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - for (IScoreSnapshot score : lastTurnSnapshot.getSortedTeamScores()) { - - int totalScore = (int) (0.5 + score.getTotalSurvivalScore() + score.getTotalLastSurvivorBonus() - + score.getTotalBulletDamageScore() + score.getTotalBulletKillBonus() + score.getTotalRammingDamageScore() - + score.getTotalRammingKillBonus()); - - Assert.assertThat(totalScore, is((int) (0.5 + score.getTotalScore()))); - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestSkippedTurns.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestSkippedTurns.java deleted file mode 100644 index c119173..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestSkippedTurns.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import org.junit.Ignore; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Pavel Savara (original) - */ -@Ignore("is very timing sensitive test, so it usually fails on different machines, please run explicitly if you did something to security or timing") -public class TestSkippedTurns extends RobocodeTestBed { - boolean messagedBattle; - boolean messagedEvent; - - @Test - public void run() { - super.run(); - } - - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("Skipped!!!")) { - messagedEvent = true; - } - if (out.contains("not performed any actions in a reasonable")) { - messagedBattle = true; - } - } - - @Override - public String getRobotNames() { - return "SampleCs.TrackFire,tested.robotscs.SkipTurns"; - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedEvent); - Assert.assertTrue(messagedBattle); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestThreadAttack.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestThreadAttack.java deleted file mode 100644 index 80a4368..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestThreadAttack.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Pavel Savara (original) - */ -public class TestThreadAttack extends RobocodeTestBed { - boolean messagedMax; - - @Override - public String getRobotNames() { - return "tested.robotscs.ThreadAttack,SampleCs.SittingDuck"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("You may only create 5 threads")) { - messagedMax = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedMax); - } - - @Override - protected int getExpectedErrors() { - return 1; // Security error must be reported as an error - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestUndeadThread.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestUndeadThread.java deleted file mode 100644 index 4338c2a..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestUndeadThread.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.BattleErrorEvent; - - -/** - * @author Pavel Savara (original) - */ -public class TestUndeadThread extends RobocodeTestBed { - boolean messagedStop; - - @Test - public void run() { - super.run(); - } - - public void onBattleError(BattleErrorEvent event) { - super.onBattleError(event); - final String error = event.getError(); - - if (error.contains("Unable to stop thread")) { - messagedStop = true; - } - } - - @Override - protected int getExpectedErrors() { - return 1; - } - - @Override - public String getRobotNames() { - return "SampleCs.SittingDuck,tested.robotscs.UndeadThread"; - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedStop); - } - -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestWatchBullet.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestWatchBullet.java deleted file mode 100644 index f404095..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestWatchBullet.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import org.junit.Assert; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestWatchBullet extends RobocodeTestBed { - boolean messagedIdentity; - - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "tested.robotscs.WatchBullets,SampleCs.SittingDuck"; - } - - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[0]; - - final String out = robot.getOutputStreamSnapshot(); - final int time = event.getTurnSnapshot().getTurn(); - - test(out, time, 33, "33 487.43878 119.51132 347.66745 True"); - test(out, time, 45, "45 459.24551 248.46534 347.66745 True"); - test(out, time, 52, "52 442.79943 323.68851 347.66745 True"); - test(out, time, 53, "53 440.44999 334.43468 347.66745 False"); - - if (out.contains("Failed bullet identity")) { - messagedIdentity = true; - } - } - - @Override - protected void runTeardown() { - net.sf.robocode.test.helpers.Assert.assertFalse(messagedIdentity); - } - - private void test(String out, int timecurr, int timeWatch, String in) { - if (timecurr == timeWatch) { - Assert.assertTrue("got: " + out + ", expected: " + in, out.contains(in)); - } - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestWin.java b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestWin.java deleted file mode 100644 index c736838..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/java/net/sf/robocode/test/robotscs/TestWin.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robotscs; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import static org.hamcrest.CoreMatchers.is; -import org.junit.Assert; -import org.junit.Test; -import robocode.BattleResults; -import robocode.control.events.BattleCompletedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestWin extends RobocodeTestBed { - private int win = 0; - private int end = 0; - private int rend = 0; - private BattleResults[] results; - - @Test - public void run() { - super.run(); - } - - @Override - public int getNumRounds() { - return 5; - } - - @Override - public String getRobotNames() { - return "SampleCs.Target,tested.robotscs.BattleWin"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1]; - final String streamSnapshot = robot.getOutputStreamSnapshot(); - - if (streamSnapshot.contains("Win!")) { - win++; - } - if (streamSnapshot.contains("BattleEnded!")) { - end++; - } - if (streamSnapshot.contains("RoundEnded!")) { - rend++; - } - } - - public void onBattleCompleted(BattleCompletedEvent event) { - results = event.getSortedResults(); - } - - @Override - protected void runTeardown() { - Assert.assertThat("always should win", win, is(getNumRounds())); - Assert.assertThat("should get BattleEnded event", end, is(1)); - Assert.assertThat("should get RoundEnded event", rend, is(5)); - Assert.assertThat("always should be FIRST", results[0].getTeamLeaderName(), is("tested.robotscs.BattleWin")); - Assert.assertThat("always should get score", results[0].getScore(), is(900)); - } -} diff --git a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/resources/config/robocode.properties b/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/resources/config/robocode.properties deleted file mode 100644 index 35ec106..0000000 --- a/workspace_robo/plugins/dotnet/robocode.dotnet.tests/src/test/resources/config/robocode.properties +++ /dev/null @@ -1,4 +0,0 @@ -#Robocode Properties -#Fri Jan 02 00:50:04 CET 2009 -robocode.options.development.path=../../../robocode.samples/target/classes;../robocode.dotnet.samples/target;../robocode.dotnet.robotscs/target -robocode.versionchecked=01/04/2109 23\:46\:20 diff --git a/workspace_robo/plugins/dotnet/tools/.gitignore b/workspace_robo/plugins/dotnet/tools/.gitignore deleted file mode 100644 index a65b417..0000000 --- a/workspace_robo/plugins/dotnet/tools/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/workspace_robo/plugins/dotnet/tools/keys/.gitignore b/workspace_robo/plugins/dotnet/tools/keys/.gitignore deleted file mode 100644 index 4bcc837..0000000 --- a/workspace_robo/plugins/dotnet/tools/keys/.gitignore +++ /dev/null @@ -1 +0,0 @@ -robocode.snk diff --git a/workspace_robo/plugins/dotnet/tools/keys/gennetkey.cmd b/workspace_robo/plugins/dotnet/tools/keys/gennetkey.cmd deleted file mode 100644 index 49c0d6b..0000000 --- a/workspace_robo/plugins/dotnet/tools/keys/gennetkey.cmd +++ /dev/null @@ -1,9 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -"C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\sn.exe" -k robocode.snk \ No newline at end of file diff --git a/workspace_robo/plugins/dotnet/tools/loadTools.cmd b/workspace_robo/plugins/dotnet/tools/loadTools.cmd deleted file mode 100644 index c6e3cce..0000000 --- a/workspace_robo/plugins/dotnet/tools/loadTools.cmd +++ /dev/null @@ -1,23 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off - -if not exist "%~dp0/lib/" ( - mkdir "%~dp0/lib/" -) - -java -cp "%~dp0/../../../tools/loader" Loader http://robocode.sourceforge.net/mvnrepo/net/sf/jni4net/jni4net.n/0.8.7.0/ "%~dp0/lib/" jni4net.n-0.8.7.0.dll -java -cp "%~dp0/../../../tools/loader" Loader http://robocode.sourceforge.net/mvnrepo/net/sf/jni4net/jni4net.n.w32.v20/0.8.7.0/ "%~dp0/lib/" jni4net.n.w32.v20-0.8.7.0.dll -java -cp "%~dp0/../../../tools/loader" Loader http://robocode.sourceforge.net/mvnrepo/net/sf/jni4net/jni4net.n.w64.v20/0.8.7.0/ "%~dp0/lib/" jni4net.n.w64.v20-0.8.7.0.dll -java -cp "%~dp0/../../../tools/loader" Loader http://robocode.sourceforge.net/mvnrepo/net/sf/jni4net/jni4net.n.w32.v40/0.8.7.0/ "%~dp0/lib/" jni4net.n.w32.v40-0.8.7.0.dll -java -cp "%~dp0/../../../tools/loader" Loader http://robocode.sourceforge.net/mvnrepo/net/sf/jni4net/jni4net.n.w64.v40/0.8.7.0/ "%~dp0/lib/" jni4net.n.w64.v40-0.8.7.0.dll -java -cp "%~dp0/../../../tools/loader" Loader http://robocode.sourceforge.net/mvnrepo/net/sf/jni4net/jni4net.j/0.8.7.0/ "%~dp0/lib/" jni4net.j-0.8.7.0.jar -java -cp "%~dp0/../../../tools/loader" Loader http://robocode.sourceforge.net/mvnrepo/net/sf/jni4net/proxygen/0.8.7.0/ "%~dp0/lib/" proxygen.exe -java -cp "%~dp0/../../../tools/loader" Loader http://jni4net.googlecode.com/svn/mvnrepo/org/nunit/nunit.framework/2.4.3.0/ "%~dp0/lib/" nunit.framework-2.4.3.0.dll - diff --git a/workspace_robo/plugins/dotnet/tools/proxygen/robocode.control.proxygen.xml b/workspace_robo/plugins/dotnet/tools/proxygen/robocode.control.proxygen.xml deleted file mode 100644 index f288fcd..0000000 --- a/workspace_robo/plugins/dotnet/tools/proxygen/robocode.control.proxygen.xml +++ /dev/null @@ -1,56 +0,0 @@ - - - - robocode.dotnet.host/src/main/java - robocode.dotnet.control.api/src/generated - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/tools/proxygen/robocode.proxygen.net.xml b/workspace_robo/plugins/dotnet/tools/proxygen/robocode.proxygen.net.xml deleted file mode 100644 index dbdda05..0000000 --- a/workspace_robo/plugins/dotnet/tools/proxygen/robocode.proxygen.net.xml +++ /dev/null @@ -1,28 +0,0 @@ - - - - - robocode.dotnet.host/src/main/java - robocode.dotnet.nhost/src/generated - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/dotnet/tools/proxygen/robocode.proxygen.xml b/workspace_robo/plugins/dotnet/tools/proxygen/robocode.proxygen.xml deleted file mode 100644 index db99900..0000000 --- a/workspace_robo/plugins/dotnet/tools/proxygen/robocode.proxygen.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - - - robocode.dotnet.host/src/main/java - robocode.dotnet.nhost/src/generated - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/testing/.gitignore b/workspace_robo/plugins/testing/.gitignore deleted file mode 100644 index ef1aab0..0000000 --- a/workspace_robo/plugins/testing/.gitignore +++ /dev/null @@ -1 +0,0 @@ -tools diff --git a/workspace_robo/plugins/testing/mvn.cmd b/workspace_robo/plugins/testing/mvn.cmd deleted file mode 100644 index 0e56a2d..0000000 --- a/workspace_robo/plugins/testing/mvn.cmd +++ /dev/null @@ -1,19 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off - -if not exist "%~dp0\tools\lib" ( - mkdir "%~dp0\tools\lib" -) - -if not exist "%~dp0\..\..\tools\lib\maven-*-uber.jar" ( - call "%~dp0\..\..\tools\loadTools.cmd" -) - -call "%~dp0\..\..\mvn" %* \ No newline at end of file diff --git a/workspace_robo/plugins/testing/mvn.sh b/workspace_robo/plugins/testing/mvn.sh deleted file mode 100644 index 7a6b177..0000000 --- a/workspace_robo/plugins/testing/mvn.sh +++ /dev/null @@ -1,20 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - -dp0=${0%/*} - -if [ ! -d "$dp0/tools/lib" ]; then - mkdir $dp0/tools/lib -fi - -if [ ! -f $dp0/../../tools/lib/maven-*-uber.jar ]; then - $dp0/../../tools/loadTools.sh -fi - -$dp0/../../mvn.sh $* \ No newline at end of file diff --git a/workspace_robo/plugins/testing/mvnassembly.cmd b/workspace_robo/plugins/testing/mvnassembly.cmd deleted file mode 100644 index fb10c4c..0000000 --- a/workspace_robo/plugins/testing/mvnassembly.cmd +++ /dev/null @@ -1,12 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off - -mvn clean install ant:ant -DskipTests=false %* -rem mvn eclipse:eclipse \ No newline at end of file diff --git a/workspace_robo/plugins/testing/mvnassembly.sh b/workspace_robo/plugins/testing/mvnassembly.sh deleted file mode 100644 index a498a71..0000000 --- a/workspace_robo/plugins/testing/mvnassembly.sh +++ /dev/null @@ -1,11 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - -./mvn.sh clean install ant:ant -DskipTests=false $* -#./mvn.sh eclipse:eclipse \ No newline at end of file diff --git a/workspace_robo/plugins/testing/pom.xml b/workspace_robo/plugins/testing/pom.xml deleted file mode 100644 index 6e5adcc..0000000 --- a/workspace_robo/plugins/testing/pom.xml +++ /dev/null @@ -1,21 +0,0 @@ - - - 4.0.0 - robocode.testing - Robot Testing Framework - pom - - net.sf.robocode - robocode - ${robocode.version} - ../.. - - - robocode.testing.api - robocode.testing.content - robocode.testing.distribution - robocode.testing.installer - robocode.testing.samples - - diff --git a/workspace_robo/plugins/testing/robocode.testing.api/.classpath b/workspace_robo/plugins/testing/robocode.testing.api/.classpath deleted file mode 100644 index 30c629f..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.api/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.api/.project b/workspace_robo/plugins/testing/robocode.testing.api/.project deleted file mode 100644 index 6cac192..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.api/.project +++ /dev/null @@ -1,14 +0,0 @@ - - - robocode.testing.api - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.api/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/testing/robocode.testing.api/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index ee629d3..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.api/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:14:19 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/testing/robocode.testing.api/pom.xml b/workspace_robo/plugins/testing/robocode.testing.api/pom.xml deleted file mode 100644 index 89cf1b6..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.api/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - 4.0.0 - robocode.testing.api - Robot Testing Framework API - - net.sf.robocode - robocode.testing - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - junit - junit - 4.11 - - - - - - org.apache.maven.plugins - maven-jar-plugin - - robocode.testing - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - package - - javadoc - - - - - Robocode Testing Framework ${project.version} - true - - Robocode Testing Framework ${project.version}]]> - - - http://docs.oracle.com/javase/6/docs/api/ - http://junit.sourceforge.net/javadoc - http://robocode.sourceforge.net/docs/robocode - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.api/robocode.testing.api.iml b/workspace_robo/plugins/testing/robocode.testing.api/robocode.testing.api.iml deleted file mode 100644 index 774c095..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.api/robocode.testing.api.iml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.api/src/main/java/robocode/control/testing/RobotTestBed.java b/workspace_robo/plugins/testing/robocode.testing.api/src/main/java/robocode/control/testing/RobotTestBed.java deleted file mode 100644 index b88e90a..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.api/src/main/java/robocode/control/testing/RobotTestBed.java +++ /dev/null @@ -1,329 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.testing; - - -import robocode.control.BattleSpecification; -import robocode.control.BattlefieldSpecification; -import robocode.control.IRobocodeEngine; -import robocode.control.RandomFactory; -import robocode.control.RobocodeEngine; -import robocode.control.RobotSpecification; -import robocode.control.events.BattleAdaptor; -import robocode.control.events.BattleErrorEvent; -import robocode.control.events.BattleMessageEvent; -import robocode.control.events.TurnEndedEvent; -import net.sf.robocode.io.Logger; -import static org.hamcrest.CoreMatchers.is; -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import robocode.control.snapshot.IRobotSnapshot; - -import java.io.File; - - -/** - * RobotTestBed provides a superclass that can be extended in order to implement JUnit tests - * for Robocode robots. - *

- * The user must set the system property robocode.home to the location of the robocode installation, - * otherwise we cannot set up the Robocode engine. If robocode.home is not a system property, - * we throw a RuntimeException. - * - * @author Philip Johnson (original) - * @author Pavel Savara (contributor) - */ -public abstract class RobotTestBed extends BattleAdaptor { - - /** - * The Robocode game engine instance used for this test. - */ - protected final IRobocodeEngine engine; - - /** - * The battlefield specification, which is the default. - */ - protected final BattlefieldSpecification battleFieldSpec = new BattlefieldSpecification(); - - /** - * The number of errors generated during this battle so far. - */ - protected int errors = 0; - - /** - * The number of messages generated during this battle so far. - */ - protected int messages = 0; - - /** - * The height of the battle field, initialized at the beginning of the battle. - */ - protected int height = 0; - - /** - * The width of the battle field, initialized at the beginning of the battle. - */ - protected int width = 0; - - /** - * True to specify that the position during each turn should be printed out. - */ - protected boolean isDumpingPositions = false; - - /** - * True to specify that each turn should be printed out. - */ - protected boolean isDumpingTurns = false; - - /** - * True to specify that Robot output should be printed out. - */ - protected boolean isDumpingOutput = false; - - /** - * True to specify that error messages should be printed out. - */ - protected boolean isDumpingErrors = true; - - /** - * True to specify that Robot messages should be printed out. - */ - protected boolean isDumpingMessages = true; - - /** - * Create an instance of RobotTestBed which provides default implementations for some (not all) - * of the IBattleListener methods. Your subclass can provide overridden methods for more - * of the IBattleListener methods, or override any of the methods in this class, in order to - * check for the desired behavior by your robot. - *

- * Also instantiates a Robocode engine for running the test battle. This requires a system - * property called robocode.home to be defined and to provide the path to a Robocode installation - * containing the robots under test. - * - * @throws RuntimeException If robocode.home is not defined or does not point to a robocode - * installation. - */ - public RobotTestBed() { - // Set some system properties for use by the robocode engine. - System.setProperty("EXPERIMENTAL", "true"); - System.setProperty("TESTING", "true"); - - // Check that robocode.home is defined and points to a robocode installation. - String robocodeHome = System.getProperty("robocode.home"); - - if (robocodeHome == null) { - throw new RuntimeException("System property robocode.home is not set."); - } - - File robocodeJar = new File(new File(robocodeHome), "libs/robocode.jar"); - - if (!robocodeJar.exists()) { - throw new RuntimeException("robocode.jar not found. robocode.home: " + robocodeHome); - } - - // Now create the robocode engine. - engine = new RobocodeEngine(new File(robocodeHome)); - } - - /** - * Called after each turn, and implements basic logging information about the turn number and - * the position of each robot. - *

- * Override this method to perform testing at the end of each turn. - * - * @param event The TurnEndedEvent. - */ - public void onTurnEnded(TurnEndedEvent event) { - if (isDumpingTurns) { - Logger.realOut.println("turn " + event.getTurnSnapshot().getTurn()); - } - for (IRobotSnapshot robot : event.getTurnSnapshot().getRobots()) { - if (isDumpingPositions) { - Logger.realOut.print(robot.getVeryShortName()); - Logger.realOut.print(" X:"); - Logger.realOut.print(robot.getX()); - Logger.realOut.print(" Y:"); - Logger.realOut.print(robot.getY()); - Logger.realOut.print(" V:"); - Logger.realOut.print(robot.getVelocity()); - Logger.realOut.println(); - } - if (isDumpingOutput) { - Logger.realOut.print(robot.getOutputStreamSnapshot()); - } - } - } - - /** - * Must return a comma-separated list of fully qualified robot names to be in this battle. - *

- * You must override this event to specify the robots to battle in this test case. - * - * @return The list of robots. - */ - public abstract String getRobotNames(); - - /** - * Provides the number of rounds in this battle. Defaults to 1. - * Override this to change the number of rounds. - * - * @return The number of rounds. - */ - public int getNumRounds() { - return 1; - } - - /** - * Returns a comma or space separated list like: x1,y1,heading1, x2,y2,heading2, which are the - * coordinates and heading of robot #1 and #2. So "0,0,180, 50,80,270" means that robot #1 - * has position (0,0) and heading 180, and robot #2 has position (50,80) and heading 270. - *

- * Override this method to explicitly specify the initial positions. - *

- * Defaults to null, which means that the initial positions are determined randomly. Since - * battles are deterministic by default, the initial positions are randomly chosen but will - * always be the same each time you run the test case. - * - * @return The list of initial positions. - */ - public String getInitialPositions() { - return null; - } - - /** - * Provides the number of robots in this battle. - * - * @param robotList The list of robots. - * @return The number of robots in this battle. - */ - private int getExpectedRobotCount(String robotList) { - return robotList.split("[\\s,;]+").length; - } - - /** - * Defaults to true, indicating that the battle is deterministic and robots will always start - * in the same position each time. - *

- * Override to support random initialization. - * - * @return True if the battle will be deterministic. - */ - public boolean isDeterministic() { - return true; - } - - /** - * The setup method run before each test, which sets up the listener on the engine for testing. - * Don't override this method; instead, override runSetup to add behavior before the test - * battle starts. - */ - @Before - public void setup() { - engine.addBattleListener(this); - if (isDeterministic()) { - RandomFactory.resetDeterministic(0); - } - this.height = battleFieldSpec.getHeight(); - this.width = battleFieldSpec.getWidth(); - errors = 0; - messages = 0; - } - - /** - * After each test is run, the listener is removed. - * Don't override this method; instead, override runTearDown to add behavior after the test - * battle ends. - */ - @After - public void tearDown() { - engine.removeBattleListener(this); - } - - /** - * Runs a test, invoking the runSetup method before the battle starts and the - * runTearDown method after the battle ends. - * Asserts that the expected number of errors for this battle were obtained. - */ - @Test - public void run() { - runSetup(); - runBattle(getRobotNames(), getNumRounds(), getInitialPositions()); - runTeardown(); - RobotTestBedAssert.assertThat(errors, is(getExpectedErrors())); - } - - /** - * Specifies how many errors you expect this battle to generate. - * Defaults to 0. Override this method to change the number of expected errors. - * - * @return The expected number of errors. - */ - protected int getExpectedErrors() { - return 0; - } - - /** - * Invoked before the test battle begins. - * Default behavior is to do nothing. - * Override this method in your test case to add behavior before the battle starts. - */ - protected void runSetup() {// Default does nothing. - } - - /** - * Invoked after the test battle ends. - * Default behavior is to do nothing. - * Override this method in your test case to add behavior after the battle ends. - */ - protected void runTeardown() {// Default does nothing. - } - - /** - * Runs the test battle. - * - * @param robotList The list of robots. - * @param numRounds The number of rounds. - * @param initialPositions The initial positions for the robots. - */ - private void runBattle(String robotList, int numRounds, String initialPositions) { - final RobotSpecification[] robotSpecifications = engine.getLocalRepository(robotList); - - if (getExpectedRobotCount(robotList) > 0) { - RobotTestBedAssert.assertNotNull("Robot not loaded", robotSpecifications); - RobotTestBedAssert.assertEquals("Robot not loaded", getExpectedRobotCount(robotList), - robotSpecifications.length); - engine.runBattle(new BattleSpecification(numRounds, battleFieldSpec, robotSpecifications), initialPositions, - true); - } - } - - /** - * Keep track of the number of messages. Print them if desired. - * - * @param event The BattleMessageEvent. - */ - public void onBattleMessage(BattleMessageEvent event) { - if (isDumpingMessages) { - Logger.realOut.println(event.getMessage()); - } - messages++; - } - - /** - * Keep track of the number of errors. Print them if desired. - * - * @param event The BattleErrorEvent. - */ - public void onBattleError(BattleErrorEvent event) { - if (isDumpingErrors) { - Logger.realErr.println(event.getError()); - } - errors++; - } -} diff --git a/workspace_robo/plugins/testing/robocode.testing.api/src/main/java/robocode/control/testing/RobotTestBedAssert.java b/workspace_robo/plugins/testing/robocode.testing.api/src/main/java/robocode/control/testing/RobotTestBedAssert.java deleted file mode 100644 index efb7fe8..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.api/src/main/java/robocode/control/testing/RobotTestBedAssert.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.testing; - - -import robocode.util.Utils; - - -/** - * Provides some additional Assert methods for use in Robocode. - * - * @author Philip Johnson (original) - * @author Pavel Savara (contributor) - */ -public class RobotTestBedAssert extends org.junit.Assert { - - /** - * Asserts that the two values are "sufficiently close". - * Define sufficiently close using Utils.NEAR_DELTA. - * - * @param value1 First value. - * @param value2 Second value. - */ - public static void assertNear(double value1, double value2) { - org.junit.Assert.assertEquals(value1, value2, Utils.NEAR_DELTA); - } -} diff --git a/workspace_robo/plugins/testing/robocode.testing.api/src/main/java/robocode/control/testing/package.html b/workspace_robo/plugins/testing/robocode.testing.api/src/main/java/robocode/control/testing/package.html deleted file mode 100644 index b0fe82d..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.api/src/main/java/robocode/control/testing/package.html +++ /dev/null @@ -1,12 +0,0 @@ - - -Provides a harness for JUnit testing. - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.content/.classpath b/workspace_robo/plugins/testing/robocode.testing.content/.classpath deleted file mode 100644 index 31eaf22..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.content/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.content/.project b/workspace_robo/plugins/testing/robocode.testing.content/.project deleted file mode 100644 index a5b7468..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.content/.project +++ /dev/null @@ -1,16 +0,0 @@ - - - robocode.testing.content - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.testing.samples - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.content/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/testing/robocode.testing.content/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7040061..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.content/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:14:20 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/testing/robocode.testing.content/pom.xml b/workspace_robo/plugins/testing/robocode.testing.content/pom.xml deleted file mode 100644 index 11e7063..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.content/pom.xml +++ /dev/null @@ -1,33 +0,0 @@ - - - 4.0.0 - robocode.testing.content - Robot Testing Framework Static Content - - net.sf.robocode - robocode.testing - ${robocode.version} - - - - net.sf.robocode - robocode.testing.samples - ${project.version} - - - net.sf.robocode - robocode.testing.api - - - net.sf.robocode - robocode.api - - - junit - junit - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.content/robocode.testing.content.iml b/workspace_robo/plugins/testing/robocode.testing.content/robocode.testing.content.iml deleted file mode 100644 index 4203486..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.content/robocode.testing.content.iml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.content/src/main/resources/testing/Read.Me.txt b/workspace_robo/plugins/testing/robocode.testing.content/src/main/resources/testing/Read.Me.txt deleted file mode 100644 index f856f5f..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.content/src/main/resources/testing/Read.Me.txt +++ /dev/null @@ -1,33 +0,0 @@ -==== - Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://robocode.sourceforge.net/license/epl-v10.html -==== - -This is way how to test your robots with JUnit and Robocode. - -1) Look at robocode/testing/sample/TestWallBehavior.java - - it's behavioral integration test, to proove that samples.Wall robot will visit all 4 corners of battlefield - - it's inherited from robocode.control.testing.RobotTestBed, which is part of robocode.testing extension - -2) RobotTestBed - base class for tests - - provides setup of Robocode engine itself - - expects you to set Java system property robocode.home to path to your robocode installation. For example C:\Robocode - - supports setup of battle by overriding various virtual methods, among others - - getRobotNames() - allows you to specify coma separated list of robos for battle - - getNumRounds() - allows you to specify number of rounds for the battle - - for more see robocode/testing/javadoc/index.html - - implements IBattleListener interface of robocode and it's notified about battle events - - override onTurnEnded() method to be invoked after each turn, with snapshot of current battlefield - - override onBattleCompleted() method to be invoked after battle, with battle resutls and scores - - for more see robocode/testing/javadoc/index.html and robocode/javadoc/index.html - -3) Build the unit test by starting robocode\testing\compile.cmd or do it in your IDE - -4) Run the test with JUnit by starting robocode\testing\test.cmd or do it in your IDE - - note that we pass -Drobocode.home Java property - -5) watch the test result - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.content/src/main/resources/testing/compile.cmd b/workspace_robo/plugins/testing/robocode.testing.content/src/main/resources/testing/compile.cmd deleted file mode 100644 index b877710..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.content/src/main/resources/testing/compile.cmd +++ /dev/null @@ -1,10 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off -javac -cp ../libs/junit-4.5.jar;../libs/robocode.jar;../libs/robocode.testing.jar sample/TestWallBehavior.java \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.content/src/main/resources/testing/test.cmd b/workspace_robo/plugins/testing/robocode.testing.content/src/main/resources/testing/test.cmd deleted file mode 100644 index 3f14b58..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.content/src/main/resources/testing/test.cmd +++ /dev/null @@ -1,10 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off -java -Drobocode.home=.. -cp ../libs/junit-4.5.jar;../libs/robocode.jar;../libs/robocode.testing.jar;.; org.junit.runner.JUnitCore sample.TestWallBehavior diff --git a/workspace_robo/plugins/testing/robocode.testing.distribution/.classpath b/workspace_robo/plugins/testing/robocode.testing.distribution/.classpath deleted file mode 100644 index 93698dc..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.distribution/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.distribution/.project b/workspace_robo/plugins/testing/robocode.testing.distribution/.project deleted file mode 100644 index 716aee0..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.distribution/.project +++ /dev/null @@ -1,19 +0,0 @@ - - - robocode.testing.distribution - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.testing.api - robocode.testing.content - robocode.testing.samples - robocode.testing.installer - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.distribution/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/testing/robocode.testing.distribution/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7040061..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.distribution/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:14:20 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/testing/robocode.testing.distribution/pom.xml b/workspace_robo/plugins/testing/robocode.testing.distribution/pom.xml deleted file mode 100644 index 93569f0..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.distribution/pom.xml +++ /dev/null @@ -1,72 +0,0 @@ - - - 4.0.0 - robocode.testing.distribution - Robot Testing Framework Distribution - - net.sf.robocode - robocode.testing - ${robocode.version} - - - - net.sf.robocode - robocode.testing.api - ${project.version} - jar - - - net.sf.robocode - robocode.testing.content - ${project.version} - jar - - - net.sf.robocode - robocode.testing.installer - ${project.version} - jar - - - net.sf.robocode - robocode.testing.samples - ${project.version} - jar - - - junit - junit - 4.11 - jar - - - - - - maven-assembly-plugin - - ${project.parent.artifactId}-${project.version} - true - - testing-setup.asm.xml - - - - net.sf.robocode.installer.AutoExtract - - - - - - make-assembly - package - - single - - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.distribution/robocode.testing.distribution.iml b/workspace_robo/plugins/testing/robocode.testing.distribution/robocode.testing.distribution.iml deleted file mode 100644 index 60e4af3..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.distribution/robocode.testing.distribution.iml +++ /dev/null @@ -1,90 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.distribution/testing-setup.asm.xml b/workspace_robo/plugins/testing/robocode.testing.distribution/testing-setup.asm.xml deleted file mode 100644 index 54b0fc4..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.distribution/testing-setup.asm.xml +++ /dev/null @@ -1,79 +0,0 @@ - - - setup - - dir - jar - - false - - - - - junit:junit - - libs - false - - - - - net.sf.robocode:robocode.testing.api - - libs - false - robocode.testing.${artifact.extension} - - - - net.sf.robocode:robocode.testing.api:javadoc - - testing/javadoc - true - - - - - net.sf.robocode:robocode.testing.samples - - testing - true - - - **/META-INF/** - **/*.class - - - - - - - net.sf.robocode:robocode.testing.installer - net.sf.robocode:robocode.testing.content - - true - - - **/META-INF/** - - - - - - - ../robocode.testing.api/target/site/apidocs - /testing/javadoc - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.iml b/workspace_robo/plugins/testing/robocode.testing.iml deleted file mode 100644 index c163c5f..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.iml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.installer/.classpath b/workspace_robo/plugins/testing/robocode.testing.installer/.classpath deleted file mode 100644 index faff71b..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.installer/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.installer/.project b/workspace_robo/plugins/testing/robocode.testing.installer/.project deleted file mode 100644 index dc2dd6e..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.installer/.project +++ /dev/null @@ -1,14 +0,0 @@ - - - robocode.testing.installer - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.installer/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/testing/robocode.testing.installer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 7040061..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.installer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:14:20 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/testing/robocode.testing.installer/pom.xml b/workspace_robo/plugins/testing/robocode.testing.installer/pom.xml deleted file mode 100644 index 5336a18..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.installer/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - robocode.testing.installer - Robot Testing Framework Installer - - net.sf.robocode - robocode.testing - ${robocode.version} - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - net.sf.robocode.installer.AutoExtract - - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.installer/robocode.testing.installer.iml b/workspace_robo/plugins/testing/robocode.testing.installer/robocode.testing.installer.iml deleted file mode 100644 index 93c108a..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.installer/robocode.testing.installer.iml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java b/workspace_robo/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java deleted file mode 100644 index c7825a0..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java +++ /dev/null @@ -1,389 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.installer; - - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; -import java.net.URL; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.JarInputStream; - - -/** - * Installer for Robocode. - * - * @author Mathew A. Nelsen (original) - * @author Flemming N. Larsen (contributor) - */ -public class AutoExtract implements ActionListener { - private JDialog licenseDialog; - private boolean accepted; - private final String[] spinner = { "-", "\\", "|", "/"}; - private String message = ""; - private static final String javaVersion = System.getProperty("java.version"); - - /** - * AutoExtract constructor. - */ - public AutoExtract() { - super(); - } - - private boolean acceptLicense() { - String licenseText = ""; - - InputStream is; - - try { - JarFile extractJar = new JarFile("extract.jar"); - - is = extractJar.getInputStream(extractJar.getJarEntry("license/cpl-v10.html")); - } catch (IOException e) { - return true; - } - if (is == null) { - return true; - } - - BufferedReader r = new BufferedReader(new InputStreamReader(is)); - - try { - String line = r.readLine(); - - while (line != null) { - licenseText += line; - line = r.readLine(); - } - return acceptReject(licenseText); - - } catch (IOException e) { - System.err.println("Could not read line from license file: " + e); - } - return true; - } - - private boolean acceptReject(String text) { - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - licenseDialog = new JDialog(); - licenseDialog.setTitle("License Agreement"); - licenseDialog.setModal(true); - licenseDialog.setLocation((screenSize.width - 500) / 2, (screenSize.height - 400) / 2); - licenseDialog.setSize(500, 400); - JTextPane t = new JTextPane(); - - t.setContentType("text/html"); - t.setText(text); - t.setFont(new Font("Dialog", Font.PLAIN, 12)); - t.setEditable(false); - - JScrollPane s = new JScrollPane(); - - s.setViewportView(t); - - licenseDialog.getContentPane().setLayout(new BorderLayout()); - licenseDialog.getContentPane().add(s, BorderLayout.CENTER); - - JPanel p = new JPanel(); - - p.setLayout(new BorderLayout()); - JButton b1 = new JButton("Accept"); - JButton b2 = new JButton("Cancel"); - - p.add(b1, BorderLayout.WEST); - p.add(b2, BorderLayout.EAST); - - b1.addActionListener(this); - b2.addActionListener(this); - - licenseDialog.getContentPane().add(p, BorderLayout.SOUTH); - - licenseDialog.setVisible(true); - - return accepted; - } - - public void actionPerformed(ActionEvent e) { - accepted = e.getActionCommand().equals("Accept"); - licenseDialog.dispose(); - licenseDialog = null; - } - - private boolean extract(File dest) { - JDialog statusDialog = new JDialog(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - int width = 500; - int height = 100; - - statusDialog.setTitle("Installing"); - statusDialog.setLocation((screenSize.width - width) / 2, (screenSize.height - height) / 2); - statusDialog.setSize(width, height); - JLabel status = new JLabel(); - - statusDialog.getContentPane().setLayout(new BorderLayout()); - statusDialog.getContentPane().add(status, BorderLayout.CENTER); - - statusDialog.setVisible(true); - - FileOutputStream fos; - String entryName; - - byte buf[] = new byte[2048]; - - final String name = AutoExtract.class.getName().replaceAll("\\.", "/") + ".class"; - String urlJar = AutoExtract.class.getClassLoader().getResource(name).toString(); - final String src = urlJar.substring("jar:file:/".length(), urlJar.indexOf("!/")); - - if (src.indexOf('!') > -1) { - final String message = src - + "\nContains an exclamation point. Please move the file to a different directory."; - - JOptionPane.showMessageDialog(null, message); - System.err.println(message); - System.exit(0); - } - JarInputStream jarIS = null; - try { - final URL url = new URL("file:/" + src); - InputStream is = url.openStream(); - jarIS = new JarInputStream(is); - - JarEntry entry = jarIS.getNextJarEntry(); - - while (entry != null) { - int spin = 0; - - entryName = entry.getName(); - if (entry.isDirectory()) { - if (!entryName.startsWith("net")) { - File dir = new File(dest, entry.getName()); - - if (!dir.exists() && !dir.mkdirs()) { - System.out.println("Can't create dir " + dir); - } - } - } else { - if (!entryName.equals(name)) { - status.setText(entryName + " " + spinner[spin++]); - - File out = new File(dest, entry.getName()); - File parentDirectory = new File(out.getParent()); - - if (!parentDirectory.exists() && !parentDirectory.mkdirs()) { - System.out.println("Can't create dir " + parentDirectory); - } - fos = new FileOutputStream(out); - - int index = 0; - int num; - int count = 0; - - while ((num = jarIS.read(buf, 0, 2048)) != -1) { - fos.write(buf, 0, num); - index += num; - count++; - if (count > 80) { - status.setText(entryName + " " + spinner[spin++] + " (" + index + " bytes)"); - if (spin > 3) { - spin = 0; - } - count = 0; - } - } - fos.close(); - - if (entryName.length() > 3 && entryName.substring(entryName.length() - 3).equals(".sh")) { - if (File.separatorChar == '/') { - Runtime.getRuntime().exec("chmod 755 " + out.toString()); - } - } - - status.setText(entryName + " " + spinner[spin] + " (" + index + " bytes)"); - } - } - entry = jarIS.getNextJarEntry(); - } - statusDialog.dispose(); - message = "Installation successful"; - return true; - } catch (IOException e) { - message = "Installation failed" + e; - return false; - } finally { - if (jarIS != null) { - try { - jarIS.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - public static void main(String argv[]) { - // Verify that the Java version is version 6 (1.6.0) or newer - if (javaVersion.startsWith("1.") && javaVersion.charAt(2) < '5') { - final String message = "Robocode requires Java 6 (1.6.0) or newer.\n" - + "Your system is currently running Java " + javaVersion + ".\n" - + "If you have not installed (or activated) at least\n" + "JRE 6 or JDK 6, please do so."; - - JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE); - System.err.println(message); - System.exit(0); - } - - // Set native look and feel - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF - } - - File installDir = null; - File suggestedDir; - - AutoExtract extractor = new AutoExtract(); - - if (extractor.acceptLicense()) { - if (argv.length == 1) { - suggestedDir = new File(argv[0]); - } else if (File.separatorChar == '\\') { - suggestedDir = new File("c:\\robocode\\"); - } else { - suggestedDir = new File(System.getProperty("user.home") + File.separator + "robocode" + File.separator); - } - - boolean done = false; - - while (!done) { - int rc = JOptionPane.showConfirmDialog(null, - "Robocode plugin will be installed in:\n" + suggestedDir + "\nIs this ok?", "Installing Robocode", - JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); - - if (rc == JOptionPane.YES_OPTION) { - installDir = suggestedDir; - done = true; - } else if (rc == JOptionPane.NO_OPTION) { - Object r = JOptionPane.showInputDialog(null, "Please type in the installation directory", - "Installation Directory", JOptionPane.PLAIN_MESSAGE, null, null, suggestedDir); - - if (r == null) { - JOptionPane.showMessageDialog(null, "Installation cancelled."); - System.exit(0); - } else { - suggestedDir = new File(((String) r).trim()); - } - } else if (rc == JOptionPane.CANCEL_OPTION) { - JOptionPane.showMessageDialog(null, "Installation cancelled."); - System.exit(0); - } - } - if (!installDir.exists()) { - int rc = JOptionPane.showConfirmDialog(null, - installDir.getPath() + "\ndoes not exist. Would you like to create it?", "Installing Robocode", - JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); - - if (rc == JOptionPane.YES_OPTION) { - if (!installDir.exists() && !installDir.mkdirs()) { - System.out.println("Can't create dir " + installDir); - } - } else { - JOptionPane.showMessageDialog(null, "Installation cancelled."); - System.exit(0); - } - } - boolean rv = extractor.extract(installDir); - - if (!rv) { - JOptionPane.showMessageDialog(null, extractor.message); - } - } else { - JOptionPane.showMessageDialog(null, "Installation cancelled."); - } - - // Delete the class file with the installer and it's parent folders in the robocode home dir - if (installDir != null) { - String installerPath = AutoExtract.class.getName().replaceAll("\\.", "/") + "$1.class"; - - deleteFileAndParentDirsIfEmpty(new File(installDir, installerPath)); - } - - System.exit(0); - } - - private static boolean deleteDir(File dir) { - if (dir.isDirectory()) { - for (File file : dir.listFiles()) { - if (file.isDirectory()) { - // Skip directories ending with ".data" - if (file.getName().endsWith(".data")) { - continue; - } - try { - // Test for symlink and ignore. - // Robocode won't create one, but just in case a user does... - if (file.getCanonicalFile().getParentFile().equals(dir.getCanonicalFile())) { - deleteDir(file); - if (file.exists() && !file.delete()) { - System.err.println("Can't delete: " + file); - } - } else { - System.out.println("Warning: " + file + " may be a symlink. It has been ignored"); - } - } catch (IOException e) { - System.out.println( - "Warning: Cannot determine canonical file for " + file + ". It has been ignored"); - } - } else { - if (file.exists() && !file.delete()) { - System.err.println("Can't delete: " + file); - } - } - } - return dir.delete(); - } - return false; - } - - /** - * Deletes a file and afterwards deletes the parent directories that are empty. - * - * @param file the file or directory to delete - * @return true if success - */ - private static boolean deleteFileAndParentDirsIfEmpty(final File file) { - boolean wasDeleted = false; - - if (file != null && file.exists()) { - if (file.isDirectory()) { - wasDeleted = deleteDir(file); - } else { - wasDeleted = file.delete(); - - File parent = file; - - while (wasDeleted && (parent = parent.getParentFile()) != null) { - // Delete parent directory, but only if it is empty - File[] files = parent.listFiles(); - - if (files != null && files.length == 0) { - wasDeleted = deleteDir(parent); - } else { - wasDeleted = false; - } - } - } - } - return wasDeleted; - } -} diff --git a/workspace_robo/plugins/testing/robocode.testing.ipr b/workspace_robo/plugins/testing/robocode.testing.ipr deleted file mode 100644 index 55ed2f3..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.ipr +++ /dev/null @@ -1,112 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.iws b/workspace_robo/plugins/testing/robocode.testing.iws deleted file mode 100644 index 03c854e..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.iws +++ /dev/null @@ -1,418 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.samples/.classpath b/workspace_robo/plugins/testing/robocode.testing.samples/.classpath deleted file mode 100644 index 1a0f28e..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.samples/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.samples/.project b/workspace_robo/plugins/testing/robocode.testing.samples/.project deleted file mode 100644 index 8fa0726..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.samples/.project +++ /dev/null @@ -1,16 +0,0 @@ - - - robocode.testing.samples - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.testing.api - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/plugins/testing/robocode.testing.samples/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/plugins/testing/robocode.testing.samples/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index ee629d3..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.samples/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:14:19 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/plugins/testing/robocode.testing.samples/pom.xml b/workspace_robo/plugins/testing/robocode.testing.samples/pom.xml deleted file mode 100644 index c237b80..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.samples/pom.xml +++ /dev/null @@ -1,65 +0,0 @@ - - - 4.0.0 - robocode.testing.samples - Robot Testing Framework Samples - - net.sf.robocode - robocode.testing - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - net.sf.robocode - robocode.testing.api - ${project.version} - - - net.sf.robocode - robocode.tests - ${project.version} - test - - - junit - junit - 4.11 - - - - - - org.apache.maven.plugins - maven-surefire-plugin - - - - robocode.home - ${project.build.directory}/../../../../robocode.tests/target/classes - - - - - - - - src/main/java - false - - **/*.java - - - - src/main/resources - false - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.samples/robocode.testing.samples.iml b/workspace_robo/plugins/testing/robocode.testing.samples/robocode.testing.samples.iml deleted file mode 100644 index fc33155..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.samples/robocode.testing.samples.iml +++ /dev/null @@ -1,110 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/plugins/testing/robocode.testing.samples/src/main/java/sample/TestWallBehavior.java b/workspace_robo/plugins/testing/robocode.testing.samples/src/main/java/sample/TestWallBehavior.java deleted file mode 100644 index 1a8bf38..0000000 --- a/workspace_robo/plugins/testing/robocode.testing.samples/src/main/java/sample/TestWallBehavior.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import static org.junit.Assert.assertTrue; -import robocode.control.events.BattleCompletedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.control.testing.RobotTestBed; - - -/** - * Tests that sample.Walls moves to all four corners. - * - * @author Philip Johnson (original) - * @author Pavel Savara (contributor) - */ -public class TestWallBehavior extends RobotTestBed { - - /** - * True if the robot visited this corner during the test case. - */ - boolean visitedUpperLeft = false; - - /** - * True if the robot visited this corner during the test case. - */ - boolean visitedUpperRight = false; - - /** - * True if the robot visited this corner during the test case. - */ - boolean visitedLowerLeft = false; - - /** - * True if the robot visited this corner during the test case. - */ - boolean visitedLowerRight = false; - - /** - * Specifies that SittingDuck and DaCruzer are to be matched up in this test case. - * - * @return The comma-delimited list of robots in this match. - */ - @Override - public String getRobotNames() { - return "sample.SittingDuck,sample.Walls"; - } - - /** - * This test runs for 1 round. - * - * @return The number of rounds. - */ - @Override - public int getNumRounds() { - return 1; - } - - /** - * After each turn, check to see if we're at a corner. If so, set the corresponding flag. - * - * @param event Info about the current state of the battle. - */ - @Override - public void onTurnEnded(TurnEndedEvent event) { - IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1]; - double xPos = robot.getX(); - double yPos = robot.getY(); - - if ((xPos < 40) && (yPos < 40)) { - visitedUpperLeft = true; - } - if ((xPos < 40 && (yPos > (height - 40)))) { - visitedLowerLeft = true; - } - if ((xPos > (width - 40)) && (yPos < 40)) { - visitedUpperRight = true; - } - if ((xPos > (width - 40) && (yPos > (height - 40)))) { - visitedLowerRight = true; - } - } - - /** - * After the battle, check to see that we've visited the corners. - * - * @param event Details about the completed battle. - */ - @Override - public void onBattleCompleted(BattleCompletedEvent - event) { - assertTrue("Check UpperLeft", visitedUpperLeft); - assertTrue("Check LowerLeft", visitedLowerLeft); - assertTrue("Check UpperRight", visitedUpperRight); - assertTrue("Check LowerRight", visitedLowerRight); - } -} diff --git a/workspace_robo/pom.xml b/workspace_robo/pom.xml deleted file mode 100644 index c880dfc..0000000 --- a/workspace_robo/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - 4.0.0 - robocode - Robocode - pom - - super-pom - net.sf.robocode - ${robocode.version} - super-pom - - - robocode.api - robocode.core - robocode.battle - robocode.host - robocode.ui - robocode.ui.editor - robocode.sound - robocode.samples - robocode.roborumble - robocode.tests.robots - robocode.tests - robocode.installer - robocode.repository - robocode.content - robocode.distribution - - - - - com.mycila - license-maven-plugin - 2.6 - -

super-pom/robocode-license-header.txt
- - **/*.properties - **/ReadMe.* - tools/bin/** - tools/licenses/** - LICENSE.txt - **/license/** - **/CILReader.cs - **/roborumble/*.txt - **/pom.xml - - - - - - format - - - - - - - diff --git a/workspace_robo/robocode.api/.classpath b/workspace_robo/robocode.api/.classpath deleted file mode 100644 index faff71b..0000000 --- a/workspace_robo/robocode.api/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.api/.externalToolBuilders/Launch Dir Builder.launch b/workspace_robo/robocode.api/.externalToolBuilders/Launch Dir Builder.launch deleted file mode 100644 index 1f54b39..0000000 --- a/workspace_robo/robocode.api/.externalToolBuilders/Launch Dir Builder.launch +++ /dev/null @@ -1,21 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.api/.gitignore b/workspace_robo/robocode.api/.gitignore deleted file mode 100644 index eb5a316..0000000 --- a/workspace_robo/robocode.api/.gitignore +++ /dev/null @@ -1 +0,0 @@ -target diff --git a/workspace_robo/robocode.api/.project b/workspace_robo/robocode.api/.project deleted file mode 100644 index 0818ab5..0000000 --- a/workspace_robo/robocode.api/.project +++ /dev/null @@ -1,23 +0,0 @@ - - - robocode.api - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - org.eclipse.jdt.core.javabuilder - - - org.eclipse.ui.externaltools.ExternalToolBuilder - - - LaunchConfigHandle - <project>/.externalToolBuilders/Launch Dir Builder.launch - - - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.api/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.api/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 65f3846..0000000 --- a/workspace_robo/robocode.api/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:08 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.api/Robocode.launch b/workspace_robo/robocode.api/Robocode.launch deleted file mode 100644 index f775bf6..0000000 --- a/workspace_robo/robocode.api/Robocode.launch +++ /dev/null @@ -1,31 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.api/pom.xml b/workspace_robo/robocode.api/pom.xml deleted file mode 100644 index f26680a..0000000 --- a/workspace_robo/robocode.api/pom.xml +++ /dev/null @@ -1,60 +0,0 @@ - - - 4.0.0 - robocode.api - Robocode API - - net.sf.robocode - robocode - ${robocode.version} - - - - - org.apache.maven.plugins - maven-jar-plugin - - robocode - - - robocode.Robocode - - - - - - org.apache.maven.plugins - maven-javadoc-plugin - - - package - - javadoc - - - - - Robocode ${project.version} API - true - - Robocode ${project.version} API]]> - - - http://docs.oracle.com/javase/6/docs/api/ - - false - robocode.exception:net.sf.robocode:gl4java:robocode.robocodeGL - ${javadoc.additionalparam} - - - - org.apache.maven.plugins - maven-deploy-plugin - - false - - - - - diff --git a/workspace_robo/robocode.api/robocode.api.iml b/workspace_robo/robocode.api/robocode.api.iml deleted file mode 100644 index 613ddb1..0000000 --- a/workspace_robo/robocode.api/robocode.api.iml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.api/src/main/java/gl4java/GLFont.java b/workspace_robo/robocode.api/src/main/java/gl4java/GLFont.java deleted file mode 100644 index 5ed7f60..0000000 --- a/workspace_robo/robocode.api/src/main/java/gl4java/GLFont.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package gl4java; - - -/** - * Dummy class that stub out RobocodeGL 0.1.4 functionality. - * - * Original author is David Alves for RobocodeGL. - */ -public class GLFont {} diff --git a/workspace_robo/robocode.api/src/main/java/gl4java/GLFunc.java b/workspace_robo/robocode.api/src/main/java/gl4java/GLFunc.java deleted file mode 100644 index 6f8bc58..0000000 --- a/workspace_robo/robocode.api/src/main/java/gl4java/GLFunc.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package gl4java; - - -/** - * Dummy class that stub out RobocodeGL 0.1.4 functionality. - * - * Original author is David Alves for RobocodeGL. - */ -public class GLFunc {} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/api/Module.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/api/Module.java deleted file mode 100644 index 0936dd9..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/api/Module.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.api; - - -import net.sf.robocode.core.IModule; -import net.sf.robocode.serialization.RbSerializer; -import robocode.*; - -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public class Module implements IModule { - public void afterLoaded(List allModules) { - RbSerializer.register(RobotStatus.class, RbSerializer.RobotStatus_TYPE); - RbSerializer.register(BattleResults.class, RbSerializer.BattleResults_TYPE); - RbSerializer.register(Bullet.class, RbSerializer.Bullet_TYPE); - - // events - RbSerializer.register(RoundEndedEvent.class, RbSerializer.RoundEndedEvent_TYPE); - RbSerializer.register(BattleEndedEvent.class, RbSerializer.BattleEndedEvent_TYPE); - RbSerializer.register(BulletHitBulletEvent.class, RbSerializer.BulletHitBulletEvent_TYPE); - RbSerializer.register(BulletHitEvent.class, RbSerializer.BulletHitEvent_TYPE); - RbSerializer.register(BulletMissedEvent.class, RbSerializer.BulletMissedEvent_TYPE); - RbSerializer.register(DeathEvent.class, RbSerializer.DeathEvent_TYPE); - - RbSerializer.register(WinEvent.class, RbSerializer.WinEvent_TYPE); - RbSerializer.register(HitWallEvent.class, RbSerializer.HitWallEvent_TYPE); - RbSerializer.register(RobotDeathEvent.class, RbSerializer.RobotDeathEvent_TYPE); - RbSerializer.register(SkippedTurnEvent.class, RbSerializer.SkippedTurnEvent_TYPE); - RbSerializer.register(ScannedRobotEvent.class, RbSerializer.ScannedRobotEvent_TYPE); - RbSerializer.register(HitByBulletEvent.class, RbSerializer.HitByBulletEvent_TYPE); - RbSerializer.register(HitRobotEvent.class, RbSerializer.HitRobotEvent_TYPE); - RbSerializer.register(KeyPressedEvent.class, RbSerializer.KeyPressedEvent_TYPE); - RbSerializer.register(KeyReleasedEvent.class, RbSerializer.KeyReleasedEvent_TYPE); - RbSerializer.register(KeyTypedEvent.class, RbSerializer.KeyTypedEvent_TYPE); - RbSerializer.register(MouseClickedEvent.class, RbSerializer.MouseClickedEvent_TYPE); - RbSerializer.register(MouseDraggedEvent.class, RbSerializer.MouseDraggedEvent_TYPE); - RbSerializer.register(MouseEnteredEvent.class, RbSerializer.MouseEnteredEvent_TYPE); - RbSerializer.register(MouseExitedEvent.class, RbSerializer.MouseExitedEvent_TYPE); - RbSerializer.register(MouseMovedEvent.class, RbSerializer.MouseMovedEvent_TYPE); - RbSerializer.register(MousePressedEvent.class, RbSerializer.MousePressedEvent_TYPE); - RbSerializer.register(MouseReleasedEvent.class, RbSerializer.MouseReleasedEvent_TYPE); - RbSerializer.register(MouseWheelMovedEvent.class, RbSerializer.MouseWheelMovedEvent_TYPE); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/battle/IBattleManagerBase.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/battle/IBattleManagerBase.java deleted file mode 100644 index f32f146..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/battle/IBattleManagerBase.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -import robocode.control.BattleSpecification; -import robocode.control.events.IBattleListener; - - -/** - * @author Pavel Savara (original) - */ -public interface IBattleManagerBase { - void addListener(IBattleListener listener); - - void removeListener(IBattleListener listener); - - void waitTillOver(); - - void stop(boolean waitTillEnd); - - void startNewBattle(BattleSpecification spec, String initialPositions, boolean waitTillOver, boolean enableCLIRecording); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/core/ContainerBase.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/core/ContainerBase.java deleted file mode 100644 index 341c6a8..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/core/ContainerBase.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.core; - - -/** - * @author Pavel Savara (original) - */ -public abstract class ContainerBase { - public static ContainerBase instance; - - protected abstract T getBaseComponent(java.lang.Class tClass); - - public static T getComponent(java.lang.Class tClass) { - return instance == null ? null : instance.getBaseComponent(tClass); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/core/IModule.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/core/IModule.java deleted file mode 100644 index 177717e..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/core/IModule.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.core; - - -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public interface IModule { - void afterLoaded(List allModules); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/gui/IWindowManagerBase.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/gui/IWindowManagerBase.java deleted file mode 100644 index 815715b..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/gui/IWindowManagerBase.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.gui; - - -/** - * @author Pavel Savara (original) - */ -public interface IWindowManagerBase { - void setVisibleForRobotEngine(boolean visible); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/io/FileUtil.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/io/FileUtil.java deleted file mode 100644 index c9994b3..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/io/FileUtil.java +++ /dev/null @@ -1,352 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.io; - - -import static net.sf.robocode.io.Logger.logError; - -import java.io.*; - - -/** - * This is a class for file utilization. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class FileUtil { - - // Current working directory - private static File cwd; - - // Initializes the current working directory - static { - try { - final String wd = System.getProperty("WORKINGDIRECTORY", ""); - - FileUtil.setCwd(new File(wd)); - } catch (IOException e) { - e.printStackTrace(); - } - } - - /** - * Returns the current working directory. - * - * @return a File for the current working directory - */ - public static File getCwd() { - return cwd; - } - - /** - * Changes the current working directory. - * - * @param cwd a File that is the new working directory - * @throws IOException if an I/O exception occurs - */ - public static void setCwd(File cwd) throws IOException { - FileUtil.cwd = cwd.getCanonicalFile(); - } - - /** - * Returns the file type of a file, i.e. it's extension. - * - * @param file the file - * @return the file type of the file, e.g. ".class", ".jar" or "" if the - * file name does not contain an extension. - */ - public static String getFileType(File file) { - return getFileType(file.getName()); - } - - /** - * Returns the file type of a file name, i.e. it's extension. - * - * @param fileName the file name - * @return the file type of the file name, e.g. ".class", ".jar" or "" if - * the file name does not contain an extension. - */ - public static String getFileType(String fileName) { - int lastdot = fileName.lastIndexOf('.'); - - return (lastdot < 0) ? "" : fileName.substring(lastdot); - } - - /** - * Quotes a file name if it contains white spaces and has not already been - * quoted. - * - * @param filename the file to quote - * @return a quoted version of the specified filename - */ - public static String quoteFileName(String filename) { - if (filename.startsWith("\"") && filename.endsWith("\"")) { - return filename; - } - if (System.getProperty("os.name").toLowerCase().startsWith("windows") && filename.startsWith("file://")) { - filename = filename.substring(7); - } - if (filename.matches(".*\\s+?.*")) { - return '"' + filename + '"'; - } - return filename; - } - - /** - * Copies a file into another file. - * - * @param srcFile the input file to copy - * @param destFile the output file to copy to - * @throws IOException if an I/O exception occurs - */ - public static void copy(File srcFile, File destFile) throws IOException { - if (srcFile.equals(destFile)) { - throw new IOException("You cannot copy a file onto itself"); - } - - byte buf[] = new byte[4096]; - - FileInputStream in = null; - FileOutputStream out = null; - - try { - in = new FileInputStream(srcFile); - out = new FileOutputStream(destFile); - - while (in.available() > 0) { - out.write(buf, 0, in.read(buf, 0, buf.length)); - } - } finally { - if (in != null) { - in.close(); - } - if (out != null) { - out.close(); - } - } - } - - /** - * Deletes a directory. - * - * @param dir the file for the directory to delete - * @return true if success - */ - public static boolean deleteDir(File dir) { - if (dir.isDirectory()) { - for (File file : dir.listFiles()) { - if (file.isDirectory()) { - try { - // Test for symlink and ignore. - // Robocode won't create one, but just in case a user does... - if (file.getCanonicalFile().getParentFile().equals(dir.getCanonicalFile())) { - deleteDir(file); - if (file.exists() && !file.delete()) { - Logger.logError("Cannot delete: " + file); - } - } else { - Logger.logWarning(file + " may be a symlink. Ignoring."); - } - } catch (IOException e) { - Logger.logWarning("Cannot determine canonical file for " + file + ". Ignoring."); - } - } else { - if (file.exists() && !file.delete()) { - Logger.logError("Cannot delete: " + file); - } - } - } - return dir.delete(); - } - return false; - } - - /** - * Creates a directory if it does not exist already - * - * @param dir the File that represents the new directory to create. - * @return the created directory - */ - public static File createDir(File dir) { - if (dir != null && !dir.exists()) { - if (!dir.mkdir()) { - Logger.logError("Cannot create dir: " + dir); - } - } - return dir; - } - - /** - * Returns the class name of the specified filename. - * - * @param fileName the filename to extract the class name from - * @return the class name of the specified filename - */ - public static String getClassName(String fileName) { - int lastdot = fileName.lastIndexOf('.'); - - if (lastdot < 0) { - return fileName; - } - if (fileName.length() - 1 == lastdot) { - return fileName.substring(0, fileName.length() - 1); - } - return fileName.substring(0, lastdot); - } - - /** - * Returns the directory containing the robots. - * - * @return a File that is the directory containing the robots - */ - public static File getRobotsDir() { - String robotPath = System.getProperty("ROBOTPATH"); - File file; - - if (robotPath != null) { - file = new File(robotPath); - } else { - file = new File(cwd, "/robots"); - } - return createDir(file); - } - - /** - * Returns the robot database file. - * - * @return a File that is the directory containing the robot cache. - */ - public static File getRobotDatabaseFile() { - return new File(getRobotsDir(), "/robot.database"); - } - - /** - * Returns the directory containing data files of robots. - * - * @return a File that is the directory containing the robot data. - */ - public static File getRobotsDataDir() { - return createDir(new File(getRobotsDir(), "/.data/")); - } - - /** - * Returns the directory containing the battle files. - * - * @return a File that is the directory containing the battle files - */ - public static File getBattlesDir() { - return createDir(new File(cwd, "/battles")); - } - - /** - * Returns the directory containing the configuration files. - * If the directory does not exist, it will be created automatically. - * - * @return a File that is the directory containing configuration files - */ - public static File getConfigDir() { - return createDir(new File(cwd, "/config")); - } - - /** - * Returns the directory containing the screen shot files. - * If the directory does not exist, it will be created automatically. - * - * @return a File that is the directory containing screen shot files - */ - public static File getScreenshotsDir() { - return createDir(new File(cwd, "/screenshots")); - } - - /** - * Returns the Robocode configuration file. - * - * @return a File that is the Robocode configuration file. - */ - public static File getRobocodeConfigFile() { - return new File(getConfigDir(), "robocode.properties"); - } - - /** - * Returns the window configuration file. - * - * @return a File that is the window configuration file. - */ - public static File getWindowConfigFile() { - return new File(getConfigDir(), "window.properties"); - } - - /** - * Returns the compiler configuration file. - * - * @return a File that is the compiler configuration file. - */ - public static File getCompilerConfigFile() { - return new File(getConfigDir(), "compiler.properties"); - } - - /** - * Returns the source code editor configuration file. - * - * @return a File that is the editor configuration file. - */ - public static File getEditorConfigFile() { - return new File(getConfigDir(), "editor.properties"); - } - - /** - * Returns the editor theme directory. - * - * @return a File that is the directory containing the editor theme files. - */ - public static File getEditorThemeConfigDir() { - return createDir(new File(cwd, "/theme/editor")); - } - - /** - * Cleans up a stream by flushing it and closing it if it is not null. - * - * @param stream the stream to clean up. - */ - public static void cleanupStream(Object stream) { - if (stream == null) { - return; - } - if (stream instanceof Flushable) { - try { - ((Flushable) stream).flush(); - } catch (IOException e) { - logError(e); - } - } - if (stream instanceof Closeable) { - try { - ((Closeable) stream).close(); - } catch (IOException e) { - logError(e); - } - } - } - - /** - * Checks if a filename is valid. - * - * @param file the filename to check. - * @return true if the filename is valid; false otherwise. - */ - public static boolean isFilenameValid(String file) { - File f = new File(file); - try { - f.getCanonicalPath(); - return true; - } catch (IOException e) { - return false; - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/io/Logger.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/io/Logger.java deleted file mode 100644 index a903fd8..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/io/Logger.java +++ /dev/null @@ -1,109 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.io; - - -import net.sf.robocode.security.HiddenAccess; -import net.sf.robocode.util.StringUtil; -import robocode.control.events.BattleErrorEvent; -import robocode.control.events.BattleMessageEvent; -import robocode.control.events.IBattleListener; - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; - - -/** - * This is a class used for logging. - * - * @author Flemming N. Larsen (original) - * @author Mathew A. Nelson (original) - */ -public class Logger { - public static final PrintStream realOut = System.out; - public static final PrintStream realErr = System.err; - - private static IBattleListener logListener; - - private final static StringBuffer logBuffer = new StringBuffer(); - - public static void setLogListener(IBattleListener logListener) { - Logger.logListener = logListener; - } - - public static void logMessage(String s) { - logMessage(s, true); - } - - public static void logMessage(String s, boolean newline) { - if (logListener == null) { - if (System.getProperty("logMessages", "true").equalsIgnoreCase("true")) { - s = StringUtil.toBasicLatin(s); - if (newline) { - realOut.println(s); - } else { - realOut.print(s); - realOut.flush(); - } - } - } else { - synchronized (logBuffer) { - if (!HiddenAccess.isSafeThread()) { - // we just queue it, to not let unsafe thread travel thru system - logBuffer.append(s); - logBuffer.append("\n"); - } else if (newline) { - logListener.onBattleMessage(new BattleMessageEvent(logBuffer + s)); - logBuffer.setLength(0); - } else { - logBuffer.append(s); - } - } - } - } - - public static void logWarning(String s) { - logMessage("Warning: " + s, true); - } - - public static void logError(String message, Throwable t) { - logError(message + ":\n" + toStackTraceString(t)); - } - - public static void logError(Throwable t) { - logError(toStackTraceString(t)); - } - - public static void logError(String s) { - if (logListener == null) { - if (System.getProperty("logErrors", "true").equalsIgnoreCase("true")) { - s = StringUtil.toBasicLatin(s); - realErr.println(s); - } - } else { - logListener.onBattleError(new BattleErrorEvent(s)); - } - } - - private static String toStackTraceString(Throwable t) { - if (t == null) { - return ""; - } - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - PrintStream ps = new PrintStream(baos); - - t.printStackTrace(ps); - ps.close(); - return baos.toString(); - } - - public static void printlnToRobotsConsole(String s) { - // this will get redirected to robot's console - System.out.println(s); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/io/RobocodeProperties.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/io/RobocodeProperties.java deleted file mode 100644 index d39924f..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/io/RobocodeProperties.java +++ /dev/null @@ -1,79 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.io; - - -/** - * Utility class for convenient access to Robocode system wide properties. - * - * @author Flemming N. Larsen (original) - */ -public final class RobocodeProperties { - - // These properties can only be set at startup - private static final boolean NO_SECURITY = System.getProperty("NOSECURITY", "false").equals("true"); - private static final boolean DEBUG = System.getProperty("debug", "false").equals("true"); - - private RobocodeProperties() {} - - /** - * Checks if security is off, i.e. that the NOSECURITY property has been set to true. - * @return true if security is disabled; false if security is enabled. - */ - public static boolean isSecurityOff() { - return NO_SECURITY; - } - - /** - * Checks if security is on, i.e. that the NOSECURITY property has been set to false or not defined at all. - * @return true if security is enabled; false if security is disabled. - */ - public static boolean isSecurityOn() { - return !NO_SECURITY; - } - - /** - * Checks if debugging is disabled. - * @return true if debugging is disabled; false is debugging is enabled. - */ - public static boolean isDebuggingOff() { - return !DEBUG; - } - - /** - * Checks if debugging is enabled. - * @return true if debugging is enabled; false is debugging is disabled. - */ - public static boolean isDebuggingOn() { - return DEBUG; - } - - /** - * Sets the testing flag. - * @param enabled true if testing is being enabled; false if testing is being disabled. - */ - public static void setTesting(boolean enabled) { - System.setProperty("TESTING", "" + enabled); - } - - /** - * Checks if testing is disabled. - * @return true if testing is disabled; false is testing is enabled. - */ - public static boolean isTestingOff() { - return !isTestingOn(); - } - - /** - * Checks if testing is enabled. - * @return true if testing is enabled; false is testing is disabled. - */ - public static boolean isTestingOn() { - return System.getProperty("TESTING", "false").equals("true"); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/manager/IVersionManagerBase.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/manager/IVersionManagerBase.java deleted file mode 100644 index f679071..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/manager/IVersionManagerBase.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.manager; - - -/** - * @author Pavel Savara (original) - */ -public interface IVersionManagerBase { - String getVersion(); - String getVersionN(); - int getVersionAsInt(); - boolean isLastRunVersionChanged(); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/peer/IRobotStatics.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/peer/IRobotStatics.java deleted file mode 100644 index 3a1646c..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/peer/IRobotStatics.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.peer; - - -/** - * @author Pavel Savara (original) - */ -public interface IRobotStatics { - boolean isInteractiveRobot(); - - boolean isPaintRobot(); - - boolean isAdvancedRobot(); - - boolean isTeamRobot(); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/repository/CodeSizeCalculator.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/repository/CodeSizeCalculator.java deleted file mode 100644 index b1bbdb4..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/repository/CodeSizeCalculator.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - - -/** - * Tool used for calculating the code size of a directory or jar file. - * - * @author Flemming N. Larsen (original) - */ -public final class CodeSizeCalculator { - - public static Integer getDirectoryCodeSize(File dir) { - return getCodeSize("processDirectory", dir); - } - - public static Integer getJarFileCodeSize(File jarFile) { - return getCodeSize("processZipFile", jarFile); - } - - private static Integer getCodeSize(String invokeMethod, File jarFile) { - Integer codesize; - try { - // Call the code size utility using reflection - Class classType = Class.forName("codesize.Codesize"); - - Method method = classType.getMethod(invokeMethod, new Class[] { File.class }); - Object item = method.invoke(null/* static method */, jarFile); - - // Calls Codesize.Item.getCodeSize() - method = item.getClass().getMethod("getCodeSize", (Class[]) null); - codesize = (Integer) method.invoke(item, (Object[]) null); - - } catch (IllegalAccessException e) { - codesize = null; - } catch (InvocationTargetException e) { - codesize = null; - } catch (NoSuchMethodException e) { - codesize = null; - } catch (ClassNotFoundException e) { - codesize = null; - } - return codesize; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/repository/IRepositoryManagerBase.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/repository/IRepositoryManagerBase.java deleted file mode 100644 index 5873b6c..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/repository/IRepositoryManagerBase.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import robocode.control.RobotSpecification; - - -/** - * @author Pavel Savara (original) - */ -public interface IRepositoryManagerBase { - boolean refresh(); - RobotSpecification[] getSpecifications(); - RobotSpecification[] loadSelectedRobots(String selectedRobots); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/HiddenAccess.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/HiddenAccess.java deleted file mode 100644 index 2616238..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/HiddenAccess.java +++ /dev/null @@ -1,290 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.security; - - -import net.sf.robocode.core.ContainerBase; -import net.sf.robocode.io.Logger; -import net.sf.robocode.peer.IRobotStatics; -import robocode.BattleRules; -import robocode.Bullet; -import robocode.Event; -import robocode.RobotStatus; -import robocode.control.RobotSpecification; -import robocode.control.events.IBattleListener; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.io.File; -import java.io.FilenameFilter; -import java.io.UnsupportedEncodingException; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.net.URLDecoder; -import java.util.ArrayList; - - -/** - * Helpers for accessing hidden methods on events. - * - * @author Pavel Savara (original) - */ -public class HiddenAccess { - private static IHiddenEventHelper eventHelper; - private static IHiddenBulletHelper bulletHelper; - private static IHiddenSpecificationHelper specificationHelper; - private static IHiddenStatusHelper statusHelper; - private static IHiddenRulesHelper rulesHelper; - private static Method initContainer; - private static Method initContainerRe; - private static Method cleanup; - private static Method robocodeMain; - private static boolean initialized; - private static boolean foundCore = false; - - public static void init() { - if (initialized) { - return; - } - Method method; - - try { - method = Event.class.getDeclaredMethod("createHiddenHelper"); - method.setAccessible(true); - eventHelper = (IHiddenEventHelper) method.invoke(null); - method.setAccessible(false); - - method = Bullet.class.getDeclaredMethod("createHiddenHelper"); - method.setAccessible(true); - bulletHelper = (IHiddenBulletHelper) method.invoke(null); - method.setAccessible(false); - - method = RobotSpecification.class.getDeclaredMethod("createHiddenHelper"); - method.setAccessible(true); - specificationHelper = (IHiddenSpecificationHelper) method.invoke(null); - method.setAccessible(false); - - method = RobotStatus.class.getDeclaredMethod("createHiddenSerializer"); - method.setAccessible(true); - statusHelper = (IHiddenStatusHelper) method.invoke(null); - method.setAccessible(false); - - method = BattleRules.class.getDeclaredMethod("createHiddenHelper"); - method.setAccessible(true); - rulesHelper = (IHiddenRulesHelper) method.invoke(null); - method.setAccessible(false); - - ClassLoader loader = getClassLoader(); - Class main = loader.loadClass("net.sf.robocode.core.RobocodeMainBase"); - - initContainer = main.getDeclaredMethod("initContainer"); - initContainer.setAccessible(true); - - initContainerRe = main.getDeclaredMethod("initContainerForRobocodeEngine", File.class, IBattleListener.class); - initContainerRe.setAccessible(true); - - cleanup = main.getDeclaredMethod("cleanupForRobocodeEngine"); - cleanup.setAccessible(true); - - robocodeMain = main.getDeclaredMethod("robocodeMain", Object.class); - robocodeMain.setAccessible(true); - - initialized = true; - } catch (NoSuchMethodException e) { - Logger.logError(e); - } catch (InvocationTargetException e) { - Logger.logError(e); - } catch (IllegalAccessException e) { - Logger.logError(e); - } catch (ClassNotFoundException e) { - Logger.logError(e); - if (!foundCore) { - Logger.logError("Can't find robocode.core-1.x.jar module near to robocode.jar"); - Logger.logError("Class path: " + System.getProperty("robocode.class.path", null)); - } - System.exit(-1); - } catch (MalformedURLException e) { - Logger.logError(e); - } catch (Error e) { - Logger.logError(e); - throw e; - } - - } - - private static ClassLoader getClassLoader() throws MalformedURLException { - // if other modules are .jar next to robocode.jar on same path, we will create classloader which will load them - // otherwise we rely on that they are already on classpath - StringBuilder classPath = new StringBuilder(System.getProperty("java.class.path", null)); - ClassLoader loader = ClassLoader.getSystemClassLoader(); - String path = HiddenAccess.class.getProtectionDomain().getCodeSource().getLocation().getPath(); - - try { - path = URLDecoder.decode(path, "UCS2"); - } catch (UnsupportedEncodingException e) { - path = new File(".", "libs/robocode.jar").toString(); - } - final int i = path.lastIndexOf("robocode.jar"); - - if (i > 0) { - loader = createClassLoader(classPath, loader, path.substring(0, i)); - } - System.setProperty("robocode.class.path", classPath.toString()); - return loader; - } - - private static ClassLoader createClassLoader(StringBuilder classPath, ClassLoader loader, String dir) throws MalformedURLException { - - File dirf = new File(dir); - ArrayList urls = new ArrayList(); - - final File[] files = dirf.listFiles(new FilenameFilter() { - public boolean accept(File dir, String name) { - final String test = name.toLowerCase(); - - return test.endsWith(".jar") && !test.endsWith("robocode.jar"); - } - }); - - if (files != null) { - for (File file : files) { - final String name = file.toString().toLowerCase(); - - if (name.contains("robocode.core")) { - foundCore = true; - urls.add(file.toURI().toURL()); - } - if (name.contains("picocontainer")) { - urls.add(file.toURI().toURL()); - } - if (name.contains("codesize")) { - urls.add(file.toURI().toURL()); - } - classPath.append(File.pathSeparator); - classPath.append(file.toString()); - } - } - return new URLClassLoader(urls.toArray(new URL[urls.size()]), loader); - } - - public static boolean isCriticalEvent(Event e) { - return eventHelper.isCriticalEvent(e); - } - - public static void setEventTime(Event e, long newTime) { - eventHelper.setTime(e, newTime); - } - - public static void setEventPriority(Event e, int newPriority) { - eventHelper.setPriority(e, newPriority); - } - - public static void dispatch(Event event, IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - eventHelper.dispatch(event, robot, statics, graphics); - } - - public static void setDefaultPriority(Event e) { - eventHelper.setDefaultPriority(e); - } - - public static byte getSerializationType(Event e) { - return eventHelper.getSerializationType(e); - } - - public static void update(Bullet bullet, double x, double y, String victimName, boolean isActive) { - bulletHelper.update(bullet, x, y, victimName, isActive); - } - - public static RobotSpecification createSpecification(Object fileSpecification, String name, String author, String webpage, String version, String robocodeVersion, String jarFile, String fullClassName, String description) { - return specificationHelper.createSpecification(fileSpecification, name, author, webpage, version, - robocodeVersion, jarFile, fullClassName, description); - } - - public static Object getFileSpecification(RobotSpecification specification) { - return specificationHelper.getFileSpecification(specification); - } - - public static String getRobotTeamName(RobotSpecification specification) { - return specificationHelper.getTeamName(specification); - } - - public static void setTeamId(RobotSpecification specification, String teamName) { - specificationHelper.setTeamName(specification, teamName); - } - - public static RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading, double radarHeading, double velocity, - double bodyTurnRemaining, double radarTurnRemaining, double gunTurnRemaining, double distanceRemaining, double gunHeat, int others, - int numSentries, int roundNum, int numRounds, long time) { - return statusHelper.createStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, - bodyTurnRemaining, radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries, - roundNum, numRounds, time); - } - - public static BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime, boolean hideEnemyNames, int sentryBorderSize) { - return rulesHelper.createRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, - hideEnemyNames, sentryBorderSize); - } - - public static boolean isSafeThread() { - final IThreadManagerBase threadManager = ContainerBase.getComponent(IThreadManagerBase.class); - - return threadManager != null && threadManager.isSafeThread(); - } - - public static void initContainerForRobotEngine(File robocodeHome, IBattleListener listener) { - init(); - try { - initContainerRe.invoke(null, robocodeHome, listener); - } catch (IllegalAccessException e) { - Logger.logError(e); - } catch (InvocationTargetException e) { - Logger.logError(e.getCause()); - Logger.logError(e); - } - } - - public static void initContainer() { - init(); - try { - initContainer.invoke(null); - } catch (IllegalAccessException e) { - Logger.logError(e); - } catch (InvocationTargetException e) { - Logger.logError(e.getCause()); - Logger.logError(e); - } - } - - public static void cleanup() { - init(); - try { - cleanup.invoke(null); - } catch (IllegalAccessException e) { - Logger.logError(e); - } catch (InvocationTargetException e) { - Logger.logError(e.getCause()); - Logger.logError(e); - } - } - - public static void robocodeMain(final String[] args) { - init(); - try { - robocodeMain.invoke(null, (Object) args); - } catch (IllegalAccessException e) { - Logger.logError(e); - } catch (InvocationTargetException e) { - Logger.logError(e.getCause()); - Logger.logError(e); - } - } - -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenBulletHelper.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenBulletHelper.java deleted file mode 100644 index 08b8b67..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenBulletHelper.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.security; - - -import robocode.Bullet; - - -/** - * @author Pavel Savara (original) - */ -public interface IHiddenBulletHelper { - void update(Bullet bullet, double x, double y, String victimName, boolean isActive); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenEventHelper.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenEventHelper.java deleted file mode 100644 index 8c6d2e0..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenEventHelper.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.security; - - -import net.sf.robocode.peer.IRobotStatics; -import robocode.Event; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; - - -/** - * @author Pavel Savara (original) - */ -public interface IHiddenEventHelper { - void setDefaultPriority(Event event); - void setPriority(Event event, int newPriority); - void setTime(Event event, long newTime); - boolean isCriticalEvent(Event event); - void dispatch(Event event, IBasicRobot robot, IRobotStatics statics, Graphics2D graphics); - byte getSerializationType(Event event); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenRulesHelper.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenRulesHelper.java deleted file mode 100644 index 85dec02..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenRulesHelper.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.security; - - -import robocode.BattleRules; - - -/** - * @author Pavel Savara (original) - */ -public interface IHiddenRulesHelper { - BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime, boolean hideEnemyNames, int sentryBorderSizes); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenSpecificationHelper.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenSpecificationHelper.java deleted file mode 100644 index 05bc943..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenSpecificationHelper.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.security; - - -import robocode.control.RobotSpecification; - - -/** - * @author Pavel Savara (original) - */ -public interface IHiddenSpecificationHelper { - - RobotSpecification createSpecification(Object specification, String name, String author, String webpage, String version, String robocodeVersion, String jarFile, String fullClassName, String description); - Object getFileSpecification(RobotSpecification specification); - void setTeamName(RobotSpecification specification, String teamName); - String getTeamName(RobotSpecification specification); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenStatusHelper.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenStatusHelper.java deleted file mode 100644 index 8bff082..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IHiddenStatusHelper.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.security; - - -import robocode.RobotStatus; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public interface IHiddenStatusHelper { - RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading, double radarHeading, - double velocity, double bodyTurnRemaining, double radarTurnRemaining, double gunTurnRemaining, - double distanceRemaining, double gunHeat, int others, int numSentries, int roundNum, int numRounds, long time); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IThreadManagerBase.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IThreadManagerBase.java deleted file mode 100644 index b69d1cd..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/IThreadManagerBase.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.security; - - -import java.io.FileOutputStream; -import java.io.IOException; - - -/** - * @author Pavel Savara (original) - */ -public interface IThreadManagerBase { - boolean isSafeThread(); - FileOutputStream createRobotFileStream(String fileName, boolean append) throws IOException; -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/SafeComponent.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/SafeComponent.java deleted file mode 100644 index 74d96a9..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/security/SafeComponent.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.security; - - -import java.awt.*; - - -/** - * @author Pavel Savara (original) - */ -@SuppressWarnings("serial") -public class SafeComponent extends Component { - // Dummy component used to preventing robots in accessing the real source component - private static Component safeEventComponent; - - public static Component getSafeEventComponent() { - if (safeEventComponent == null) { - safeEventComponent = new SafeComponent(); - } - return safeEventComponent; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/serialization/ISerializableHelper.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/serialization/ISerializableHelper.java deleted file mode 100644 index 97ef510..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/serialization/ISerializableHelper.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.serialization; - - -import java.nio.ByteBuffer; - - -/** - * @author Pavel Savara (original) - */ -public interface ISerializableHelper { - int sizeOf(RbSerializer serializer, Object object); - void serialize(RbSerializer serializer, ByteBuffer buffer, Object object); - Object deserialize(RbSerializer serializer, ByteBuffer buffer); -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/serialization/RbSerializer.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/serialization/RbSerializer.java deleted file mode 100644 index 3a01c8e..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/serialization/RbSerializer.java +++ /dev/null @@ -1,539 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.serialization; - - -import net.sf.robocode.core.ContainerBase; -import net.sf.robocode.io.Logger; -import net.sf.robocode.manager.IVersionManagerBase; -import net.sf.robocode.security.HiddenAccess; -import robocode.Event; - -import java.io.*; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; -import java.nio.ByteBuffer; -import java.nio.CharBuffer; -import java.nio.charset.*; -import java.util.HashMap; -import java.util.Map; - - -/** - * @author Pavel Savara (original) - */ -public final class RbSerializer { - public final static int SIZEOF_TYPEINFO = 1; - public final static int SIZEOF_BYTE = 1; - public final static int SIZEOF_BOOL = 1; - public final static int SIZEOF_CHAR = 2; - public final static int SIZEOF_INT = 4; - public final static int SIZEOF_LONG = 8; - public final static int SIZEOF_DOUBLE = 8; - - public final static byte TERMINATOR_TYPE = -1; - public final static byte ExecCommands_TYPE = 1; - public final static byte BulletCommand_TYPE = 2; - public final static byte TeamMessage_TYPE = 3; - public final static byte DebugProperty_TYPE = 4; - public final static byte ExecResults_TYPE = 5; - public final static byte RobotStatus_TYPE = 6; - public final static byte BulletStatus_TYPE = 7; - public final static byte BattleResults_TYPE = 8; - public final static byte Bullet_TYPE = 9; - public final static byte RobotStatics_TYPE = 10; - - public final static byte BattleEndedEvent_TYPE = 32; - public final static byte BulletHitBulletEvent_TYPE = 33; - public final static byte BulletHitEvent_TYPE = 34; - public final static byte BulletMissedEvent_TYPE = 35; - public final static byte DeathEvent_TYPE = 36; - public final static byte WinEvent_TYPE = 37; - public final static byte HitWallEvent_TYPE = 38; - public final static byte RobotDeathEvent_TYPE = 39; - public final static byte SkippedTurnEvent_TYPE = 40; - public final static byte ScannedRobotEvent_TYPE = 41; - public final static byte HitByBulletEvent_TYPE = 42; - public final static byte HitRobotEvent_TYPE = 43; - public final static byte KeyPressedEvent_TYPE = 44; - public final static byte KeyReleasedEvent_TYPE = 45; - public final static byte KeyTypedEvent_TYPE = 46; - public final static byte MouseClickedEvent_TYPE = 47; - public final static byte MouseDraggedEvent_TYPE = 48; - public final static byte MouseEnteredEvent_TYPE = 49; - public final static byte MouseExitedEvent_TYPE = 50; - public final static byte MouseMovedEvent_TYPE = 51; - public final static byte MousePressedEvent_TYPE = 52; - public final static byte MouseReleasedEvent_TYPE = 53; - public final static byte MouseWheelMovedEvent_TYPE = 54; - public final static byte RoundEndedEvent_TYPE = 55; - - private final static ISerializableHelper[] typeToHelper = new ISerializableHelper[256]; - private static Map, Byte> classToType = new HashMap, Byte>(); - private final static Charset charset; - private final CharsetEncoder encoder; - private final CharsetDecoder decoder; - - private static final int BYTE_ORDER = 0xC0DEDEA1; - private final int currentVersion; - - static { - charset = Charset.forName("UTF8"); // we will use it as UCS-2 - register(null, TERMINATOR_TYPE); // reserved for end of (list) element - } - - public RbSerializer() { - this.currentVersion = ContainerBase.getComponent(IVersionManagerBase.class).getVersionAsInt(); - encoder = charset.newEncoder(); - encoder.onMalformedInput(CodingErrorAction.REPORT); - encoder.onUnmappableCharacter(CodingErrorAction.REPLACE); - // throw away forst bom - ByteBuffer buffer = ByteBuffer.allocate(8); - - encoder.encode(CharBuffer.wrap("BOM"), buffer, false); - - decoder = charset.newDecoder(); - decoder.onMalformedInput(CodingErrorAction.REPORT); - decoder.onUnmappableCharacter(CodingErrorAction.REPLACE); - } - - public void serialize(OutputStream target, byte type, Object object) throws IOException { - int length = sizeOf(type, object); - - // header - ByteBuffer buffer = ByteBuffer.allocate(SIZEOF_INT + SIZEOF_INT + SIZEOF_INT); - - buffer.putInt(BYTE_ORDER); - buffer.putInt(currentVersion); - buffer.putInt(length); - target.write(buffer.array()); - - // body - buffer = ByteBuffer.allocate(length); - serialize(buffer, type, object); - if (buffer.remaining() != 0) { - throw new IOException("Serialization failed: bad size"); - } - target.write(buffer.array()); - } - - public ByteBuffer serialize(byte type, Object object) throws IOException { - int length = sizeOf(type, object); - - // header - ByteBuffer buffer = ByteBuffer.allocateDirect(SIZEOF_INT + SIZEOF_INT + SIZEOF_INT + length); - - buffer.putInt(BYTE_ORDER); - buffer.putInt(currentVersion); - buffer.putInt(length); - - // body - serialize(buffer, type, object); - if (buffer.remaining() != 0) { - throw new IOException("Serialization failed: bad size"); - } - return buffer; - } - - public ByteBuffer serializeToBuffer(ByteBuffer buffer, byte type, Object object) throws IOException { - int length = sizeOf(type, object); - - buffer.limit(SIZEOF_INT + SIZEOF_INT + SIZEOF_INT + length); - - buffer.putInt(BYTE_ORDER); - buffer.putInt(currentVersion); - buffer.putInt(length); - - // body - serialize(buffer, type, object); - if (buffer.remaining() != 0) { - throw new IOException("Serialization failed: bad size"); - } - return buffer; - } - - public Object deserialize(InputStream source) throws IOException { - // header - ByteBuffer buffer = ByteBuffer.allocate(SIZEOF_INT + SIZEOF_INT + SIZEOF_INT); - - fillBuffer(source, buffer); - buffer.flip(); - int bo = buffer.getInt(); - - if (bo != BYTE_ORDER) { - throw new IOException("Different byte order is not supported"); - } - int version = buffer.getInt(); - - if (version != currentVersion) { - throw new IOException("Version of data is not supported. We support only strong match"); - } - int length = buffer.getInt(); - - // body - buffer = ByteBuffer.allocate(length); - fillBuffer(source, buffer); - buffer.flip(); - final Object res = deserializeAny(buffer); - - if (buffer.remaining() != 0) { - throw new IOException("Serialization failed"); - } - return res; - } - - public Object deserialize(final ByteBuffer buffer) throws IOException { - int bo = buffer.getInt(); - - if (bo != BYTE_ORDER) { - throw new IOException("Different byte order is not supported"); - } - - int version = buffer.getInt(); - - if (version != currentVersion) { - throw new IOException("Version of data is not supported. We support only strong match"); - } - int length = buffer.getInt(); - - if (length != buffer.remaining()) { - throw new IOException("Wrong buffer size, " + length + "expected but got " + buffer.remaining()); - } - - // body - final Object res = deserializeAny(buffer); - - if (buffer.remaining() != 0) { - throw new IOException("Serialization failed"); - } - return res; - } - - public void serialize(ByteBuffer buffer, byte type, Object object) { - ISerializableHelper helper = getHelper(type); - - // FOR-DEBUG int expect = sizeOf(type, object) + buffer.position(); - - if (object != null) { - buffer.put(type); - helper.serialize(this, buffer, object); - } else { - buffer.put(TERMINATOR_TYPE); - } - // FOR-DEBUG if (expect != buffer.position()) { - // FOR-DEBUG throw new Error("Bad size"); - // FOR-DEBUG } - } - - public void serialize(ByteBuffer buffer, String data) { - if (data == null) { - buffer.putInt(-1); - } else { - ByteBuffer slice = encode(data); - - buffer.putInt(slice.limit()); - buffer.put(slice); - } - } - - public void serialize(ByteBuffer buffer, byte[] data) { - if (data == null) { - buffer.putInt(-1); - } else { - buffer.putInt(data.length); - buffer.put(data); - } - } - - public void serialize(ByteBuffer buffer, int[] data) { - if (data == null) { - buffer.putInt(-1); - } else { - buffer.putInt(data.length); - for (int aData : data) { - buffer.putInt(aData); - } - } - } - - public void serialize(ByteBuffer buffer, char[] data) { - if (data == null) { - buffer.putInt(-1); - } else { - buffer.putInt(data.length); - for (char aData : data) { - buffer.putChar(aData); - } - } - } - - public void serialize(ByteBuffer buffer, double[] data) { - if (data == null) { - buffer.putInt(-1); - } else { - buffer.putInt(data.length); - for (double aData : data) { - buffer.putDouble(aData); - } - } - } - - public void serialize(ByteBuffer buffer, float[] data) { - if (data == null) { - buffer.putInt(-1); - } else { - buffer.putInt(data.length); - for (float aData : data) { - buffer.putFloat(aData); - } - } - } - - public void serialize(ByteBuffer buffer, boolean value) { - buffer.put((byte) (value ? 1 : 0)); - } - - public void serialize(ByteBuffer buffer, double value) { - buffer.putDouble(value); - } - - public void serialize(ByteBuffer buffer, char value) { - buffer.putChar(value); - } - - public void serialize(ByteBuffer buffer, long value) { - buffer.putLong(value); - } - - public void serialize(ByteBuffer buffer, int value) { - buffer.putInt(value); - } - - public void serialize(ByteBuffer buffer, Event event) { - final byte type = HiddenAccess.getSerializationType(event); - - serialize(buffer, type, event); - } - - public Object deserializeAny(ByteBuffer buffer) { - final byte type = buffer.get(); - - if (type == TERMINATOR_TYPE) { - return null; - } - return getHelper(type).deserialize(this, buffer); - } - - public String deserializeString(ByteBuffer buffer) { - final int bytes = buffer.getInt(); - - if (bytes == -1) { - return null; - } - final ByteBuffer slice = buffer.slice(); - - slice.limit(bytes); - final String res; - - try { - res = decoder.decode(slice).toString(); - } catch (CharacterCodingException e) { - throw new Error("Bad character", e); - } - buffer.position(buffer.position() + bytes); - return res; - } - - public byte[] deserializeBytes(ByteBuffer buffer) { - final int len = buffer.getInt(); - - if (len == -1) { - return null; - } - byte[] res = new byte[len]; - - buffer.get(res); - return res; - } - - public int[] deserializeIntegers(ByteBuffer buffer) { - final int len = buffer.getInt(); - - if (len == -1) { - return null; - } - int[] res = new int[len]; - - for (int i = 0; i < len; i++) { - res[i] = buffer.getInt(); - } - return res; - } - - public float[] deserializeFloats(ByteBuffer buffer) { - final int len = buffer.getInt(); - - if (len == -1) { - return null; - } - float[] res = new float[len]; - - for (int i = 0; i < len; i++) { - res[i] = buffer.getFloat(); - } - return res; - } - - public char[] deserializeChars(ByteBuffer buffer) { - final int len = buffer.getInt(); - - if (len == -1) { - return null; - } - char[] res = new char[len]; - - for (int i = 0; i < len; i++) { - res[i] = buffer.getChar(); - } - return res; - } - - public double[] deserializeDoubles(ByteBuffer buffer) { - final int len = buffer.getInt(); - - if (len == -1) { - return null; - } - double[] res = new double[len]; - - for (int i = 0; i < len; i++) { - res[i] = buffer.getDouble(); - } - return res; - } - - public boolean deserializeBoolean(ByteBuffer buffer) { - return buffer.get() != 0; - } - - public char deserializeChar(ByteBuffer buffer) { - return buffer.getChar(); - } - - public int deserializeInt(ByteBuffer buffer) { - return buffer.getInt(); - } - - public Float deserializeFloat(ByteBuffer buffer) { - return buffer.getFloat(); - } - - public double deserializeDouble(ByteBuffer buffer) { - return buffer.getDouble(); - } - - public long deserializeLong(ByteBuffer buffer) { - return buffer.getLong(); - } - - public int sizeOf(String data) { - return (data == null) ? SIZEOF_INT : SIZEOF_INT + encode(data).limit(); - } - - public int sizeOf(byte[] data) { - return (data == null) ? SIZEOF_INT : SIZEOF_INT + data.length; - } - - public int sizeOf(byte type, Object object) { - return getHelper(type).sizeOf(this, object); - } - - public int sizeOf(Event event) { - return sizeOf(HiddenAccess.getSerializationType(event), event); - } - - private ISerializableHelper getHelper(byte type) { - final ISerializableHelper helper = typeToHelper[type]; - - if (helper == null) { - throw new Error("Unknownd or unsupported data type"); - } - return helper; - } - - private ByteBuffer encode(String data) { - final ByteBuffer slice = ByteBuffer.allocate(data.length() * 3); - - encoder.encode(CharBuffer.wrap(data), slice, false); - slice.flip(); - return slice; - } - - private void fillBuffer(InputStream source, ByteBuffer buffer) throws IOException { - int res; - - do { - res = source.read(buffer.array(), buffer.position(), buffer.remaining()); - if (res == -1) { - throw new IOException("Unexpected EOF"); - } - buffer.position(buffer.position() + res); - } while (buffer.remaining() != 0); - } - - public static void register(Class realClass, byte type) { - try { - if (realClass != null) { - Method method = realClass.getDeclaredMethod("createHiddenSerializer"); - - method.setAccessible(true); - ISerializableHelper helper = (ISerializableHelper) method.invoke(null); - - method.setAccessible(false); - typeToHelper[type] = helper; - classToType.put(realClass, type); - } - } catch (NoSuchMethodException e) { - Logger.logError(e); - } catch (InvocationTargetException e) { - Logger.logError(e); - } catch (IllegalAccessException e) { - Logger.logError(e); - } - } - - public static ByteBuffer serializeToBuffer(Object src) throws IOException { - RbSerializer rbs = new RbSerializer(); - final Byte type = classToType.get(src.getClass()); - - return rbs.serialize(type, src); - } - - @SuppressWarnings({ "unchecked"}) - public static T deserializeFromBuffer(ByteBuffer buffer) throws IOException { - RbSerializer rbs = new RbSerializer(); - final Object res = rbs.deserialize(buffer); - - return (T) res; - } - - public static Object deepCopy(byte type, Object src) { - ByteArrayOutputStream out = new ByteArrayOutputStream(1024); - RbSerializer rbs = new RbSerializer(); - - try { - rbs.serialize(out, type, src); - ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); - - return rbs.deserialize(in); - } catch (IOException e) { - Logger.logError(e); - return null; - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/util/StringUtil.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/util/StringUtil.java deleted file mode 100644 index 4feb2e3..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/util/StringUtil.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.util; - - -/** - * Class for utilizing strings. - * - * @author Flemming N. Larsen (original) - */ -public final class StringUtil { - - /** - * Returns a string encoded into Basic Latin, where characters that cannot - * be represented in Basic Latin are represented as encoded unicode characters. - * - * @param sequence - * @return - */ - public static String toBasicLatin(CharSequence sequence) { - StringBuilder out = new StringBuilder(); - - for (int i = 0; i < sequence.length(); i++) { - char ch = sequence.charAt(i); - - if (Character.UnicodeBlock.of(ch) == Character.UnicodeBlock.BASIC_LATIN) { - out.append(ch); - } else { - int codepoint = Character.codePointAt(sequence, i); - - // Handle supplementary range chars - i += Character.charCount(codepoint) - 1; - // Emit entity as a unicode character - out.append(String.format("\\u%1$04X", codepoint)); - } - } - return out.toString(); - } - - /** - * Returns the number of occurrences of a specific character. - * - * @param str is the string containing the character to look for. - * @param chr is the character we look for. - * @return the number of occurrences. - */ - public static int countChar(String str, char chr) { - int count = 0; - for (char c : str.toCharArray()) { - if (c == chr) { - count++; - } - } - return count; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/util/UrlUtil.java b/workspace_robo/robocode.api/src/main/java/net/sf/robocode/util/UrlUtil.java deleted file mode 100644 index e2c4372..0000000 --- a/workspace_robo/robocode.api/src/main/java/net/sf/robocode/util/UrlUtil.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.util; - - -/** - * Utility class used for working on URLs. - * - * @author Flemming N. Larsen (original) - */ -public class UrlUtil { - - /** - * Removes a file extension from a string containing a file name, e.g. the string "filename.ext" would become using - * this method "filename". - * - * @param fileName is a string containing a file name with an extension to remove. - * @return a new string where the file extension has been removed from the file name. - * If no extension is found, the input file name is returned. - */ - public static String removeFileExtension(String fileName) { - if (fileName != null) { - int index = fileName.lastIndexOf('.'); - if (index > 0 && index < (fileName.length() - 1)) { - return fileName.substring(0, index); - } - } - return fileName; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/AdvancedRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/AdvancedRobot.java deleted file mode 100644 index e391ceb..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/AdvancedRobot.java +++ /dev/null @@ -1,2027 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import robocode.robotinterfaces.IAdvancedEvents; -import robocode.robotinterfaces.IAdvancedRobot; -import robocode.robotinterfaces.peer.IAdvancedRobotPeer; - -import java.io.File; -import java.util.Vector; - - -/** - * A more advanced type of robot than Robot that allows non-blocking calls, - * custom events, and writes to the filesystem. - *

- * This call returns both positive and negative values. Positive values - * means that the robot is currently moving forwards. Negative values means - * that the robot is currently moving backwards. If the returned value is 0, - * the robot currently stands still. - * - * @return the distance remaining in the robot's current move measured in - * pixels. - * @see #getTurnRemaining() getTurnRemaining() - * @see #getTurnRemainingRadians() getTurnRemainingRadians() - * @see #getGunTurnRemaining() getGunTurnRemaining() - * @see #getGunTurnRemainingRadians() getGunTurnRemainingRadians() - * @see #getRadarTurnRemaining() getRadarTurnRemaining() - * @see #getRadarTurnRemainingRadians() getRadarTurnRemainingRadians() - */ - public double getDistanceRemaining() { - if (peer != null) { - return peer.getDistanceRemaining(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the angle remaining in the robots's turn, in degrees. - *

- * This call returns both positive and negative values. Positive values - * means that the robot is currently turning to the right. Negative values - * means that the robot is currently turning to the left. If the returned - * value is 0, the robot is currently not turning. - * - * @return the angle remaining in the robots's turn, in degrees - * @see #getTurnRemainingRadians() getTurnRemainingRadians() - * @see #getDistanceRemaining() getDistanceRemaining() - * @see #getGunTurnRemaining() getGunTurnRemaining() - * @see #getGunTurnRemainingRadians() getGunTurnRemainingRadians() - * @see #getRadarTurnRemaining() getRadarTurnRemaining() - * @see #getRadarTurnRemainingRadians() getRadarTurnRemainingRadians() - */ - public double getTurnRemaining() { - if (peer != null) { - return Math.toDegrees(peer.getBodyTurnRemaining()); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the angle remaining in the gun's turn, in degrees. - *

- * This call returns both positive and negative values. Positive values - * means that the gun is currently turning to the right. Negative values - * means that the gun is currently turning to the left. If the returned - * value is 0, the gun is currently not turning. - * - * @return the angle remaining in the gun's turn, in degrees - * @see #getGunTurnRemainingRadians() getGunTurnRemainingRadians() - * @see #getDistanceRemaining() getDistanceRemaining() - * @see #getTurnRemaining() getTurnRemaining() - * @see #getTurnRemainingRadians() getTurnRemainingRadians() - * @see #getRadarTurnRemaining() getRadarTurnRemaining() - * @see #getRadarTurnRemainingRadians() getRadarTurnRemainingRadians() - */ - public double getGunTurnRemaining() { - if (peer != null) { - return Math.toDegrees(peer.getGunTurnRemaining()); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the angle remaining in the radar's turn, in degrees. - *

- * This call returns both positive and negative values. Positive values - * means that the radar is currently turning to the right. Negative values - * means that the radar is currently turning to the left. If the returned - * value is 0, the radar is currently not turning. - * - * @return the angle remaining in the radar's turn, in degrees - * @see #getRadarTurnRemainingRadians() getRadarTurnRemainingRadians() - * @see #getDistanceRemaining() getDistanceRemaining() - * @see #getGunTurnRemaining() getGunTurnRemaining() - * @see #getGunTurnRemainingRadians() getGunTurnRemainingRadians() - * @see #getRadarTurnRemaining() getRadarTurnRemaining() - * @see #getRadarTurnRemainingRadians() getRadarTurnRemainingRadians() - */ - public double getRadarTurnRemaining() { - if (peer != null) { - return Math.toDegrees(peer.getRadarTurnRemaining()); - } - uninitializedException(); - return 0; // never called - } - - /** - * Sets the robot to move ahead (forward) by distance measured in pixels - * when the next execution takes place. - *

- * This call returns immediately, and will not execute until you call - * {@link #execute()} or take an action that executes. - *

- * Note that both positive and negative values can be given as input, where - * positive values means that the robot is set to move ahead, and negative - * values means that the robot is set to move back. If 0 is given as input, - * the robot will stop its movement, but will have to decelerate - * till it stands still, and will thus not be able to stop its movement - * immediately, but eventually. - *

- * Example: - *

-	 *   // Set the robot to move 50 pixels ahead
-	 *   setAhead(50);
-	 *
-	 *   // Set the robot to move 100 pixels back
-	 *   // (overrides the previous order)
-	 *   setAhead(-100);
-	 *
-	 *   ...
-	 *   // Executes the last setAhead()
-	 *   execute();
-	 * 
- * - * @param distance the distance to move measured in pixels. - * If {@code distance} > 0 the robot is set to move ahead. - * If {@code distance} < 0 the robot is set to move back. - * If {@code distance} = 0 the robot is set to stop its movement. - * @see #ahead(double) ahead(double) - * @see #back(double) back(double) - * @see #setBack(double) - */ - public void setAhead(double distance) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setMove(distance); - } else { - uninitializedException(); - } - } - - /** - * Sets the robot to move back by distance measured in pixels when the next - * execution takes place. - *

- * This call returns immediately, and will not execute until you call - * {@link #execute()} or take an action that executes. - *

- * Note that both positive and negative values can be given as input, where - * positive values means that the robot is set to move back, and negative - * values means that the robot is set to move ahead. If 0 is given as input, - * the robot will stop its movement, but will have to decelerate - * till it stands still, and will thus not be able to stop its movement - * immediately, but eventually. - *

- * Example: - *

-	 *   // Set the robot to move 50 pixels back
-	 *   setBack(50);
-	 *
-	 *   // Set the robot to move 100 pixels ahead
-	 *   // (overrides the previous order)
-	 *   setBack(-100);
-	 *
-	 *   ...
-	 *   // Executes the last setBack()
-	 *   execute();
-	 * 
- * - * @param distance the distance to move measured in pixels. - * If {@code distance} > 0 the robot is set to move back. - * If {@code distance} < 0 the robot is set to move ahead. - * If {@code distance} = 0 the robot is set to stop its movement. - * @see #back(double) back(double) - * @see #ahead(double) ahead(double) - * @see #setAhead(double) - */ - public void setBack(double distance) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setMove(-distance); - } else { - uninitializedException(); - } - } - - /** - * Sets the robot's body to turn left by degrees when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's body is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Set the robot to turn 180 degrees to the left
-	 *   setTurnLeft(180);
-	 *
-	 *   // Set the robot to turn 90 degrees to the right instead of left
-	 *   // (overrides the previous order)
-	 *   setTurnLeft(-90);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnLeft()
-	 *   execute();
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's body to the left. - * If {@code degrees} > 0 the robot is set to turn left. - * If {@code degrees} < 0 the robot is set to turn right. - * If {@code degrees} = 0 the robot is set to stop turning. - * @see #setTurnLeftRadians(double) setTurnLeftRadians(double) - * @see #turnLeft(double) turnLeft(double) - * @see #turnLeftRadians(double) turnLeftRadians(double) - * @see #turnRight(double) turnRight(double) - * @see #turnRightRadians(double) turnRightRadians(double) - * @see #setTurnRight(double) setTurnRight(double) - * @see #setTurnRightRadians(double) setTurnRightRadians(double) - */ - public void setTurnLeft(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnBody(-Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Sets the robot's body to turn right by degrees when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's body is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Set the robot to turn 180 degrees to the right
-	 *   setTurnRight(180);
-	 *
-	 *   // Set the robot to turn 90 degrees to the left instead of right
-	 *   // (overrides the previous order)
-	 *   setTurnRight(-90);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnRight()
-	 *   execute();
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's body to the right. - * If {@code degrees} > 0 the robot is set to turn right. - * If {@code degrees} < 0 the robot is set to turn left. - * If {@code degrees} = 0 the robot is set to stop turning. - * @see #setTurnRightRadians(double) setTurnRightRadians(double) - * @see #turnRight(double) turnRight(double) - * @see #turnRightRadians(double) turnRightRadians(double) - * @see #turnLeft(double) turnLeft(double) - * @see #turnLeftRadians(double) turnLeftRadians(double) - * @see #setTurnLeft(double) setTurnLeft(double) - * @see #setTurnLeftRadians(double) setTurnLeftRadians(double) - */ - public void setTurnRight(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnBody(Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Sets the gun to fire a bullet when the next execution takes place. - * The bullet will travel in the direction the gun is pointing. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * The specified bullet power is an amount of energy that will be taken from - * the robot's energy. Hence, the more power you want to spend on the - * bullet, the more energy is taken from your robot. - *

- * The bullet will do (4 * power) damage if it hits another robot. If power - * is greater than 1, it will do an additional 2 * (power - 1) damage. - * You will get (3 * power) back if you hit the other robot. You can call - * Rules#getBulletDamage(double)} for getting the damage that a - * bullet with a specific bullet power will do. - *

- * The specified bullet power should be between - * {@link Rules#MIN_BULLET_POWER} and {@link Rules#MAX_BULLET_POWER}. - *

- * Note that the gun cannot fire if the gun is overheated, meaning that - * {@link #getGunHeat()} returns a value > 0. - *

- * An event is generated when the bullet hits a robot, wall, or another - * bullet. - *

- * Example: - *

-	 *   // Fire a bullet with maximum power if the gun is ready
-	 *   if (getGunHeat() == 0) {
-	 *       setFire(Rules.MAX_BULLET_POWER);
-	 *   }
-	 *   ...
-	 *   execute();
-	 * 
- * - * @param power the amount of energy given to the bullet, and subtracted - * from the robot's energy. - * @see #setFireBullet(double) - * @see #fire(double) fire(double) - * @see #fireBullet(double) fireBullet(double) - * @see #getGunHeat() getGunHeat() - * @see #getGunCoolingRate() getGunCoolingRate() - * @see #onBulletHit(BulletHitEvent) onBulletHit(BulletHitEvent) - * @see #onBulletHitBullet(BulletHitBulletEvent) onBulletHitBullet(BulletHitBulletEvent) - * @see #onBulletMissed(BulletMissedEvent) onBulletMissed(BulletMissedEvent) - */ - public void setFire(double power) { - if (peer != null) { - peer.setFire(power); - } else { - uninitializedException(); - } - } - - /** - * Sets the gun to fire a bullet when the next execution takes place. - * The bullet will travel in the direction the gun is pointing. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * The specified bullet power is an amount of energy that will be taken from - * the robot's energy. Hence, the more power you want to spend on the - * bullet, the more energy is taken from your robot. - *

- * The bullet will do (4 * power) damage if it hits another robot. If power - * is greater than 1, it will do an additional 2 * (power - 1) damage. - * You will get (3 * power) back if you hit the other robot. You can call - * {@link Rules#getBulletDamage(double)} for getting the damage that a - * bullet with a specific bullet power will do. - *

- * The specified bullet power should be between - * {@link Rules#MIN_BULLET_POWER} and {@link Rules#MAX_BULLET_POWER}. - *

- * Note that the gun cannot fire if the gun is overheated, meaning that - * {@link #getGunHeat()} returns a value > 0. - *

- * A event is generated when the bullet hits a robot - * ({@link BulletHitEvent}), wall ({@link BulletMissedEvent}), or another - * bullet ({@link BulletHitBulletEvent}). - *

- * Example: - *

-	 *   Bullet bullet = null;
-	 * 

- * // Fire a bullet with maximum power if the gun is ready - * if (getGunHeat() == 0) { - * bullet = setFireBullet(Rules.MAX_BULLET_POWER); - * } - * ... - * execute(); - * ... - * // Get the velocity of the bullet - * if (bullet != null) { - * double bulletVelocity = bullet.getVelocity(); - * } - *

- * - * @param power the amount of energy given to the bullet, and subtracted - * from the robot's energy. - * @return a {@link Bullet} that contains information about the bullet if it - * was actually fired, which can be used for tracking the bullet after it - * has been fired. If the bullet was not fired, {@code null} is returned. - * @see #setFire(double) - * @see Bullet - * @see #fire(double) fire(double) - * @see #fireBullet(double) fireBullet(double) - * @see #getGunHeat() getGunHeat() - * @see #getGunCoolingRate() getGunCoolingRate() - * @see #onBulletHit(BulletHitEvent) onBulletHit(BulletHitEvent) - * @see #onBulletHitBullet(BulletHitBulletEvent) onBulletHitBullet(BulletHitBulletEvent) - * @see #onBulletMissed(BulletMissedEvent) onBulletMissed(BulletMissedEvent) - */ - public Bullet setFireBullet(double power) { - if (peer != null) { - return peer.setFire(power); - } - uninitializedException(); - return null; - } - - /** - * Registers a custom event to be called when a condition is met. - * When you are finished with your condition or just want to remove it you - * must call {@link #removeCustomEvent(Condition)}. - *

- * Example: - *

-	 *   // Create the condition for our custom event
-	 *   Condition triggerHitCondition = new Condition("triggerhit") {
-	 *       public boolean test() {
-	 *           return (getEnergy() <= trigger);
-	 *       }
-	 *   }
-	 *
-	 *   // Add our custom event based on our condition
-	 *   addCustomEvent(triggerHitCondition);
-	 * 
- * - * @param condition the condition that must be met. - * @throws NullPointerException if the condition parameter has been set to - * {@code null}. - * @see Condition - * @see #removeCustomEvent(Condition) - */ - public void addCustomEvent(Condition condition) { - if (condition == null) { - throw new NullPointerException("the condition cannot be null"); - } - if (peer != null) { - ((IAdvancedRobotPeer) peer).addCustomEvent(condition); - } else { - uninitializedException(); - } - } - - /** - * Removes a custom event that was previously added by calling - * {@link #addCustomEvent(Condition)}. - *

- * Example: - *

-	 *   // Create the condition for our custom event
-	 *   Condition triggerHitCondition = new Condition("triggerhit") {
-	 *       public boolean test() {
-	 *           return (getEnergy() <= trigger);
-	 *       }
-	 *   }
-	 *
-	 *   // Add our custom event based on our condition
-	 *   addCustomEvent(triggerHitCondition);
-	 *   ...
-	 *   do something with your robot
-	 *   ...
-	 *   // Remove the custom event based on our condition
-	 *   removeCustomEvent(triggerHitCondition);
-	 * 
- * - * @param condition the condition that was previous added and that must be - * removed now. - * @throws NullPointerException if the condition parameter has been set to - * {@code null}. - * @see Condition - * @see #addCustomEvent(Condition) - */ - public void removeCustomEvent(Condition condition) { - if (condition == null) { - throw new NullPointerException("the condition cannot be null"); - } - if (peer != null) { - ((IAdvancedRobotPeer) peer).removeCustomEvent(condition); - } else { - uninitializedException(); - } - } - - /** - * Clears out any pending events in the robot's event queue immediately. - * - * @see #getAllEvents() - */ - public void clearAllEvents() { - if (peer != null) { - ((IAdvancedRobotPeer) peer).clearAllEvents(); - } else { - uninitializedException(); - } - } - - /** - * Executes any pending actions, or continues executing actions that are - * in process. This call returns after the actions have been started. - *

- * Note that advanced robots must call this function in order to - * execute pending set* calls like e.g. {@link #setAhead(double)}, - * {@link #setFire(double)}, {@link #setTurnLeft(double)} etc. Otherwise, - * these calls will never get executed. - *

- * In this example the robot will move while turning: - *

-	 *   setTurnRight(90);
-	 *   setAhead(100);
-	 *   execute();
-	 *
-	 *   while (getDistanceRemaining() > 0 && getTurnRemaining() > 0) {
-	 *       execute();
-	 *   }
-	 * 
- */ - public void execute() { - if (peer != null) { - peer.execute(); - } else { - uninitializedException(); - } - } - - /** - * Returns a vector containing all events currently in the robot's queue. - * You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (Event event : getAllEvents()) {
-	 *       if (event instanceof HitRobotEvent) {
-	 *           // do something with the event
-	 *       } else if (event instanceof HitByBulletEvent) {
-	 *           // do something with the event
-	 *       }
-	 *   }
-	 * 
- * - * @return a vector containing all events currently in the robot's queue - * @see Event - * @see #clearAllEvents() - * @see #getStatusEvents() - * @see #getScannedRobotEvents() - * @see #getBulletHitEvents() - * @see #getBulletMissedEvents() - * @see #getBulletHitBulletEvents() - * @see #getRobotDeathEvents() - */ - public Vector getAllEvents() { - if (peer != null) { - return new Vector(((IAdvancedRobotPeer) peer).getAllEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns a vector containing all BulletHitBulletEvents currently in the - * robot's queue. You might, for example, call this while processing another - * event. - *

- * Example: - *

-	 *   for (BulletHitBulletEvent event : getBulletHitBulletEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all BulletHitBulletEvents currently in the - * robot's queue - * @see #onBulletHitBullet(BulletHitBulletEvent) onBulletHitBullet(BulletHitBulletEvent) - * @see BulletHitBulletEvent - * @see #getAllEvents() - */ - public Vector getBulletHitBulletEvents() { - if (peer != null) { - return new Vector(((IAdvancedRobotPeer) peer).getBulletHitBulletEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns a vector containing all BulletHitEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (BulletHitEvent event: getBulletHitEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all BulletHitEvents currently in the robot's - * queue - * @see #onBulletHit(BulletHitEvent) onBulletHit(BulletHitEvent) - * @see BulletHitEvent - * @see #getAllEvents() - */ - public Vector getBulletHitEvents() { - if (peer != null) { - return new Vector(((IAdvancedRobotPeer) peer).getBulletHitEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns a vector containing all BulletMissedEvents currently in the - * robot's queue. You might, for example, call this while processing another - * event. - *

- * Example: - *

-	 *   for (BulletMissedEvent event : getBulletMissedEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all BulletMissedEvents currently in the - * robot's queue - * @see #onBulletMissed(BulletMissedEvent) onBulletMissed(BulletMissedEvent) - * @see BulletMissedEvent - * @see #getAllEvents() - */ - public Vector getBulletMissedEvents() { - if (peer != null) { - return new Vector(((IAdvancedRobotPeer) peer).getBulletMissedEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns a file representing a data directory for the robot, which can be - * written to using {@link RobocodeFileOutputStream} or - * {@link RobocodeFileWriter}. - *

- * The system will automatically create the directory for you, so you do not - * need to create it by yourself. - * - * @return a file representing the data directory for your robot - * @see #getDataFile(String) - * @see RobocodeFileOutputStream - * @see RobocodeFileWriter - */ - public File getDataDirectory() { - if (peer != null) { - return ((IAdvancedRobotPeer) peer).getDataDirectory(); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns a file in your data directory that you can write to using - * {@link RobocodeFileOutputStream} or {@link RobocodeFileWriter}. - *

- * The system will automatically create the directory for you, so you do not - * need to create it by yourself. - *

- * Please notice that the max. size of your data file is set to 200000 - * (~195 KB). - *

- * See the {@code sample.SittingDuck} to see an example of how to use this - * method. - * - * @param filename the file name of the data file for your robot - * @return a file representing the data file for your robot or null if the data - * file could not be created due to an error. - * @see #getDataDirectory() - * @see RobocodeFileOutputStream - * @see RobocodeFileWriter - */ - public File getDataFile(String filename) { - if (peer != null) { - return ((IAdvancedRobotPeer) peer).getDataFile(filename); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns the data quota available in your data directory, i.e. the amount - * of bytes left in the data directory for the robot. - * - * @return the amount of bytes left in the robot's data directory - * @see #getDataDirectory() - * @see #getDataFile(String) - */ - public long getDataQuotaAvailable() { - if (peer != null) { - return ((IAdvancedRobotPeer) peer).getDataQuotaAvailable(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the current priority of a class of events. - * An event priority is a value from 0 - 99. The higher value, the higher - * priority. - *

- * Example: - *

-	 *   int myHitRobotPriority = getEventPriority("HitRobotEvent");
-	 * 
- *

- * The default priorities are, from highest to lowest: - *

-	 *   {@link RoundEndedEvent}:      100 (reserved)
-	 *   {@link BattleEndedEvent}:     100 (reserved)
-	 *   {@link WinEvent}:             100 (reserved)
-	 *   {@link SkippedTurnEvent}:     100 (reserved)
-	 *   {@link StatusEvent}:           99
-	 *   Key and mouse events:  98
-	 *   {@link CustomEvent}:           80 (default value)
-	 *   {@link MessageEvent}:          75
-	 *   {@link RobotDeathEvent}:       70
-	 *   {@link BulletMissedEvent}:     60
-	 *   {@link BulletHitBulletEvent}:  55
-	 *   {@link BulletHitEvent}:        50
-	 *   {@link HitByBulletEvent}:      40
-	 *   {@link HitWallEvent}:          30
-	 *   {@link HitRobotEvent}:         20
-	 *   {@link ScannedRobotEvent}:     10
-	 *   {@link PaintEvent}:             5
-	 *   {@link DeathEvent}:            -1 (reserved)
-	 * 
- * - * @param eventClass the name of the event class (string) - * @return the current priority of a class of events - * @see #setEventPriority(String, int) - */ - public int getEventPriority(String eventClass) { - if (peer != null) { - return ((IAdvancedRobotPeer) peer).getEventPriority(eventClass); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns a vector containing all HitByBulletEvents currently in the - * robot's queue. You might, for example, call this while processing - * another event. - *

- * Example: - *

-	 *   for (HitByBulletEvent event : getHitByBulletEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all HitByBulletEvents currently in the - * robot's queue - * @see #onHitByBullet(HitByBulletEvent) onHitByBullet(HitByBulletEvent) - * @see HitByBulletEvent - * @see #getAllEvents() - */ - public Vector getHitByBulletEvents() { - if (peer != null) { - return new Vector(((IAdvancedRobotPeer) peer).getHitByBulletEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns a vector containing all HitRobotEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (HitRobotEvent event : getHitRobotEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all HitRobotEvents currently in the robot's - * queue - * @see #onHitRobot(HitRobotEvent) onHitRobot(HitRobotEvent) - * @see HitRobotEvent - * @see #getAllEvents() - */ - public Vector getHitRobotEvents() { - if (peer != null) { - return new Vector(((IAdvancedRobotPeer) peer).getHitRobotEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns a vector containing all HitWallEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (HitWallEvent event : getHitWallEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all HitWallEvents currently in the robot's - * queue - * @see #onHitWall(HitWallEvent) onHitWall(HitWallEvent) - * @see HitWallEvent - * @see #getAllEvents() - */ - public Vector getHitWallEvents() { - if (peer != null) { - return new Vector(((IAdvancedRobotPeer) peer).getHitWallEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns a vector containing all RobotDeathEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (RobotDeathEvent event : getRobotDeathEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all RobotDeathEvents currently in the robot's - * queue - * @see #onRobotDeath(RobotDeathEvent) onRobotDeath(RobotDeathEvent) - * @see RobotDeathEvent - * @see #getAllEvents() - */ - public Vector getRobotDeathEvents() { - if (peer != null) { - return new Vector(((IAdvancedRobotPeer) peer).getRobotDeathEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns a vector containing all ScannedRobotEvents currently in the - * robot's queue. You might, for example, call this while processing another - * event. - *

- * Example: - *

-	 *   for (ScannedRobotEvent event : getScannedRobotEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all ScannedRobotEvents currently in the - * robot's queue - * @see #onScannedRobot(ScannedRobotEvent) onScannedRobot(ScannedRobotEvent) - * @see ScannedRobotEvent - * @see #getAllEvents() - */ - public Vector getScannedRobotEvents() { - if (peer != null) { - return new Vector(((IAdvancedRobotPeer) peer).getScannedRobotEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns a vector containing all StatusEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (StatusEvent event : getStatusEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all StatusEvents currently in the robot's queue - * @see #onStatus(StatusEvent) onStatus(StatusEvent) - * @see StatusEvent - * @see #getAllEvents() - * @since 1.6.1 - */ - public Vector getStatusEvents() { - if (peer != null) { - return new Vector(((IAdvancedRobotPeer) peer).getStatusEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Checks if the gun is set to adjust for the robot turning, i.e. to turn - * independent from the robot's body turn. - *

- * This call returns {@code true} if the gun is set to turn independent of - * the turn of the robot's body. Otherwise, {@code false} is returned, - * meaning that the gun is set to turn with the robot's body turn. - * - * @return {@code true} if the gun is set to turn independent of the robot - * turning; {@code false} if the gun is set to turn with the robot - * turning - * @see #setAdjustGunForRobotTurn(boolean) setAdjustGunForRobotTurn(boolean) - * @see #isAdjustRadarForRobotTurn() - * @see #isAdjustRadarForGunTurn() - */ - public boolean isAdjustGunForRobotTurn() { - if (peer != null) { - return ((IAdvancedRobotPeer) peer).isAdjustGunForBodyTurn(); - } - uninitializedException(); - return false; // never called - } - - /** - * Checks if the radar is set to adjust for the robot turning, i.e. to turn - * independent from the robot's body turn. - *

- * This call returns {@code true} if the radar is set to turn independent of - * the turn of the robot. Otherwise, {@code false} is returned, meaning that - * the radar is set to turn with the robot's turn. - * - * @return {@code true} if the radar is set to turn independent of the robot - * turning; {@code false} if the radar is set to turn with the robot - * turning - * @see #setAdjustRadarForRobotTurn(boolean) setAdjustRadarForRobotTurn(boolean) - * @see #isAdjustGunForRobotTurn() - * @see #isAdjustRadarForGunTurn() - */ - public boolean isAdjustRadarForRobotTurn() { - if (peer != null) { - return ((IAdvancedRobotPeer) peer).isAdjustRadarForBodyTurn(); - } - uninitializedException(); - return false; // never called - } - - /** - * Checks if the radar is set to adjust for the gun turning, i.e. to turn - * independent from the gun's turn. - *

- * This call returns {@code true} if the radar is set to turn independent of - * the turn of the gun. Otherwise, {@code false} is returned, meaning that - * the radar is set to turn with the gun's turn. - * - * @return {@code true} if the radar is set to turn independent of the gun - * turning; {@code false} if the radar is set to turn with the gun - * turning - * @see #setAdjustRadarForGunTurn(boolean) setAdjustRadarForGunTurn(boolean) - * @see #isAdjustGunForRobotTurn() - * @see #isAdjustRadarForRobotTurn() - */ - public boolean isAdjustRadarForGunTurn() { - if (peer != null) { - return ((IAdvancedRobotPeer) peer).isAdjustRadarForGunTurn(); - } - uninitializedException(); - return false; // never called - } - - /** - * {@inheritDoc} - */ - public void onCustomEvent(CustomEvent event) {} - - /** - * Sets the priority of a class of events. - *

- * Events are sent to the onXXX handlers in order of priority. - * Higher priority events can interrupt lower priority events. - * For events with the same priority, newer events are always sent first. - * Valid priorities are 0 - 99, where 100 is reserved and 80 is the default - * priority. - *

- * Example: - *

-	 *   setEventPriority("RobotDeathEvent", 15);
-	 * 
- *

- * The default priorities are, from highest to lowest: - *

-	 * 	 {@link WinEvent}:             100 (reserved)
-	 * 	 {@link SkippedTurnEvent}:     100 (reserved)
-	 *   {@link StatusEvent}:           99
-	 * 	 {@link CustomEvent}:           80
-	 * 	 {@link MessageEvent}:          75
-	 * 	 {@link RobotDeathEvent}:       70
-	 * 	 {@link BulletMissedEvent}:     60
-	 * 	 {@link BulletHitBulletEvent}:  55
-	 * 	 {@link BulletHitEvent}:        50
-	 * 	 {@link HitByBulletEvent}:      40
-	 * 	 {@link HitWallEvent}:          30
-	 * 	 {@link HitRobotEvent}:         20
-	 * 	 {@link ScannedRobotEvent}:     10
-	 *   {@link PaintEvent}:             5
-	 * 	 {@link DeathEvent}:            -1 (reserved)
-	 * 
- *

- * Note that you cannot change the priority for events with the special - * priority value -1 or 100 (reserved) as these event are system events. - * Also note that you cannot change the priority of CustomEvent. - * Instead you must change the priority of the condition(s) for your custom - * event(s). - * - * @param eventClass the name of the event class (string) to set the - * priority for - * @param priority the new priority for that event class - * @see #getEventPriority(String) - * @see #setInterruptible(boolean) - * @since 1.5, the priority of DeathEvent was changed from 100 to -1 in - * order to let robots process pending events on its event queue before - * it dies. When the robot dies, it will not be able to process events. - */ - public void setEventPriority(String eventClass, int priority) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setEventPriority(eventClass, priority); - } else { - uninitializedException(); - } - } - - /** - * Call this during an event handler to allow new events of the same - * priority to restart the event handler. - *

- *

Example: - *

-	 *   public void onScannedRobot(ScannedRobotEvent e) {
-	 *       fire(1);
-	 *       setInterruptible(true);
-	 *       ahead(100); // If you see a robot while moving ahead,
-	 *                   // this handler will start from the top
-	 *                   // Without setInterruptible(true), we wouldn't
-	 *                   // receive scan events at all!
-	 *       // We'll only get here if we don't see a robot during the move.
-	 *       out.println("Ok, I can't see anyone");
-	 *   }
-	 * 
- * - * @param interruptible {@code true} if the event handler should be - * interrupted if new events of the same priority occurs; {@code false} - * otherwise - * @see #setEventPriority(String, int) - * @see Robot#onScannedRobot(ScannedRobotEvent) onScannedRobot(ScannedRobotEvent) - */ - @Override - public void setInterruptible(boolean interruptible) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setInterruptible(interruptible); - } else { - uninitializedException(); - } - } - - /** - * Sets the maximum turn rate of the robot measured in degrees if the robot - * should turn slower than {@link Rules#MAX_TURN_RATE} (10 degress/turn). - * - * @param newMaxTurnRate the new maximum turn rate of the robot measured in - * degrees. Valid values are 0 - {@link Rules#MAX_TURN_RATE} - * @see #turnRight(double) turnRight(double) - * @see #turnLeft(double) turnLeft(double) - * @see #setTurnRight(double) - * @see #setTurnLeft(double) - * @see #setMaxVelocity(double) - */ - public void setMaxTurnRate(double newMaxTurnRate) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setMaxTurnRate(Math.toRadians(newMaxTurnRate)); - } else { - uninitializedException(); - } - } - - /** - * Sets the maximum velocity of the robot measured in pixels/turn if the - * robot should move slower than {@link Rules#MAX_VELOCITY} (8 pixels/turn). - * - * @param newMaxVelocity the new maximum turn rate of the robot measured in - * pixels/turn. Valid values are 0 - {@link Rules#MAX_VELOCITY} - * @see #ahead(double) - * @see #setAhead(double) - * @see #back(double) - * @see #setBack(double) - * @see #setMaxTurnRate(double) - */ - public void setMaxVelocity(double newMaxVelocity) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setMaxVelocity(newMaxVelocity); - } else { - uninitializedException(); - } - } - - /** - * Sets the robot to resume the movement stopped by {@link #stop() stop()} - * or {@link #setStop()}, if any. - *

- * This call returns immediately, and will not execute until you call - * {@link #execute()} or take an action that executes. - * - * @see #resume() resume() - * @see #stop() stop() - * @see #stop(boolean) stop(boolean) - * @see #setStop() - * @see #setStop(boolean) - * @see #execute() - */ - public void setResume() { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setResume(); - } else { - uninitializedException(); - } - } - - /** - * This call is identical to {@link #stop() stop()}, but returns immediately, and - * will not execute until you call {@link #execute()} or take an action that - * executes. - *

- * If there is already movement saved from a previous stop, this will have - * no effect. - *

- * This call is equivalent to calling {@code setStop(false)}; - * - * @see #stop() stop() - * @see #stop(boolean) stop(boolean) - * @see #resume() resume() - * @see #setResume() - * @see #setStop(boolean) - * @see #execute() - */ - public void setStop() { - setStop(false); - } - - /** - * This call is identical to {@link #stop(boolean) stop(boolean)}, but - * returns immediately, and will not execute until you call - * {@link #execute()} or take an action that executes. - *

- * If there is already movement saved from a previous stop, you can - * overwrite it by calling {@code setStop(true)}. - * - * @param overwrite {@code true} if the movement saved from a previous stop - * should be overwritten; {@code false} otherwise. - * @see #stop() stop() - * @see #stop(boolean) stop(boolean) - * @see #resume() resume() - * @see #setResume() - * @see #setStop() - * @see #execute() - */ - public void setStop(boolean overwrite) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setStop(overwrite); - } else { - uninitializedException(); - } - } - - /** - * Sets the robot's gun to turn left by degrees when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's gun is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Set the gun to turn 180 degrees to the left
-	 *   setTurnGunLeft(180);
-	 *
-	 *   // Set the gun to turn 90 degrees to the right instead of left
-	 *   // (overrides the previous order)
-	 *   setTurnGunLeft(-90);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnGunLeft()
-	 *   execute();
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's gun to the left. - * If {@code degrees} > 0 the robot's gun is set to turn left. - * If {@code degrees} < 0 the robot's gun is set to turn right. - * If {@code degrees} = 0 the robot's gun is set to stop turning. - * @see #setTurnGunLeftRadians(double) setTurnGunLeftRadians(double) - * @see #turnGunLeft(double) turnGunLeft(double) - * @see #turnGunLeftRadians(double) turnGunLeftRadians(double) - * @see #turnGunRight(double) turnGunRight(double) - * @see #turnGunRightRadians(double) turnGunRightRadians(double) - * @see #setTurnGunRight(double) setTurnGunRight(double) - * @see #setTurnGunRightRadians(double) setTurnGunRightRadians(double) - * @see #setAdjustGunForRobotTurn(boolean) setAdjustGunForRobotTurn(boolean) - */ - public void setTurnGunLeft(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnGun(-Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Sets the robot's gun to turn right by degrees when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's gun is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Set the gun to turn 180 degrees to the right
-	 *   setTurnGunRight(180);
-	 *
-	 *   // Set the gun to turn 90 degrees to the left instead of right
-	 *   // (overrides the previous order)
-	 *   setTurnGunRight(-90);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnGunRight()
-	 *   execute();
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's gun to the right. - * If {@code degrees} > 0 the robot's gun is set to turn right. - * If {@code degrees} < 0 the robot's gun is set to turn left. - * If {@code degrees} = 0 the robot's gun is set to stop turning. - * @see #setTurnGunRightRadians(double) setTurnGunRightRadians(double) - * @see #turnGunRight(double) turnGunRight(double) - * @see #turnGunRightRadians(double) turnGunRightRadians(double) - * @see #turnGunLeft(double) turnGunLeft(double) - * @see #turnGunLeftRadians(double) turnGunLeftRadians(double) - * @see #setTurnGunLeft(double) setTurnGunLeft(double) - * @see #setTurnGunLeftRadians(double) setTurnGunLeftRadians(double) - * @see #setAdjustGunForRobotTurn(boolean) setAdjustGunForRobotTurn(boolean) - */ - public void setTurnGunRight(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnGun(Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Sets the robot's radar to turn left by degrees when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's radar is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Set the radar to turn 180 degrees to the left
-	 *   setTurnRadarLeft(180);
-	 *
-	 *   // Set the radar to turn 90 degrees to the right instead of left
-	 *   // (overrides the previous order)
-	 *   setTurnRadarLeft(-90);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnRadarLeft()
-	 *   execute();
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's radar to the left. - * If {@code degrees} > 0 the robot's radar is set to turn left. - * If {@code degrees} < 0 the robot's radar is set to turn right. - * If {@code degrees} = 0 the robot's radar is set to stop turning. - * @see #setTurnRadarLeftRadians(double) setTurnRadarLeftRadians(double) - * @see #turnRadarLeft(double) turnRadarLeft(double) - * @see #turnRadarLeftRadians(double) turnRadarLeftRadians(double) - * @see #turnRadarRight(double) turnRadarRight(double) - * @see #turnRadarRightRadians(double) turnRadarRightRadians(double) - * @see #setTurnRadarRight(double) setTurnRadarRight(double) - * @see #setTurnRadarRightRadians(double) setTurnRadarRightRadians(double) - * @see #setAdjustRadarForRobotTurn(boolean) setAdjustRadarForRobotTurn(boolean) - * @see #setAdjustRadarForGunTurn(boolean) setAdjustRadarForGunTurn(boolean) - */ - public void setTurnRadarLeft(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnRadar(-Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Sets the robot's radar to turn right by degrees when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's radar is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Set the radar to turn 180 degrees to the right
-	 *   setTurnRadarRight(180);
-	 *
-	 *   // Set the radar to turn 90 degrees to the right instead of right
-	 *   // (overrides the previous order)
-	 *   setTurnRadarRight(-90);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnRadarRight()
-	 *   execute();
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's radar to the right. - * If {@code degrees} > 0 the robot's radar is set to turn right. - * If {@code degrees} < 0 the robot's radar is set to turn left. - * If {@code degrees} = 0 the robot's radar is set to stop turning. - * @see #setTurnRadarRightRadians(double) setTurnRadarRightRadians(double) - * @see #turnRadarRight(double) turnRadarRight(double) - * @see #turnRadarRightRadians(double) turnRadarRightRadians(double) - * @see #turnRadarLeft(double) turnRadarLeft(double) - * @see #turnRadarLeftRadians(double) turnRadarLeftRadians(double) - * @see #setTurnRadarLeft(double) setTurnRadarLeft(double) - * @see #setTurnRadarLeftRadians(double) setTurnRadarLeftRadians(double) - * @see #setAdjustRadarForRobotTurn(boolean) setAdjustRadarForRobotTurn(boolean) - * @see #setAdjustRadarForGunTurn(boolean) setAdjustRadarForGunTurn(boolean) - */ - public void setTurnRadarRight(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnRadar(Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Does not return until a condition is met, i.e. when a - * {@link Condition#test()} returns {@code true}. - *

- * This call executes immediately. - *

- * See the {@code sample.Crazy} robot for how this method can be used. - * - * @param condition the condition that must be met before this call returns - * @see Condition - * @see Condition#test() - */ - public void waitFor(Condition condition) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).waitFor(condition); - } else { - uninitializedException(); - } - } - - /** - * This method is called if your robot dies. - *

- * You should override it in your robot if you want to be informed of this - * event. Actions will have no effect if called from this section. The - * intent is to allow you to perform calculations or print something out - * when the robot is killed. - * - * @param event the death event set by the game - * @see DeathEvent - * @see Event - */ - @Override - public void onDeath(DeathEvent event) {} - - /** - * {@inheritDoc} - */ - public void onSkippedTurn(SkippedTurnEvent event) {} - - /** - * Returns the direction that the robot's body is facing, in radians. - * The value returned will be between 0 and 2 * PI (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * PI / 2 means East, PI means South, and 3 * PI / 2 means West. - * - * @return the direction that the robot's body is facing, in radians. - * @see #getHeadingDegrees() - * @see #getGunHeadingRadians() - * @see #getRadarHeadingRadians() - */ - public double getHeadingRadians() { - return super.getHeadingRadians(); - } - - /** - * Sets the robot's body to turn left by radians when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's body is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Set the robot to turn 180 degrees to the left
-	 *   setTurnLeftRadians(Math.PI);
-	 *
-	 *   // Set the robot to turn 90 degrees to the right instead of left
-	 *   // (overrides the previous order)
-	 *   setTurnLeftRadians(-Math.PI / 2);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnLeftRadians()
-	 *   execute();
-	 * 
- * - * @param radians the amount of radians to turn the robot's body to the left. - * If {@code radians} > 0 the robot is set to turn left. - * If {@code radians} < 0 the robot is set to turn right. - * If {@code radians} = 0 the robot is set to stop turning. - * @see AdvancedRobot#setTurnLeft(double) setTurnLeft(double) - * @see #turnLeft(double) - * @see #turnLeftRadians(double) - * @see #turnRight(double) - * @see #turnRightRadians(double) - * @see AdvancedRobot#setTurnRight(double) setTurnRight(double) - * @see AdvancedRobot#setTurnRightRadians(double) setTurnRightRadians(double) - */ - public void setTurnLeftRadians(double radians) { - super.setTurnLeftRadians(radians); - } - - /** - * Sets the robot's body to turn right by radians when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's body is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Set the robot to turn 180 degrees to the right
-	 *   setTurnRightRadians(Math.PI);
-	 *
-	 *   // Set the robot to turn 90 degrees to the left instead of right
-	 *   // (overrides the previous order)
-	 *   setTurnRightRadians(-Math.PI / 2);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnRightRadians()
-	 *   execute();
-	 * 
- * - * @param radians the amount of radians to turn the robot's body to the right. - * If {@code radians} > 0 the robot is set to turn right. - * If {@code radians} < 0 the robot is set to turn left. - * If {@code radians} = 0 the robot is set to stop turning. - * @see AdvancedRobot#setTurnRight(double) setTurnRight(double) - * @see #turnRight(double) - * @see #turnRightRadians(double) - * @see #turnLeft(double) - * @see #turnLeftRadians(double) - * @see AdvancedRobot#setTurnLeft(double) setTurnLeft(double) - * @see AdvancedRobot#setTurnLeftRadians(double) setTurnLeftRadians(double) - */ - public void setTurnRightRadians(double radians) { - super.setTurnRightRadians(radians); - } - - /** - * Immediately turns the robot's body to the left by radians. - *

- * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the robot's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's body is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Turn the robot 180 degrees to the left
-	 *   turnLeftRadians(Math.PI);
-	 *
-	 *   // Afterwards, turn the robot 90 degrees to the right
-	 *   turnLeftRadians(-Math.PI / 2);
-	 * 
- * - * @param radians the amount of radians to turn the robot's body to the left. - * If {@code radians} > 0 the robot will turn right. - * If {@code radians} < 0 the robot will turn left. - * If {@code radians} = 0 the robot will not turn, but execute. - * @see #turnLeft(double) - * @see #turnRight(double) - * @see #turnRightRadians(double) - * @see #turnGunLeft(double) - * @see #turnGunLeftRadians(double) - * @see #turnGunRight(double) - * @see #turnGunRightRadians(double) - * @see #turnRadarLeft(double) - * @see #turnRadarLeftRadians(double) - * @see #turnRadarRight(double) - * @see #turnRadarRightRadians(double) - * @see #setAdjustGunForRobotTurn(boolean) - */ - public void turnLeftRadians(double radians) { - super.turnLeftRadians(radians); - } - - /** - * Immediately turns the robot's body to the right by radians. - * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the robot's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's body is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Turn the robot 180 degrees to the right
-	 *   turnRightRadians(Math.PI);
-	 *
-	 *   // Afterwards, turn the robot 90 degrees to the left
-	 *   turnRightRadians(-Math.PI / 2);
-	 * 
- * - * @param radians the amount of radians to turn the robot's body to the right. - * If {@code radians} > 0 the robot will turn right. - * If {@code radians} < 0 the robot will turn left. - * If {@code radians} = 0 the robot will not turn, but execute. - * @see #turnRight(double) - * @see #turnLeft(double) - * @see #turnLeftRadians(double) - * @see #turnGunLeft(double) - * @see #turnGunLeftRadians(double) - * @see #turnGunRight(double) - * @see #turnGunRightRadians(double) - * @see #turnRadarLeft(double) - * @see #turnRadarLeftRadians(double) - * @see #turnRadarRight(double) - * @see #turnRadarRightRadians(double) - * @see #setAdjustGunForRobotTurn(boolean) - */ - public void turnRightRadians(double radians) { - super.turnRightRadians(radians); - } - - /** - * Returns the direction that the robot's gun is facing, in radians. - * The value returned will be between 0 and 2 * PI (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * PI / 2 means East, PI means South, and 3 * PI / 2 means West. - * - * @return the direction that the robot's gun is facing, in radians. - * @see #getGunHeadingDegrees() - * @see #getHeadingRadians() - * @see #getRadarHeadingRadians() - */ - public double getGunHeadingRadians() { - return super.getGunHeadingRadians(); - } - - /** - * Returns the direction that the robot's radar is facing, in radians. - * The value returned will be between 0 and 2 * PI (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * PI / 2 means East, PI means South, and 3 * PI / 2 means West. - * - * @return the direction that the robot's radar is facing, in radians. - * @see #getRadarHeadingDegrees() - * @see #getHeadingRadians() - * @see #getGunHeadingRadians() - */ - public double getRadarHeadingRadians() { - return super.getRadarHeadingRadians(); - } - - /** - * Sets the robot's gun to turn left by radians when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's gun is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Set the gun to turn 180 degrees to the left
-	 *   setTurnGunLeftRadians(Math.PI);
-	 *
-	 *   // Set the gun to turn 90 degrees to the right instead of left
-	 *   // (overrides the previous order)
-	 *   setTurnGunLeftRadians(-Math.PI / 2);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnGunLeftRadians()
-	 *   execute();
-	 * 
- * - * @param radians the amount of radians to turn the robot's gun to the left. - * If {@code radians} > 0 the robot's gun is set to turn left. - * If {@code radians} < 0 the robot's gun is set to turn right. - * If {@code radians} = 0 the robot's gun is set to stop turning. - * @see AdvancedRobot#setTurnGunLeft(double) setTurnGunLeft(double) - * @see #turnGunLeft(double) - * @see #turnGunLeftRadians(double) - * @see #turnGunRight(double) - * @see #turnGunRightRadians(double) - * @see AdvancedRobot#setTurnGunRight(double) setTurnGunRight(double) - * @see AdvancedRobot#setTurnGunRightRadians(double) setTurnGunRightRadians(double) - * @see #setAdjustGunForRobotTurn(boolean) - */ - public void setTurnGunLeftRadians(double radians) { - super.setTurnGunLeftRadians(radians); - } - - /** - * Sets the robot's gun to turn right by radians when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's gun is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Set the gun to turn 180 degrees to the right
-	 *   setTurnGunRightRadians(Math.PI);
-	 *
-	 *   // Set the gun to turn 90 degrees to the left instead of right
-	 *   // (overrides the previous order)
-	 *   setTurnGunRightRadians(-Math.PI / 2);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnGunRightRadians()
-	 *   execute();
-	 * 
- * - * @param radians the amount of radians to turn the robot's gun to the right. - * If {@code radians} > 0 the robot's gun is set to turn left. - * If {@code radians} < 0 the robot's gun is set to turn right. - * If {@code radians} = 0 the robot's gun is set to stop turning. - * @see AdvancedRobot#setTurnGunRight(double) setTurnGunRight(double) - * @see #turnGunRight(double) - * @see #turnGunRightRadians(double) - * @see #turnGunLeft(double) - * @see #turnGunLeftRadians(double) - * @see AdvancedRobot#setTurnGunLeft(double) setTurnGunLeft(double) - * @see AdvancedRobot#setTurnGunLeftRadians(double) setTurnGunLeftRadians(double) - * @see #setAdjustGunForRobotTurn(boolean) - */ - public void setTurnGunRightRadians(double radians) { - super.setTurnGunRightRadians(radians); - } - - /** - * Sets the robot's radar to turn left by radians when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's radar is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Set the radar to turn 180 degrees to the left
-	 *   setTurnRadarLeftRadians(Math.PI);
-	 *
-	 *   // Set the radar to turn 90 degrees to the right instead of left
-	 *   // (overrides the previous order)
-	 *   setTurnRadarLeftRadians(-Math.PI / 2);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnRadarLeftRadians()
-	 *   execute();
-	 * 
- * - * @param radians the amount of radians to turn the robot's radar to the left. - * If {@code radians} > 0 the robot's radar is set to turn left. - * If {@code radians} < 0 the robot's radar is set to turn right. - * If {@code radians} = 0 the robot's radar is set to stop turning. - * @see AdvancedRobot#setTurnRadarLeft(double) setTurnRadarLeft(double) - * @see #turnRadarLeft(double) - * @see #turnRadarLeftRadians(double) - * @see #turnRadarRight(double) - * @see #turnRadarRightRadians(double) - * @see AdvancedRobot#setTurnRadarRight(double) setTurnRadarRight(double) - * @see AdvancedRobot#setTurnRadarRightRadians(double) setTurnRadarRightRadians(double) - * @see #setAdjustRadarForRobotTurn(boolean) - * @see #setAdjustRadarForGunTurn(boolean) - */ - public void setTurnRadarLeftRadians(double radians) { - super.setTurnRadarLeftRadians(radians); - } - - /** - * Sets the robot's radar to turn right by radians when the next execution - * takes place. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's radar is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Set the radar to turn 180 degrees to the right
-	 *   setTurnRadarRightRadians(Math.PI);
-	 *
-	 *   // Set the radar to turn 90 degrees to the right instead of right
-	 *   // (overrides the previous order)
-	 *   setTurnRadarRightRadians(-Math.PI / 2);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnRadarRightRadians()
-	 *   execute();
-	 * 
- * - * @param radians the amount of radians to turn the robot's radar to the right. - * If {@code radians} > 0 the robot's radar is set to turn left. - * If {@code radians} < 0 the robot's radar is set to turn right. - * If {@code radians} = 0 the robot's radar is set to stop turning. - * @see AdvancedRobot#setTurnRadarRight(double) setTurnRadarRight(double) - * @see #turnRadarRight(double) - * @see #turnRadarRightRadians(double) - * @see #turnRadarLeft(double) - * @see #turnRadarLeftRadians(double) - * @see AdvancedRobot#setTurnRadarLeft(double) setTurnRadarLeft(double) - * @see AdvancedRobot#setTurnRadarLeftRadians(double) setTurnRadarLeftRadians(double) - * @see #setAdjustRadarForRobotTurn(boolean) - * @see #setAdjustRadarForGunTurn(boolean) - */ - public void setTurnRadarRightRadians(double radians) { - super.setTurnRadarRightRadians(radians); - } - - /** - * Immediately turns the robot's gun to the left by radians. - *

- * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the gun's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's gun is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Turn the robot's gun 180 degrees to the left
-	 *   turnGunLeftRadians(Math.PI);
-	 *
-	 *   // Afterwards, turn the robot's gun 90 degrees to the right
-	 *   turnGunLeftRadians(-Math.PI / 2);
-	 * 
- * - * @param radians the amount of radians to turn the robot's gun to the left. - * If {@code radians} > 0 the robot's gun will turn left. - * If {@code radians} < 0 the robot's gun will turn right. - * If {@code radians} = 0 the robot's gun will not turn, but execute. - * @see #turnGunLeft(double) - * @see #turnGunRight(double) - * @see #turnGunRightRadians(double) - * @see #turnLeft(double) - * @see #turnLeftRadians(double) - * @see #turnRight(double) - * @see #turnRightRadians(double) - * @see #turnRadarLeft(double) - * @see #turnRadarLeftRadians(double) - * @see #turnRadarRight(double) - * @see #turnRadarRightRadians(double) - * @see #setAdjustGunForRobotTurn(boolean) - */ - public void turnGunLeftRadians(double radians) { - super.turnGunLeftRadians(radians); - } - - /** - * Immediately turns the robot's gun to the right by radians. - * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the gun's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's gun is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Turn the robot's gun 180 degrees to the right
-	 *   turnGunRightRadians(Math.PI);
-	 *
-	 *   // Afterwards, turn the robot's gun 90 degrees to the left
-	 *   turnGunRightRadians(-Math.PI / 2);
-	 * 
- * - * @param radians the amount of radians to turn the robot's gun to the right. - * If {@code radians} > 0 the robot's gun will turn right. - * If {@code radians} < 0 the robot's gun will turn left. - * If {@code radians} = 0 the robot's gun will not turn, but execute. - * @see #turnGunRight(double) - * @see #turnGunLeft(double) - * @see #turnGunLeftRadians(double) - * @see #turnLeft(double) - * @see #turnLeftRadians(double) - * @see #turnRight(double) - * @see #turnRightRadians(double) - * @see #turnRadarLeft(double) - * @see #turnRadarLeftRadians(double) - * @see #turnRadarRight(double) - * @see #turnRadarRightRadians(double) - * @see #setAdjustGunForRobotTurn(boolean) - */ - public void turnGunRightRadians(double radians) { - super.turnGunRightRadians(radians); - } - - /** - * Immediately turns the robot's radar to the left by radians. - *

- * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the radar's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's radar is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Turn the robot's radar 180 degrees to the left
-	 *   turnRadarLeftRadians(Math.PI);
-	 *
-	 *   // Afterwards, turn the robot's radar 90 degrees to the right
-	 *   turnRadarLeftRadians(-Math.PI / 2);
-	 * 
- * - * @param radians the amount of radians to turn the robot's radar to the left. - * If {@code radians} > 0 the robot's radar will turn left. - * If {@code radians} < 0 the robot's radar will turn right. - * If {@code radians} = 0 the robot's radar will not turn, but execute. - * @see #turnRadarLeft(double) - * @see #turnRadarRight(double) - * @see #turnGunRightRadians(double) - * @see #turnLeft(double) - * @see #turnLeftRadians(double) - * @see #turnRight(double) - * @see #turnRightRadians(double) - * @see #turnGunLeft(double) - * @see #turnGunLeftRadians(double) - * @see #turnGunRight(double) - * @see #turnGunRightRadians(double) - * @see #setAdjustRadarForRobotTurn(boolean) - * @see #setAdjustRadarForGunTurn(boolean) - */ - public void turnRadarLeftRadians(double radians) { - super.turnRadarLeftRadians(radians); - } - - /** - * Immediately turns the robot's radar to the right by radians. - * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the radar's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's radar is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Turn the robot's radar 180 degrees to the right
-	 *   turnRadarRightRadians(Math.PI);
-	 *
-	 *   // Afterwards, turn the robot's radar 90 degrees to the left
-	 *   turnRadarRightRadians(-Math.PI / 2);
-	 * 
- * - * @param radians the amount of radians to turn the robot's radar to the right. - * If {@code radians} > 0 the robot's radar will turn right. - * If {@code radians} < 0 the robot's radar will turn left. - * If {@code radians} = 0 the robot's radar will not turn, but execute. - * @see #turnRadarRight(double) - * @see #turnRadarLeft(double) - * @see #turnGunLeftRadians(double) - * @see #turnLeft(double) - * @see #turnLeftRadians(double) - * @see #turnRight(double) - * @see #turnRightRadians(double) - * @see #turnGunLeft(double) - * @see #turnGunLeftRadians(double) - * @see #turnGunRight(double) - * @see #turnGunRightRadians(double) - * @see #setAdjustRadarForRobotTurn(boolean) - * @see #setAdjustRadarForGunTurn(boolean) - */ - public void turnRadarRightRadians(double radians) { - super.turnRadarRightRadians(radians); - } - - /** - * Returns the angle remaining in the gun's turn, in radians. - *

- * This call returns both positive and negative values. Positive values - * means that the gun is currently turning to the right. Negative values - * means that the gun is currently turning to the left. - * - * @return the angle remaining in the gun's turn, in radians - * @see AdvancedRobot#getGunTurnRemaining() - * @see AdvancedRobot#getTurnRemaining() getTurnRemaining() - * @see #getTurnRemainingRadians() - * @see AdvancedRobot#getRadarTurnRemaining() getRadarTurnRemaining() - * @see #getRadarTurnRemainingRadians() - */ - public double getGunTurnRemainingRadians() { - return super.getGunTurnRemainingRadians(); - } - - /** - * Returns the angle remaining in the radar's turn, in radians. - *

- * This call returns both positive and negative values. Positive values - * means that the radar is currently turning to the right. Negative values - * means that the radar is currently turning to the left. - * - * @return the angle remaining in the radar's turn, in radians - * @see AdvancedRobot#getRadarTurnRemaining() - * @see AdvancedRobot#getTurnRemaining() getTurnRemaining() - * @see #getTurnRemainingRadians() - * @see AdvancedRobot#getGunTurnRemaining() getGunTurnRemaining() - * @see #getGunTurnRemainingRadians() - */ - public double getRadarTurnRemainingRadians() { - return super.getRadarTurnRemainingRadians(); - } - - /** - * Returns the angle remaining in the robot's turn, in radians. - *

- * This call returns both positive and negative values. Positive values - * means that the robot is currently turning to the right. Negative values - * means that the robot is currently turning to the left. - * - * @return the angle remaining in the robot's turn, in radians - * @see AdvancedRobot#getTurnRemaining() - * @see AdvancedRobot#getGunTurnRemaining() getGunTurnRemaining() - * @see #getGunTurnRemainingRadians() - * @see AdvancedRobot#getRadarTurnRemaining() getRadarTurnRemaining() - * @see #getRadarTurnRemainingRadians() - */ - public double getTurnRemainingRadians() { - return super.getTurnRemainingRadians(); - } - - /** - * Do not call this method! - *

- * {@inheritDoc} - */ - public final IAdvancedEvents getAdvancedEventListener() { - return this; // this robot is listening - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/BattleEndedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/BattleEndedEvent.java deleted file mode 100644 index de3bd6a..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/BattleEndedEvent.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicEvents2; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A BattleEndedEvent is sent to {@link Robot#onBattleEnded(BattleEndedEvent) - * onBattleEnded()} when the battle is ended. - * You can use the information contained in this event to determine if the - * battle was aborted and also get the results of the battle. - * - * @see BattleResults - * @see Robot#onBattleEnded(BattleEndedEvent) - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class BattleEndedEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 100; // System event -> cannot be changed! - - private final boolean aborted; - private final BattleResults results; - - /** - * Called by the game to create a new BattleEndedEvent. - * - * @param aborted {@code true} if the battle was aborted; {@code false} otherwise. - * @param results the battle results - */ - public BattleEndedEvent(boolean aborted, BattleResults results) { - this.aborted = aborted; - this.results = results; - } - - /** - * Checks if this battle was aborted. - * - * @return {@code true} if the battle was aborted; {@code false} otherwise. - */ - public boolean isAborted() { - return aborted; - } - - /** - * Returns the battle results. - * - * @return the battle results. - */ - public BattleResults getResults() { - return results; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - public final int getPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (robot != null) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null && IBasicEvents2.class.isAssignableFrom(listener.getClass())) { - ((IBasicEvents2) listener).onBattleEnded(this); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - final boolean isCriticalEvent() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.BattleEndedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - BattleEndedEvent obj = (BattleEndedEvent) object; - - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_BOOL - + serializer.sizeOf(RbSerializer.BattleResults_TYPE, obj.results); - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - BattleEndedEvent obj = (BattleEndedEvent) object; - - serializer.serialize(buffer, obj.aborted); - serializer.serialize(buffer, RbSerializer.BattleResults_TYPE, obj.results); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - boolean aborted = serializer.deserializeBoolean(buffer); - BattleResults results = (BattleResults) serializer.deserializeAny(buffer); - - return new BattleEndedEvent(aborted, results); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/BattleResults.java b/workspace_robo/robocode.api/src/main/java/robocode/BattleResults.java deleted file mode 100644 index 572d8e6..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/BattleResults.java +++ /dev/null @@ -1,282 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; - -import java.nio.ByteBuffer; - - -/** - * Contains the battle results returned by {@link BattleEndedEvent#getResults()} - * when a battle has ended. - * - * @see BattleEndedEvent#getResults() - * @see Robot#onBattleEnded(BattleEndedEvent) - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public class BattleResults implements java.io.Serializable, Comparable { - protected static final long serialVersionUID = 1L; - - protected String teamLeaderName; - protected int rank; - protected double score; - protected double survival; - protected double lastSurvivorBonus; - protected double bulletDamage; - protected double bulletDamageBonus; - protected double ramDamage; - protected double ramDamageBonus; - protected int firsts; - protected int seconds; - protected int thirds; - - /** - * Constructs this BattleResults object. - * - * @param teamLeaderName the name of the team leader. - * @param rank the rank of the robot in the battle. - * @param score the total score for the robot in the battle. - * @param survival the survival score for the robot in the battle. - * @param lastSurvivorBonus the last survivor bonus for the robot in the battle. - * @param bulletDamage the bullet damage score for the robot in the battle. - * @param bulletDamageBonus the bullet damage bonus for the robot in the battle. - * @param ramDamage the ramming damage for the robot in the battle. - * @param ramDamageBonus the ramming damage bonus for the robot in the battle. - * @param firsts the number of rounds this robot placed first. - * @param seconds the number of rounds this robot placed second. - * @param thirds the number of rounds this robot placed third. - */ - public BattleResults( - String teamLeaderName, - int rank, - double score, - double survival, - double lastSurvivorBonus, - double bulletDamage, - double bulletDamageBonus, - double ramDamage, - double ramDamageBonus, - int firsts, - int seconds, - int thirds - ) { - this.teamLeaderName = teamLeaderName; - this.rank = rank; - this.score = score; - this.survival = survival; - this.lastSurvivorBonus = lastSurvivorBonus; - this.bulletDamage = bulletDamage; - this.bulletDamageBonus = bulletDamageBonus; - this.ramDamage = ramDamage; - this.ramDamageBonus = ramDamageBonus; - this.firsts = firsts; - this.seconds = seconds; - this.thirds = thirds; - } - - /** - * Returns the name of the team leader in the team or the name of the - * robot if the robot is not participating in a team. - * - * @return the name of the team leader in the team or the name of the robot. - */ - public String getTeamLeaderName() { - return teamLeaderName; - } - - /** - * Returns the rank of this robot in the battle results. - * - * @return the rank of this robot in the battle results. - */ - public int getRank() { - return rank; - } - - /** - * Returns the total score of this robot in the battle. - * - * @return the total score of this robot in the battle. - */ - public int getScore() { - return (int) (score + 0.5); - } - - /** - * Returns the survival score of this robot in the battle. - * - * @return the survival score of this robot in the battle. - */ - public int getSurvival() { - return (int) (survival + 0.5); - } - - /** - * Returns the last survivor score of this robot in the battle. - * - * @return the last survivor score of this robot in the battle. - */ - public int getLastSurvivorBonus() { - return (int) (lastSurvivorBonus + 0.5); - } - - /** - * Returns the bullet damage score of this robot in the battle. - * - * @return the bullet damage score of this robot in the battle. - */ - public int getBulletDamage() { - return (int) (bulletDamage + 0.5); - } - - /** - * Returns the bullet damage bonus of this robot in the battle. - * - * @return the bullet damage bonus of this robot in the battle. - */ - public int getBulletDamageBonus() { - return (int) (bulletDamageBonus + 0.5); - } - - /** - * Returns the ram damage score of this robot in the battle. - * - * @return the ram damage score of this robot in the battle. - */ - public int getRamDamage() { - return (int) (ramDamage + 0.5); - } - - /** - * Returns the ram damage bonus of this robot in the battle. - * - * @return the ram damage bonus of this robot in the battle. - */ - public int getRamDamageBonus() { - return (int) (ramDamageBonus + 0.5); - } - - /** - * Returns the number of rounds this robot placed first in the battle. - * - * @return the number of rounds this robot placed first in the battle. - */ - public int getFirsts() { - return firsts; - } - - /** - * Returns the number of rounds this robot placed second in the battle. - * - * @return the number of rounds this robot placed second in the battle. - */ - public int getSeconds() { - return seconds; - } - - /** - * Returns the number of rounds this robot placed third in the battle. - * - * @return the number of rounds this robot placed third in the battle. - */ - public int getThirds() { - return thirds; - } - - /** - * {@inheritDoc} - */ - public int compareTo(BattleResults o) { - return ((Double) score).compareTo(o.score); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - - temp = Double.doubleToLongBits(score); - result = prime * result + (int) (temp ^ (temp >>> 32)); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - BattleResults other = (BattleResults) obj; - - if (Double.doubleToLongBits(score) != Double.doubleToLongBits(other.score)) { - return false; - } - return true; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - BattleResults obj = (BattleResults) object; - - return RbSerializer.SIZEOF_TYPEINFO + serializer.sizeOf(obj.teamLeaderName) + 4 * RbSerializer.SIZEOF_INT - + 7 * RbSerializer.SIZEOF_DOUBLE; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - BattleResults obj = (BattleResults) object; - - serializer.serialize(buffer, obj.teamLeaderName); - serializer.serialize(buffer, obj.rank); - serializer.serialize(buffer, obj.score); - serializer.serialize(buffer, obj.survival); - serializer.serialize(buffer, obj.lastSurvivorBonus); - serializer.serialize(buffer, obj.bulletDamage); - serializer.serialize(buffer, obj.bulletDamageBonus); - serializer.serialize(buffer, obj.ramDamage); - serializer.serialize(buffer, obj.ramDamageBonus); - serializer.serialize(buffer, obj.firsts); - serializer.serialize(buffer, obj.seconds); - serializer.serialize(buffer, obj.thirds); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - String teamLeaderName = serializer.deserializeString(buffer); - int rank = buffer.getInt(); - double score = buffer.getDouble(); - double survival = buffer.getDouble(); - double lastSurvivorBonus = buffer.getDouble(); - double bulletDamage = buffer.getDouble(); - double bulletDamageBonus = buffer.getDouble(); - double ramDamage = buffer.getDouble(); - double ramDamageBonus = buffer.getDouble(); - int firsts = buffer.getInt(); - int seconds = buffer.getInt(); - int thirds = buffer.getInt(); - - return new BattleResults(teamLeaderName, rank, score, survival, lastSurvivorBonus, bulletDamage, - bulletDamageBonus, ramDamage, ramDamageBonus, firsts, seconds, thirds); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/BattleRules.java b/workspace_robo/robocode.api/src/main/java/robocode/BattleRules.java deleted file mode 100644 index af70c8d..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/BattleRules.java +++ /dev/null @@ -1,148 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.security.IHiddenRulesHelper; - - -/** - * Contains the battle rules returned by {@link robocode.control.events.BattleStartedEvent#getBattleRules() - * BattleStartedEvent.getBattleRules()} when a battle is started and - * {@link robocode.control.events.BattleCompletedEvent#getBattleRules() BattleCompletedEvent.getBattleRules()} - * when a battle is completed. - * - * @see robocode.control.events.BattleStartedEvent BattleStartedEvent - * @see robocode.control.events.BattleCompletedEvent BattleCompletedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public final class BattleRules implements java.io.Serializable { - private static final long serialVersionUID = 1L; - - private final int battlefieldWidth; - private final int battlefieldHeight; - private final int numRounds; - private final double gunCoolingRate; - private final long inactivityTime; - private final boolean hideEnemyNames; - private final int sentryBorderSize; - - /** - * Returns the battlefield width. - * - * @return the battlefield width. - */ - public int getBattlefieldWidth() { - return battlefieldWidth; - } - - /** - * Returns the battlefield height. - * - * @return the battlefield height. - */ - public int getBattlefieldHeight() { - return battlefieldHeight; - } - - /** - * Returns the number of rounds. - * - * @return the number of rounds. - */ - public int getNumRounds() { - return numRounds; - } - - /** - * Returns the rate at which the gun will cool down, i.e. the amount of heat the gun heat will drop per turn. - *

- * The gun cooling rate is default 0.1 per turn, but can be changed by the battle setup. - * So don't count on the cooling rate being 0.1! - * - * @return the gun cooling rate. - * @see Robot#getGunHeat() - * @see Robot#fire(double) - * @see Robot#fireBullet(double) - */ - public double getGunCoolingRate() { - return gunCoolingRate; - } - - /** - * Returns the allowed inactivity time, where the robot is not taking any action, before will begin to be zapped. - * The inactivity time is measured in turns, and is the allowed time that a robot is allowed to omit taking - * action before being punished by the game by zapping. - *

- * When a robot is zapped by the game, it will loose 0.1 energy points per turn. Eventually the robot will be - * killed by zapping until the robot takes action. When the robot takes action, the inactivity time counter is - * reset. - *

- * The allowed inactivity time is per default 450 turns, but can be changed by the battle setup. - * So don't count on the inactivity time being 450 turns! - * - * @return the allowed inactivity time. - * @see Robot#doNothing() - * @see AdvancedRobot#execute() - */ - public long getInactivityTime() { - return inactivityTime; - } - - /** - * Returns true if the enemy names are hidden, i.e. anonymous; false otherwise. - * - * @Since 1.7.3 - */ - public boolean getHideEnemyNames() { - return hideEnemyNames; - } - - /** - * Returns the sentry border size for a {@link robocode.BorderSentry BorderSentry} that defines the how - * far a BorderSentry is allowed to move from the border edges measured in units.
- * Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that - * BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the - * distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this - * border area. - * - * @return the border size in units/pixels. - * - * @since 1.9.0.0 - */ - public int getSentryBorderSize() { - return sentryBorderSize; - } - - private BattleRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, - long inactivityTime, boolean hideEnemyNames, int sentryBorderSize) { - this.battlefieldWidth = battlefieldWidth; - this.battlefieldHeight = battlefieldHeight; - this.numRounds = numRounds; - this.gunCoolingRate = gunCoolingRate; - this.inactivityTime = inactivityTime; - this.hideEnemyNames = hideEnemyNames; - this.sentryBorderSize = sentryBorderSize; - } - - static IHiddenRulesHelper createHiddenHelper() { - return new HiddenHelper(); - } - - private static class HiddenHelper implements IHiddenRulesHelper { - - public BattleRules createRules(int battlefieldWidth, int battlefieldHeight, int numRounds, double gunCoolingRate, long inactivityTime, boolean hideEnemyNames, int sentryBorderSize) { - return new BattleRules(battlefieldWidth, battlefieldHeight, numRounds, gunCoolingRate, inactivityTime, - hideEnemyNames, sentryBorderSize); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/BorderSentry.java b/workspace_robo/robocode.api/src/main/java/robocode/BorderSentry.java deleted file mode 100644 index ea99cf5..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/BorderSentry.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * A robot that implements BorderSentry is a robot type used for keeping other robots away from the borders, - * i.e. guarding the borders in order to prevent "wall crawlers".
- * Robots that implement BorderSentry have 400 extra life/energy (500 in total), but is placed at the border - * of the battlefield when the game is started.
- * Border sentry robots cannot move away from the border area, and they can only make damage to robots that - * are moving into the border area. The size of the border area is determined by the - * {@link BattleRules#getSentryBorderSize() battle rules}.
- * This type of robot is intended for use in battles where robots should be forced away from the borders - * in order to prevent "wall crawlers".
- * Border sentry robots does not get scores, and will not occur in the battle results or rankings. - * - * @see BattleRules#getSentryBorderSize() - * @see JuniorRobot - * @see Robot - * @see AdvancedRobot - * @see TeamRobot - * @see RateControlRobot - * @see Droid - * - * @author Flemming N. Larsen (original) - * - * @since 1.9.0.0 - */ -public interface BorderSentry {} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/Bullet.java b/workspace_robo/robocode.api/src/main/java/robocode/Bullet.java deleted file mode 100644 index d0b1e1c..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/Bullet.java +++ /dev/null @@ -1,261 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.security.IHiddenBulletHelper; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; - -import java.io.Serializable; -import java.nio.ByteBuffer; - - -/** - * Represents a bullet. This is returned from {@link Robot#fireBullet(double)} - * and {@link AdvancedRobot#setFireBullet(double)}, and all the bullet-related - * events. - * - * @see Robot#fireBullet(double) - * @see AdvancedRobot#setFireBullet(double) - * @see BulletHitEvent - * @see BulletMissedEvent - * @see BulletHitBulletEvent - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class Bullet implements Serializable { - private static final long serialVersionUID = 1L; - - private final double headingRadians; - private double x; - private double y; - private final double power; - private final String ownerName; - private String victimName; - private boolean isActive; - private final int bulletId; - - /** - * Called by the game to create a new {@code Bullet} object - * - * @param heading the heading of the bullet, in radians. - * @param x the starting X position of the bullet. - * @param y the starting Y position of the bullet. - * @param power the power of the bullet. - * @param ownerName the name of the owner robot that owns the bullet. - * @param victimName the name of the robot hit by the bullet. - * @param isActive {@code true} if the bullet still moves; {@code false} otherwise. - * @param bulletId unique id of bullet for owner robot. - */ - public Bullet(double heading, double x, double y, double power, String ownerName, String victimName, boolean isActive, int bulletId) { - this.headingRadians = heading; - this.x = x; - this.y = y; - this.power = power; - this.ownerName = ownerName; - this.victimName = victimName; - this.isActive = isActive; - this.bulletId = bulletId; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - return bulletId == ((Bullet) obj).bulletId; - } - - @Override - public int hashCode() { - return bulletId; - } - - /** - * Returns the direction the bullet is/was heading, in degrees - * (0 <= getHeading() < 360). This is not relative to the direction you are - * facing. - * - * @return the direction the bullet is/was heading, in degrees - */ - public double getHeading() { - return Math.toDegrees(headingRadians); - } - - /** - * Returns the direction the bullet is/was heading, in radians - * (0 <= getHeadingRadians() < 2 * Math.PI). This is not relative to the - * direction you are facing. - * - * @return the direction the bullet is/was heading, in radians - */ - public double getHeadingRadians() { - return headingRadians; - } - - /** - * Returns the name of the robot that fired this bullet. - * - * @return the name of the robot that fired this bullet - */ - public String getName() { - return ownerName; - } - - /** - * Returns the power of this bullet. - *

- * The bullet will do (4 * power) damage if it hits another robot. - * If power is greater than 1, it will do an additional 2 * (power - 1) - * damage. You will get (3 * power) back if you hit the other robot. - * - * @return the power of the bullet - */ - public double getPower() { - return power; - } - - /** - * Returns the velocity of this bullet. The velocity of the bullet is - * constant once it has been fired. - * - * @return the velocity of the bullet - */ - public double getVelocity() { - return Rules.getBulletSpeed(power); - } - - /** - * Returns the name of the robot that this bullet hit, or {@code null} if - * the bullet has not hit a robot. - * - * @return the name of the robot that this bullet hit, or {@code null} if - * the bullet has not hit a robot. - */ - public String getVictim() { - return victimName; - } - - /** - * Returns the X position of the bullet. - * - * @return the X position of the bullet - */ - public double getX() { - return x; - } - - /** - * Returns the Y position of the bullet. - * - * @return the Y position of the bullet - */ - public double getY() { - return y; - } - - /** - * Checks if this bullet is still active on the battlefield. - * - * @return {@code true} if the bullet is still active on the battlefield; - * {@code false} otherwise - */ - public boolean isActive() { - return isActive; - } - - /** - * Updates this bullet based on the specified bullet status. - * - * @param x the new X position of the bullet . - * @param y the new Y position of the bullet. - * @param victimName the name if the victim that has been hit by this bullet. - * @param isActive {@code true} if the bullet still moves; {@code false} otherwise. - */ - // this method is invisible on RobotAPI - private void update(double x, double y, String victimName, boolean isActive) { - this.x = x; - this.y = y; - this.victimName = victimName; - this.isActive = isActive; - } - - // this method is invisible on RobotAPI - /** - * @return unique id of bullet for owner robot - */ - int getBulletId() { - return bulletId; - } - - /** - * Creates a hidden bullet helper for accessing hidden methods on this object. - * - * @return a hidden bullet helper. - */ - // this method is invisible on RobotAPI - static IHiddenBulletHelper createHiddenHelper() { - return new HiddenBulletHelper(); - } - - /** - * Creates a hidden bullet helper for accessing hidden methods on this object. - * - * @return a hidden bullet helper. - */ - // this class is invisible on RobotAPI - static ISerializableHelper createHiddenSerializer() { - return new HiddenBulletHelper(); - } - - // this class is invisible on RobotAPI - private static class HiddenBulletHelper implements IHiddenBulletHelper, ISerializableHelper { - - public void update(Bullet bullet, double x, double y, String victimName, boolean isActive) { - bullet.update(x, y, victimName, isActive); - } - - public int sizeOf(RbSerializer serializer, Object object) { - Bullet obj = (Bullet) object; - - return RbSerializer.SIZEOF_TYPEINFO + 4 * RbSerializer.SIZEOF_DOUBLE + serializer.sizeOf(obj.ownerName) - + serializer.sizeOf(obj.victimName) + RbSerializer.SIZEOF_BOOL + RbSerializer.SIZEOF_INT; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - Bullet obj = (Bullet) object; - - serializer.serialize(buffer, obj.headingRadians); - serializer.serialize(buffer, obj.x); - serializer.serialize(buffer, obj.y); - serializer.serialize(buffer, obj.power); - serializer.serialize(buffer, obj.ownerName); - serializer.serialize(buffer, obj.victimName); - serializer.serialize(buffer, obj.isActive); - serializer.serialize(buffer, obj.bulletId); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - double headingRadians = buffer.getDouble(); - double x = buffer.getDouble(); - double y = buffer.getDouble(); - double power = buffer.getDouble(); - String ownerName = serializer.deserializeString(buffer); - String victimName = serializer.deserializeString(buffer); - boolean isActive = serializer.deserializeBoolean(buffer); - int bulletId = serializer.deserializeInt(buffer); - - return new Bullet(headingRadians, x, y, power, ownerName, victimName, isActive, bulletId); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/BulletHitBulletEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/BulletHitBulletEvent.java deleted file mode 100644 index db738b9..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/BulletHitBulletEvent.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * This event is sent to {@link Robot#onBulletHitBullet(BulletHitBulletEvent) - * onBulletHitBullet} when one of your bullets has hit another bullet. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public final class BulletHitBulletEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 55; - - private Bullet bullet; - private final Bullet hitBullet; - - /** - * Called by the game to create a new {@code BulletHitEvent}. - * - * @param bullet your bullet that hit another bullet - * @param hitBullet the bullet that was hit by your bullet - */ - public BulletHitBulletEvent(Bullet bullet, Bullet hitBullet) { - super(); - this.bullet = bullet; - this.hitBullet = hitBullet; - } - - /** - * Returns your bullet that hit another bullet. - * - * @return your bullet - */ - public Bullet getBullet() { - return bullet; - } - - /** - * Returns the bullet that was hit by your bullet. - * - * @return the bullet that was hit - */ - public Bullet getHitBullet() { - return hitBullet; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null) { - listener.onBulletHitBullet(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.BulletHitBulletEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - BulletHitBulletEvent obj = (BulletHitBulletEvent) object; - - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_INT - + serializer.sizeOf(RbSerializer.Bullet_TYPE, obj.hitBullet); - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - BulletHitBulletEvent obj = (BulletHitBulletEvent) object; - - // no need to transmit whole bullet, rest of it is already known to proxy side - serializer.serialize(buffer, obj.bullet.getBulletId()); - serializer.serialize(buffer, RbSerializer.Bullet_TYPE, obj.hitBullet); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - Bullet bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt()); - Bullet hitBullet = (Bullet) serializer.deserializeAny(buffer); - - return new BulletHitBulletEvent(bullet, hitBullet); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/BulletHitEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/BulletHitEvent.java deleted file mode 100644 index 3e08a88..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/BulletHitEvent.java +++ /dev/null @@ -1,161 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * This event is sent to {@link Robot#onBulletHit(BulletHitEvent) onBulletHit} - * when one of your bullets has hit another robot. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public final class BulletHitEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 50; - - private final String name; - private final double energy; - private Bullet bullet; - - /** - * Called by the game to create a new {@code BulletHitEvent}. - * - * @param name the name of the robot your bullet hit - * @param energy the remaining energy of the robot that your bullet has hit - * @param bullet the bullet that hit the robot - */ - public BulletHitEvent(String name, double energy, Bullet bullet) { - super(); - this.name = name; - this.energy = energy; - this.bullet = bullet; - } - - /** - * Returns the bullet of yours that hit the robot. - * - * @return the bullet that hit the robot - */ - public Bullet getBullet() { - return bullet; - } - - /** - * Returns the remaining energy of the robot your bullet has hit (after the - * damage done by your bullet). - * - * @return energy the remaining energy of the robot that your bullet has hit - */ - public double getEnergy() { - return energy; - } - - /** - * @return energy the remaining energy of the robot that your bullet has hit - * @deprecated Use {@link #getEnergy()} instead. - */ - @Deprecated - public double getLife() { - return energy; - } - - /** - * Returns the name of the robot your bullet hit. - * - * @return the name of the robot your bullet hit. - */ - public String getName() { - return name; - } - - /** - * @return energy the remaining energy of the robot that your bullet has hit - * @deprecated Use {@link #getEnergy()} instead. - */ - @Deprecated - public double getRobotLife() { - return energy; - } - - /** - * @return the name of the robot your bullet hit. - * @deprecated Use {@link #getName()} instead. - */ - @Deprecated - public String getRobotName() { - return name; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null) { - listener.onBulletHit(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.BulletHitEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - BulletHitEvent obj = (BulletHitEvent) object; - - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_INT + serializer.sizeOf(obj.name) - + RbSerializer.SIZEOF_DOUBLE; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - BulletHitEvent obj = (BulletHitEvent) object; - - serializer.serialize(buffer, obj.bullet.getBulletId()); - serializer.serialize(buffer, obj.name); - serializer.serialize(buffer, obj.energy); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - Bullet bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt()); - String name = serializer.deserializeString(buffer); - double energy = buffer.getDouble(); - - return new BulletHitEvent(name, energy, bullet); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/BulletMissedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/BulletMissedEvent.java deleted file mode 100644 index 5d0db37..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/BulletMissedEvent.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * This event is sent to {@link Robot#onBulletMissed(BulletMissedEvent) - * onBulletMissed} when one of your bullets has missed, i.e. when the bullet has - * reached the border of the battlefield. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public final class BulletMissedEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 60; - - private Bullet bullet; - - /** - * Called by the game to create a new {@code BulletMissedEvent}. - * - * @param bullet the bullet that missed - */ - public BulletMissedEvent(Bullet bullet) { - this.bullet = bullet; - } - - /** - * Returns the bullet that missed. - * - * @return the bullet that missed - */ - public Bullet getBullet() { - return bullet; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null) { - listener.onBulletMissed(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.BulletMissedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_INT; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - BulletMissedEvent obj = (BulletMissedEvent) object; - - serializer.serialize(buffer, obj.bullet.getBulletId()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - Bullet bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt()); - - return new BulletMissedEvent(bullet); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/Condition.java b/workspace_robo/robocode.api/src/main/java/robocode/Condition.java deleted file mode 100644 index 58c6a1b..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/Condition.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * Condition is used to define custom {@link AdvancedRobot#waitFor(Condition) - * waitFor(Condition)} and custom events for an {@link AdvancedRobot}. The code - * below is taken from the sample robot named {@code sample.Target}. See the - * {@code sample/Target.java} for details. - *

- *   addCustomEvent(
- *       new Condition("triggerhit") {
- *           public boolean test() {
- *               return (getEnergy() <= trigger);
- *           };
- *       }
- *   );
- * 
- * You should note that by extending Condition this way, you are actually - * creating an inner class -- so if you distribute your robot, there will be - * multiple class files. (i.e. {@code Target$1.class}) - * - * @see AdvancedRobot#waitFor(Condition) - * @see AdvancedRobot#addCustomEvent(Condition) - * @see AdvancedRobot#removeCustomEvent(Condition) - * @see AdvancedRobot#onCustomEvent(CustomEvent) - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Nathaniel Troutman (contributor) - */ -public abstract class Condition { - - /** - * The priority of this condition. Defaults to 80. - */ - public int priority = 80; - - /** - * The name of this condition. - */ - public String name; - - /** - * Creates a new, unnamed Condition with the default priority, which is 80. - */ - public Condition() {} - - /** - * Creates a new Condition with the specified name, and default priority, - * which is 80. - * - * @param name the name for the new Condition - */ - public Condition(String name) { - this.name = name; - } - - /** - * Creates a new Condition with the specified name and priority. - * A condition priority is a value from 0 - 99. The higher value, the - * higher priority. The default priority is 80. - * - * @param name the name for the new condition - * @param priority the priority of the new condition - */ - public Condition(String name, int priority) { - this.name = name; - if (priority < 0) { - System.out.println("SYSTEM: Priority must be between 0 and 99."); - System.out.println("SYSTEM: Priority for condition " + name + " will be 0."); - priority = 0; - } else if (priority > 99) { - System.out.println("SYSTEM: Priority must be between 0 and 99."); - System.out.println("SYSTEM: Priority for condition " + name + " will be 99."); - priority = 99; - } - this.priority = priority; - } - - /** - * Returns the name of this condition. - * - * @return the name of this condition - */ - public String getName() { - return (name != null) ? name : getClass().getName(); - } - - /** - * Returns the priority of this condition. - * A condition priority is a value from 0 - 99. The higher value, the - * higher priority. The default priority is 80. - * - * @return the priority of this condition - */ - public final int getPriority() { - return priority; - } - - /** - * Sets the name of this condition. - * - * @param newName the new name of this condition - */ - public void setName(String newName) { - name = newName; - } - - /** - * Sets the priority of this condition. - * A condition priority is a value from 0 - 99. The higher value, the - * higher priority. The default priority is 80. - * - * @param newPriority the new priority of this condition. - */ - public void setPriority(int newPriority) { - priority = newPriority; - } - - /** - * Overriding the test() method is the point of a Condition. - * The game will call your test() function, and take action if it returns - * {@code true}. This is valid for both {@link AdvancedRobot#waitFor} and - * {@link AdvancedRobot#addCustomEvent}. - *

- * You may not take any actions inside of test(). - * - * @return {@code true} if the condition has been met, {@code false} - * otherwise. - */ - public abstract boolean test(); - - /** - * Called by the system in order to clean up references to internal objects. - * - * @since 1.4.3 - */ - public void cleanup() {/* Do nothing: Should be overridden by sub-classes to perform needed - clean up to ensure that there are NO circular references */} -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/CustomEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/CustomEvent.java deleted file mode 100644 index 30be654..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/CustomEvent.java +++ /dev/null @@ -1,143 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import robocode.robotinterfaces.IAdvancedEvents; -import robocode.robotinterfaces.IAdvancedRobot; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; - - -/** - * This event is sent to {@link AdvancedRobot#onCustomEvent(CustomEvent) - * onCustomEvent()} when a custom condition is met. Be sure to reset or remove - * the custom condition to avoid having it recurring repeatedly (see the - * example for the {@link #getCondition()} method. - * - * @see #getCondition() - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class CustomEvent extends Event { - private static final long serialVersionUID = 1L; - private static final int DEFAULT_PRIORITY = 80; - - private transient final Condition condition; - - /** - * Called by the game to create a new CustomEvent when a condition is met. - * - * @param condition the condition that must be met - */ - public CustomEvent(Condition condition) { - this.condition = condition; - if (condition != null) { - setPriority(condition.getPriority()); - } - } - - /** - * Called by the game to create a new CustomEvent when a condition is met. - * The event will have the given priority. - * An event priority is a value from 0 - 99. The higher value, the higher - * priority. The default priority is 80. - *

- * This is equivalent to calling {@link Condition#setPriority(int)} on the - * Condition. - * - * @param condition the condition that must be met - * @param priority the priority of the condition - */ - public CustomEvent(Condition condition, int priority) { - this.condition = condition; - setPriority(priority); - if (condition != null) { - condition.setPriority(getPriority()); - } - } - - /** - * Returns the condition that fired, causing this event to be generated. - * Use this to determine which condition fired, and to remove the custom - * event. - *

-	 *   public void onCustomEvent(CustomEvent event) {
-	 *       if (event.getCondition().getName().equals("mycondition")) {
-	 *           removeCustomEvent(event.getCondition());
-	 *           // do something else
-	 *       }
-	 *   }
-	 * 
- * - * @return the condition that fired, causing this event to be generated - */ - public Condition getCondition() { - return condition; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isAdvancedRobot()) { - IAdvancedEvents listener = ((IAdvancedRobot) robot).getAdvancedEventListener(); - - if (listener != null) { - listener.onCustomEvent(this); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - // final to disable overrides - public final int compareTo(Event event) { - return super.compareTo(event); - } - - /** - * {@inheritDoc} - */ - @Override - // final to disable overrides - final boolean isCriticalEvent() { - return false; - } - - /** - * {@inheritDoc} - */ - @Override - // final to disable overrides - public final int getPriority() { - return super.getPriority(); - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - throw new Error("Serialization not supported on this event type"); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/DeathEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/DeathEvent.java deleted file mode 100644 index b5f6f0e..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/DeathEvent.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * This event is sent to {@link Robot#onDeath(DeathEvent) onDeath()} when your - * robot dies. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public final class DeathEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = -1; // System event -> cannot be changed! - - /** - * Called by the game to create a new DeathEvent. - */ - public DeathEvent() { - super(); - } - - /** - * {@inheritDoc} - */ - @Override - public final int getPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null) { - listener.onDeath(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - final boolean isCriticalEvent() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.DeathEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) {} - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - return new DeathEvent(); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/Droid.java b/workspace_robo/robocode.api/src/main/java/robocode/Droid.java deleted file mode 100644 index 73fffef..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/Droid.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * Robots that implement Droid have no scanner, but an extra 20 life/energy. - * This class is intended for use in teams. - * - * @see JuniorRobot - * @see Robot - * @see AdvancedRobot - * @see TeamRobot - * @see RateControlRobot - * @see BorderSentry - * - * @author Mathew A. Nelson (original) - */ -public interface Droid {} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/Event.java b/workspace_robo/robocode.api/src/main/java/robocode/Event.java deleted file mode 100644 index ccb128c..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/Event.java +++ /dev/null @@ -1,266 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.IHiddenEventHelper; -import net.sf.robocode.io.Logger; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.io.Serializable; - - -// XXX Remember to update the .NET version whenever a change is made to this class! - -/** - * The superclass of all Robocode events. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public abstract class Event implements Comparable, Serializable { - private static final long serialVersionUID = 1L; - private static final int DEFAULT_PRIORITY = 80; - - private long time; - private int priority; - - // time is valid only after adding to event manager on proxy side, we do not update it on battle side - private transient boolean addedToQueue; - - /** - * Default constructor used by the game to create a new event. - */ - public Event() { - super(); - } - - /** - * Compares this event to another event regarding precedence. - * The event precedence is first and foremost determined by the event time, - * secondly the event priority, and lastly specific event information. - *

- * This method will first compare the time of each event. If the event time - * is the same for both events, then this method compared the priority of - * each event. If the event priorities are equals, then this method will - * compare the two event based on specific event information. - *

- * This method is called by the game in order to sort the event queue of a - * robot to make sure the events are listed in chronological order. - * - * @param event the event to compare to this event. - * @return a negative value if this event has higher precedence, i.e. must - * be listed before the specified event. A positive value if this event - * has a lower precedence, i.e. must be listed after the specified event. - * 0 means that the precedence of the two events are equal. - */ - public int compareTo(Event event) { - // Compare the time difference which has precedence over priority. - int timeDiff = (int) (time - event.time); - - if (timeDiff != 0) { - return timeDiff; // Time differ - } - - // Same time -> Compare the difference in priority - int priorityDiff = event.getPriority() - getPriority(); - - if (priorityDiff != 0) { - return priorityDiff; // Priority differ - } - - // Same time and priority -> Compare specific event types - // look at overrides in ScannedRobotEvent and HitRobotEvent - - // No difference found - return 0; - } - - /** - * Returns the time when this event occurred. - *

- * Note that the time is equal to the turn of a battle round. - * - * @return the time when this event occurred. - */ - // Note: We rolled back the use of 'final' here due to Bug [2928688], where some old robots do override getTime() - // with their own events that inherits from robocode.Event. - public /* final*/long getTime() { - return time; - } - - /** - * Changes the time when this event occurred. - *

- * Note that the time is equal to the turn of a battle round. - *

- * This method is intended for letting robot developers create their own event types. - * It is not possible to change the time of an event after it has been added to the event - * queue of the robot. - * - * @param newTime the time this event occurred - */ - public void setTime(long newTime) { - if (addedToQueue) { - Logger.printlnToRobotsConsole( - "SYSTEM: The time of an event cannot be changed after it has been added the event queue."); - } else { - time = newTime; - } - } - - /** - * Returns the priority of this event. - *

- * An event priority is a value from 0 - 99. The higher value, the higher priority. - *

- * The default priority is 80, but varies depending on the type of event. - * - * @return the priority of this event. - */ - public int getPriority() { - return priority; - } - - /** - * Changes the priority of this event. - * An event priority is a value from 0 - 99. The higher value, the higher priority. - *

- * The default priority is 80, but varies depending on the type of event. - *

- * This method is intended for letting robot developers create their own event types. - * It is not possible to change the priority of an event after it has been added to the event - * queue of the robot. - * - * @param newPriority the new priority of this event - * @see AdvancedRobot#setEventPriority(String, int) - */ - public final void setPriority(int newPriority) { - if (addedToQueue) { - Logger.printlnToRobotsConsole( - "SYSTEM: The priority of an event cannot be changed after it has been added the event queue."); - } else { - setPriorityHidden(newPriority); - } - } - - /** - * Hidden method for setting the exact time when this event occurred. - *

- * Notice: This method is called by the game engine only. - * - * @param time the time when this event occurred. - */ - // This method must be invisible on Robot API - private void setTimeHidden(long time) { - // we do not replace time which is set by robot to the future - if (this.time < time) { - this.time = time; - } - // when this flag is set, robots are not allowed to change the time or priority of the event anymore - addedToQueue = true; - } - - /** - * Hidden method for setting the priority from the game engine without checking for the 'addedToQueue' flag. - *

- * Notice: This method is called by the game engine only. - * - * @param newPriority the new priority of this event. - */ - // This method must be invisible on Robot API - private void setPriorityHidden(int newPriority) { - if (newPriority < 0) { - Logger.printlnToRobotsConsole("SYSTEM: Priority must be between 0 and 99"); - Logger.printlnToRobotsConsole("SYSTEM: Priority for " + this.getClass().getName() + " will be 0"); - newPriority = 0; - } else if (newPriority > 99) { - Logger.printlnToRobotsConsole("SYSTEM: Priority must be between 0 and 99"); - Logger.printlnToRobotsConsole("SYSTEM: Priority for " + this.getClass().getName() + " will be 99"); - newPriority = 99; - } - priority = newPriority; - } - - /** - * Dispatch this event a the robot, it's statistics, and graphics context. - * - * @param robot the robot to dispatch to. - * @param statics the statistics to dispatch to. - * @param graphics the graphics to dispatch to. - */ - // This method must be invisible on Robot API - void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) {} - - /** - * Returns the default priority of this event class. - */ - // This method must be invisible on Robot API - int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * Checks if this event must be delivered even after timeout. - * - * @return {@code true} when this event must be delivered even after timeout; - * {@code false} otherwise. - */ - // This method must be invisible on Robot API - boolean isCriticalEvent() { - return false; - } - - // This method must be invisible on Robot API - byte getSerializationType() { - throw new Error("Serialization not supported on this event type"); - } - - /** - * Returns a hidden event helper for accessing hidden methods on this object. - */ - // This method must be invisible on Robot API - static IHiddenEventHelper createHiddenHelper() { - return new HiddenEventHelper(); - } - - /** - * Hidden event helper implementation for accessing the internal methods of an event. - *

- * This class is used internally by the game engine. - */ - // This method must be invisible on Robot API - private static class HiddenEventHelper implements IHiddenEventHelper { - - public void setTime(Event event, long newTime) { - event.setTimeHidden(newTime); - } - - public void setDefaultPriority(Event event) { - event.setPriority(event.getDefaultPriority()); - } - - public void setPriority(Event event, int newPriority) { - event.setPriorityHidden(newPriority); - } - - public boolean isCriticalEvent(Event event) { - return event.isCriticalEvent(); - } - - public void dispatch(Event event, IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - event.dispatch(robot, statics, graphics); - } - - public byte getSerializationType(Event event) { - return event.getSerializationType(); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/GunTurnCompleteCondition.java b/workspace_robo/robocode.api/src/main/java/robocode/GunTurnCompleteCondition.java deleted file mode 100644 index 63deee1..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/GunTurnCompleteCondition.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * A prebuilt condition you can use that indicates your gun has finished - * turning. - * - * @see Condition - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Nathaniel Troutman (contributor) - */ -public class GunTurnCompleteCondition extends Condition { - private AdvancedRobot robot = null; - - /** - * Creates a new GunTurnCompleteCondition with default priority. - * The default priority is 80. - * - * @param robot your robot, which must be a {@link AdvancedRobot} - */ - public GunTurnCompleteCondition(AdvancedRobot robot) { - super(); - this.robot = robot; - } - - /** - * Creates a new GunTurnCompleteCondition with a specific priority. - * A condition priority is a value from 0 - 99. The higher value, the - * higher priority. The default priority is 80. - * - * @param robot your robot, which must be a {@link AdvancedRobot} - * @param priority the priority of this condition - * @see Condition#setPriority(int) - */ - public GunTurnCompleteCondition(AdvancedRobot robot, int priority) { - super(); - this.robot = robot; - this.priority = priority; - } - - /** - * Tests if the gun has stopped turning. - * - * @return {@code true} if the gun has stopped turning; {@code false} - * otherwise - */ - @Override - public boolean test() { - return (robot.getGunTurnRemaining() == 0); - } - - /** - * Called by the system in order to clean up references to internal objects. - * - * @since 1.4.3 - */ - @Override - public final void cleanup() { - robot = null; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/HitByBulletEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/HitByBulletEvent.java deleted file mode 100644 index 9d215d4..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/HitByBulletEvent.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A HitByBulletEvent is sent to {@link Robot#onHitByBullet(HitByBulletEvent) - * onHitByBullet()} when your robot has been hit by a bullet. - * You can use the information contained in this event to determine what to do. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public final class HitByBulletEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 20; - - private final double bearing; - private final Bullet bullet; - - /** - * Called by the game to create a new HitByBulletEvent. - * - * @param bearing the bearing of the bullet that hit your robot, in radians - * @param bullet the bullet that has hit your robot - */ - public HitByBulletEvent(double bearing, Bullet bullet) { - super(); - this.bearing = bearing; - this.bullet = bullet; - } - - /** - * Returns the bearing to the bullet, relative to your robot's heading, - * in degrees (-180 < getBearing() <= 180). - *

- * If you were to turnRight(event.getBearing()), you would be facing the - * direction the bullet came from. The calculation used here is: - * (bullet's heading in degrees + 180) - (your heading in degrees) - * - * @return the bearing to the bullet, in degrees - */ - public double getBearing() { - return bearing * 180.0 / Math.PI; - } - - /** - * Returns the bearing to the bullet, relative to your robot's heading, - * in radians (-Math.PI < getBearingRadians() <= Math.PI). - *

- * If you were to turnRightRadians(event.getBearingRadians()), you would be - * facing the direction the bullet came from. The calculation used here is: - * (bullet's heading in radians + Math.PI) - (your heading in radians) - * - * @return the bearing to the bullet, in radians - */ - public double getBearingRadians() { - return bearing; - } - - /** - * Returns the bullet that hit your robot. - * - * @return the bullet that hit your robot - */ - public Bullet getBullet() { - return bullet; - } - - /** - * Returns the heading of the bullet when it hit you, in degrees - * (0 <= getHeading() < 360). - *

- * Note: This is not relative to the direction you are facing. The robot - * that fired the bullet was in the opposite direction of getHeading() when - * it fired the bullet. - * - * @return the heading of the bullet, in degrees - */ - public double getHeading() { - return bullet.getHeading(); - } - - /** - * @return the heading of the bullet, in degrees - * @deprecated Use {@link #getHeading()} instead. - */ - @Deprecated - public double getHeadingDegrees() { - return getHeading(); - } - - /** - * Returns the heading of the bullet when it hit you, in radians - * (0 <= getHeadingRadians() < 2 * PI). - *

- * Note: This is not relative to the direction you are facing. The robot - * that fired the bullet was in the opposite direction of - * getHeadingRadians() when it fired the bullet. - * - * @return the heading of the bullet, in radians - */ - public double getHeadingRadians() { - return bullet.getHeadingRadians(); - } - - /** - * Returns the name of the robot that fired the bullet. - * - * @return the name of the robot that fired the bullet - */ - public String getName() { - return bullet.getName(); - } - - /** - * Returns the power of this bullet. The damage you take (in fact, already - * took) is 4 * power, plus 2 * (power-1) if power > 1. The robot that fired - * the bullet receives 3 * power back. - * - * @return the power of the bullet - */ - public double getPower() { - return bullet.getPower(); - } - - /** - * Returns the velocity of this bullet. - * - * @return the velocity of the bullet - */ - public double getVelocity() { - return bullet.getVelocity(); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null) { - listener.onHitByBullet(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.HitByBulletEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - HitByBulletEvent obj = (HitByBulletEvent) object; - - return RbSerializer.SIZEOF_TYPEINFO + serializer.sizeOf(RbSerializer.Bullet_TYPE, obj.bullet) - + RbSerializer.SIZEOF_DOUBLE; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - HitByBulletEvent obj = (HitByBulletEvent) object; - - serializer.serialize(buffer, RbSerializer.Bullet_TYPE, obj.bullet); - serializer.serialize(buffer, obj.bearing); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - Bullet bullet = (Bullet) serializer.deserializeAny(buffer); - double bearing = buffer.getDouble(); - - return new HitByBulletEvent(bearing, bullet); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/HitRobotEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/HitRobotEvent.java deleted file mode 100644 index 81307c2..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/HitRobotEvent.java +++ /dev/null @@ -1,209 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A HitRobotEvent is sent to {@link Robot#onHitRobot(HitRobotEvent) onHitRobot()} - * when your robot collides with another robot. - * You can use the information contained in this event to determine what to do. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public final class HitRobotEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 40; - - private final String robotName; - private final double bearing; - private final double energy; - private final boolean atFault; - - /** - * Called by the game to create a new HitRobotEvent. - * - * @param name the name of the robot you hit - * @param bearing the bearing to the robot that your robot hit, in radians - * @param energy the amount of energy of the robot you hit - * @param atFault {@code true} if your robot was moving toward the other - * robot; {@code false} otherwise - */ - public HitRobotEvent(String name, double bearing, double energy, boolean atFault) { - this.robotName = name; - this.bearing = bearing; - this.energy = energy; - this.atFault = atFault; - } - - /** - * Returns the bearing to the robot you hit, relative to your robot's - * heading, in degrees (-180 <= getBearing() < 180) - * - * @return the bearing to the robot you hit, in degrees - */ - public double getBearing() { - return bearing * 180.0 / Math.PI; - } - - /** - * @return the bearing to the robot you hit, in degrees - * @deprecated Use {@link #getBearing()} instead. - */ - @Deprecated - public double getBearingDegrees() { - return getBearing(); - } - - /** - * Returns the bearing to the robot you hit, relative to your robot's - * heading, in radians (-PI <= getBearingRadians() < PI) - * - * @return the bearing to the robot you hit, in radians - */ - public double getBearingRadians() { - return bearing; - } - - /** - * Returns the amount of energy of the robot you hit. - * - * @return the amount of energy of the robot you hit - */ - public double getEnergy() { - return energy; - } - - /** - * Returns the name of the robot you hit. - * - * @return the name of the robot you hit - */ - public String getName() { - return robotName; - } - - /** - * @return the name of the robot you hit - * @deprecated Use {@link #getName()} instead. - */ - @Deprecated - public String getRobotName() { - return robotName; - } - - /** - * Checks if your robot was moving towards the robot that was hit. - *

- * If {@link #isMyFault()} returns {@code true} then your robot's movement - * (including turning) will have stopped and been marked complete. - *

- * Note: If two robots are moving toward each other and collide, they will - * each receive two HitRobotEvents. The first will be the one if - * {@link #isMyFault()} returns {@code true}. - * - * @return {@code true} if your robot was moving towards the robot that was - * hit; {@code false} otherwise. - */ - public boolean isMyFault() { - return atFault; - } - - /** - * {@inheritDoc} - */ - @Override - public final int compareTo(Event event) { - final int res = super.compareTo(event); - - if (res != 0) { - return res; - } - - // Compare the isMyFault, if the events are HitRobotEvents - // The isMyFault has higher priority when it is set compared to when it is not set - if (event instanceof HitRobotEvent) { - int compare1 = (this).isMyFault() ? -1 : 0; - int compare2 = ((HitRobotEvent) event).isMyFault() ? -1 : 0; - - return compare1 - compare2; - } - - // No difference found - return 0; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null) { - listener.onHitRobot(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.HitRobotEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - HitRobotEvent obj = (HitRobotEvent) object; - - return RbSerializer.SIZEOF_TYPEINFO + serializer.sizeOf(obj.robotName) + 2 * RbSerializer.SIZEOF_DOUBLE - + RbSerializer.SIZEOF_BOOL; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - HitRobotEvent obj = (HitRobotEvent) object; - - serializer.serialize(buffer, obj.robotName); - serializer.serialize(buffer, obj.bearing); - serializer.serialize(buffer, obj.energy); - serializer.serialize(buffer, obj.atFault); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - String robotName = serializer.deserializeString(buffer); - double bearing = buffer.getDouble(); - double energy = buffer.getDouble(); - boolean atFault = serializer.deserializeBoolean(buffer); - - return new HitRobotEvent(robotName, bearing, energy, atFault); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/HitWallEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/HitWallEvent.java deleted file mode 100644 index 4043070..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/HitWallEvent.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A HitWallEvent is sent to {@link Robot#onHitWall(HitWallEvent) onHitWall()} - * when you collide a wall. - * You can use the information contained in this event to determine what to do. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public final class HitWallEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 30; - - private final double bearing; - - /** - * Called by the game to create a new HitWallEvent. - * - * @param bearing the bearing to the wall that your robot hit, in radians - */ - public HitWallEvent(double bearing) { - this.bearing = bearing; - } - - /** - * Returns the bearing to the wall you hit, relative to your robot's - * heading, in degrees (-180 <= getBearing() < 180) - * - * @return the bearing to the wall you hit, in degrees - */ - public double getBearing() { - return bearing * 180.0 / Math.PI; - } - - /** - * @return the bearing to the wall you hit, in degrees - * @deprecated Use {@link #getBearing()} instead. - */ - @Deprecated - public double getBearingDegrees() { - return getBearing(); - } - - /** - * Returns the bearing to the wall you hit, relative to your robot's - * heading, in radians (-PI <= getBearingRadians() < PI) - * - * @return the bearing to the wall you hit, in radians - */ - public double getBearingRadians() { - return bearing; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null) { - listener.onHitWall(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.HitWallEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_DOUBLE; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - HitWallEvent obj = (HitWallEvent) object; - - serializer.serialize(buffer, obj.bearing); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - double bearing = buffer.getDouble(); - - return new HitWallEvent(bearing); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/JuniorRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/JuniorRobot.java deleted file mode 100644 index 8531c7b..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/JuniorRobot.java +++ /dev/null @@ -1,907 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IJuniorRobot; -import robocode.robotinterfaces.peer.IJuniorRobotPeer; -import robocode.util.Utils; - -import java.awt.*; -import static java.lang.Math.toRadians; - - -/** - * This is the simplest robot type, which is simpler than the {@link Robot} and - * {@link AdvancedRobot} classes. The JuniorRobot has a simplified model, in - * purpose of teaching programming skills to inexperienced in programming - * students. The simplified robot model will keep player from overwhelming of - * Robocode's rules, programming syntax and programming concept. - *

- * Instead of using getters and setters, public fields are provided for - * receiving information like the last scanned robot, the coordinate of the - * robot etc. - *

- * All methods on this class are blocking calls, i.e. they do not return before - * their action has been completed and will at least take one turn to execute. - * However, setting colors is executed immediately and does not cost a turn to - * perform. - * - * @see Robot - * @see AdvancedRobot - * @see TeamRobot - * @see RateControlRobot - * @see Droid - * @see BorderSentry - * - * @author Nutch Poovarawan from Cubic Creative (designer) - * @author Flemming N. Larsen (original) - * @author Pavel Savara (contributor) - * - * @since 1.4 - */ -public class JuniorRobot extends _RobotBase implements IJuniorRobot { - - /** - * The color black (0x000000) - */ - public final static int black = 0x000000; - - /** - * The color white (0xFFFFFF) - */ - public final static int white = 0xFFFFFF; - - /** - * The color red (0xFF0000) - */ - public final static int red = 0xFF0000; - - /** - * The color orange (0xFFA500) - */ - public final static int orange = 0xFFA500; - - /** - * The color yellow (0xFFFF00) - */ - public final static int yellow = 0xFFFF00; - - /** - * The color green (0x008000) - */ - public final static int green = 0x008000; - - /** - * The color blue (0x0000FF) - */ - public final static int blue = 0x0000FF; - - /** - * The color purple (0x800080) - */ - public final static int purple = 0x800080; - - /** - * The color brown (0x8B4513) - */ - public final static int brown = 0x8B4513; - - /** - * The color gray (0x808080) - */ - public final static int gray = 0x808080; - - /** - * Contains the width of the battlefield. - * - * @see #fieldWidth - */ - public int fieldWidth; - - /** - * Contains the height of the battlefield. - * - * @see #fieldWidth - */ - public int fieldHeight; - - /** - * Current number of other robots on the battle field. - */ - public int others; - - /** - * Current energy of this robot, where 100 means full energy and 0 means no energy (dead). - */ - public int energy; - - /** - * Current horizontal location of this robot (in pixels). - * - * @see #robotY - */ - public int robotX; - - /** - * Current vertical location of this robot (in pixels). - * - * @see #robotX - */ - public int robotY; - - /** - * Current heading angle of this robot (in degrees). - * - * @see #turnLeft(int) - * @see #turnRight(int) - * @see #turnTo(int) - * @see #turnAheadLeft(int, int) - * @see #turnAheadRight(int, int) - * @see #turnBackLeft(int, int) - * @see #turnBackRight(int, int) - */ - public int heading; - - /** - * Current gun heading angle of this robot (in degrees). - * - * @see #gunBearing - * @see #turnGunLeft(int) - * @see #turnGunRight(int) - * @see #turnGunTo(int) - * @see #bearGunTo(int) - */ - public int gunHeading; - - /** - * Current gun heading angle of this robot compared to its body (in degrees). - * - * @see #gunHeading - * @see #turnGunLeft(int) - * @see #turnGunRight(int) - * @see #turnGunTo(int) - * @see #bearGunTo(int) - */ - public int gunBearing; - - /** - * Flag specifying if the gun is ready to fire, i.e. gun heat <= 0. - * {@code true} means that the gun is able to fire; {@code false} - * means that the gun cannot fire yet as it still needs to cool down. - * - * @see #fire() - * @see #fire(double) - */ - public boolean gunReady; - - /** - * Current distance to the scanned nearest other robot (in pixels). - * If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - * This field will not be updated while {@link #onScannedRobot()} event is active. - * - * @see #onScannedRobot() - * @see #scannedAngle - * @see #scannedBearing - * @see #scannedEnergy - * @see #scannedVelocity - * @see #scannedHeading - */ - public int scannedDistance = -1; - - /** - * Current angle to the scanned nearest other robot (in degrees). - * If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - * This field will not be updated while {@link #onScannedRobot()} event is active. - * - * @see #onScannedRobot() - * @see #scannedDistance - * @see #scannedBearing - * @see #scannedEnergy - * @see #scannedVelocity - * @see #scannedHeading - */ - public int scannedAngle = -1; - - /** - * Current angle to the scanned nearest other robot (in degrees) compared to - * the body of this robot. - * If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - * This field will not be updated while {@link #onScannedRobot()} event is active. - * - * @see #onScannedRobot() - * @see #scannedDistance - * @see #scannedAngle - * @see #scannedEnergy - * @see #scannedVelocity - * @see #scannedHeading - */ - public int scannedBearing = -1; - - /** - * Current velocity of the scanned nearest other robot. - * If there is no robot in the radar's sight, this field will be -99. - * Note that a positive value means that the robot moves forward, a negative - * value means that the robot moved backward, and 0 means that the robot is - * not moving at all. - * This field will not be updated while {@link #onScannedRobot()} event is active. - * - * @see #onScannedRobot() - * @see #scannedDistance - * @see #scannedAngle - * @see #scannedBearing - * @see #scannedEnergy - * @see #scannedHeading - */ - public int scannedVelocity = -99; - - /** - * Current heading of the scanned nearest other robot (in degrees). - * If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - * This field will not be updated while {@link #onScannedRobot()} event is active. - * - * @see #onScannedRobot() - * @see #scannedDistance - * @see #scannedAngle - * @see #scannedBearing - * @see #scannedEnergy - * @see #scannedVelocity - */ - public int scannedHeading = -1; - - /** - * Current energy of scanned nearest other robot. - * If there is no robot in the radar's sight, this field will be less than 0, i.e -1. - * This field will not be updated while {@link #onScannedRobot()} event is active. - * - * @see #onScannedRobot() - * @see #scannedDistance - * @see #scannedAngle - * @see #scannedBearing - * @see #scannedVelocity - */ - public int scannedEnergy = -1; - - /** - * Latest angle from where this robot was hit by a bullet (in degrees). - * If the robot has never been hit, this field will be less than 0, i.e. -1. - * This field will not be updated while {@link #onHitByBullet()} event is active. - * - * @see #onHitByBullet() - * @see #hitByBulletBearing - */ - public int hitByBulletAngle = -1; - - /** - * Latest angle from where this robot was hit by a bullet (in degrees) - * compared to the body of this robot. - * If the robot has never been hit, this field will be less than 0, i.e. -1. - * This field will not be updated while {@link #onHitByBullet()} event is active. - * - * @see #onHitByBullet() - * @see #hitByBulletAngle - */ - public int hitByBulletBearing = -1; - - /** - * Latest angle where this robot has hit another robot (in degrees). - * If this robot has never hit another robot, this field will be less than 0, i.e. -1. - * This field will not be updated while {@link #onHitRobot()} event is active. - * - * @see #onHitRobot() - * @see #hitRobotBearing - */ - public int hitRobotAngle = -1; - - /** - * Latest angle where this robot has hit another robot (in degrees) - * compared to the body of this robot. - * If this robot has never hit another robot, this field will be less than 0, i.e. -1. - * This field will not be updated while {@link #onHitRobot()} event is active. - * - * @see #onHitRobot() - * @see #hitRobotAngle - */ - public int hitRobotBearing = -1; - - /** - * Latest angle where this robot has hit a wall (in degrees). - * If this robot has never hit a wall, this field will be less than 0, i.e. -1. - * This field will not be updated while {@link #onHitWall()} event is active. - * - * @see #onHitWall() - * @see #hitWallBearing - */ - public int hitWallAngle = -1; - - /** - * Latest angle where this robot has hit a wall (in degrees) - * compared to the body of this robot. - * If this robot has never hit a wall, this field will be less than 0, i.e. -1. - * This field will not be updated while {@link #onHitWall()} event is active. - * - * @see #onHitWall() - * @see #hitWallAngle - */ - public int hitWallBearing = -1; - - /** - * The robot event handler for this robot. - */ - private InnerEventHandler innerEventHandler; - - /** - * Moves this robot forward by pixels. - * - * @param distance the amount of pixels to move forward - * @see #back(int) - * @see #robotX - * @see #robotY - */ - public void ahead(int distance) { - if (peer != null) { - peer.move(distance); - } else { - uninitializedException(); - } - } - - /** - * Moves this robot backward by pixels. - * - * @param distance the amount of pixels to move backward - * @see #ahead(int) - * @see #robotX - * @see #robotY - */ - public void back(int distance) { - ahead(-distance); - } - - /** - * Turns the gun to the specified angle (in degrees) relative to body of this robot. - * The gun will turn to the side with the shortest delta angle to the specified angle. - * - * @param angle the angle to turn the gun to relative to the body of this robot - * @see #gunHeading - * @see #gunBearing - * @see #turnGunLeft(int) - * @see #turnGunRight(int) - * @see #turnGunTo(int) - */ - public void bearGunTo(int angle) { - if (peer != null) { - peer.turnGun(Utils.normalRelativeAngle(peer.getBodyHeading() + toRadians(angle) - peer.getGunHeading())); - } else { - uninitializedException(); - } - } - - /** - * Skips a turn. - * - * @see #doNothing(int) - */ - public void doNothing() { - if (peer != null) { - peer.execute(); - } else { - uninitializedException(); - } - } - - /** - * Skips the specified number of turns. - * - * @param turns the number of turns to skip - * @see #doNothing() - */ - public void doNothing(int turns) { - if (turns <= 0) { - return; - } - if (peer != null) { - for (int i = 0; i < turns; i++) { - peer.execute(); - } - } else { - uninitializedException(); - } - } - - /** - * Fires a bullet with the default power of 1. - * If the gun heat is more than 0 and hence cannot fire, this method will - * suspend until the gun is ready to fire, and then fire a bullet. - * - * @see #gunReady - */ - public void fire() { - fire(1); - } - - /** - * Fires a bullet with the specified bullet power, which is between 0.1 and 3 - * where 3 is the maximum bullet power. - * If the gun heat is more than 0 and hence cannot fire, this method will - * suspend until the gun is ready to fire, and then fire a bullet. - * - * @param power between 0.1 and 3 - * @see #gunReady - */ - public void fire(double power) { - if (peer != null) { - getEventHandler().juniorFirePower = power; - peer.execute(); - } else { - uninitializedException(); - } - } - - /** - * Do not call this method! - *

- * {@inheritDoc} - */ - public final IBasicEvents getBasicEventListener() { - return getEventHandler(); - } - - /** - * Do not call this method! - *

- * {@inheritDoc} - */ - public final Runnable getRobotRunnable() { - return getEventHandler(); - } - - /** - * This event methods is called from the game when this robot has been hit - * by another robot's bullet. When this event occurs the - * {@link #hitByBulletAngle} and {@link #hitByBulletBearing} fields values - * are automatically updated. - * - * @see #hitByBulletAngle - * @see #hitByBulletBearing - */ - public void onHitByBullet() {} - - /** - * This event methods is called from the game when a bullet from this robot - * has hit another robot. When this event occurs the {@link #hitRobotAngle} - * and {@link #hitRobotBearing} fields values are automatically updated. - * - * @see #hitRobotAngle - * @see #hitRobotBearing - */ - public void onHitRobot() {} - - /** - * This event methods is called from the game when this robot has hit a wall. - * When this event occurs the {@link #hitWallAngle} and {@link #hitWallBearing} - * fields values are automatically updated. - * - * @see #hitWallAngle - * @see #hitWallBearing - */ - public void onHitWall() {} - - /** - * This event method is called from the game when the radar detects another - * robot. When this event occurs the {@link #scannedDistance}, - * {@link #scannedAngle}, {@link #scannedBearing}, and {@link #scannedEnergy} - * field values are automatically updated. - * - * @see #scannedDistance - * @see #scannedAngle - * @see #scannedBearing - * @see #scannedEnergy - */ - public void onScannedRobot() {} - - /** - * The main method in every robot. You must override this to set up your - * robot's basic behavior. - *

- * Example: - *

-	 *   // A basic robot that moves around in a square
-	 *   public void run() {
-	 *       ahead(100);
-	 *       turnRight(90);
-	 *   }
-	 * 
- * This method is automatically re-called when it has returned. - */ - public void run() {} - - /** - * Sets the colors of the robot. The color values are RGB values. - * You can use the colors that are already defined for this class. - * - * @param bodyColor the RGB color value for the body - * @param gunColor the RGB color value for the gun - * @param radarColor the RGB color value for the radar - * @see #setColors(int, int, int, int, int) - */ - public void setColors(int bodyColor, int gunColor, int radarColor) { - if (peer != null) { - peer.setBodyColor(new Color(bodyColor)); - peer.setGunColor(new Color(gunColor)); - peer.setRadarColor(new Color(radarColor)); - } else { - uninitializedException(); - } - } - - /** - * Sets the colors of the robot. The color values are RGB values. - * You can use the colors that are already defined for this class. - * - * @param bodyColor the RGB color value for the body - * @param gunColor the RGB color value for the gun - * @param radarColor the RGB color value for the radar - * @param bulletColor the RGB color value for the bullets - * @param scanArcColor the RGB color value for the scan arc - * @see #setColors(int, int, int) - */ - public void setColors(int bodyColor, int gunColor, int radarColor, int bulletColor, int scanArcColor) { - if (peer != null) { - peer.setBodyColor(new Color(bodyColor)); - peer.setGunColor(new Color(gunColor)); - peer.setRadarColor(new Color(radarColor)); - peer.setBulletColor(new Color(bulletColor)); - peer.setScanColor(new Color(scanArcColor)); - } else { - uninitializedException(); - } - } - - /** - * Moves this robot forward by pixels and turns this robot left by degrees - * at the same time. The robot will move in a curve that follows a perfect - * circle, and the moving and turning will end at the same time. - *

- * Note that the max. velocity and max. turn rate is automatically adjusted, - * which means that the robot will move slower the sharper the turn is - * compared to the distance. - * - * @param distance the amount of pixels to move forward - * @param degrees the amount of degrees to turn to the left - * @see #heading - * @see #robotX - * @see #robotY - * @see #turnLeft(int) - * @see #turnRight(int) - * @see #turnTo(int) - * @see #turnAheadRight(int, int) - * @see #turnBackLeft(int, int) - * @see #turnBackRight(int, int) - */ - public void turnAheadLeft(int distance, int degrees) { - turnAheadRight(distance, -degrees); - } - - /** - * Moves this robot forward by pixels and turns this robot right by degrees - * at the same time. The robot will move in a curve that follows a perfect - * circle, and the moving and turning will end at the same time. - *

- * Note that the max. velocity and max. turn rate is automatically adjusted, - * which means that the robot will move slower the sharper the turn is - * compared to the distance. - * - * @param distance the amount of pixels to move forward - * @param degrees the amount of degrees to turn to the right - * @see #heading - * @see #robotX - * @see #robotY - * @see #turnLeft(int) - * @see #turnRight(int) - * @see #turnTo(int) - * @see #turnAheadLeft(int, int) - * @see #turnBackLeft(int, int) - * @see #turnBackRight(int, int) - */ - public void turnAheadRight(int distance, int degrees) { - if (peer != null) { - ((IJuniorRobotPeer) peer).turnAndMove(distance, toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Moves this robot backward by pixels and turns this robot left by degrees - * at the same time. The robot will move in a curve that follows a perfect - * circle, and the moving and turning will end at the same time. - *

- * Note that the max. velocity and max. turn rate is automatically adjusted, - * which means that the robot will move slower the sharper the turn is - * compared to the distance. - * - * @param distance the amount of pixels to move backward - * @param degrees the amount of degrees to turn to the left - * @see #heading - * @see #robotX - * @see #robotY - * @see #turnLeft(int) - * @see #turnRight(int) - * @see #turnTo(int) - * @see #turnAheadLeft(int, int) - * @see #turnAheadRight(int, int) - * @see #turnBackRight(int, int) - */ - public void turnBackLeft(int distance, int degrees) { - turnAheadRight(-distance, degrees); - } - - /** - * Moves this robot backward by pixels and turns this robot right by degrees - * at the same time. The robot will move in a curve that follows a perfect - * circle, and the moving and turning will end at the same time. - *

- * Note that the max. velocity and max. turn rate is automatically adjusted, - * which means that the robot will move slower the sharper the turn is - * compared to the distance. - * - * @param distance the amount of pixels to move backward - * @param degrees the amount of degrees to turn to the right - * @see #heading - * @see #robotX - * @see #robotY - * @see #turnLeft(int) - * @see #turnRight(int) - * @see #turnTo(int) - * @see #turnAheadLeft(int, int) - * @see #turnAheadRight(int, int) - * @see #turnBackLeft(int, int) - */ - public void turnBackRight(int distance, int degrees) { - turnAheadRight(-distance, -degrees); - } - - /** - * Turns the gun left by degrees. - * - * @param degrees the amount of degrees to turn the gun to the left - * @see #gunHeading - * @see #gunBearing - * @see #turnGunRight(int) - * @see #turnGunTo(int) - * @see #bearGunTo(int) - */ - public void turnGunLeft(int degrees) { - turnGunRight(-degrees); - } - - /** - * Turns the gun right by degrees. - * - * @param degrees the amount of degrees to turn the gun to the right - * @see #gunHeading - * @see #gunBearing - * @see #turnGunLeft(int) - * @see #turnGunTo(int) - * @see #bearGunTo(int) - */ - public void turnGunRight(int degrees) { - if (peer != null) { - peer.turnGun(toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Turns the gun to the specified angle (in degrees). - * The gun will turn to the side with the shortest delta angle to the - * specified angle. - * - * @param angle the angle to turn the gun to - * @see #gunHeading - * @see #gunBearing - * @see #turnGunLeft(int) - * @see #turnGunRight(int) - * @see #bearGunTo(int) - */ - public void turnGunTo(int angle) { - if (peer != null) { - peer.turnGun(Utils.normalRelativeAngle(toRadians(angle) - peer.getGunHeading())); - } else { - uninitializedException(); - } - } - - /** - * Turns this robot left by degrees. - * - * @param degrees the amount of degrees to turn to the left - * @see #heading - * @see #turnRight(int) - * @see #turnTo(int) - * @see #turnAheadLeft(int, int) - * @see #turnAheadRight(int, int) - * @see #turnBackLeft(int, int) - * @see #turnBackRight(int, int) - */ - public void turnLeft(int degrees) { - turnRight(-degrees); - } - - /** - * Turns this robot right by degrees. - * - * @param degrees the amount of degrees to turn to the right - * @see #heading - * @see #turnLeft(int) - * @see #turnTo(int) - * @see #turnAheadLeft(int, int) - * @see #turnAheadRight(int, int) - * @see #turnBackLeft(int, int) - * @see #turnBackRight(int, int) - */ - public void turnRight(int degrees) { - if (peer != null) { - peer.turnBody(toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Turns this robot to the specified angle (in degrees). - * The robot will turn to the side with the shortest delta angle to the - * specified angle. - * - * @param angle the angle to turn this robot to - * @see #heading - * @see #turnLeft(int) - * @see #turnRight(int) - * @see #turnAheadLeft(int, int) - * @see #turnAheadRight(int, int) - * @see #turnBackLeft(int, int) - * @see #turnBackRight(int, int) - */ - public void turnTo(int angle) { - if (peer != null) { - peer.turnBody(Utils.normalRelativeAngle(toRadians(angle) - peer.getBodyHeading())); - } else { - uninitializedException(); - } - } - - /* - * Returns the event handler of this robot. - */ - private InnerEventHandler getEventHandler() { - if (innerEventHandler == null) { - innerEventHandler = new InnerEventHandler(); - } - return innerEventHandler; - } - - /* - * The JuniorRobot event handler, which implements the basic robot events, - * JuniorRobot event, and Runnable. - */ - private final class InnerEventHandler implements IBasicEvents, Runnable { - - private double juniorFirePower; - private long currentTurn; - - public void onBulletHit(BulletHitEvent event) {} - - public void onBulletHitBullet(BulletHitBulletEvent event) {} - - public void onBulletMissed(BulletMissedEvent event) {} - - public void onDeath(DeathEvent event) {} - - public void onHitByBullet(HitByBulletEvent event) { - double angle = peer.getBodyHeading() + event.getBearingRadians(); - - hitByBulletAngle = (int) (Math.toDegrees(Utils.normalAbsoluteAngle(angle)) + 0.5); - hitByBulletBearing = (int) (event.getBearing() + 0.5); - JuniorRobot.this.onHitByBullet(); - } - - public void onHitRobot(HitRobotEvent event) { - double angle = peer.getBodyHeading() + event.getBearingRadians(); - - hitRobotAngle = (int) (Math.toDegrees(Utils.normalAbsoluteAngle(angle)) + 0.5); - hitRobotBearing = (int) (event.getBearing() + 0.5); - JuniorRobot.this.onHitRobot(); - } - - public void onHitWall(HitWallEvent event) { - double angle = peer.getBodyHeading() + event.getBearingRadians(); - - hitWallAngle = (int) (Math.toDegrees(Utils.normalAbsoluteAngle(angle)) + 0.5); - hitWallBearing = (int) (event.getBearing() + 0.5); - JuniorRobot.this.onHitWall(); - } - - public void onRobotDeath(RobotDeathEvent event) { - others = peer.getOthers(); - } - - public void onScannedRobot(ScannedRobotEvent event) { - scannedDistance = (int) (event.getDistance() + 0.5); - scannedEnergy = Math.max(1, (int) (event.getEnergy() + 0.5)); - scannedAngle = (int) (Math.toDegrees( - Utils.normalAbsoluteAngle(peer.getBodyHeading() + event.getBearingRadians())) - + 0.5); - scannedBearing = (int) (event.getBearing() + 0.5); - scannedHeading = (int) (event.getHeading() + 0.5); - scannedVelocity = (int) (event.getVelocity() + 0.5); - - JuniorRobot.this.onScannedRobot(); - } - - public void onStatus(StatusEvent e) { - final RobotStatus s = e.getStatus(); - - others = peer.getOthers(); - energy = Math.max(1, (int) (s.getEnergy() + 0.5)); - robotX = (int) (s.getX() + 0.5); - robotY = (int) (s.getY() + 0.5); - heading = (int) (s.getHeading() + 0.5); - gunHeading = (int) (s.getGunHeading() + 0.5); - gunBearing = (int) (Utils.normalRelativeAngle(s.getGunHeading() - s.getHeading()) + 0.5); - gunReady = (s.getGunHeat() <= 0); - - currentTurn = e.getTime(); - - // Auto fire - if (juniorFirePower > 0 && gunReady && (peer.getGunTurnRemaining() == 0)) { - if (peer.setFire(juniorFirePower) != null) { - gunReady = false; - juniorFirePower = 0; - } - } - - // Reset event data - scannedDistance = -1; - scannedAngle = -1; - scannedBearing = -1; - scannedVelocity = -99; - scannedHeading = -1; - scannedEnergy = -1; - hitByBulletAngle = -1; - hitByBulletBearing = -1; - hitRobotAngle = -1; - hitRobotBearing = -1; - hitWallAngle = -1; - hitWallBearing = -1; - } - - public void onWin(WinEvent event) {} - - public void run() { - fieldWidth = (int) (peer.getBattleFieldWidth() + 0.5); - fieldHeight = (int) (peer.getBattleFieldHeight() + 0.5); - - // noinspection InfiniteLoopStatement - while (true) { - long lastTurn = currentTurn; // Used for the rescan check - - JuniorRobot.this.run(); // Run the code in the JuniorRobot - - // Make sure that we rescan if the robot did not execute anything this turn. - // When the robot executes the currentTurn will automatically be increased by 1, - // So when the turn stays the same, the robot did not take any action this turn. - if (lastTurn == currentTurn) { - peer.rescan(); // Spend a turn on rescanning - } - } - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/KeyEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/KeyEvent.java deleted file mode 100644 index 4189d3e..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/KeyEvent.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * Super class of all events that originates from the keyboard. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public abstract class KeyEvent extends Event { - private static final long serialVersionUID = 1L; - private final java.awt.event.KeyEvent source; - - /** - * Called by the game to create a new KeyEvent. - * - * @param source the source key event originating from the AWT. - */ - public KeyEvent(java.awt.event.KeyEvent source) { - this.source = source; - } - - /** - * Do not call this method! - *

- * This method is used by the game to determine the type of the source key - * event that occurred in the AWT. - * - * @return the source key event that originates from the AWT. - */ - public java.awt.event.KeyEvent getSourceEvent() { - return source; - } - -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/KeyPressedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/KeyPressedEvent.java deleted file mode 100644 index ba8d1f8..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/KeyPressedEvent.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A KeyPressedEvent is sent to {@link Robot#onKeyPressed(java.awt.event.KeyEvent) - * onKeyPressed()} when a key has been pressed on the keyboard. - * - * @see KeyReleasedEvent - * @see KeyTypedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class KeyPressedEvent extends KeyEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new KeyPressedEvent. - * - * @param source the source key event originating from the AWT. - */ - public KeyPressedEvent(java.awt.event.KeyEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onKeyPressed(getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.KeyPressedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_CHAR + RbSerializer.SIZEOF_INT - + RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG + RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_INT; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - KeyPressedEvent obj = (KeyPressedEvent) object; - java.awt.event.KeyEvent src = obj.getSourceEvent(); - - serializer.serialize(buffer, src.getKeyChar()); - serializer.serialize(buffer, src.getKeyCode()); - serializer.serialize(buffer, src.getKeyLocation()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - char keyChar = buffer.getChar(); - int keyCode = buffer.getInt(); - int keyLocation = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new KeyPressedEvent( - new java.awt.event.KeyEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, keyCode, keyChar, - keyLocation)); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/KeyReleasedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/KeyReleasedEvent.java deleted file mode 100644 index 0c44ab8..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/KeyReleasedEvent.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A KeyReleasedEvent is sent to {@link Robot#onKeyReleased(java.awt.event.KeyEvent) - * onKeyReleased()} when a key has been released on the keyboard. - * - * @see KeyPressedEvent - * @see KeyTypedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class KeyReleasedEvent extends KeyEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new KeyReleasedEvent. - * - * @param source the source key event originating from the AWT. - */ - public KeyReleasedEvent(java.awt.event.KeyEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onKeyReleased(getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.KeyReleasedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_CHAR + RbSerializer.SIZEOF_INT - + RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG + RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_INT; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - KeyReleasedEvent obj = (KeyReleasedEvent) object; - java.awt.event.KeyEvent src = obj.getSourceEvent(); - - serializer.serialize(buffer, src.getKeyChar()); - serializer.serialize(buffer, src.getKeyCode()); - serializer.serialize(buffer, src.getKeyLocation()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - char keyChar = buffer.getChar(); - int keyCode = buffer.getInt(); - int keyLocation = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new KeyReleasedEvent( - new java.awt.event.KeyEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, keyCode, keyChar, - keyLocation)); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/KeyTypedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/KeyTypedEvent.java deleted file mode 100644 index 271b0f1..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/KeyTypedEvent.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A KeyTypedEvent is sent to {@link Robot#onKeyTyped(java.awt.event.KeyEvent) - * onKeyTyped()} when a key has been typed (pressed and released) on the keyboard. - * - * @see KeyPressedEvent - * @see KeyReleasedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class KeyTypedEvent extends KeyEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new KeyTypedEvent. - * - * @param source the source key event originating from the AWT. - */ - public KeyTypedEvent(java.awt.event.KeyEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onKeyTyped(getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.KeyTypedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_CHAR + RbSerializer.SIZEOF_INT - + RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG + RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_INT; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - KeyTypedEvent obj = (KeyTypedEvent) object; - java.awt.event.KeyEvent src = obj.getSourceEvent(); - - serializer.serialize(buffer, src.getKeyChar()); - serializer.serialize(buffer, src.getKeyCode()); - serializer.serialize(buffer, src.getKeyLocation()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - char keyChar = buffer.getChar(); - int keyCode = buffer.getInt(); - int keyLocation = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new KeyTypedEvent( - new java.awt.event.KeyEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, keyCode, keyChar, - keyLocation)); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MessageEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/MessageEvent.java deleted file mode 100644 index c9bbf08..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MessageEvent.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.ITeamEvents; -import robocode.robotinterfaces.ITeamRobot; - -import java.awt.*; -import java.io.Serializable; - - -/** - * A MessageEvent is sent to {@link TeamRobot#onMessageReceived(MessageEvent) - * onMessageReceived()} when a teammate sends a message to your robot. - * You can use the information contained in this event to determine what to do. - * - * @author Mathew A. Nelson (original) - */ -public final class MessageEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 75; - - private final String sender; - private final Serializable message; - - /** - * Called by the game to create a new MessageEvent. - * - * @param sender the name of the sending robot - * @param message the message for your robot - */ - public MessageEvent(String sender, Serializable message) { - this.sender = sender; - this.message = message; - } - - /** - * Returns the name of the sending robot. - * - * @return the name of the sending robot - */ - public String getSender() { - return sender; - } - - /** - * Returns the message itself. - * - * @return the message - */ - public Serializable getMessage() { - return message; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isTeamRobot()) { - ITeamEvents listener = ((ITeamRobot) robot).getTeamEventListener(); - - if (listener != null) { - listener.onMessageReceived(this); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - throw new Error("Serialization of event type not supported"); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MouseClickedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/MouseClickedEvent.java deleted file mode 100644 index 0cda6f9..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MouseClickedEvent.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A MouseClickedEvent is sent to {@link Robot#onMouseClicked(java.awt.event.MouseEvent) - * onMouseClicked()} when the mouse is clicked inside the battle view. - * - * @see MousePressedEvent - * @see MouseReleasedEvent - * @see MouseEnteredEvent - * @see MouseExitedEvent - * @see MouseMovedEvent - * @see MouseDraggedEvent - * @see MouseWheelMovedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class MouseClickedEvent extends MouseEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new MouseClickedEvent. - * - * @param source the source mouse event originating from the AWT. - */ - public MouseClickedEvent(java.awt.event.MouseEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onMouseClicked(getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.MouseClickedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + 6 * RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - MouseClickedEvent obj = (MouseClickedEvent) object; - java.awt.event.MouseEvent src = obj.getSourceEvent(); - - serializer.serialize(buffer, src.getButton()); - serializer.serialize(buffer, src.getClickCount()); - serializer.serialize(buffer, src.getX()); - serializer.serialize(buffer, src.getY()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseClickedEvent( - new java.awt.event.MouseEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, x, y, - clickCount, false, button)); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MouseDraggedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/MouseDraggedEvent.java deleted file mode 100644 index 4f57fe8..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MouseDraggedEvent.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A MouseDraggedEvent is sent to {@link Robot#onMouseDragged(java.awt.event.MouseEvent) - * onMouseDragged()} when the mouse is dragged inside the battle view. - * - * @see MouseClickedEvent - * @see MousePressedEvent - * @see MouseReleasedEvent - * @see MouseEnteredEvent - * @see MouseExitedEvent - * @see MouseMovedEvent - * @see MouseWheelMovedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class MouseDraggedEvent extends MouseEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new MouseDraggedEvent. - * - * @param source the source mouse event originating from the AWT. - */ - public MouseDraggedEvent(java.awt.event.MouseEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onMouseDragged(getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.MouseDraggedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + 6 * RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - MouseDraggedEvent obj = (MouseDraggedEvent) object; - java.awt.event.MouseEvent src = obj.getSourceEvent(); - - serializer.serialize(buffer, src.getButton()); - serializer.serialize(buffer, src.getClickCount()); - serializer.serialize(buffer, src.getX()); - serializer.serialize(buffer, src.getY()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseDraggedEvent( - new java.awt.event.MouseEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, x, y, - clickCount, false, button)); - } - } - -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MouseEnteredEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/MouseEnteredEvent.java deleted file mode 100644 index 18a91f2..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MouseEnteredEvent.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A MouseEnteredEvent is sent to {@link Robot#onMouseEntered(java.awt.event.MouseEvent) - * onMouseEntered()} when the mouse has entered the battle view. - * - * @see MouseClickedEvent - * @see MousePressedEvent - * @see MouseReleasedEvent - * @see MouseExitedEvent - * @see MouseMovedEvent - * @see MouseDraggedEvent - * @see MouseWheelMovedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class MouseEnteredEvent extends MouseEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new MouseEnteredEvent. - * - * @param source the source mouse event originating from the AWT. - */ - public MouseEnteredEvent(java.awt.event.MouseEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onMouseEntered(getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.MouseEnteredEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + 6 * RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - MouseEnteredEvent obj = (MouseEnteredEvent) object; - java.awt.event.MouseEvent src = obj.getSourceEvent(); - - serializer.serialize(buffer, src.getButton()); - serializer.serialize(buffer, src.getClickCount()); - serializer.serialize(buffer, src.getX()); - serializer.serialize(buffer, src.getY()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseEnteredEvent( - new java.awt.event.MouseEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, x, y, - clickCount, false, button)); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MouseEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/MouseEvent.java deleted file mode 100644 index 62836c8..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MouseEvent.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * Super class of all events that originates from the mouse. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public abstract class MouseEvent extends Event { - private static final long serialVersionUID = 1L; - private final java.awt.event.MouseEvent source; - - /** - * Called by the game to create a new MouseEvent. - * - * @param source the source mouse event originating from the AWT. - */ - public MouseEvent(java.awt.event.MouseEvent source) { - this.source = source; - } - - /** - * Do not call this method! - *

- * This method is used by the game to determine the type of the source mouse - * event that occurred in the AWT. - * - * @return the source mouse event that originates from the AWT. - */ - public java.awt.event.MouseEvent getSourceEvent() { - return source; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MouseExitedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/MouseExitedEvent.java deleted file mode 100644 index f4e8907..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MouseExitedEvent.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A MouseExitedEvent is sent to {@link Robot#onMouseExited(java.awt.event.MouseEvent) - * onMouseExited()} when the mouse has exited the battle view. - * - * @see MouseClickedEvent - * @see MousePressedEvent - * @see MouseReleasedEvent - * @see MouseEnteredEvent - * @see MouseMovedEvent - * @see MouseDraggedEvent - * @see MouseWheelMovedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class MouseExitedEvent extends MouseEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new MouseExitedEvent. - * - * @param source the source mouse event originating from the AWT. - */ - public MouseExitedEvent(java.awt.event.MouseEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onMouseExited(getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.MouseExitedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + 6 * RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - MouseExitedEvent obj = (MouseExitedEvent) object; - java.awt.event.MouseEvent src = obj.getSourceEvent(); - - serializer.serialize(buffer, src.getButton()); - serializer.serialize(buffer, src.getClickCount()); - serializer.serialize(buffer, src.getX()); - serializer.serialize(buffer, src.getY()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseExitedEvent( - new java.awt.event.MouseEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, x, y, - clickCount, false, button)); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MouseMovedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/MouseMovedEvent.java deleted file mode 100644 index 46cfa56..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MouseMovedEvent.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A MouseMovedEvent is sent to {@link Robot#onMouseMoved(java.awt.event.MouseEvent) - * onMouseMoved()} when the mouse has moved inside the battle view. - * - * @see MouseClickedEvent - * @see MousePressedEvent - * @see MouseReleasedEvent - * @see MouseEnteredEvent - * @see MouseExitedEvent - * @see MouseDraggedEvent - * @see MouseWheelMovedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class MouseMovedEvent extends MouseEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new MouseMovedEvent. - * - * @param source the source mouse event originating from the AWT. - */ - public MouseMovedEvent(java.awt.event.MouseEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onMouseMoved(getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.MouseMovedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + 6 * RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - MouseMovedEvent obj = (MouseMovedEvent) object; - java.awt.event.MouseEvent src = obj.getSourceEvent(); - - serializer.serialize(buffer, src.getButton()); - serializer.serialize(buffer, src.getClickCount()); - serializer.serialize(buffer, src.getX()); - serializer.serialize(buffer, src.getY()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseMovedEvent( - new java.awt.event.MouseEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, x, y, - clickCount, false, button)); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MousePressedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/MousePressedEvent.java deleted file mode 100644 index 9b0ddb2..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MousePressedEvent.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A MousePressedEvent is sent to {@link Robot#onMousePressed(java.awt.event.MouseEvent) - * onMousePressed()} when the mouse is pressed inside the battle view. - * - * @see MouseClickedEvent - * @see MouseReleasedEvent - * @see MouseEnteredEvent - * @see MouseExitedEvent - * @see MouseMovedEvent - * @see MouseDraggedEvent - * @see MouseWheelMovedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class MousePressedEvent extends MouseEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new MousePressedEvent. - * - * @param source the source mouse event originating from the AWT. - */ - public MousePressedEvent(java.awt.event.MouseEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onMousePressed(getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.MousePressedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + 6 * RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - MousePressedEvent obj = (MousePressedEvent) object; - java.awt.event.MouseEvent src = obj.getSourceEvent(); - - serializer.serialize(buffer, src.getButton()); - serializer.serialize(buffer, src.getClickCount()); - serializer.serialize(buffer, src.getX()); - serializer.serialize(buffer, src.getY()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MousePressedEvent( - new java.awt.event.MouseEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, x, y, - clickCount, false, button)); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MouseReleasedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/MouseReleasedEvent.java deleted file mode 100644 index 17a4323..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MouseReleasedEvent.java +++ /dev/null @@ -1,120 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A MouseReleasedEvent is sent to {@link Robot#onMouseReleased(java.awt.event.MouseEvent) - * onMouseReleased()} when the mouse is released inside the battle view. - * - * @see MouseClickedEvent - * @see MousePressedEvent - * @see MouseEnteredEvent - * @see MouseExitedEvent - * @see MouseMovedEvent - * @see MouseDraggedEvent - * @see MouseWheelMovedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class MouseReleasedEvent extends MouseEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new MouseReleasedEvent. - * - * @param source the source mouse event originating from the AWT. - */ - public MouseReleasedEvent(java.awt.event.MouseEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onMouseReleased(getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.MouseReleasedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + 6 * RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - MouseReleasedEvent obj = (MouseReleasedEvent) object; - java.awt.event.MouseEvent src = obj.getSourceEvent(); - - serializer.serialize(buffer, src.getButton()); - serializer.serialize(buffer, src.getClickCount()); - serializer.serialize(buffer, src.getX()); - serializer.serialize(buffer, src.getY()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - int button = buffer.getInt(); - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseReleasedEvent( - new java.awt.event.MouseEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, x, y, - clickCount, false, button)); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MouseWheelMovedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/MouseWheelMovedEvent.java deleted file mode 100644 index cb6e27b..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MouseWheelMovedEvent.java +++ /dev/null @@ -1,124 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.security.SafeComponent; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.IInteractiveRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A MouseWheelMovedEvent is sent to {@link Robot#onMouseWheelMoved(java.awt.event.MouseWheelEvent e) - * onMouseWheelMoved()} when the mouse wheel is rotated inside the battle view. - * - * @see MouseClickedEvent - * @see MousePressedEvent - * @see MouseReleasedEvent - * @see MouseEnteredEvent - * @see MouseExitedEvent - * @see MouseMovedEvent - * @see MouseDraggedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public final class MouseWheelMovedEvent extends MouseEvent { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 98; - - /** - * Called by the game to create a new MouseWheelMovedEvent. - * - * @param source the source mouse event originating from the AWT. - */ - public MouseWheelMovedEvent(java.awt.event.MouseEvent source) { - super(source); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isInteractiveRobot()) { - IInteractiveEvents listener = ((IInteractiveRobot) robot).getInteractiveEventListener(); - - if (listener != null) { - listener.onMouseWheelMoved((java.awt.event.MouseWheelEvent) getSourceEvent()); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.MouseWheelMovedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + 8 * RbSerializer.SIZEOF_INT + RbSerializer.SIZEOF_LONG; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - MouseWheelMovedEvent obj = (MouseWheelMovedEvent) object; - java.awt.event.MouseWheelEvent src = (java.awt.event.MouseWheelEvent) obj.getSourceEvent(); - - serializer.serialize(buffer, src.getClickCount()); - serializer.serialize(buffer, src.getX()); - serializer.serialize(buffer, src.getY()); - serializer.serialize(buffer, src.getScrollType()); - serializer.serialize(buffer, src.getScrollAmount()); - serializer.serialize(buffer, src.getWheelRotation()); - serializer.serialize(buffer, src.getID()); - serializer.serialize(buffer, src.getModifiersEx()); - serializer.serialize(buffer, src.getWhen()); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - int clickCount = buffer.getInt(); - int x = buffer.getInt(); - int y = buffer.getInt(); - int scrollType = buffer.getInt(); - int scrollAmount = buffer.getInt(); - int wheelRotation = buffer.getInt(); - int id = buffer.getInt(); - int modifiersEx = buffer.getInt(); - long when = buffer.getLong(); - - return new MouseWheelMovedEvent( - new java.awt.event.MouseWheelEvent(SafeComponent.getSafeEventComponent(), id, when, modifiersEx, x, y, - clickCount, false, scrollType, scrollAmount, wheelRotation)); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/MoveCompleteCondition.java b/workspace_robo/robocode.api/src/main/java/robocode/MoveCompleteCondition.java deleted file mode 100644 index 00ea5fc..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/MoveCompleteCondition.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * A prebuilt condition you can use that indicates your robot has finished - * moving. - * - * @see Condition - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Nathaniel Troutman (contributor) - */ -public class MoveCompleteCondition extends Condition { - private AdvancedRobot robot; - - /** - * Creates a new MoveCompleteCondition with default priority. - * The default priority is 80. - * - * @param robot your robot, which must be a {@link AdvancedRobot} - */ - public MoveCompleteCondition(AdvancedRobot robot) { - super(); - this.robot = robot; - } - - /** - * Creates a new MoveCompleteCondition with the specified priority. - * A condition priority is a value from 0 - 99. The higher value, the - * higher priority. The default priority is 80. - * - * @param robot your robot, which must be a {@link AdvancedRobot} - * @param priority the priority of this condition - * @see Condition#setPriority(int) - */ - public MoveCompleteCondition(AdvancedRobot robot, int priority) { - super(); - this.robot = robot; - this.priority = priority; - } - - /** - * Tests if the robot has stopped moving. - * - * @return {@code true} if the robot has stopped moving; {@code false} - * otherwise - */ - @Override - public boolean test() { - return (robot.getDistanceRemaining() == 0); - } - - /** - * Called by the system in order to clean up references to internal objects. - * - * @since 1.4.3 - */ - @Override - public void cleanup() { - robot = null; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/PaintEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/PaintEvent.java deleted file mode 100644 index e189284..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/PaintEvent.java +++ /dev/null @@ -1,69 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.IPaintEvents; -import robocode.robotinterfaces.IPaintRobot; - -import java.awt.*; - - -/** - * This event occurs when your robot should paint, where the {@link - * Robot#onPaint(Graphics2D) onPaint()} is called on your robot. - *

- * You can use this event for setting the event priority by calling - * {@link AdvancedRobot#setEventPriority(String, int) - * setEventPriority("PaintEvent", priority)} - * - * @author Flemming N. Larsen (original) - */ -public final class PaintEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 5; - - /** - * Called by the game to create a new PaintEvent. - */ - public PaintEvent() { - super(); - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isPaintRobot()) { - IPaintEvents listener = ((IPaintRobot) robot).getPaintEventListener(); - - if (listener != null) { - listener.onPaint(graphics); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - throw new Error("Serialization of this type is not supported"); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/RadarTurnCompleteCondition.java b/workspace_robo/robocode.api/src/main/java/robocode/RadarTurnCompleteCondition.java deleted file mode 100644 index e5fc586..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/RadarTurnCompleteCondition.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * A prebuilt condition you can use that indicates your radar has finished - * turning. - * - * @see Condition - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Nathaniel Troutman (contributor) - */ -public class RadarTurnCompleteCondition extends Condition { - private AdvancedRobot robot; - - /** - * Creates a new RadarTurnCompleteCondition with default priority. - * The default priority is 80. - * - * @param robot your robot, which must be a {@link AdvancedRobot} - */ - public RadarTurnCompleteCondition(AdvancedRobot robot) { - super(); - this.robot = robot; - } - - /** - * Creates a new RadarTurnCompleteCondition with the specified priority. - * A condition priority is a value from 0 - 99. The higher value, the - * higher priority. The default priority is 80. - * - * @param robot your robot, which must be a {@link AdvancedRobot} - * @param priority the priority of this condition - * @see Condition#setPriority(int) - */ - public RadarTurnCompleteCondition(AdvancedRobot robot, int priority) { - super(); - this.robot = robot; - this.priority = priority; - } - - /** - * Tests if the radar has stopped turning. - * - * @return {@code true} if the radar has stopped turning; {@code false} - * otherwise - */ - @Override - public boolean test() { - return (robot.getRadarTurnRemaining() == 0); - } - - /** - * Called by the system in order to clean up references to internal objects. - * - * @since 1.4.3 - */ - @Override - public void cleanup() { - robot = null; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/RateControlRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/RateControlRobot.java deleted file mode 100644 index 1cb647d..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/RateControlRobot.java +++ /dev/null @@ -1,450 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import static java.lang.Math.toRadians; -import static java.lang.Math.toDegrees; - - -/** - * This advanced robot type allows you to set a rate for each of the robot's movements. - *

- * You can set the rate for:

    - *
  • velocity - pixels per turn
  • - *
  • robot turn - radians per turn
  • - *
  • gun rotation - radians per turn
  • - *
  • radar rotation - radians per turn
  • - *
- * When you set a rate for one of the above movements, the movement will continue the move by - * specified rate for ever, until the rate is changed. In order to move ahead or right, the - * rate must be set to a positive value. If a negative value is used instead, the movement - * will go back or to the left. In order to stop the movement, the rate must be - * set to 0. - *

- * Note: When calling {@code setVelocityRate()}, {@code setTurnRate()}, {@code setGunRotationRate()}, - * {@code setRadarRotationRate()} and variants, Any previous calls to "movement" functions outside of - * {@code RateControlRobot}, such as {@code setAhead()}, {@code setTurnLeft()}, - * {@code setTurnRadarRightRadians()} and similar will be overridden when calling the - * {@link #execute() execute()} on this robot class. - *

- * Look into the source code for the {@code sample.VelociRobot} in order to see how to use this - * robot type. - * - * @see JuniorRobot - * @see Robot - * @see AdvancedRobot - * @see TeamRobot - * @see Droid - * @see BorderSentry - * - * @author Joshua Galecki (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.7.1.3 - */ -public class RateControlRobot extends TeamRobot { - - private double velocityRate; // Pixels per turn - private double turnRate; // Radians per turn - private double gunRotationRate; // Radians per turn - private double radarRotationRate; // Radians per turn - - /** - * Sets the speed the robot will move (forward), in pixels per turn. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot will move backwards - *

- * Example: - *

-	 *   // Set the robot to move forward 2 pixels per turn
-	 *   setVelocityRate(2);
-	 *
-	 *   // Set the robot to move backwards 8 pixels per turn
-	 *   // (overrides the previous order)
-	 *   setVelocityRate(-8);
-	 *
-	 *   ...
-	 *   // Executes the last setVelocityRate()
-	 *   execute();
-	 * 
- * - * Note: This method overrules {@link robocode.AdvancedRobot#setAhead(double)} and - * {@link robocode.AdvancedRobot#setBack(double)}. - * - * @param velocityRate pixels per turn the robot will move. - * - * @see #getVelocityRate() - * @see #setTurnRate(double) - * @see #setGunRotationRate(double) - * @see #setRadarRotationRate(double) - * @see AdvancedRobot#setAhead(double) - * @see AdvancedRobot#setBack(double) - */ - public void setVelocityRate(double velocityRate) { - this.velocityRate = velocityRate; - } - - /** - * Returns the speed the robot will move, in pixels per turn. - * Positive values means that the robot will move forward. - * Negative values means that the robot will move backwards. - * If the value is 0, the robot will stand still. - * - * @return The speed of the robot in pixels per turn - * - * @see #setVelocityRate(double) - */ - public double getVelocityRate() { - return velocityRate; - } - - /** - * Sets the robot's clockwise (right) rotation per turn, in degrees. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot turns counterclockwise (left) - *

- * Example: - *

-	 *   // Set the robot to turn right 10 degrees per turn
-	 *   setTurnRate(10);
-	 *
-	 *   // Set the robot to turn left 4 degrees per turn
-	 *   // (overrides the previous order)
-	 *   setTurnRate(-5);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnRate()
-	 *   execute();
-	 * 
- * - * @param turnRate angle of the clockwise rotation, in degrees. - * - * @see #getTurnRate() - * @see #setVelocityRate(double) - * @see #setGunRotationRate(double) - * @see #setRadarRotationRate(double) - * @see AdvancedRobot#setTurnRight(double) - * @see AdvancedRobot#setTurnLeft(double) - */ - public void setTurnRate(double turnRate) { - this.turnRate = toRadians(turnRate); - } - - /** - * Gets the robot's clockwise rotation per turn, in degrees. - * Positive values means that the robot will turn to the right. - * Negative values means that the robot will turn to the left. - * If the value is 0, the robot will not turn. - * - * @return Angle of the clockwise rotation, in degrees. - * - * @see #setTurnRate(double) - */ - public double getTurnRate() { - return toDegrees(turnRate); - } - - /** - * Sets the robot's clockwise (right) rotation per turn, in radians. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot turns counterclockwise (left) - *

- * Example: - *

-	 *   // Set the robot to turn right pi / 32 radians per turn
-	 *   setTurnRateRadians(Math.PI / 32);
-	 *
-	 *   // Set the robot to turn left pi / 20 radians per turn
-	 *   // (overrides the previous order)
-	 *   setTurnRateRadians(-Math.PI / 20);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnRateRadians()
-	 *   execute();
-	 * 
- * - * @param turnRate angle of the clockwise rotation, in radians. - * - * @see #getTurnRateRadians()() - * @see #setVelocityRate(double) - * @see #setGunRotationRateRadians(double) - * @see #setRadarRotationRateRadians(double) - * @see AdvancedRobot#setTurnRightRadians(double) - * @see AdvancedRobot#setTurnLeftRadians(double) - */ - public void setTurnRateRadians(double turnRate) { - this.turnRate = turnRate; - } - - /** - * Gets the robot's clockwise rotation per turn, in radians. - * Positive values means that the robot will turn to the right. - * Negative values means that the robot will turn to the left. - * If the value is 0, the robot will not turn. - * - * @return Angle of the clockwise rotation, in radians. - * - * @see #getTurnRateRadians() - */ - public double getTurnRateRadians() { - return turnRate; - } - - /** - * Sets the gun's clockwise (right) rotation per turn, in degrees. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the gun turns counterclockwise (left) - *

- * Example: - *

-	 *   // Set the gun to turn right 15 degrees per turn
-	 *   setGunRotationRate(15);
-	 *
-	 *   // Set the gun to turn left 9 degrees per turn
-	 *   // (overrides the previous order)
-	 *   setGunRotationRate(-9);
-	 *
-	 *   ...
-	 *   // Executes the last setGunRotationRate()
-	 *   execute();
-	 * 
- * - * @param gunRotationRate angle of the clockwise rotation, in degrees. - * - * @see #getGunRotationRate() - * @see #setVelocityRate(double) - * @see #setTurnRate(double) - * @see #setRadarRotationRate(double) - * @see AdvancedRobot#setTurnGunRight(double) - * @see AdvancedRobot#setTurnGunLeft(double) - */ - public void setGunRotationRate(double gunRotationRate) { - this.gunRotationRate = toRadians(gunRotationRate); - } - - /** - * Gets the gun's clockwise rotation per turn, in degrees. - * Positive values means that the gun will turn to the right. - * Negative values means that the gun will turn to the left. - * If the value is 0, the gun will not turn. - * - * @return Angle of the clockwise rotation, in degrees. - * - * @see #setGunRotationRate(double) - */ - public double getGunRotationRate() { - return toDegrees(gunRotationRate); - } - - /** - * Sets the gun's clockwise (right) rotation per turn, in radians. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the gun turns counterclockwise (left) - *

- * Example: - *

-	 *   // Set the gun to turn right pi / 16 radians per turn
-	 *   setGunRotationRateRadians(Math.PI / 16);
-	 *
-	 *   // Set the gun to turn left pi / 12 radians per turn
-	 *   // (overrides the previous order)
-	 *   setGunRotationRateRadians(-Math.PI / 12);
-	 *
-	 *   ...
-	 *   // Executes the last setGunRotationRateRadians()
-	 *   execute();
-	 * 
- * - * @param gunRotationRate angle of the clockwise rotation, in radians. - * - * @see #getGunRotationRateRadians() - * @see #setVelocityRate(double) - * @see #setTurnRateRadians(double) - * @see #setRadarRotationRateRadians(double) - * @see AdvancedRobot#setTurnGunRightRadians(double) - * @see AdvancedRobot#setTurnGunLeftRadians(double) - */ - public void setGunRotationRateRadians(double gunRotationRate) { - this.gunRotationRate = gunRotationRate; - } - - /** - * Gets the gun's clockwise rotation per turn, in radians. - * Positive values means that the gun will turn to the right. - * Negative values means that the gun will turn to the left. - * If the value is 0, the gun will not turn. - * - * @return Angle of the clockwise rotation, in radians. - * - * @see #setGunRotationRateRadians(double) - */ - public double getGunRotationRateRadians() { - return gunRotationRate; - } - - /** - * Sets the radar's clockwise (right) rotation per turn, in degrees. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the radar turns counterclockwise (left) - *

- * Example: - *

-	 *   // Set the radar to turn right 45 degrees per turn
-	 *   setRadarRotationRate(45);
-	 *
-	 *   // Set the radar to turn left 15 degrees per turn
-	 *   // (overrides the previous order)
-	 *   setRadarRotationRate(-15);
-	 *
-	 *   ...
-	 *   // Executes the last setRadarRotationRate()
-	 *   execute();
-	 * 
- * - * @param radarRotationRate angle of the clockwise rotation, in degrees. - * - * @see #getRadarRotationRate() - * @see #setVelocityRate(double) - * @see #setTurnRate(double) - * @see #setGunRotationRate(double) - * @see AdvancedRobot#setTurnRadarRight(double) - * @see AdvancedRobot#setTurnRadarLeft(double) - */ - public void setRadarRotationRate(double radarRotationRate) { - this.radarRotationRate = toRadians(radarRotationRate); - } - - /** - * Gets the radar's clockwise rotation per turn, in degrees. - * Positive values means that the radar will turn to the right. - * Negative values means that the radar will turn to the left. - * If the value is 0, the radar will not turn. - * - * @return Angle of the clockwise rotation, in degrees. - * - * @see #setRadarRotationRate(double) - */ - public double getRadarRotationRate() { - return toDegrees(radarRotationRate); - } - - /** - * Sets the radar's clockwise (right) rotation per turn, in radians. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the radar turns counterclockwise (left) - *

- * Example: - *

-	 *   // Set the radar to turn right pi / 4 radians per turn
-	 *   setRadarRotationRateRadians(Math.PI / 4);
-	 *
-	 *   // Set the radar to turn left pi / 8 radians per turn
-	 *   // (overrides the previous order)
-	 *   setRadarRotationRateRadians(-Math.PI / 8);
-	 *
-	 *   ...
-	 *   // Executes the last setRadarRotationRateRadians()
-	 *   execute();
-	 * 
- * - * @param radarRotationRate angle of the clockwise rotation, in radians. - * - * @see #getRadarRotationRateRadians() - * @see #setVelocityRate(double) - * @see #setTurnRateRadians(double) - * @see #setGunRotationRateRadians(double) - * @see AdvancedRobot#setTurnRadarRightRadians(double) - * @see AdvancedRobot#setTurnRadarLeftRadians(double) - */ - public void setRadarRotationRateRadians(double radarRotationRate) { - this.radarRotationRate = radarRotationRate; - } - - /** - * Gets the radar's clockwise rotation per turn, in radians. - * Positive values means that the radar will turn to the right. - * Negative values means that the radar will turn to the left. - * If the value is 0, the radar will not turn. - * - * @return Angle of the clockwise rotation, in radians. - * - * @see #setRadarRotationRateRadians(double) - */ - public double getRadarRotationRateRadians() { - return radarRotationRate; - } - - /** - * Executes any pending actions, or continues executing actions that are - * in process. This call returns after the actions have been started. - *

- * Note that advanced robots must call this function in order to - * execute pending set* calls like e.g. {@code setVelocityRate()}, {@code setFire()}, - * {@code setTurnRate()} etc. Otherwise, these calls will never get executed. - *

- * Any previous calls to "movement" functions outside of {@code RateControlRobot}, - * such as {@code setAhead()}, {@code setTurnLeft()}, {@code setTurnRadarLeftRadians()} - * etc. will be overridden when this method is called on this robot class. - *

- * In this example the robot will move while turning: - *

-	 *   setVelocityRate(6);
-	 *   setTurnRate(7);
-	 *
-	 *   while (true) {
-	 *       execute();
-	 *   }
-	 * 
- */ - @Override - public void execute() { - setMaxVelocity(velocityRate); - if (velocityRate > 0) { - setAhead(Double.POSITIVE_INFINITY); - } else if (velocityRate < 0) { - setBack(Double.POSITIVE_INFINITY); - } else { - setAhead(0); - } - - setTurnGunRightRadians(gunRotationRate); - setTurnRadarRightRadians(radarRotationRate); - setTurnRightRadians(turnRate); - - super.execute(); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/Robocode.java b/workspace_robo/robocode.api/src/main/java/robocode/Robocode.java deleted file mode 100644 index d9fad25..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/Robocode.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.security.HiddenAccess; - - -/** - * Robocode - A programming game involving battling AI tanks.
- * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * - * @see
robocode.sourceforge.net - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Pavel Savara (contributor) - */ -public class Robocode { - - public static void main(final String[] args) { - HiddenAccess.robocodeMain(args); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/RobocodeFileOutputStream.java b/workspace_robo/robocode.api/src/main/java/robocode/RobocodeFileOutputStream.java deleted file mode 100644 index 3972331..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/RobocodeFileOutputStream.java +++ /dev/null @@ -1,157 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.core.ContainerBase; -import net.sf.robocode.security.IThreadManagerBase; -import robocode.exception.RobotException; - -import java.io.*; - - -/** - * RobocodeFileOutputStream is similar to a {@link java.io.FileOutputStream} - * and is used for streaming/writing data out to a file, which you got - * previously by calling {@link AdvancedRobot#getDataFile(String) getDataFile()}. - *

- * You should read {@link java.io.FileOutputStream} for documentation of this - * class. - *

- * Please notice that the max. size of your data file is set to 200000 - * (~195 KB). - * - * @see AdvancedRobot#getDataFile(String) - * @see java.io.FileOutputStream - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class RobocodeFileOutputStream extends OutputStream { - private final FileOutputStream out; - private final String fileName; - - /** - * Constructs a new RobocodeFileOutputStream. - * See {@link java.io.FileOutputStream#FileOutputStream(File)} - * for documentation about this constructor. - * - * @see java.io.FileOutputStream#FileOutputStream(File) - */ - public RobocodeFileOutputStream(File file) throws IOException { - this(file.getPath()); - } - - /** - * Constructs a new RobocodeFileOutputStream. - * See {@link java.io.FileOutputStream#FileOutputStream(FileDescriptor)} - * for documentation about this constructor. - * - * @see java.io.FileOutputStream#FileOutputStream(FileDescriptor) - */ - public RobocodeFileOutputStream(FileDescriptor fdObj) { - throw new RobotException("Creating a RobocodeFileOutputStream with a FileDescriptor is not supported."); - } - - /** - * Constructs a new RobocodeFileOutputStream. - * See {@link java.io.FileOutputStream#FileOutputStream(String)} - * for documentation about this constructor. - * - * @see java.io.FileOutputStream#FileOutputStream(String) - */ - public RobocodeFileOutputStream(String fileName) throws java.io.IOException { - this(fileName, false); - } - - /** - * Constructs a new RobocodeFileOutputStream. - * See {@link java.io.FileOutputStream#FileOutputStream(String, boolean)} - * for documentation about this constructor. - * - * @see java.io.FileOutputStream#FileOutputStream(String, boolean) - */ - public RobocodeFileOutputStream(String fileName, boolean append) throws IOException { - this.fileName = fileName; - - final IThreadManagerBase threadManager = ContainerBase.getComponent(IThreadManagerBase.class); - - if (threadManager == null) { - throw new RobotException("ThreadManager cannot be null!"); - } - - out = threadManager.createRobotFileStream(fileName, append); - } - - /** - * Closes this output stream. See {@link java.io.FileOutputStream#close()} - * for documentation about this method. - * - * @see java.io.FileOutputStream#close() - */ - @Override - public final void close() throws IOException { - out.close(); - } - - /** - * Flushes this output stream. See {@link java.io.FileOutputStream#flush()} - * for documentation about this method. - * - * @see java.io.FileOutputStream#flush() - */ - @Override - public final void flush() throws IOException { - out.flush(); - } - - /** - * Returns the filename of this output stream. - * - * @return the filename of this output stream. - */ - public final String getName() { - return fileName; - } - - /** - * Writes a byte array to this output stream. - * See {@link java.io.FileOutputStream#write(byte[])} for documentation - * about this method. - * - * @see java.io.FileOutputStream#write(byte[]) - */ - @Override - public final void write(byte[] b) throws IOException { - out.write(b); - } - - /** - * Writes a byte array to this output stream. - * See {@link java.io.FileOutputStream#write(byte[], int, int)} for - * documentation about this method. - * - * @see java.io.FileOutputStream#write(byte[], int, int) - */ - @Override - public final void write(byte[] b, int off, int len) throws IOException { - out.write(b, off, len); - } - - /** - * Writes a single byte to this output stream. - * See {@link java.io.FileOutputStream#write(int)} for documentation about - * this method. - * - * @see java.io.FileOutputStream#write(int) - */ - @Override - public final void write(int b) throws IOException { - out.write(b); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/RobocodeFileWriter.java b/workspace_robo/robocode.api/src/main/java/robocode/RobocodeFileWriter.java deleted file mode 100644 index 98cd0d8..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/RobocodeFileWriter.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import java.io.File; -import java.io.FileDescriptor; -import java.io.IOException; - - -/** - * RobocodeFileWriter is similar to a {@link java.io.FileWriter} and is used for - * writing data out to a file, which you got by calling {@link - * AdvancedRobot#getDataFile(String) getDataFile()}. - *

- * You should read {@link java.io.FileWriter} for documentation of this class. - *

- * Please notice that the max. size of your data file is set to 200000 - * (~195 KB). - * - * @see AdvancedRobot#getDataFile(String) - * @see java.io.FileWriter - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class RobocodeFileWriter extends java.io.OutputStreamWriter { - - /** - * Constructs a new RobocodeFileWriter. - * See {@link java.io.FileWriter#FileWriter(File)} for documentation about - * this constructor. - * - * @param file the file to write to. - * @throws java.io.IOException if an I/O exception occurs. - * @see java.io.FileWriter#FileWriter(File) - */ - public RobocodeFileWriter(File file) throws IOException { - super(new RobocodeFileOutputStream(file)); - } - - /** - * Constructs a new RobocodeFileWriter. - * See {@link java.io.FileWriter#FileWriter(FileDescriptor)} for - * documentation about this constructor. - * - * @param fd the file descriptor of the file to write to. - * @see java.io.FileWriter#FileWriter(FileDescriptor) - */ - public RobocodeFileWriter(FileDescriptor fd) { - super(new RobocodeFileOutputStream(fd)); - } - - /** - * Constructs a new RobocodeFileWriter. - * See {@link java.io.FileWriter#FileWriter(String)} for documentation about - * this constructor. - * - * @param fileName the filename of the file to write to. - * @throws java.io.IOException if an I/O exception occurs. - * @see java.io.FileWriter#FileWriter(String) - */ - public RobocodeFileWriter(String fileName) throws IOException { - super(new RobocodeFileOutputStream(fileName)); - } - - /** - * Constructs a new RobocodeFileWriter. - * See {@link java.io.FileWriter#FileWriter(String, boolean)} for - * documentation about this constructor. - * - * @param fileName the filename of the file to write to. - * @param append set this to true if the output must be appended to the file. - * @throws java.io.IOException if an I/O exception occurs. - * @see java.io.FileWriter#FileWriter(String, boolean) - */ - public RobocodeFileWriter(String fileName, boolean append) throws IOException { - super(new RobocodeFileOutputStream(fileName, append)); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/Robot.java b/workspace_robo/robocode.api/src/main/java/robocode/Robot.java deleted file mode 100644 index 84d2858..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/Robot.java +++ /dev/null @@ -1,1561 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import robocode.robotinterfaces.*; -import robocode.robotinterfaces.peer.IStandardRobotPeer; - -import java.awt.*; - - -/** - * The basic robot class that you will extend to create your own robots. - *

- *

Please note the following standards will be used: - *
heading - absolute angle in degrees with 0 facing up the screen, - * positive clockwise. 0 <= heading < 360. - *
bearing - relative angle to some object from your robot's heading, - * positive clockwise. -180 < bearing <= 180 - *
All coordinates are expressed as (x,y). - *
All coordinates are positive. - *
The origin (0,0) is at the bottom left of the screen. - *
Positive x is right. - *
Positive y is up. - * - * @see - * robocode.sourceforge.net - * @see - * Building your first robot - * - * @see JuniorRobot - * @see AdvancedRobot - * @see TeamRobot - * @see Droid - * @see RateControlRobot - * @see BorderSentry - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Matthew Reeder (contributor) - * @author Stefan Westen (contributor) - * @author Pavel Savara (contributor) - */ -public class Robot extends _Robot implements IInteractiveRobot, IPaintRobot, IBasicEvents3, IInteractiveEvents, IPaintEvents { - - private static final int - WIDTH = 36, - HEIGHT = 36; - - /** - * Constructs a new robot. - */ - public Robot() {} - - /** - * {@inheritDoc}} - */ - public final Runnable getRobotRunnable() { - return this; - } - - /** - * {@inheritDoc}} - */ - public final IBasicEvents getBasicEventListener() { - return this; - } - - /** - * {@inheritDoc}} - */ - public final IInteractiveEvents getInteractiveEventListener() { - return this; - } - - /** - * {@inheritDoc}} - */ - public final IPaintEvents getPaintEventListener() { - return this; - } - - /** - * Immediately moves your robot ahead (forward) by distance measured in - * pixels. - *

- * This call executes immediately, and does not return until it is complete, - * i.e. when the remaining distance to move is 0. - *

- * If the robot collides with a wall, the move is complete, meaning that the - * robot will not move any further. If the robot collides with another - * robot, the move is complete if you are heading toward the other robot. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot is set to move backward - * instead of forward. - *

- * Example: - *

-	 *   // Move the robot 100 pixels forward
-	 *   ahead(100);
-	 *
-	 *   // Afterwards, move the robot 50 pixels backward
-	 *   ahead(-50);
-	 * 
- * - * @param distance the distance to move ahead measured in pixels. - * If this value is negative, the robot will move back instead of ahead. - * @see #back(double) - * @see #onHitWall(HitWallEvent) - * @see #onHitRobot(HitRobotEvent) - */ - public void ahead(double distance) { - if (peer != null) { - peer.move(distance); - } else { - uninitializedException(); - } - } - - /** - * Immediately moves your robot backward by distance measured in pixels. - *

- * This call executes immediately, and does not return until it is complete, - * i.e. when the remaining distance to move is 0. - *

- * If the robot collides with a wall, the move is complete, meaning that the - * robot will not move any further. If the robot collides with another - * robot, the move is complete if you are heading toward the other robot. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot is set to move forward instead - * of backward. - *

- * Example: - *

-	 *   // Move the robot 100 pixels backward
-	 *   back(100);
-	 *
-	 *   // Afterwards, move the robot 50 pixels forward
-	 *   back(-50);
-	 * 
- * - * @param distance the distance to move back measured in pixels. - * If this value is negative, the robot will move ahead instead of back. - * @see #ahead(double) - * @see #onHitWall(HitWallEvent) - * @see #onHitRobot(HitRobotEvent) - */ - public void back(double distance) { - if (peer != null) { - peer.move(-distance); - } else { - uninitializedException(); - } - } - - /** - * Returns the width of the current battlefield measured in pixels. - * - * @return the width of the current battlefield measured in pixels. - */ - public double getBattleFieldWidth() { - if (peer != null) { - return peer.getBattleFieldWidth(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the height of the current battlefield measured in pixels. - * - * @return the height of the current battlefield measured in pixels. - */ - public double getBattleFieldHeight() { - if (peer != null) { - return peer.getBattleFieldHeight(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the direction that the robot's body is facing, in degrees. - * The value returned will be between 0 and 360 (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * 90 means East, 180 means South, and 270 means West. - * - * @return the direction that the robot's body is facing, in degrees. - * @see #getGunHeading() - * @see #getRadarHeading() - */ - public double getHeading() { - if (peer != null) { - double rv = 180.0 * peer.getBodyHeading() / Math.PI; - - while (rv < 0) { - rv += 360; - } - while (rv >= 360) { - rv -= 360; - } - return rv; - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the height of the robot measured in pixels. - * - * @return the height of the robot measured in pixels. - * @see #getWidth() - */ - public double getHeight() { - if (peer == null) { - uninitializedException(); - } - return HEIGHT; - } - - /** - * Returns the width of the robot measured in pixels. - * - * @return the width of the robot measured in pixels. - * @see #getHeight() - */ - public double getWidth() { - if (peer == null) { - uninitializedException(); - } - return WIDTH; - } - - /** - * Returns the robot's name. - * - * @return the robot's name. - */ - public String getName() { - if (peer != null) { - return peer.getName(); - } - uninitializedException(); - return null; // never called - } - - /** - * Returns the X position of the robot. (0,0) is at the bottom left of the - * battlefield. - * - * @return the X position of the robot. - * @see #getY() - */ - public double getX() { - if (peer != null) { - return peer.getX(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the Y position of the robot. (0,0) is at the bottom left of the - * battlefield. - * - * @return the Y position of the robot. - * @see #getX() - */ - public double getY() { - if (peer != null) { - return peer.getY(); - } - uninitializedException(); - return 0; // never called - } - - /** - * The main method in every robot. You must override this to set up your - * robot's basic behavior. - *

- * Example: - *

-	 *   // A basic robot that moves around in a square
-	 *   public void run() {
-	 *       while (true) {
-	 *           ahead(100);
-	 *           turnRight(90);
-	 *       }
-	 *   }
-	 * 
- */ - public void run() {} - - /** - * Immediately turns the robot's body to the left by degrees. - *

- * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the robot's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's body is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Turn the robot 180 degrees to the left
-	 *   turnLeft(180);
-	 *
-	 *   // Afterwards, turn the robot 90 degrees to the right
-	 *   turnLeft(-90);
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's body to the left. - * If {@code degrees} > 0 the robot will turn left. - * If {@code degrees} < 0 the robot will turn right. - * If {@code degrees} = 0 the robot will not turn, but execute. - * @see #turnRight(double) - * @see #turnGunLeft(double) - * @see #turnGunRight(double) - * @see #turnRadarLeft(double) - * @see #turnRadarRight(double) - */ - public void turnLeft(double degrees) { - if (peer != null) { - peer.turnBody(-Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Immediately turns the robot's body to the right by degrees. - * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the robot's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's body is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Turn the robot 180 degrees to the right
-	 *   turnRight(180);
-	 *
-	 *   // Afterwards, turn the robot 90 degrees to the left
-	 *   turnRight(-90);
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's body to the right. - * If {@code degrees} > 0 the robot will turn right. - * If {@code degrees} < 0 the robot will turn left. - * If {@code degrees} = 0 the robot will not turn, but execute. - * @see #turnLeft(double) - * @see #turnGunLeft(double) - * @see #turnGunRight(double) - * @see #turnRadarLeft(double) - * @see #turnRadarRight(double) - */ - public void turnRight(double degrees) { - if (peer != null) { - peer.turnBody(Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Do nothing this turn, meaning that the robot will skip it's turn. - *

- * This call executes immediately, and does not return until the turn is - * over. - */ - public void doNothing() { - if (peer != null) { - peer.execute(); - } else { - uninitializedException(); - } - } - - /** - * Immediately fires a bullet. The bullet will travel in the direction the - * gun is pointing. - *

- * The specified bullet power is an amount of energy that will be taken from - * the robot's energy. Hence, the more power you want to spend on the - * bullet, the more energy is taken from your robot. - *

- * The bullet will do (4 * power) damage if it hits another robot. If power - * is greater than 1, it will do an additional 2 * (power - 1) damage. - * You will get (3 * power) back if you hit the other robot. You can call - * {@link Rules#getBulletDamage(double)} for getting the damage that a - * bullet with a specific bullet power will do. - *

- * The specified bullet power should be between - * {@link Rules#MIN_BULLET_POWER} and {@link Rules#MAX_BULLET_POWER}. - *

- * Note that the gun cannot fire if the gun is overheated, meaning that - * {@link #getGunHeat()} returns a value > 0. - *

- * A event is generated when the bullet hits a robot - * ({@link BulletHitEvent}), wall ({@link BulletMissedEvent}), or another - * bullet ({@link BulletHitBulletEvent}). - *

- * Example: - *

-	 *   // Fire a bullet with maximum power if the gun is ready
-	 *   if (getGunHeat() == 0) {
-	 *       fire(Rules.MAX_BULLET_POWER);
-	 *   }
-	 * 
- * - * @param power the amount of energy given to the bullet, and subtracted - * from the robot's energy. - * @see #fireBullet(double) - * @see #getGunHeat() - * @see #getGunCoolingRate() - * @see #onBulletHit(BulletHitEvent) - * @see #onBulletHitBullet(BulletHitBulletEvent) - * @see #onBulletMissed(BulletMissedEvent) - */ - public void fire(double power) { - if (peer != null) { - peer.setFire(power); - peer.execute(); - } else { - uninitializedException(); - } - } - - /** - * Immediately fires a bullet. The bullet will travel in the direction the - * gun is pointing. - *

- * The specified bullet power is an amount of energy that will be taken from - * the robot's energy. Hence, the more power you want to spend on the - * bullet, the more energy is taken from your robot. - *

- * The bullet will do (4 * power) damage if it hits another robot. If power - * is greater than 1, it will do an additional 2 * (power - 1) damage. - * You will get (3 * power) back if you hit the other robot. You can call - * {@link Rules#getBulletDamage(double)} for getting the damage that a - * bullet with a specific bullet power will do. - *

- * The specified bullet power should be between - * {@link Rules#MIN_BULLET_POWER} and {@link Rules#MAX_BULLET_POWER}. - *

- * Note that the gun cannot fire if the gun is overheated, meaning that - * {@link #getGunHeat()} returns a value > 0. - *

- * A event is generated when the bullet hits a robot - * ({@link BulletHitEvent}), wall ({@link BulletMissedEvent}), or another - * bullet ({@link BulletHitBulletEvent}). - *

- * Example: - *

-	 *   // Fire a bullet with maximum power if the gun is ready
-	 *   if (getGunHeat() == 0) {
-	 *       Bullet bullet = fireBullet(Rules.MAX_BULLET_POWER);
-	 *
-	 *       // Get the velocity of the bullet
-	 *       if (bullet != null) {
-	 *           double bulletVelocity = bullet.getVelocity();
-	 *       }
-	 *   }
-	 * 
- * - * @param power the amount of energy given to the bullet, and subtracted - * from the robot's energy. - * @return a {@link Bullet} that contains information about the bullet if it - * was actually fired, which can be used for tracking the bullet after it - * has been fired. If the bullet was not fired, {@code null} is returned. - * @see #fire(double) - * @see Bullet - * @see #getGunHeat() - * @see #getGunCoolingRate() - * @see #onBulletHit(BulletHitEvent) - * @see #onBulletHitBullet(BulletHitBulletEvent) - * @see #onBulletMissed(BulletMissedEvent) - */ - public Bullet fireBullet(double power) { - if (peer != null) { - return peer.fire(power); - } - uninitializedException(); - return null; - } - - /** - * Returns the rate at which the gun will cool down, i.e. the amount of heat - * the gun heat will drop per turn. - *

- * The gun cooling rate is default 0.1 / turn, but can be changed by the - * battle setup. So don't count on the cooling rate being 0.1! - * - * @return the gun cooling rate - * @see #getGunHeat() - * @see #fire(double) - * @see #fireBullet(double) - */ - public double getGunCoolingRate() { - if (peer != null) { - return peer.getGunCoolingRate(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the direction that the robot's gun is facing, in degrees. - * The value returned will be between 0 and 360 (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * 90 means East, 180 means South, and 270 means West. - * - * @return the direction that the robot's gun is facing, in degrees. - * @see #getHeading() - * @see #getRadarHeading() - */ - public double getGunHeading() { - if (peer != null) { - return peer.getGunHeading() * 180.0 / Math.PI; - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the current heat of the gun. The gun cannot fire unless this is - * 0. (Calls to fire will succeed, but will not actually fire unless - * getGunHeat() == 0). - *

- * The amount of gun heat generated when the gun is fired is - * 1 + (firePower / 5). Each turn the gun heat drops by the amount returned - * by {@link #getGunCoolingRate()}, which is a battle setup. - *

- * Note that all guns are "hot" at the start of each round, where the gun - * heat is 3. - * - * @return the current gun heat - * @see #getGunCoolingRate() - * @see #fire(double) - * @see #fireBullet(double) - */ - public double getGunHeat() { - if (peer != null) { - return peer.getGunHeat(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the number of rounds in the current battle. - * - * @return the number of rounds in the current battle - * @see #getRoundNum() - */ - public int getNumRounds() { - if (peer != null) { - return peer.getNumRounds(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the sentry border size for a {@link robocode.BorderSentry BorderSentry} that defines the how - * far a BorderSentry is allowed to move from the border edges measured in units.
- * Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that - * BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the - * distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this - * border area. - * - * @return the border size in units/pixels. - * - * @since 1.9.0.0 - */ - public int getSentryBorderSize() { - if (peer != null) { - return peer.getSentryBorderSize(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns how many opponents that are left in the current round. - * - * @return how many opponents that are left in the current round. - */ - public int getOthers() { - if (peer != null) { - return peer.getOthers(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns how many sentry robots that are left in the current round. - * - * @return how many sentry robots that are left in the current round. - * - * @since 1.9.1.0 - */ - public int getNumSentries() { - if (peer != null) { - return peer.getNumSentries(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the direction that the robot's radar is facing, in degrees. - * The value returned will be between 0 and 360 (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * 90 means East, 180 means South, and 270 means West. - * - * @return the direction that the robot's radar is facing, in degrees. - * @see #getHeading() - * @see #getGunHeading() - */ - public double getRadarHeading() { - if (peer != null) { - return peer.getRadarHeading() * 180.0 / Math.PI; - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the current round number (0 to {@link #getNumRounds()} - 1) of - * the battle. - * - * @return the current round number of the battle (zero indexed). - * @see #getNumRounds() - */ - public int getRoundNum() { - if (peer != null) { - return peer.getRoundNum(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the game time of the current round, where the time is equal to - * the current turn in the round. - *

- * A battle consists of multiple rounds. - *

- * Time is reset to 0 at the beginning of every round. - * - * @return the game time/turn of the current round. - */ - public long getTime() { - if (peer != null) { - return peer.getTime(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns the velocity of the robot measured in pixels/turn. - *

- * The maximum velocity of a robot is defined by {@link Rules#MAX_VELOCITY} - * (8 pixels / turn). - * - * @return the velocity of the robot measured in pixels/turn. - * @see Rules#MAX_VELOCITY - */ - public double getVelocity() { - if (peer != null) { - return peer.getVelocity(); - } - uninitializedException(); - return 0; // never called - } - - /** - * {@inheritDoc} - */ - public void onBulletHit(BulletHitEvent event) {} - - /** - * {@inheritDoc} - */ - public void onBulletHitBullet(BulletHitBulletEvent event) {} - - /** - * {@inheritDoc} - */ - public void onBulletMissed(BulletMissedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onDeath(DeathEvent event) {} - - /** - * {@inheritDoc} - */ - public void onHitByBullet(HitByBulletEvent event) {} - - /** - * {@inheritDoc} - */ - public void onHitRobot(HitRobotEvent event) {} - - /** - * {@inheritDoc} - */ - public void onHitWall(HitWallEvent event) {} - - /** - * {@inheritDoc} - */ - public void onRobotDeath(RobotDeathEvent event) {} - - /** - * {@inheritDoc} - */ - public void onScannedRobot(ScannedRobotEvent event) {} - - /** - * {@inheritDoc} - */ - public void onWin(WinEvent event) {} - - /** - * {@inheritDoc} - */ - public void onRoundEnded(RoundEndedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onBattleEnded(BattleEndedEvent event) {} - - /** - * Scans for other robots. This method is called automatically by the game, - * as long as the robot is moving, turning its body, turning its gun, or - * turning its radar. - *

- * Scan will cause {@link #onScannedRobot(ScannedRobotEvent) - * onScannedRobot(ScannedRobotEvent)} to be called if you see a robot. - *

- * There are 2 reasons to call {@code scan()} manually: - *

    - *
  1. You want to scan after you stop moving. - *
  2. You want to interrupt the {@code onScannedRobot} event. This is more - * likely. If you are in {@code onScannedRobot} and call {@code scan()}, - * and you still see a robot, then the system will interrupt your - * {@code onScannedRobot} event immediately and start it from the top. - *
- *

- * This call executes immediately. - * - * @see #onScannedRobot(ScannedRobotEvent) - * @see ScannedRobotEvent - */ - public void scan() { - if (peer != null) { - ((IStandardRobotPeer) peer).rescan(); - } else { - uninitializedException(); - } - } - - /** - * Sets the gun to turn independent from the robot's turn. - *

- * Ok, so this needs some explanation: The gun is mounted on the robot's - * body. So, normally, if the robot turns 90 degrees to the right, then the - * gun will turn with it as it is mounted on top of the robot's body. To - * compensate for this, you can call {@code setAdjustGunForRobotTurn(true)}. - * When this is set, the gun will turn independent from the robot's turn, - * i.e. the gun will compensate for the robot's body turn. - *

- * Note: This method is additive until you reach the maximum the gun can - * turn. The "adjust" is added to the amount you set for turning the robot, - * then capped by the physics of the game. If you turn infinite, then the - * adjust is ignored (and hence overridden). - *

- * Example, assuming both the robot and gun start out facing up (0 degrees): - *

-	 *   // Set gun to turn with the robot's turn
-	 *   setAdjustGunForRobotTurn(false); // This is the default
-	 *   turnRight(90);
-	 *   // At this point, both the robot and gun are facing right (90 degrees)
-	 *   turnLeft(90);
-	 *   // Both are back to 0 degrees
-	 *
-	 *   -- or --
-	 *
-	 *   // Set gun to turn independent from the robot's turn
-	 *   setAdjustGunForRobotTurn(true);
-	 *   turnRight(90);
-	 *   // At this point, the robot is facing right (90 degrees), but the gun is still facing up.
-	 *   turnLeft(90);
-	 *   // Both are back to 0 degrees.
-	 * 
- *

- * Note: The gun compensating this way does count as "turning the gun". - * See {@link #setAdjustRadarForGunTurn(boolean)} for details. - * - * @param independent {@code true} if the gun must turn independent from the - * robot's turn; {@code false} if the gun must turn with the robot's turn. - * @see #setAdjustRadarForGunTurn(boolean) - */ - public void setAdjustGunForRobotTurn(boolean independent) { - if (peer != null) { - ((IStandardRobotPeer) peer).setAdjustGunForBodyTurn(independent); - } else { - uninitializedException(); - } - } - - /** - * Sets the radar to turn independent from the robot's turn. - *

- * Ok, so this needs some explanation: The radar is mounted on the gun, and - * the gun is mounted on the robot's body. So, normally, if the robot turns - * 90 degrees to the right, the gun turns, as does the radar. Hence, if the - * robot turns 90 degrees to the right, then the gun and radar will turn - * with it as the radar is mounted on top of the gun. To compensate for - * this, you can call {@code setAdjustRadarForRobotTurn(true)}. When this is - * set, the radar will turn independent from the robot's turn, i.e. the - * radar will compensate for the robot's turn. - *

- * Note: This method is additive until you reach the maximum the radar can - * turn. The "adjust" is added to the amount you set for turning the robot, - * then capped by the physics of the game. If you turn infinite, then the - * adjust is ignored (and hence overridden). - *

- * Example, assuming the robot, gun, and radar all start out facing up (0 - * degrees): - *

-	 *   // Set radar to turn with the robots's turn
-	 *   setAdjustRadarForRobotTurn(false); // This is the default
-	 *   turnRight(90);
-	 *   // At this point, the body, gun, and radar are all facing right (90 degrees);
-	 *
-	 *   -- or --
-	 *
-	 *   // Set radar to turn independent from the robot's turn
-	 *   setAdjustRadarForRobotTurn(true);
-	 *   turnRight(90);
-	 *   // At this point, the robot and gun are facing right (90 degrees), but the radar is still facing up.
-	 * 
- * - * @param independent {@code true} if the radar must turn independent from - * the robots's turn; {@code false} if the radar must turn with the robot's - * turn. - * @see #setAdjustGunForRobotTurn(boolean) - * @see #setAdjustRadarForGunTurn(boolean) - */ - public void setAdjustRadarForRobotTurn(boolean independent) { - if (peer != null) { - ((IStandardRobotPeer) peer).setAdjustRadarForBodyTurn(independent); - } else { - uninitializedException(); - } - } - - /** - * Sets the radar to turn independent from the gun's turn. - *

- * Ok, so this needs some explanation: The radar is mounted on the robot's - * gun. So, normally, if the gun turns 90 degrees to the right, then the - * radar will turn with it as it is mounted on top of the gun. To compensate - * for this, you can call {@code setAdjustRadarForGunTurn(true)}. When this - * is set, the radar will turn independent from the robot's turn, i.e. the - * radar will compensate for the gun's turn. - *

- * Note: This method is additive until you reach the maximum the radar can - * turn. The "adjust" is added to the amount you set for turning the gun, - * then capped by the physics of the game. If you turn infinite, then the - * adjust is ignored (and hence overridden). - *

- * Example, assuming both the gun and radar start out facing up (0 degrees): - *

-	 *   // Set radar to turn with the gun's turn
-	 *   setAdjustRadarForGunTurn(false); // This is the default
-	 *   turnGunRight(90);
-	 *   // At this point, both the radar and gun are facing right (90 degrees);
-	 *
-	 *   -- or --
-	 *
-	 *   // Set radar to turn independent from the gun's turn
-	 *   setAdjustRadarForGunTurn(true);
-	 *   turnGunRight(90);
-	 *   // At this point, the gun is facing right (90 degrees), but the radar is still facing up.
-	 * 
- * Note: Calling {@code setAdjustRadarForGunTurn(boolean)} will - * automatically call {@link #setAdjustRadarForRobotTurn(boolean)} with the - * same value, unless you have already called it earlier. This behavior is - * primarily for backward compatibility with older Robocode robots. - * - * @param independent {@code true} if the radar must turn independent from - * the gun's turn; {@code false} if the radar must turn with the gun's - * turn. - * @see #setAdjustRadarForRobotTurn(boolean) - * @see #setAdjustGunForRobotTurn(boolean) - */ - public void setAdjustRadarForGunTurn(boolean independent) { - if (peer != null) { - ((IStandardRobotPeer) peer).setAdjustRadarForGunTurn(independent); - } else { - uninitializedException(); - } - } - - /** - * Sets the color of the robot's body, gun, and radar in the same time. - *

- * You may only call this method one time per battle. A {@code null} - * indicates the default (blue) color. - *

- * Example: - *

-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 *
-	 *   public void run() {
-	 *       setColors(null, Color.RED, new Color(150, 0, 150));
-	 *       ...
-	 *   }
-	 * 
- * - * @param bodyColor the new body color - * @param gunColor the new gun color - * @param radarColor the new radar color - * @see #setColors(Color, Color, Color, Color, Color) - * @see #setAllColors(Color) - * @see #setBodyColor(Color) - * @see #setGunColor(Color) - * @see #setRadarColor(Color) - * @see #setBulletColor(Color) - * @see #setScanColor(Color) - * @see Color - */ - public void setColors(Color bodyColor, Color gunColor, Color radarColor) { - if (peer != null) { - peer.setBodyColor(bodyColor); - peer.setGunColor(gunColor); - peer.setRadarColor(radarColor); - } else { - uninitializedException(); - } - } - - /** - * Sets the color of the robot's body, gun, radar, bullet, and scan arc in - * the same time. - *

- * You may only call this method one time per battle. A {@code null} - * indicates the default (blue) color for the body, gun, radar, and scan - * arc, but white for the bullet color. - *

- * Example: - *

-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 *
-	 *   public void run() {
-	 *       setColors(null, Color.RED, Color.GREEN, null, new Color(150, 0, 150));
-	 *       ...
-	 *   }
-	 * 
- * - * @param bodyColor the new body color - * @param gunColor the new gun color - * @param radarColor the new radar color - * @param bulletColor the new bullet color - * @param scanArcColor the new scan arc color - * @see #setColors(Color, Color, Color) - * @see #setAllColors(Color) - * @see #setBodyColor(Color) - * @see #setGunColor(Color) - * @see #setRadarColor(Color) - * @see #setBulletColor(Color) - * @see #setScanColor(Color) - * @see Color - * @since 1.1.3 - */ - public void setColors(Color bodyColor, Color gunColor, Color radarColor, Color bulletColor, Color scanArcColor) { - if (peer != null) { - peer.setBodyColor(bodyColor); - peer.setGunColor(gunColor); - peer.setRadarColor(radarColor); - peer.setBulletColor(bulletColor); - peer.setScanColor(scanArcColor); - } else { - uninitializedException(); - } - } - - /** - * Sets all the robot's color to the same color in the same time, i.e. the - * color of the body, gun, radar, bullet, and scan arc. - *

- * You may only call this method one time per battle. A {@code null} - * indicates the default (blue) color for the body, gun, radar, and scan - * arc, but white for the bullet color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 *
-	 *   public void run() {
-	 *       setAllColors(Color.RED);
-	 *       ...
-	 *   }
-	 * 
- * - * @param color the new color for all the colors of the robot - * @see #setColors(Color, Color, Color) - * @see #setColors(Color, Color, Color, Color, Color) - * @see #setBodyColor(Color) - * @see #setGunColor(Color) - * @see #setRadarColor(Color) - * @see #setBulletColor(Color) - * @see #setScanColor(Color) - * @see Color - * @since 1.1.3 - */ - public void setAllColors(Color color) { - if (peer != null) { - peer.setBodyColor(color); - peer.setGunColor(color); - peer.setRadarColor(color); - peer.setBulletColor(color); - peer.setScanColor(color); - } else { - uninitializedException(); - } - } - - /** - * Sets the color of the robot's body. - *

- * A {@code null} indicates the default (blue) color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 *
-	 *   public void run() {
-	 *       setBodyColor(Color.BLACK);
-	 *       ...
-	 *   }
-	 * 
- * - * @param color the new body color - * @see #setColors(Color, Color, Color) - * @see #setColors(Color, Color, Color, Color, Color) - * @see #setAllColors(Color) - * @see #setGunColor(Color) - * @see #setRadarColor(Color) - * @see #setBulletColor(Color) - * @see #setScanColor(Color) - * @see Color - * @since 1.1.2 - */ - public void setBodyColor(Color color) { - if (peer != null) { - peer.setBodyColor(color); - } else { - uninitializedException(); - } - } - - /** - * Sets the color of the robot's gun. - *

- * A {@code null} indicates the default (blue) color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 *
-	 *   public void run() {
-	 *       setGunColor(Color.RED);
-	 *       ...
-	 *   }
-	 * 
- * - * @param color the new gun color - * @see #setColors(Color, Color, Color) - * @see #setColors(Color, Color, Color, Color, Color) - * @see #setAllColors(Color) - * @see #setBodyColor(Color) - * @see #setRadarColor(Color) - * @see #setBulletColor(Color) - * @see #setScanColor(Color) - * @see Color - * @since 1.1.2 - */ - public void setGunColor(Color color) { - if (peer != null) { - peer.setGunColor(color); - } else { - uninitializedException(); - } - } - - /** - * Sets the color of the robot's radar. - *

- * A {@code null} indicates the default (blue) color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 *
-	 *   public void run() {
-	 *       setRadarColor(Color.YELLOW);
-	 *       ...
-	 *   }
-	 * 
- * - * @param color the new radar color - * @see #setColors(Color, Color, Color) - * @see #setColors(Color, Color, Color, Color, Color) - * @see #setAllColors(Color) - * @see #setBodyColor(Color) - * @see #setGunColor(Color) - * @see #setBulletColor(Color) - * @see #setScanColor(Color) - * @see Color - * @since 1.1.2 - */ - public void setRadarColor(Color color) { - if (peer != null) { - peer.setRadarColor(color); - } else { - uninitializedException(); - } - } - - /** - * Sets the color of the robot's bullets. - *

- * A {@code null} indicates the default white color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 *
-	 *   public void run() {
-	 *       setBulletColor(Color.GREEN);
-	 *       ...
-	 *   }
-	 * 
- * - * @param color the new bullet color - * @see #setColors(Color, Color, Color) - * @see #setColors(Color, Color, Color, Color, Color) - * @see #setAllColors(Color) - * @see #setBodyColor(Color) - * @see #setGunColor(Color) - * @see #setRadarColor(Color) - * @see #setScanColor(Color) - * @see Color - * @since 1.1.2 - */ - public void setBulletColor(Color color) { - if (peer != null) { - peer.setBulletColor(color); - } else { - uninitializedException(); - } - } - - /** - * Sets the color of the robot's scan arc. - *

- * A {@code null} indicates the default (blue) color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 *
-	 *   public void run() {
-	 *       setScanColor(Color.WHITE);
-	 *       ...
-	 *   }
-	 * 
- * - * @param color the new scan arc color - * @see #setColors(Color, Color, Color) - * @see #setColors(Color, Color, Color, Color, Color) - * @see #setAllColors(Color) - * @see #setBodyColor(Color) - * @see #setGunColor(Color) - * @see #setRadarColor(Color) - * @see #setBulletColor(Color) - * @see Color - * @since 1.1.2 - */ - public void setScanColor(Color color) { - if (peer != null) { - peer.setScanColor(color); - } else { - uninitializedException(); - } - } - - /** - * Immediately stops all movement, and saves it for a call to - * {@link #resume()}. If there is already movement saved from a previous - * stop, this will have no effect. - *

- * This method is equivalent to {@code #stop(false)}. - * - * @see #resume() - * @see #stop(boolean) - */ - public void stop() { - stop(false); - } - - /** - * Immediately stops all movement, and saves it for a call to - * {@link #resume()}. If there is already movement saved from a previous - * stop, you can overwrite it by calling {@code stop(true)}. - * - * @param overwrite If there is already movement saved from a previous stop, - * you can overwrite it by calling {@code stop(true)}. - * @see #resume() - * @see #stop() - */ - public void stop(boolean overwrite) { - if (peer != null) { - ((IStandardRobotPeer) peer).stop(overwrite); - } else { - uninitializedException(); - } - } - - /** - * Immediately resumes the movement you stopped by {@link #stop()}, if any. - *

- * This call executes immediately, and does not return until it is complete. - * - * @see #stop() - * @see #stop(boolean) - */ - public void resume() { - if (peer != null) { - ((IStandardRobotPeer) peer).resume(); - } else { - uninitializedException(); - } - } - - /** - * Immediately turns the robot's gun to the left by degrees. - *

- * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the gun's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's gun is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Turn the robot's gun 180 degrees to the left
-	 *   turnGunLeft(180);
-	 *
-	 *   // Afterwards, turn the robot's gun 90 degrees to the right
-	 *   turnGunLeft(-90);
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's gun to the left. - * If {@code degrees} > 0 the robot's gun will turn left. - * If {@code degrees} < 0 the robot's gun will turn right. - * If {@code degrees} = 0 the robot's gun will not turn, but execute. - * @see #turnGunRight(double) - * @see #turnLeft(double) - * @see #turnRight(double) - * @see #turnRadarLeft(double) - * @see #turnRadarRight(double) - * @see #setAdjustGunForRobotTurn(boolean) - */ - public void turnGunLeft(double degrees) { - if (peer != null) { - peer.turnGun(-Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Immediately turns the robot's gun to the right by degrees. - * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the gun's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's gun is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Turn the robot's gun 180 degrees to the right
-	 *   turnGunRight(180);
-	 *
-	 *   // Afterwards, turn the robot's gun 90 degrees to the left
-	 *   turnGunRight(-90);
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's gun to the right. - * If {@code degrees} > 0 the robot's gun will turn right. - * If {@code degrees} < 0 the robot's gun will turn left. - * If {@code degrees} = 0 the robot's gun will not turn, but execute. - * @see #turnGunLeft(double) - * @see #turnLeft(double) - * @see #turnRight(double) - * @see #turnRadarLeft(double) - * @see #turnRadarRight(double) - * @see #setAdjustGunForRobotTurn(boolean) - */ - public void turnGunRight(double degrees) { - if (peer != null) { - peer.turnGun(Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Immediately turns the robot's radar to the left by degrees. - *

- * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the radar's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's radar is set to turn right - * instead of left. - *

- * Example: - *

-	 *   // Turn the robot's radar 180 degrees to the left
-	 *   turnRadarLeft(180);
-	 *
-	 *   // Afterwards, turn the robot's radar 90 degrees to the right
-	 *   turnRadarLeft(-90);
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's radar to the left. - * If {@code degrees} > 0 the robot's radar will turn left. - * If {@code degrees} < 0 the robot's radar will turn right. - * If {@code degrees} = 0 the robot's radar will not turn, but execute. - * @see #turnRadarRight(double) - * @see #turnLeft(double) - * @see #turnRight(double) - * @see #turnGunLeft(double) - * @see #turnGunRight(double) - * @see #setAdjustRadarForRobotTurn(boolean) - * @see #setAdjustRadarForGunTurn(boolean) - */ - public void turnRadarLeft(double degrees) { - if (peer != null) { - ((IStandardRobotPeer) peer).turnRadar(-Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Immediately turns the robot's radar to the right by degrees. - * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the radar's turn is 0. - *

- * Note that both positive and negative values can be given as input, - * where negative values means that the robot's radar is set to turn left - * instead of right. - *

- * Example: - *

-	 *   // Turn the robot's radar 180 degrees to the right
-	 *   turnRadarRight(180);
-	 *
-	 *   // Afterwards, turn the robot's radar 90 degrees to the left
-	 *   turnRadarRight(-90);
-	 * 
- * - * @param degrees the amount of degrees to turn the robot's radar to the right. - * If {@code degrees} > 0 the robot's radar will turn right. - * If {@code degrees} < 0 the robot's radar will turn left. - * If {@code degrees} = 0 the robot's radar will not turn, but execute. - * @see #turnRadarLeft(double) - * @see #turnLeft(double) - * @see #turnRight(double) - * @see #turnGunLeft(double) - * @see #turnGunRight(double) - * @see #setAdjustRadarForRobotTurn(boolean) - * @see #setAdjustRadarForGunTurn(boolean) - */ - public void turnRadarRight(double degrees) { - if (peer != null) { - ((IStandardRobotPeer) peer).turnRadar(Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * Returns the robot's current energy. - * - * @return the robot's current energy. - */ - public double getEnergy() { - if (peer != null) { - return peer.getEnergy(); - } - uninitializedException(); - return 0; // never called - } - - /** - * Returns a graphics context used for painting graphical items for the robot. - *

- * This method is very useful for debugging your robot. - *

- * Note that the robot will only be painted if the "Paint" is enabled on the - * robot's console window; otherwise the robot will never get painted (the - * reason being that all robots might have graphical items that must be - * painted, and then you might not be able to tell what graphical items that - * have been painted for your robot). - *

- * Also note that the coordinate system for the graphical context where you - * paint items fits for the Robocode coordinate system where (0, 0) is at - * the bottom left corner of the battlefield, where X is towards right and Y - * is upwards. - * - * @return a graphics context used for painting graphical items for the robot. - * @see #onPaint(Graphics2D) - * @since 1.6.1 - */ - public Graphics2D getGraphics() { - if (peer != null) { - return peer.getGraphics(); - } - uninitializedException(); - return null; // never called - } - - /** - * Sets the debug property with the specified key to the specified value. - *

- * This method is very useful when debugging or reviewing your robot as you - * will be able to see this property displayed in the robot console for your - * robots under the Debug Properties tab page. - * - * @param key the name/key of the debug property. - * @param value the new value of the debug property, where {@code null} or - * the empty string is used for removing this debug property. - * @since 1.6.2 - */ - public void setDebugProperty(String key, String value) { - if (peer != null) { - peer.setDebugProperty(key, value); - return; - } - uninitializedException(); - } - - /** - * {@inheritDoc} - */ - public void onPaint(Graphics2D g) {} - - /** - * {@inheritDoc} - */ - public void onKeyPressed(java.awt.event.KeyEvent e) {} - - /** - * {@inheritDoc} - */ - public void onKeyReleased(java.awt.event.KeyEvent e) {} - - /** - * {@inheritDoc} - */ - public void onKeyTyped(java.awt.event.KeyEvent e) {} - - /** - * {@inheritDoc} - */ - public void onMouseClicked(java.awt.event.MouseEvent e) {} - - /** - * {@inheritDoc} - */ - public void onMouseEntered(java.awt.event.MouseEvent e) {} - - /** - * {@inheritDoc} - */ - public void onMouseExited(java.awt.event.MouseEvent e) {} - - /** - * {@inheritDoc} - */ - public void onMousePressed(java.awt.event.MouseEvent e) {} - - /** - * {@inheritDoc} - */ - public void onMouseReleased(java.awt.event.MouseEvent e) {} - - /** - * {@inheritDoc} - */ - public void onMouseMoved(java.awt.event.MouseEvent e) {} - - /** - * {@inheritDoc} - */ - public void onMouseDragged(java.awt.event.MouseEvent e) {} - - /** - * {@inheritDoc} - */ - public void onMouseWheelMoved(java.awt.event.MouseWheelEvent e) {} - - /** - * {@inheritDoc} - */ - public void onStatus(StatusEvent e) {} -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/RobotDeathEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/RobotDeathEvent.java deleted file mode 100644 index 8159ac9..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/RobotDeathEvent.java +++ /dev/null @@ -1,113 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * This event is sent to {@link Robot#onRobotDeath(RobotDeathEvent) onRobotDeath()} - * when another robot (not your robot) dies. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public final class RobotDeathEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 70; - - private final String robotName; - - /** - * Called by the game to create a new RobotDeathEvent. - * - * @param robotName the name of the robot that died - */ - public RobotDeathEvent(String robotName) { - super(); - this.robotName = robotName; - } - - /** - * Returns the name of the robot that died. - * - * @return the name of the robot that died - */ - public String getName() { - return robotName; - } - - /** - * @return the name of the robot that died - * @deprecated Use {@link #getName()} instead. - */ - @Deprecated - public String getRobotName() { - return robotName; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null) { - listener.onRobotDeath(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.RobotDeathEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - RobotDeathEvent obj = (RobotDeathEvent) object; - - return RbSerializer.SIZEOF_TYPEINFO + serializer.sizeOf(obj.robotName); - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - RobotDeathEvent obj = (RobotDeathEvent) object; - - serializer.serialize(buffer, obj.robotName); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - String name = serializer.deserializeString(buffer); - - return new RobotDeathEvent(name); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/RobotStatus.java b/workspace_robo/robocode.api/src/main/java/robocode/RobotStatus.java deleted file mode 100644 index 849fd96..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/RobotStatus.java +++ /dev/null @@ -1,426 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.security.IHiddenStatusHelper; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; - -import java.io.Serializable; -import java.nio.ByteBuffer; - - -/** - * Contains the status of a robot for a specific time/turn returned by - * {@link StatusEvent#getStatus()}. - * - * @author Flemming N. Larsen (original) - * - * @since 1.5 - */ -public final class RobotStatus implements Serializable { - private static final long serialVersionUID = 1L; - - private final double energy; - private final double x; - private final double y; - private final double bodyHeading; - private final double gunHeading; - private final double radarHeading; - private final double velocity; - private final double bodyTurnRemaining; - private final double radarTurnRemaining; - private final double gunTurnRemaining; - private final double distanceRemaining; - private final double gunHeat; - private final int others; - private final int numSentries; - private final int roundNum; - private final int numRounds; - private final long time; - - /** - * Returns the robot's current energy. - * - * @return the robot's current energy - */ - public double getEnergy() { - return energy; - } - - /** - * Returns the X position of the robot. (0,0) is at the bottom left of the - * battlefield. - * - * @return the X position of the robot - * @see #getY() - */ - public double getX() { - return x; - } - - /** - * Returns the Y position of the robot. (0,0) is at the bottom left of the - * battlefield. - * - * @return the Y position of the robot - * @see #getX() - */ - public double getY() { - return y; - } - - /** - * Returns the direction that the robot's body is facing, in radians. - * The value returned will be between 0 and 2 * PI (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * PI / 2 means East, PI means South, and 3 * PI / 2 means West. - * - * @return the direction that the robot's body is facing, in radians. - */ - public double getHeadingRadians() { - return bodyHeading; - } - - /** - * Returns the direction that the robot's body is facing, in degrees. - * The value returned will be between 0 and 360 (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * 90 means East, 180 means South, and 270 means West. - * - * @return the direction that the robot's body is facing, in degrees. - */ - public double getHeading() { - return Math.toDegrees(bodyHeading); - } - - /** - * Returns the direction that the robot's gun is facing, in radians. - * The value returned will be between 0 and 2 * PI (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * PI / 2 means East, PI means South, and 3 * PI / 2 means West. - * - * @return the direction that the robot's gun is facing, in radians. - */ - public double getGunHeadingRadians() { - return gunHeading; - } - - /** - * Returns the direction that the robot's gun is facing, in degrees. - * The value returned will be between 0 and 360 (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * 90 means East, 180 means South, and 270 means West. - * - * @return the direction that the robot's gun is facing, in degrees. - */ - public double getGunHeading() { - return Math.toDegrees(gunHeading); - } - - /** - * Returns the direction that the robot's radar is facing, in radians. - * The value returned will be between 0 and 2 * PI (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * PI / 2 means East, PI means South, and 3 * PI / 2 means West. - * - * @return the direction that the robot's radar is facing, in radians. - */ - public double getRadarHeadingRadians() { - return radarHeading; - } - - /** - * Returns the direction that the robot's radar is facing, in degrees. - * The value returned will be between 0 and 360 (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * 90 means East, 180 means South, and 270 means West. - * - * @return the direction that the robot's radar is facing, in degrees. - */ - public double getRadarHeading() { - return Math.toDegrees(radarHeading); - } - - /** - * Returns the velocity of the robot measured in pixels/turn. - *

- * The maximum velocity of a robot is defined by {@link Rules#MAX_VELOCITY} - * (8 pixels / turn). - * - * @return the velocity of the robot measured in pixels/turn - * @see Rules#MAX_VELOCITY - */ - public double getVelocity() { - return velocity; - } - - /** - * Returns the angle remaining in the robots's turn, in radians. - *

- * This call returns both positive and negative values. Positive values - * means that the robot is currently turning to the right. Negative values - * means that the robot is currently turning to the left. - * - * @return the angle remaining in the robots's turn, in radians - */ - public double getTurnRemainingRadians() { - return bodyTurnRemaining; - } - - /** - * Returns the angle remaining in the robots's turn, in degrees. - *

- * This call returns both positive and negative values. Positive values - * means that the robot is currently turning to the right. Negative values - * means that the robot is currently turning to the left. - * - * @return the angle remaining in the robots's turn, in degrees - */ - public double getTurnRemaining() { - return Math.toDegrees(bodyTurnRemaining); - } - - /** - * Returns the angle remaining in the radar's turn, in radians. - *

- * This call returns both positive and negative values. Positive values - * means that the radar is currently turning to the right. Negative values - * means that the radar is currently turning to the left. - * - * @return the angle remaining in the radar's turn, in radians - */ - public double getRadarTurnRemainingRadians() { - return radarTurnRemaining; - } - - /** - * Returns the angle remaining in the radar's turn, in degrees. - *

- * This call returns both positive and negative values. Positive values - * means that the radar is currently turning to the right. Negative values - * means that the radar is currently turning to the left. - * - * @return the angle remaining in the radar's turn, in degrees - */ - public double getRadarTurnRemaining() { - return Math.toDegrees(radarTurnRemaining); - } - - /** - * Returns the angle remaining in the gun's turn, in radians. - *

- * This call returns both positive and negative values. Positive values - * means that the gun is currently turning to the right. Negative values - * means that the gun is currently turning to the left. - * - * @return the angle remaining in the gun's turn, in radians - */ - public double getGunTurnRemainingRadians() { - return gunTurnRemaining; - } - - /** - * Returns the angle remaining in the gun's turn, in degrees. - *

- * This call returns both positive and negative values. Positive values - * means that the gun is currently turning to the right. Negative values - * means that the gun is currently turning to the left. - * - * @return the angle remaining in the gun's turn, in degrees - */ - public double getGunTurnRemaining() { - return Math.toDegrees(gunTurnRemaining); - } - - /** - * Returns the distance remaining in the robot's current move measured in - * pixels. - *

- * This call returns both positive and negative values. Positive values - * means that the robot is currently moving forwards. Negative values means - * that the robot is currently moving backwards. - * - * @return the distance remaining in the robot's current move measured in - * pixels. - */ - public double getDistanceRemaining() { - return distanceRemaining; - } - - /** - * Returns the current heat of the gun. The gun cannot fire unless this is - * 0. (Calls to fire will succeed, but will not actually fire unless - * getGunHeat() == 0). - *

- * The amount of gun heat generated when the gun is fired is - * 1 + (firePower / 5). Each turn the gun heat drops by the amount returned - * by {@link Robot#getGunCoolingRate()}, which is a battle setup. - *

- * Note that all guns are "hot" at the start of each round, where the gun - * heat is 3. - * - * @return the current gun heat - * @see Robot#getGunCoolingRate() - * @see Robot#fire(double) - * @see Robot#fireBullet(double) - */ - public double getGunHeat() { - return gunHeat; - } - - /** - * Returns how many opponents that are left in the current round. - * - * @return how many opponents that are left in the current round. - * @see #getNumSentries() - * @since 1.6.2 - */ - public int getOthers() { - return others; - } - - /** - * Returns how many sentry robots that are left in the current round. - * - * @return how many sentry robots that are left in the current round. - * @see #getOthers() - * @since 1.9.1.0 - */ - public int getNumSentries() { - return numSentries; - } - - /** - * Returns the number of rounds in the current battle. - * - * @return the number of rounds in the current battle - * @see #getRoundNum() - * @since 1.6.2 - */ - public int getNumRounds() { - return numRounds; - } - - /** - * Returns the current round number (0 to {@link #getNumRounds()} - 1) of - * the battle. - * - * @return the current round number of the battle (zero indexed). - * @see #getNumRounds() - * @since 1.6.2 - */ - public int getRoundNum() { - return roundNum; - } - - /** - * Returns the game time of the round, where the time is equal to the current turn in the round. - * - * @return the game time/turn of the current round. - * @since 1.6.2 - */ - public long getTime() { - return time; - } - - private RobotStatus(double energy, double x, double y, double bodyHeading, double gunHeading, double radarHeading, - double velocity, double bodyTurnRemaining, double radarTurnRemaining, double gunTurnRemaining, - double distanceRemaining, double gunHeat, int others, int numSentries, int roundNum, int numRounds, long time) { - this.energy = energy; - this.x = x; - this.y = y; - this.bodyHeading = bodyHeading; - this.gunHeading = gunHeading; - this.radarHeading = radarHeading; - this.bodyTurnRemaining = bodyTurnRemaining; - this.velocity = velocity; - this.radarTurnRemaining = radarTurnRemaining; - this.gunTurnRemaining = gunTurnRemaining; - this.distanceRemaining = distanceRemaining; - this.gunHeat = gunHeat; - this.others = others; - this.numSentries = numSentries; - this.roundNum = roundNum; - this.numRounds = numRounds; - this.time = time; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper, IHiddenStatusHelper { - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + 12 * RbSerializer.SIZEOF_DOUBLE + 4 * RbSerializer.SIZEOF_INT - + RbSerializer.SIZEOF_LONG; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - RobotStatus obj = (RobotStatus) object; - - serializer.serialize(buffer, obj.energy); - serializer.serialize(buffer, obj.x); - serializer.serialize(buffer, obj.y); - serializer.serialize(buffer, obj.bodyHeading); - serializer.serialize(buffer, obj.gunHeading); - serializer.serialize(buffer, obj.radarHeading); - serializer.serialize(buffer, obj.velocity); - serializer.serialize(buffer, obj.bodyTurnRemaining); - serializer.serialize(buffer, obj.radarTurnRemaining); - serializer.serialize(buffer, obj.gunTurnRemaining); - serializer.serialize(buffer, obj.distanceRemaining); - serializer.serialize(buffer, obj.gunHeat); - serializer.serialize(buffer, obj.others); - serializer.serialize(buffer, obj.numSentries); - serializer.serialize(buffer, obj.roundNum); - serializer.serialize(buffer, obj.numRounds); - serializer.serialize(buffer, obj.time); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - double energy = buffer.getDouble(); - double x = buffer.getDouble(); - double y = buffer.getDouble(); - double bodyHeading = buffer.getDouble(); - double gunHeading = buffer.getDouble(); - double radarHeading = buffer.getDouble(); - double velocity = buffer.getDouble(); - double bodyTurnRemaining = buffer.getDouble(); - double radarTurnRemaining = buffer.getDouble(); - double gunTurnRemaining = buffer.getDouble(); - double distanceRemaining = buffer.getDouble(); - double gunHeat = buffer.getDouble(); - int others = buffer.getInt(); - int numSentries = buffer.getInt(); - int roundNum = buffer.getInt(); - int numRounds = buffer.getInt(); - long time = buffer.getLong(); - - return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining, - radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries, roundNum, numRounds, - time); - } - - public RobotStatus createStatus(double energy, double x, double y, double bodyHeading, double gunHeading, double radarHeading, double velocity, - double bodyTurnRemaining, double radarTurnRemaining, double gunTurnRemaining, double distanceRemaining, double gunHeat, int others, - int numSentries, int roundNum, int numRounds, long time) { - return new RobotStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, bodyTurnRemaining, - radarTurnRemaining, gunTurnRemaining, distanceRemaining, gunHeat, others, numSentries, roundNum, numRounds, - time); - } - } - -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/RoundEndedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/RoundEndedEvent.java deleted file mode 100644 index e76fb05..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/RoundEndedEvent.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicEvents3; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A RoundEndedEvent is sent to {@link Robot#onRoundEnded(RoundEndedEvent) - * onRoundEnded()} when a round has ended. - * You can use the information contained in this event to determine which round that has ended. - * - * @see Robot#onRoundEnded(RoundEndedEvent) - * - * @author Flemming N. Larsen (original) - * - * @since 1.7.2 - */ -public final class RoundEndedEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 110; // System event -> cannot be changed! - - private final int round; - private final int turns; - private final int totalTurns; - - /** - * Called by the game to create a new RoundEndedEvent. - * - * @param round the round that has ended (zero-indexed). - * @param turns the number of turns that this round reached. - * @param totalTurns the total number of turns reached in the battle when this round ended. - */ - public RoundEndedEvent(int round, int turns, int totalTurns) { - this.round = round; - this.turns = turns; - this.totalTurns = totalTurns; - } - - /** - * Returns the round that ended (zero-indexed). - * - * @return the round that ended (zero-indexed). - */ - public int getRound() { - return round; - } - - /** - * Returns the number of turns that this round reached. - * - * @return the number of turns that this round reached. - */ - public int getTurns() { - return turns; - } - - /** - * Returns the total number of turns reached in the battle when this round ended. - * - * @return the total number of turns reached in the battle when this round ended. - */ - public int getTotalTurns() { - return totalTurns; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - public final int getPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (robot != null) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null && IBasicEvents3.class.isAssignableFrom(listener.getClass())) { - ((IBasicEvents3) listener).onRoundEnded(this); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - final boolean isCriticalEvent() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.RoundEndedEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + 3 * RbSerializer.SIZEOF_INT; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - RoundEndedEvent event = (RoundEndedEvent) object; - - serializer.serialize(buffer, event.round); - serializer.serialize(buffer, event.turns); - serializer.serialize(buffer, event.totalTurns); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - int round = serializer.deserializeInt(buffer); - int turns = serializer.deserializeInt(buffer); - int totalTurns = serializer.deserializeInt(buffer); - - return new RoundEndedEvent(round, turns, totalTurns); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/Rules.java b/workspace_robo/robocode.api/src/main/java/robocode/Rules.java deleted file mode 100644 index 96919fa..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/Rules.java +++ /dev/null @@ -1,229 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import static java.lang.Math.abs; -import static java.lang.Math.max; - - -/** - * Constants and methods that defines the rules of Robocode. - * Constants are used for rules that will not change. - * Methods are provided for rules that can be changed between battles or which depends - * on some other factor. - * - * @author Luis Crespo (original) - * @author Flemming N. Larsen (original) - * - * @since 1.1.4 - */ -public final class Rules { - - // Hide the constructor in the Javadocs as it should not be used - private Rules() {} - - /** - * The acceleration of a robot, i.e. the increase of velocity when the - * robot moves forward, which is 1 pixel/turn. - */ - public static final double ACCELERATION = 1; - - /** - * The deceleration of a robot, i.e. the decrease of velocity when the - * robot moves backwards (or brakes), which is 2 pixels/turn. - */ - public static final double DECELERATION = 2; - - /** - * The maximum velocity of a robot, which is 8 pixels/turn. - */ - public static final double MAX_VELOCITY = 8; - - /** - * The radar scan radius, which is 1200 pixels. - * Robots which is more than 1200 pixels away cannot be seen on the radar. - */ - public static final double RADAR_SCAN_RADIUS = 1200; - - /** - * The minimum bullet power, i.e the amount of energy required for firing a - * bullet, which is 0.1 energy points. - */ - public static final double MIN_BULLET_POWER = 0.1; - - /** - * The maximum bullet power, i.e. the maximum amount of energy that can be - * transferred to a bullet when it is fired, which is 3 energy points. - */ - public static final double MAX_BULLET_POWER = 3; - - /** - * The maximum turning rate of the robot, in degrees, which is - * 10 degress/turn. - * Note, that the turn rate of the robot depends on it's velocity. - * - * @see #MAX_TURN_RATE_RADIANS - * @see #getTurnRate(double) - * @see #getTurnRateRadians(double) - */ - public static final double MAX_TURN_RATE = 10; - - /** - * The maximum turning rate of the robot measured in radians instead of - * degrees. - * - * @see #MAX_TURN_RATE - * @see #getTurnRate(double) - * @see #getTurnRateRadians(double) - */ - public static final double MAX_TURN_RATE_RADIANS = Math.toRadians(MAX_TURN_RATE); - - /** - * The turning rate of the gun measured in degrees, which is - * 20 degrees/turn. - * Note, that if setAdjustGunForRobotTurn(true) has been called, the gun - * turn is independent of the robot turn. - * In this case the gun moves relatively to the screen. If - * setAdjustGunForRobotTurn(false) has been called or - * setAdjustGunForRobotTurn() has not been called at all (this is the - * default), then the gun turn is dependent on the robot turn, and in this - * case the gun moves relatively to the robot body. - * - * @see #GUN_TURN_RATE_RADIANS - * @see Robot#setAdjustGunForRobotTurn(boolean) - */ - public static final double GUN_TURN_RATE = 20; - - /** - * The turning rate of the gun measured in radians instead of degrees. - * - * @see #GUN_TURN_RATE - */ - public static final double GUN_TURN_RATE_RADIANS = Math.toRadians(GUN_TURN_RATE); - - /** - * The turning rate of the radar measured in degrees, which is - * 45 degrees/turn. - * Note, that if setAdjustRadarForRobotTurn(true) and/or - * setAdjustRadarForGunTurn(true) has been called, the radar turn is - * independent of the robot and/or gun turn. If both methods has been set to - * true, the radar moves relatively to the screen. - * If setAdjustRadarForRobotTurn(false) and/or setAdjustRadarForGunTurn(false) - * has been called or not called at all (this is the default), then the - * radar turn is dependent on the robot and/or gun turn, and in this case - * the radar moves relatively to the gun and/or robot body. - * - * @see #RADAR_TURN_RATE_RADIANS - * @see Robot#setAdjustGunForRobotTurn(boolean) - * @see Robot#setAdjustRadarForGunTurn(boolean) - */ - public static final double RADAR_TURN_RATE = 45; - - /** - * The turning rate of the radar measured in radians instead of degrees. - * - * @see #RADAR_TURN_RATE - */ - public static final double RADAR_TURN_RATE_RADIANS = Math.toRadians(RADAR_TURN_RATE); - - /** - * The amount of damage taken when a robot hits or is hit by another robot, - * which is 0.6 energy points. - */ - public static final double ROBOT_HIT_DAMAGE = 0.6; - - /** - * The amount of bonus given when a robot moving forward hits an opponent - * robot (ramming), which is 1.2 energy points. - */ - public static final double ROBOT_HIT_BONUS = 1.2; - - /** - * Returns the turn rate of a robot given a specific velocity measured in - * degrees/turn. - * - * @param velocity the velocity of the robot. - * @return turn rate in degrees/turn. - * @see #getTurnRateRadians(double) - */ - public static double getTurnRate(double velocity) { - return MAX_TURN_RATE - 0.75 * abs(velocity); - } - - /** - * Returns the turn rate of a robot given a specific velocity measured in - * radians/turn. - * - * @param velocity the velocity of the robot. - * @return turn rate in radians/turn. - * @see #getTurnRate(double) - */ - public static double getTurnRateRadians(double velocity) { - return Math.toRadians(getTurnRate(velocity)); - } - - /** - * Returns the amount of damage taken when robot hits a wall with a - * specific velocity. - * - * @param velocity the velocity of the robot. - * @return wall hit damage in energy points. - */ - public static double getWallHitDamage(double velocity) { - return max(abs(velocity) / 2 - 1, 0); - } - - /** - * Returns the amount of damage of a bullet given a specific bullet power. - * - * @param bulletPower the energy power of the bullet. - * @return bullet damage in energy points. - */ - public static double getBulletDamage(double bulletPower) { - double damage = 4 * bulletPower; - - if (bulletPower > 1) { - damage += 2 * (bulletPower - 1); - } - return damage; - } - - /** - * Returns the amount of bonus given when a robot's bullet hits an opponent - * robot given a specific bullet power. - * - * @param bulletPower the energy power of the bullet. - * @return bullet hit bonus in energy points. - */ - public static double getBulletHitBonus(double bulletPower) { - return 3 * bulletPower; - } - - /** - * Returns the speed of a bullet given a specific bullet power measured in pixels/turn. - * - * @param bulletPower the energy power of the bullet. - * @return bullet speed in pixels/turn - */ - public static double getBulletSpeed(double bulletPower) { - bulletPower = Math.min(Math.max(bulletPower, MIN_BULLET_POWER), MAX_BULLET_POWER); - return 20 - 3 * bulletPower; - } - - /** - * Returns the heat produced by firing the gun given a specific bullet - * power. - * - * @param bulletPower the energy power of the bullet. - * @return gun heat - */ - public static double getGunHeat(double bulletPower) { - return 1 + (bulletPower / 5); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/ScannedRobotEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/ScannedRobotEvent.java deleted file mode 100644 index b089751..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/ScannedRobotEvent.java +++ /dev/null @@ -1,361 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A ScannedRobotEvent is sent to {@link Robot#onScannedRobot(ScannedRobotEvent) - * onScannedRobot()} when you scan a robot. - * You can use the information contained in this event to determine what to do. - *

- * Note: You should not inherit from this class in your own event class! - * The internal logic of this event class might change. Hence, your robot might - * not work in future Robocode versions, if you choose to inherit from this class. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class ScannedRobotEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 10; - - private final String name; - private final double energy; - private final double heading; - private final double bearing; - private final double distance; - private final double velocity; - private final boolean isSentryRobot; - - /** - * This constructor is only provided in order to preserve backwards compatibility with old robots that - * inherits from this Event class. - *

- * Note: You should not inherit from this class in your own event class! - * The internal logic of this event class might change. Hence, your robot might - * not work in future Robocode versions, if you choose to inherit from this class. - * - * @deprecated Use {@link #ScannedRobotEvent(String, double, double, double, double, double, boolean)} instead. - */ - public ScannedRobotEvent() { - this(null, 0, 0, 0, 0, 0, false); - } - - /** - * Called by the game to create a new ScannedRobotEvent. - * - * @param name the name of the scanned robot - * @param energy the energy of the scanned robot - * @param bearing the bearing of the scanned robot, in radians - * @param distance the distance from your robot to the scanned robot - * @param heading the heading of the scanned robot - * @param velocity the velocity of the scanned robot - * - * @deprecated Use {@link #ScannedRobotEvent(String, double, double, double, double, double, boolean)} instead. - */ - public ScannedRobotEvent(String name, double energy, double bearing, double distance, double heading, double velocity) { - this(name, energy, bearing, distance, heading, velocity, false); - } - - /** - * Called by the game to create a new ScannedRobotEvent. - * - * @param name the name of the scanned robot - * @param energy the energy of the scanned robot - * @param bearing the bearing of the scanned robot, in radians - * @param distance the distance from your robot to the scanned robot - * @param heading the heading of the scanned robot - * @param velocity the velocity of the scanned robot - * @param isSentryRobot flag specifying if the scanned robot is a sentry robot - * - * @since 1.9.0.0 - */ - public ScannedRobotEvent(String name, double energy, double bearing, double distance, double heading, double velocity, boolean isSentryRobot) { - super(); - this.name = name; - this.energy = energy; - this.bearing = bearing; - this.distance = distance; - this.heading = heading; - this.velocity = velocity; - this.isSentryRobot = isSentryRobot; - } - - /** - * Returns the bearing to the robot you scanned, relative to your robot's - * heading, in degrees (-180 <= getBearing() < 180) - * - * @return the bearing to the robot you scanned, in degrees - */ - public double getBearing() { - return bearing * 180.0 / Math.PI; - } - - /** - * Returns the bearing to the robot you scanned, relative to your robot's - * heading, in radians (-PI <= getBearingRadians() < PI) - * - * @return the bearing to the robot you scanned, in radians - */ - public double getBearingRadians() { - return bearing; - } - - /** - * Returns the distance to the robot (your center to his center). - * - * @return the distance to the robot. - */ - public double getDistance() { - return distance; - } - - /** - * Returns the energy of the robot. - * - * @return the energy of the robot - */ - public double getEnergy() { - return energy; - } - - /** - * Returns the heading of the robot, in degrees (0 <= getHeading() < 360) - * - * @return the heading of the robot, in degrees - */ - public double getHeading() { - return heading * 180.0 / Math.PI; - } - - /** - * Returns the heading of the robot, in radians (0 <= getHeading() < 2 * PI) - * - * @return the heading of the robot, in radians - */ - public double getHeadingRadians() { - return heading; - } - - /** - * @return the energy of the robot - * @deprecated Use {@link #getEnergy()} instead. - */ - @Deprecated - public double getLife() { - return energy; - } - - /** - * Returns the name of the robot. - * - * @return the name of the robot - */ - public String getName() { - return name; - } - - /** - * @return the bearing to the robot you scanned, in degrees - * @deprecated Use {@link #getBearing()} instead. - */ - @Deprecated - public double getRobotBearing() { - return getBearing(); - } - - /** - * @return the robot bearing in degrees - * @deprecated Use {@link #getBearing()} instead. - */ - @Deprecated - public double getRobotBearingDegrees() { - return getBearing(); - } - - /** - * @return the bearing to the robot you scanned, in radians - * @deprecated Use {@link #getBearingRadians()} instead. - */ - @Deprecated - public double getRobotBearingRadians() { - return getBearingRadians(); - } - - /** - * @return the distance to the robot. - * @deprecated Use {@link #getDistance()} instead. - */ - @Deprecated - public double getRobotDistance() { - return getDistance(); - } - - /** - * @return the heading of the robot, in degrees - * @deprecated Use {@link #getHeading()} instead. - */ - @Deprecated - public double getRobotHeading() { - return getHeading(); - } - - /** - * @return the heading of the robot, in degrees - * @deprecated Use {@link #getHeading()} instead. - */ - @Deprecated - public double getRobotHeadingDegrees() { - return getHeading(); - } - - /** - * @return the heading of the robot, in radians - * @deprecated Use {@link #getHeadingRadians()} instead. - */ - @Deprecated - public double getRobotHeadingRadians() { - return getHeadingRadians(); - } - - /** - * @return the energy of the robot - * @deprecated Use {@link #getEnergy()} instead. - */ - @Deprecated - public double getRobotLife() { - return getEnergy(); - } - - /** - * @return the name of the robot - * @deprecated Use {@link #getName()} instead. - */ - @Deprecated - public String getRobotName() { - return getName(); - } - - /** - * @return the velocity of the robot - * @deprecated Use {@link #getVelocity()} instead. - */ - @Deprecated - public double getRobotVelocity() { - return getVelocity(); - } - - /** - * Returns the velocity of the robot. - * - * @return the velocity of the robot - */ - public double getVelocity() { - return velocity; - } - - /** - * Checks if the scanned robot is a sentry robot. - * @return {@code true} if the scanned robot is a sentry robot; {@code false} otherwise. - * - * @since 1.9.0.0 - */ - public boolean isSentryRobot() { - return isSentryRobot; - } - - /** - * {@inheritDoc} - */ - @Override - public final int compareTo(Event event) { - final int res = super.compareTo(event); - if (res != 0) { - return res; - } - // Compare the distance, if the events are ScannedRobotEvents - // The shorter distance to the robot, the higher priority - if (event instanceof ScannedRobotEvent) { - return (int) (this.getDistance() - ((ScannedRobotEvent) event).getDistance()); - } - // No difference found - return 0; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - if (listener != null) { - listener.onScannedRobot(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.ScannedRobotEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - ScannedRobotEvent obj = (ScannedRobotEvent) object; - return RbSerializer.SIZEOF_TYPEINFO + serializer.sizeOf(obj.name) + 5 * RbSerializer.SIZEOF_DOUBLE - + RbSerializer.SIZEOF_BOOL; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - ScannedRobotEvent obj = (ScannedRobotEvent) object; - serializer.serialize(buffer, obj.name); - serializer.serialize(buffer, obj.energy); - serializer.serialize(buffer, obj.heading); - serializer.serialize(buffer, obj.bearing); - serializer.serialize(buffer, obj.distance); - serializer.serialize(buffer, obj.velocity); - serializer.serialize(buffer, obj.isSentryRobot); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - String name = serializer.deserializeString(buffer); - double energy = buffer.getDouble(); - double heading = buffer.getDouble(); - double bearing = buffer.getDouble(); - double distance = buffer.getDouble(); - double velocity = buffer.getDouble(); - boolean isSentryRobot = serializer.deserializeBoolean(buffer); - - return new ScannedRobotEvent(name, energy, bearing, distance, heading, velocity, isSentryRobot); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/SkippedTurnEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/SkippedTurnEvent.java deleted file mode 100644 index 2e1d7ba..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/SkippedTurnEvent.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IAdvancedEvents; -import robocode.robotinterfaces.IAdvancedRobot; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * A SkippedTurnEvent is sent to {@link AdvancedRobot#onSkippedTurn(SkippedTurnEvent) - * onSkippedTurn()} when your robot is forced to skipping a turn. - * You must take an action every turn in order to participate in the game. - * For example, - *

- *    try {
- *        Thread.sleep(1000);
- *    } catch (InterruptedException e) {
- *        // Immediately reasserts the exception by interrupting the caller thread
- *        // itself.
- *        Thread.currentThread().interrupt();
- *    }
- * 
- * will cause many SkippedTurnEvents, because you are not responding to the game. - * If you receive 30 SkippedTurnEvents, you will be removed from the round. - *

- * Instead, you should do something such as: - *

- *     for (int i = 0; i < 30; i++) {
- *         doNothing(); // or perhaps scan();
- *     }
- * 
- *

- * This event may also be generated if you are simply doing too much processing - * between actions, that is using too much processing power for the calculations - * etc. in your robot. - * - * @see AdvancedRobot#onSkippedTurn(SkippedTurnEvent) - * @see SkippedTurnEvent - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public final class SkippedTurnEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 100; // System event -> cannot be changed!; - - private final long skippedTurn; - - /** - * Called by the game to create a new SkippedTurnEvent. - * - * @param skippedTurn the skipped turn - */ - public SkippedTurnEvent(long skippedTurn) { - super(); - this.skippedTurn = skippedTurn; - } - - /** - * Returns the turn that was skipped. - * - * @return the turn that was skipped. - * - * @since 1.7.2.0 - */ - public long getSkippedTurn() { - return skippedTurn; - } - - /** - * {@inheritDoc} - */ - @Override - public final int getPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - if (statics.isAdvancedRobot()) { - IAdvancedEvents listener = ((IAdvancedRobot) robot).getAdvancedEventListener(); - - if (listener != null) { - listener.onSkippedTurn(this); - } - } - } - - /** - * {@inheritDoc} - */ - @Override - final boolean isCriticalEvent() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.SkippedTurnEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_LONG; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - SkippedTurnEvent obj = (SkippedTurnEvent) object; - - serializer.serialize(buffer, obj.skippedTurn); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - long skippedTurn = buffer.getLong(); - - return new SkippedTurnEvent(skippedTurn); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/StatusEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/StatusEvent.java deleted file mode 100644 index 3ef4c80..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/StatusEvent.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; - - -/** - * This event is sent to {@link Robot#onStatus(StatusEvent) onStatus()} every - * turn in a battle to provide the status of the robot. - * - * @author Flemming N. Larsen (original) - * - * @since 1.5 - */ -public final class StatusEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 99; - - private final RobotStatus status; - - /** - * This constructor is called internally from the game in order to create - * a new {@link RobotStatus}. - * - * @param status the current states - */ - public StatusEvent(RobotStatus status) { - super(); - - this.status = status; - } - - /** - * Returns the {@link RobotStatus} at the time defined by {@link Robot#getTime()}. - * - * @return the {@link RobotStatus} at the time defined by {@link Robot#getTime()}. - * @see #getTime() - */ - public RobotStatus getStatus() { - return status; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null) { - listener.onStatus(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - throw new Error("Serialization of this type is not supported"); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/TeamRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/TeamRobot.java deleted file mode 100644 index dc550c1..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/TeamRobot.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import robocode.robotinterfaces.ITeamEvents; -import robocode.robotinterfaces.ITeamRobot; -import robocode.robotinterfaces.peer.ITeamRobotPeer; - -import java.io.IOException; -import java.io.Serializable; -import java.util.Vector; - - -/** - * An advanced type of robot that supports sending messages between team - * mates in a robot team. - *

- * If you have not done already, you should create a {@link Robot} or - * {@link AdvancedRobot} first. - * - * @see JuniorRobot - * @see Robot - * @see AdvancedRobot - * @see RateControlRobot - * @see Droid - * @see BorderSentry - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Pavel Savara (contributor) - */ -public class TeamRobot extends AdvancedRobot implements ITeamRobot, ITeamEvents { - - /** - * Broadcasts a message to all teammates. - *

- * Example: - *

-	 *   public void run() {
-	 *       broadcastMessage("I'm here!");
-	 *   }
-	 * 
- * - * @param message the message to broadcast to all teammates - * @throws IOException if the message could not be broadcasted to the - * teammates - * @see #isTeammate(String) - * @see #getTeammates() - * @see #sendMessage(String, Serializable) - */ - public void broadcastMessage(Serializable message) throws IOException { - if (peer != null) { - ((ITeamRobotPeer) peer).broadcastMessage(message); - } else { - uninitializedException(); - } - } - - /** - * Returns a vector containing all MessageEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (MessageEvent e : getMessageEvents()) {
-	 *      // do something with e
-	 *   }
-	 * 
- * - * @return a vector containing all MessageEvents currently in the robot's - * queue - * @see #onMessageReceived(MessageEvent) - * @see MessageEvent - * @since 1.2.6 - */ - public Vector getMessageEvents() { - if (peer != null) { - return new Vector(((ITeamRobotPeer) peer).getMessageEvents()); - } - uninitializedException(); - return null; // never called - } - - /** - * Do not call this method! - *

- * {@inheritDoc} - */ - public final ITeamEvents getTeamEventListener() { - return this; // this robot is listening - } - - /** - * Returns the names of all teammates, or {@code null} there is no - * teammates. - *

- * Example: - *

-	 *   public void run() {
-	 *       // Prints out all teammates
-	 *       String[] teammates = getTeammates();
-	 *       if (teammates != null) {
-	 *           for (String member : teammates) {
-	 *               out.println(member);
-	 *           }
-	 *       }
-	 *   }
-	 * 
- * - * @return a String array containing the names of all your teammates, or - * {@code null} if there is no teammates. The length of the String array - * is equal to the number of teammates. - * @see #isTeammate(String) - * @see #broadcastMessage(Serializable) - * @see #sendMessage(String, Serializable) - */ - public String[] getTeammates() { - if (peer != null) { - return ((ITeamRobotPeer) peer).getTeammates(); - } - uninitializedException(); - return null; - } - - /** - * Checks if a given robot name is the name of one of your teammates. - *

- * Example: - *

-	 *   public void onScannedRobot(ScannedRobotEvent e) {
-	 *       if (isTeammate(e.getName()) {
-	 *           return;
-	 *       }
-	 *       fire(1);
-	 *   }
-	 * 
- * - * @param name the robot name to check - * @return {@code true} if the specified name belongs to one of your - * teammates; {@code false} otherwise. - * @see #getTeammates() - * @see #broadcastMessage(Serializable) - * @see #sendMessage(String, Serializable) - */ - public boolean isTeammate(String name) { - if (peer != null) { - return ((ITeamRobotPeer) peer).isTeammate(name); - } - uninitializedException(); - return false; - } - - /** - * {@inheritDoc} - */ - public void onMessageReceived(MessageEvent event) {} - - /** - * Sends a message to one (or more) teammates. - *

- * Example: - *

-	 *   public void run() {
-	 *       sendMessage("sample.DroidBot", "I'm here!");
-	 *   }
-	 * 
- * - * @param name the name of the intended recipient of the message - * @param message the message to send - * @throws IOException if the message could not be sent - * @see #isTeammate(String) - * @see #getTeammates() - * @see #broadcastMessage(Serializable) - */ - public void sendMessage(String name, Serializable message) throws IOException { - if (peer != null) { - ((ITeamRobotPeer) peer).sendMessage(name, message); - } else { - uninitializedException(); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/TurnCompleteCondition.java b/workspace_robo/robocode.api/src/main/java/robocode/TurnCompleteCondition.java deleted file mode 100644 index 9e25dbb..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/TurnCompleteCondition.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * A prebuilt condition you can use that indicates your robot has finished - * turning. - * - * @see Condition - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Nathaniel Troutman (contributor) - */ -public class TurnCompleteCondition extends Condition { - private AdvancedRobot robot; - - /** - * Creates a new TurnCompleteCondition with default priority. - * The default priority is 80. - * - * @param robot your robot, which must be a {@link AdvancedRobot} - */ - public TurnCompleteCondition(AdvancedRobot robot) { - super(); - this.robot = robot; - } - - /** - * Creates a new TurnCompleteCondition with the specified priority. - * A condition priority is a value from 0 - 99. The higher value, the - * higher priority. The default priority is 80. - * - * @param robot your robot, which must be a {@link AdvancedRobot} - * @param priority the priority of this condition - * @see Condition#setPriority(int) - */ - public TurnCompleteCondition(AdvancedRobot robot, int priority) { - super(); - this.robot = robot; - this.priority = priority; - } - - /** - * Tests if the robot has finished turning. - * - * @return {@code true} if the robot has stopped turning; {@code false} - * otherwise - */ - @Override - public boolean test() { - return (robot.getTurnRemaining() == 0); - } - - /** - * Called by the system in order to clean up references to internal objects. - * - * @since 1.4.3 - */ - @Override - public void cleanup() { - robot = null; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/WinEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/WinEvent.java deleted file mode 100644 index 6d79462..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/WinEvent.java +++ /dev/null @@ -1,98 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; - -import java.awt.*; -import java.nio.ByteBuffer; - - -/** - * This event is sent to {@link Robot#onWin(WinEvent) onWin()} when your robot - * wins the round in a battle. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public final class WinEvent extends Event { - private static final long serialVersionUID = 1L; - private final static int DEFAULT_PRIORITY = 100; // System event -> cannot be changed! - - /** - * Called by the game to create a new WinEvent. - */ - public WinEvent() { - super(); - } - - /** - * {@inheritDoc} - */ - @Override - public final int getPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final int getDefaultPriority() { - return DEFAULT_PRIORITY; - } - - /** - * {@inheritDoc} - */ - @Override - final void dispatch(IBasicRobot robot, IRobotStatics statics, Graphics2D graphics) { - IBasicEvents listener = robot.getBasicEventListener(); - - if (listener != null) { - listener.onWin(this); - } - } - - /** - * {@inheritDoc} - */ - @Override - final boolean isCriticalEvent() { - return true; - } - - /** - * {@inheritDoc} - */ - @Override - byte getSerializationType() { - return RbSerializer.WinEvent_TYPE; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) {} - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - return new WinEvent(); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/_AdvancedRadiansRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/_AdvancedRadiansRobot.java deleted file mode 100644 index 32dddbb..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/_AdvancedRadiansRobot.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import robocode.robotinterfaces.peer.IAdvancedRobotPeer; - - -/** - * This class is used by the system as a placeholder for all *Radians calls in - * {@link AdvancedRobot}. You may refer to this class for documentation only. - *

- * You should create a {@link AdvancedRobot} instead. - *

- * (The Radians methods themselves will continue work, however). - * - * @see Robot - * @see JuniorRobot - * @see AdvancedRobot - * @see TeamRobot - * @see RateControlRobot - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Pavel Savara (contributor) - */ -public class _AdvancedRadiansRobot extends _AdvancedRobot { - - _AdvancedRadiansRobot() {} - - public double getHeadingRadians() { - if (peer != null) { - return peer.getBodyHeading(); - } - uninitializedException(); - return 0; // never called - } - - public void setTurnLeftRadians(double radians) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnBody(-radians); - } else { - uninitializedException(); - } - } - - public void setTurnRightRadians(double radians) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnBody(radians); - } else { - uninitializedException(); - } - } - - public void turnLeftRadians(double radians) { - if (peer != null) { - peer.turnBody(-radians); - } else { - uninitializedException(); - } - } - - public void turnRightRadians(double radians) { - if (peer != null) { - peer.turnBody(radians); - } else { - uninitializedException(); - } - } - - public double getGunHeadingRadians() { - if (peer != null) { - return peer.getGunHeading(); - } - uninitializedException(); - return 0; // never called - } - - public double getRadarHeadingRadians() { - if (peer != null) { - return peer.getRadarHeading(); - } - uninitializedException(); - return 0; // never called - } - - public void setTurnGunLeftRadians(double radians) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnGun(-radians); - } else { - uninitializedException(); - } - } - - public void setTurnGunRightRadians(double radians) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnGun(radians); - } else { - uninitializedException(); - } - } - - public void setTurnRadarLeftRadians(double radians) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnRadar(-radians); - } else { - uninitializedException(); - } - } - - public void setTurnRadarRightRadians(double radians) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnRadar(radians); - } else { - uninitializedException(); - } - } - - public void turnGunLeftRadians(double radians) { - if (peer != null) { - peer.turnGun(-radians); - } else { - uninitializedException(); - } - } - - public void turnGunRightRadians(double radians) { - if (peer != null) { - peer.turnGun(radians); - } else { - uninitializedException(); - } - } - - public void turnRadarLeftRadians(double radians) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).turnRadar(-radians); - } else { - uninitializedException(); - } - } - - public void turnRadarRightRadians(double radians) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).turnRadar(radians); - } else { - uninitializedException(); - } - } - - public double getGunTurnRemainingRadians() { - if (peer != null) { - return peer.getGunTurnRemaining(); - } - uninitializedException(); - return 0; // never called - } - - public double getRadarTurnRemainingRadians() { - if (peer != null) { - return peer.getRadarTurnRemaining(); - } - uninitializedException(); - return 0; // never called - } - - public double getTurnRemainingRadians() { - if (peer != null) { - return peer.getBodyTurnRemaining(); - } - uninitializedException(); - return 0; // never called - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/_AdvancedRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/_AdvancedRobot.java deleted file mode 100644 index 0090040..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/_AdvancedRobot.java +++ /dev/null @@ -1,273 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import robocode.robotinterfaces.peer.IAdvancedRobotPeer; - - -/** - * This class is used by the system, as well as being a placeholder for all deprecated - * (meaning, you should not use them) calls for {@link AdvancedRobot}. - *

- * You should create a {@link AdvancedRobot} instead. - * - * @see Robot - * @see JuniorRobot - * @see AdvancedRobot - * @see TeamRobot - * @see RateControlRobot - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Pavel Savara (contributor) - */ -public class _AdvancedRobot extends Robot { - - _AdvancedRobot() {} - - /** - * @param degrees the amount of degrees to turn the robot's gun to the left. - * If {@code degrees} > 0 the robot's gun is set to turn left. - * If {@code degrees} < 0 the robot's gun is set to turn right. - * If {@code degrees} = 0 the robot's gun is set to stop turning. - * @deprecated Use {@link AdvancedRobot#setTurnGunLeft(double) - * setTurnGunLeft} instead. - */ - @Deprecated - public void setTurnGunLeftDegrees(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnGun(-Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * @param degrees the amount of degrees to turn the robot's gun to the right. - * If {@code degrees} > 0 the robot's gun is set to turn right. - * If {@code degrees} < 0 the robot's gun is set to turn left. - * If {@code degrees} = 0 the robot's gun is set to stop turning. - * @deprecated Use {@link AdvancedRobot#setTurnGunRight(double) - * setTurnGunRight} instead. - */ - @Deprecated - public void setTurnGunRightDegrees(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnGun(Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * @param degrees the amount of degrees to turn the robot's radar to the right. - * If {@code degrees} > 0 the robot's radar will turn right. - * If {@code degrees} < 0 the robot's radar will turn left. - * If {@code degrees} = 0 the robot's radar will not turn, but execute. - * @deprecated Use {@link Robot#turnRadarRight(double) turnRadarRight} - * instead. - */ - @Deprecated - public void turnRadarRightDegrees(double degrees) { - turnRadarRight(degrees); - } - - /** - * @param degrees the amount of degrees to turn the robot's body to the right. - * If {@code degrees} > 0 the robot is set to turn right. - * If {@code degrees} < 0 the robot is set to turn left. - * If {@code degrees} = 0 the robot is set to stop turning. - * @deprecated Use {@link AdvancedRobot#setTurnRight(double) - * setTurnRight(double)} instead. - */ - @Deprecated - public void setTurnRightDegrees(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnBody(Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * @param degrees the amount of degrees to turn the robot's radar to the left. - * If {@code degrees} > 0 the robot's radar is set to turn left. - * If {@code degrees} < 0 the robot's radar is set to turn right. - * If {@code degrees} = 0 the robot's radar is set to stop turning. - * @deprecated Use {@link AdvancedRobot#setTurnRadarLeft(double) - * setTurnRadarLeft(double)} instead. - */ - @Deprecated - public void setTurnRadarLeftDegrees(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnRadar(-Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * @param degrees the amount of degrees to turn the robot's body to the left. - * If {@code degrees} > 0 the robot is set to turn left. - * If {@code degrees} < 0 the robot is set to turn right. - * If {@code degrees} = 0 the robot is set to stop turning. - * @deprecated Use {@link AdvancedRobot#setTurnLeft(double) - * setTurnLeft(double)} instead. - */ - @Deprecated - public void setTurnLeftDegrees(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnBody(-Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * @return the direction that the robot's body is facing, in degrees. - * @deprecated Use {@link Robot#getHeading() getHeading()} instead. - */ - @Deprecated - public double getHeadingDegrees() { - return getHeading(); - } - - /** - * @param degrees the amount of degrees to turn the robot's body to the left. - * If {@code degrees} > 0 the robot will turn left. - * If {@code degrees} < 0 the robot will turn right. - * If {@code degrees} = 0 the robot will not turn, but execute. - * @deprecated Use {@link Robot#turnLeft(double) turnLeft(double)} instead. - */ - @Deprecated - public void turnLeftDegrees(double degrees) { - turnLeft(degrees); - } - - /** - * @param degrees the amount of degrees to turn the robot's body to the right. - * If {@code degrees} > 0 the robot will turn right. - * If {@code degrees} < 0 the robot will turn left. - * If {@code degrees} = 0 the robot will not turn, but execute. - * @deprecated Use {@link Robot#turnRight(double) turnRight(double)} instead. - */ - @Deprecated - public void turnRightDegrees(double degrees) { - turnRight(degrees); - } - - /** - * @deprecated Use {@link AdvancedRobot#execute() execute} instead. - */ - @Deprecated - public void endTurn() { - if (peer != null) { - peer.execute(); - } else { - uninitializedException(); - } - } - - /** - * @return the direction that the robot's gun is facing, in degrees. - * @deprecated Use {@link Robot#getGunHeading() getGunHeading()} instead. - */ - @Deprecated - public double getGunHeadingDegrees() { - return getGunHeading(); - } - - /** - * @return the direction that the robot's radar is facing, in degrees. - * @deprecated Use {@link Robot#getRadarHeading() getRadarHeading()} instead. - */ - @Deprecated - public double getRadarHeadingDegrees() { - return getRadarHeading(); - } - - /** - * @return allways {@code 0} as this method is no longer functional. - * @deprecated This method is no longer functional. - * Use {@link AdvancedRobot#onSkippedTurn(SkippedTurnEvent)} instead. - */ - @Deprecated - public int getWaitCount() { - if (peer != null) { - peer.getCall(); - } - return 0; - } - - /** - * @param degrees the amount of degrees to turn the robot's radar to the right. - * If {@code degrees} > 0 the robot's radar is set to turn right. - * If {@code degrees} < 0 the robot's radar is set to turn left. - * If {@code degrees} = 0 the robot's radar is set to stop turning. - * @deprecated Use {@link AdvancedRobot#setTurnRadarRight(double) - * setTurnRadarRight} instead. - */ - @Deprecated - public void setTurnRadarRightDegrees(double degrees) { - if (peer != null) { - ((IAdvancedRobotPeer) peer).setTurnRadar(Math.toRadians(degrees)); - } else { - uninitializedException(); - } - } - - /** - * @param degrees the amount of degrees to turn the robot's gun to the left. - * If {@code degrees} > 0 the robot's gun will turn left. - * If {@code degrees} < 0 the robot's gun will turn right. - * If {@code degrees} = 0 the robot's gun will not turn, but execute. - * @deprecated Use {@link Robot#turnGunLeft(double) turnGunLeft} instead. - */ - @Deprecated - public void turnGunLeftDegrees(double degrees) { - turnGunLeft(degrees); - } - - /** - * @param degrees the amount of degrees to turn the robot's gun to the right. - * If {@code degrees} > 0 the robot's gun will turn right. - * If {@code degrees} < 0 the robot's gun will turn left. - * If {@code degrees} = 0 the robot's gun will not turn, but execute. - * @deprecated Use {@link Robot#turnGunRight(double) turnGunRight} instead. - */ - @Deprecated - public void turnGunRightDegrees(double degrees) { - turnGunRight(degrees); - } - - /** - * @param degrees the amount of degrees to turn the robot's radar to the left. - * If {@code degrees} > 0 the robot's radar will turn left. - * If {@code degrees} < 0 the robot's radar will turn right. - * If {@code degrees} = 0 the robot's radar will not turn, but execute. - * @deprecated Use {@link Robot#turnRadarLeft(double) turnRadarLeft} instead. - */ - @Deprecated - public void turnRadarLeftDegrees(double degrees) { - turnRadarLeft(degrees); - } - - /** - * @return allways {@code 0} as this method is no longer functional. - * @deprecated This method is no longer functional. - * Use {@link AdvancedRobot#onSkippedTurn(SkippedTurnEvent)} instead. - */ - @Deprecated - public int getMaxWaitCount() { - if (peer != null) { - peer.getCall(); - } - return 0; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/_Robot.java b/workspace_robo/robocode.api/src/main/java/robocode/_Robot.java deleted file mode 100644 index 3ff146c..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/_Robot.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * This class is used by the system, as well as being a placeholder for all deprecated - * (meaning, you should not use them) calls for {@link Robot}. - *

- * You should create a {@link Robot} instead. - * - * @see Robot - * @see JuniorRobot - * @see AdvancedRobot - * @see TeamRobot - * @see RateControlRobot - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Pavel Savara (contributor) - */ -public abstract class _Robot extends _RobotBase { - private String robotImageName; - private String gunImageName; - private String radarImageName; - - _Robot() {} - - /** - * @return 5 - {@link robocode.Robot#getGunHeat() getGunHeat()}. - * @deprecated Use {@link Robot#getGunHeat() getGunHeat()} instead. - */ - @Deprecated - public double getGunCharge() { - if (peer != null) { - return 5 - peer.getGunHeat(); - } - uninitializedException(); - return 0; // never called - } - - /** - * @return the robot's current life/energy. - * @deprecated Use {@link Robot#getEnergy() getEnergy()} instead. - */ - @Deprecated - public double getLife() { - if (peer != null) { - return peer.getEnergy(); - } - uninitializedException(); - return 0; // never called - } - - /** - * @return the number of rounds in the current battle - * @deprecated Use {@link Robot#getNumRounds() getNumRounds()} instead. - */ - @Deprecated - public int getNumBattles() { - if (peer != null) { - return peer.getNumRounds(); - } - uninitializedException(); - return 0; // never called - } - - /** - * @return the current round number of the battle (zero indexed). - * @deprecated Use {@link Robot#getRoundNum() getRoundNum()} instead. - */ - @Deprecated - public int getBattleNum() { - if (peer != null) { - return peer.getRoundNum(); - } - uninitializedException(); - return 0; // never called - } - - /** - * This call has moved to {@link AdvancedRobot}, and will no longer function in - * the {@link Robot} class. - * - * @param interruptible {@code true} if the event handler should be - * interrupted if new events of the same priority occurs; {@code false} - * otherwise - */ - public void setInterruptible(boolean interruptible) {} - - /** - * @return the name of the gun image - * @deprecated This call is not used. - */ - @Deprecated - public String getGunImageName() { - return gunImageName; - } - - /** - * @param newGunImageName the name of the new gun image - * @deprecated This call is not used. - */ - @Deprecated - public void setGunImageName(String newGunImageName) { - gunImageName = newGunImageName; - } - - /** - * @param newRadarImageName the name of the new radar image - * @deprecated This call is not used. - */ - @Deprecated - public void setRadarImageName(String newRadarImageName) { - radarImageName = newRadarImageName; - } - - /** - * @param newRobotImageName the name of the new robot body image - * @deprecated This call is not used. - */ - @Deprecated - public void setRobotImageName(String newRobotImageName) { - robotImageName = newRobotImageName; - } - - /** - * @return the name of the radar image - * @deprecated This call is not used. - */ - @Deprecated - public String getRadarImageName() { - return radarImageName; - } - - /** - * @return the name of the robot image - * @deprecated This call is not used. - */ - @Deprecated - public String getRobotImageName() { - return robotImageName; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/_RobotBase.java b/workspace_robo/robocode.api/src/main/java/robocode/_RobotBase.java deleted file mode 100644 index b760340..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/_RobotBase.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -import robocode.exception.RobotException; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.peer.IBasicRobotPeer; - - -/** - * This is the base class of all robots used by the system. - * You should not inherit your robot on this class. - *

- * You should create a robot that is derived from the {@link Robot}, {@link AdvancedRobot}, - * {@link JuniorRobot}, {@link TeamRobot}, or {@link RateControlRobot} class instead. - * - * @see Robot - * @see JuniorRobot - * @see AdvancedRobot - * @see TeamRobot - * @see RateControlRobot - * - * @author Flemming N. Larsen (original) - * @author Pavel Savara (contributor) - * - * @since 1.4 - */ -public abstract class _RobotBase implements IBasicRobot, Runnable { - - // Internal for this package - _RobotBase() {} - - IBasicRobotPeer peer; - - /** - * The output stream your robot should use to print. - *

- * You can view the print-outs by clicking the button for your robot in the - * right side of the battle window. - *

- * Example: - *

-	 *   // Print out a line each time my robot hits another robot
-	 *   public void onHitRobot(HitRobotEvent e) {
-	 *       out.println("I hit a robot!  My energy: " + getEnergy() + " his energy: " + e.getEnergy());
-	 *   }
-	 * 
- */ - public java.io.PrintStream out; - - /** - * Called by the system to 'clean up' after your robot. - * You may not override this method. - */ - @Override - protected final void finalize() throws Throwable { // This method must be final so it cannot be overridden! - super.finalize(); - } - - /** - * {@inheritDoc} - */ - public final void setOut(java.io.PrintStream out) { - this.out = out; - } - - /** - * {@inheritDoc} - */ - public final void setPeer(IBasicRobotPeer peer) { - this.peer = peer; - } - - /** - * Throws a RobotException. This method should be called when the robot's peer - * is uninitialized. - */ - static void uninitializedException() { - StackTraceElement[] trace = Thread.currentThread().getStackTrace(); - String methodName = trace[2].getMethodName(); - - throw new RobotException( - "You cannot call the " + methodName - + "() method before your run() method is called, or you are using a Robot object that the game doesn't know about."); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/annotation/SafeStatic.java b/workspace_robo/robocode.api/src/main/java/robocode/annotation/SafeStatic.java deleted file mode 100644 index fdebf04..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/annotation/SafeStatic.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.annotation; - - -import java.lang.annotation.*; - - -/** - * Annotation used for marking a static field as being safe so that Robocode should - * not print out warnings at runtime when this annotation is being used. - * For example, Robocode will print out warnings if a static field to a robot is found. - * But not when the @SafeStatic is declared for the static field. - * - * @author Flemming N. Larsen (original) - * - * @since 1.7.2.1 - */ -@Target(ElementType.FIELD) -@Retention(RetentionPolicy.RUNTIME) -public @interface SafeStatic {} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/annotation/package-info.java b/workspace_robo/robocode.api/src/main/java/robocode/annotation/package-info.java deleted file mode 100644 index 65daba2..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/annotation/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - -/** - * Contains annotations that can be used with Robocode. - */ -package robocode.annotation; diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/BattleSpecification.java b/workspace_robo/robocode.api/src/main/java/robocode/control/BattleSpecification.java deleted file mode 100644 index ceba0fb..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/BattleSpecification.java +++ /dev/null @@ -1,234 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control; - - -/** - * A BattleSpecification defines a battle configuration used by the {@link RobocodeEngine}. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class BattleSpecification implements java.io.Serializable { - - private static final long serialVersionUID = 1L; - - private final int battlefieldWidth; - private final int battlefieldHeight; - private final int numRounds; - private final double gunCoolingRate; - private final long inactivityTime; - private final boolean hideEnemyNames; - private final int sentryBorderSize; - private final RobotSpecification[] robots; - private final RobotSetup[] initialSetups; - - /** - * Creates a new BattleSpecification with the given number of rounds, battlefield size, and robots. - * Inactivity time for the robots defaults to 450, and the gun cooling rate defaults to 0.1. - * - * @param numRounds is the number of rounds in this battle. - * @param battlefieldSize is the battlefield size. - * @param robots is the robots participating in this battle. - */ - public BattleSpecification(int numRounds, BattlefieldSpecification battlefieldSize, RobotSpecification[] robots) { - this(numRounds, 450, 0.1, battlefieldSize, robots); - } - - /** - * Creates a new BattleSpecification with the given settings. - * - * @param numRounds is the number of rounds in this battle. - * @param inactivityTime is the inactivity time allowed for the robots before they will loose energy. - * @param gunCoolingRate is the gun cooling rate for the robots. - * @param battlefieldSize is the battlefield size. - * @param robots is the robots participating in this battle. - */ - public BattleSpecification(int numRounds, long inactivityTime, double gunCoolingRate, BattlefieldSpecification battlefieldSize, RobotSpecification[] robots) { - this(numRounds, inactivityTime, gunCoolingRate, false, battlefieldSize, robots); - } - - /** - * Creates a new BattleSpecification with the given settings. - * - * @param numRounds is the number of rounds in this battle. - * @param inactivityTime is the inactivity time allowed for the robots before they will loose energy. - * @param gunCoolingRate is the gun cooling rate for the robots. - * @param hideEnemyNames flag specifying if enemy names are hidden from robots. - * @param battlefieldSize is the battlefield size. - * @param robots is the robots participating in this battle. - * - * @since 1.7.3 - */ - public BattleSpecification(int numRounds, long inactivityTime, double gunCoolingRate, boolean hideEnemyNames, BattlefieldSpecification battlefieldSize, RobotSpecification[] robots) { - this(battlefieldSize, numRounds, inactivityTime, gunCoolingRate, 100, hideEnemyNames, robots); - } - - /** - * Creates a new BattleSpecification with the given settings. - * - * @param battlefieldSize is the battlefield size. - * @param numRounds is the number of rounds in this battle. - * @param inactivityTime is the inactivity time allowed for the robots before they will loose energy. - * @param gunCoolingRate is the gun cooling rate for the robots. - * @param sentryBorderSize is the sentry border size for a {@link robocode.BorderSentry BorderSentry}. - * @param hideEnemyNames flag specifying if enemy names are hidden from robots. - * @param robots is the robots participating in this battle. - * - * @since 1.9.0.0 - */ - public BattleSpecification(BattlefieldSpecification battlefieldSize, int numRounds, long inactivityTime, double gunCoolingRate, int sentryBorderSize, boolean hideEnemyNames, RobotSpecification[] robots) { - this(battlefieldSize, numRounds, inactivityTime, gunCoolingRate, 100, hideEnemyNames, robots, null); - } - - /** - * Creates a new BattleSpecification with the given settings. - * - * @param battlefieldSize is the battlefield size. - * @param numRounds is the number of rounds in this battle. - * @param inactivityTime is the inactivity time allowed for the robots before they will loose energy. - * @param gunCoolingRate is the gun cooling rate for the robots. - * @param sentryBorderSize is the sentry border size for a {@link robocode.BorderSentry BorderSentry}. - * @param hideEnemyNames flag specifying if enemy names are hidden from robots. - * @param robots is the robots participating in this battle. - * @param initialSetup is the initial position and heading of the robots, where the indices matches the indices from the {@code robots} parameter. - * - * @since 1.9.2.0 - */ - public BattleSpecification(BattlefieldSpecification battlefieldSize, int numRounds, long inactivityTime, double gunCoolingRate, int sentryBorderSize, boolean hideEnemyNames, RobotSpecification[] robots, RobotSetup[] initialSetups) { - if (battlefieldSize == null) { - throw new IllegalArgumentException("battlefieldSize cannot be null"); - } - if (robots == null) { - throw new IllegalArgumentException("robots cannot be null"); - } - if (robots.length < 1) { - throw new IllegalArgumentException("robots.length must be > 0"); - } - if (initialSetups != null && initialSetups.length != robots.length) { - throw new IllegalArgumentException("initialSetups.length must be == robots.length"); - } - if (numRounds < 1) { - throw new IllegalArgumentException("numRounds must be >= 1"); - } - if (inactivityTime < 1) { - throw new IllegalArgumentException("inactivityTime must be >= 1"); - } - if (gunCoolingRate < 0.1) { - throw new IllegalArgumentException("inactivityTime must be >= 0.1"); - } - if (sentryBorderSize < 50) { - throw new IllegalArgumentException("sentryBorderSize must be >= 50"); - } - this.battlefieldWidth = battlefieldSize.getWidth(); - this.battlefieldHeight = battlefieldSize.getHeight(); - this.numRounds = numRounds; - this.inactivityTime = inactivityTime; - this.gunCoolingRate = gunCoolingRate; - this.sentryBorderSize = sentryBorderSize; - this.hideEnemyNames = hideEnemyNames; - this.robots = robots; - this.initialSetups = initialSetups; - } - - /** - * Returns the allowed inactivity time for the robots in this battle. - * - * @return the allowed inactivity time for the robots in this battle. - */ - public long getInactivityTime() { - return inactivityTime; - } - - /** - * Returns the gun cooling rate of the robots in this battle. - * - * @return the gun cooling rate of the robots in this battle. - */ - public double getGunCoolingRate() { - return gunCoolingRate; - } - - /** - * Returns the battlefield size for this battle. - * - * @return the battlefield size for this battle. - */ - public BattlefieldSpecification getBattlefield() { - return new BattlefieldSpecification(battlefieldWidth, battlefieldHeight); - } - - /** - * Returns the number of rounds in this battle. - * - * @return the number of rounds in this battle. - */ - public int getNumRounds() { - return numRounds; - } - - /** - * Returns the flag specifying if the enemy names must be hidden from events sent to robots. - * - * @return {@code true} if the enemy names must be hidden; {@code false} otherwise. - * - * @since 1.7.3 - */ - public boolean getHideEnemyNames() { - return hideEnemyNames; - } - - /** - * Returns the sentry border size for a {@link robocode.BorderSentry BorderSentry} that defines the how - * far a BorderSentry is allowed to move from the border edges measured in units.
- * Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that - * border sentry robots cannot leave (they must stay in the border area), but it also define the - * distance from the border edges where border sentry robots are allowed/able to make damage to robots entering this - * border area. - * - * @return the border size in units/pixels that border sentry robots are restricted to. - * - * @since 1.9.0.0 - */ - public int getSentryBorderSize() { - return sentryBorderSize; - } - - /** - * Returns the specifications of the robots participating in this battle. - * - * @return an array of {@link RobotSpecification} instances - one entry for each robot. - * - * @see #getInitialSetups() - */ - public RobotSpecification[] getRobots() { - if (robots == null) { - return null; - } - RobotSpecification[] robotsCopy = new RobotSpecification[robots.length]; - System.arraycopy(robots, 0, robotsCopy, 0, robots.length); - return robotsCopy; - } - - /** - * Returns the initial position and heading of each robot participating in this battle. - * - * @return an array of {@link RobotSetup} instances - one entry for each robot. - * The the indices of this array matches the array indices from the robot specifications (see {@link #getRobots()}). - * - * @see #getRobots() - */ - public RobotSetup[] getInitialSetups() { - if (initialSetups == null) { - return null; - } - RobotSetup[] setupsCopy = new RobotSetup[initialSetups.length]; - System.arraycopy(initialSetups, 0, setupsCopy, 0, initialSetups.length); - return setupsCopy; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/BattlefieldSpecification.java b/workspace_robo/robocode.api/src/main/java/robocode/control/BattlefieldSpecification.java deleted file mode 100644 index abbc012..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/BattlefieldSpecification.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control; - - -/** - * Defines the size of a battlefield, which is a part of the {@link BattleSpecification}. - * - * @see BattleSpecification#BattleSpecification(int, BattlefieldSpecification, RobotSpecification[]) - * @see BattleSpecification#BattleSpecification(int, long, double, BattlefieldSpecification, RobotSpecification[]) - * @see BattleSpecification#getBattlefield() - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class BattlefieldSpecification implements java.io.Serializable { - - private static final long serialVersionUID = 1L; - - private final int width; - private final int height; - - /** - * Creates a standard 800 x 600 battlefield. - */ - public BattlefieldSpecification() { - this(800, 600); - } - - /** - * Creates a battlefield of the specified width and height. - * - * @param width the width of the battlefield, where 400 <= width <= 5000. - * @param height the height of the battlefield, where 400 <= height <= 5000. - * @throws IllegalArgumentException if the width or height < 400 or > 5000. - */ - public BattlefieldSpecification(int width, int height) { - if (width < 400 || width > 5000) { - throw new IllegalArgumentException("width must be: 400 <= width <= 5000"); - } - if (height < 400 || height > 5000) { - throw new IllegalArgumentException("height must be: 400 <= height <= 5000"); - } - - this.width = width; - this.height = height; - } - - /** - * Returns the width of this battlefield. - * - * @return the width of this battlefield. - */ - public int getWidth() { - return width; - } - - /** - * Returns the height of this battlefield. - * - * @return the height of this battlefield. - */ - public int getHeight() { - return height; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/IRobocodeEngine.java b/workspace_robo/robocode.api/src/main/java/robocode/control/IRobocodeEngine.java deleted file mode 100644 index 9b85382..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/IRobocodeEngine.java +++ /dev/null @@ -1,150 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control; - - -import robocode.control.events.IBattleListener; - - -/** - * Interface for the RobocodeEngine. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public interface IRobocodeEngine { - - /** - * Adds a battle listener that must receive events occurring in battles. - * - * @param listener the battle listener that must retrieve the event from - * the battles. - * @see #removeBattleListener(robocode.control.events.IBattleListener) - * @since 1.6.2 - */ - void addBattleListener(IBattleListener listener); - - /** - * Removes a battle listener that has previously been added to this object. - * - * @param listener the battle listener that must be removed. - * @see #addBattleListener(robocode.control.events.IBattleListener) - * @since 1.6.2 - */ - void removeBattleListener(IBattleListener listener); - - /** - * Closes the RobocodeEngine and releases any allocated resources it holds. - * You should call this when you have finished using the RobocodeEngine. - * This method automatically disposes the Robocode window if it open. - */ - void close(); - - /** - * Returns the installed version of Robocode controlled by this RobocodeEngine. - * - * @return the installed version of Robocode controlled by this RobocodeEngine. - */ - String getVersion(); - - /** - * Shows or hides the Robocode window. - * - * @param visible {@code true} if the Robocode window must be set visible; - * {@code false} otherwise. - */ - void setVisible(boolean visible); - - /** - * Returns all robots available from the local robot repository of Robocode. - * These robots must exists in the /robocode/robots directory, and must be - * compiled in advance, before these robot are returned with this method. - * - * @return an array of all available robots from the local robot repository. - * @see robocode.control.RobotSpecification - * @see #getLocalRepository(String) - */ - RobotSpecification[] getLocalRepository(); - - /** - * Returns a selection of robots available from the local robot repository - * of Robocode. These robots must exists in the /robocode/robots directory, - * and must be compiled in advance, before these robot are returned with this method. - *

- * Notice: If a specified robot cannot be found in the repository, it will - * not be returned in the array of robots returned by this method. - * - * @param selectedRobotList a comma or space separated list of robots to - * return. The full class name must be used for - * specifying the individual robot, e.g. - * "sample.Corners, sample.Crazy". - * @return an array containing the available robots from the local robot - * repository based on the selected robots specified with the - * {@code selectedRobotList} parameter. - * @see robocode.control.RobotSpecification - * @see #getLocalRepository() - * @since 1.6.2 - */ - RobotSpecification[] getLocalRepository(String selectedRobotList); - - /** - * Runs the specified battle. - * - * @param battleSpecification the specification of the battle to run including the - * participation robots. - * @see #runBattle(robocode.control.BattleSpecification, boolean) - * @see robocode.control.BattleSpecification - * @see #getLocalRepository() - */ - void runBattle(BattleSpecification battleSpecification); - - /** - * Runs the specified battle. - * - * @param battleSpecification the specification of the battle to run including the - * participating robots. - * @param waitTillOver will block caller till end of battle if set - * @see #runBattle(robocode.control.BattleSpecification) - * @see robocode.control.BattleSpecification - * @see #getLocalRepository() - * @since 1.6.2 - */ - void runBattle(BattleSpecification battleSpecification, boolean waitTillOver); - - /** - * Runs the specified battle. - * - * @param battleSpecification the specification of the battle to run including the - * participating robots. - * @param initialPositions a comma or space separated list like: x1,y1,heading1, - * x2,y2,heading2, which are the coordinates and heading of robot #1 and #2. - * So e.g. 0,0,180, 50,80,270 means that robot #1 has position (0,0) and - * heading 180, and robot #2 has position (50,80) and heading 270. - * @param waitTillOver will block caller till end of battle if set - * @see #runBattle(BattleSpecification) - * @see BattleSpecification - * @see #getLocalRepository() - * @since 1.7.1.2 - */ - void runBattle(BattleSpecification battleSpecification, String initialPositions, boolean waitTillOver); - - /** - * Will block caller until current battle is over. - * @see #runBattle(robocode.control.BattleSpecification) - * @see #runBattle(robocode.control.BattleSpecification, boolean) - * @since 1.6.2 - */ - void waitTillBattleOver(); - - /** - * Aborts the current battle if it is running. - * - * @see #runBattle(robocode.control.BattleSpecification) - */ - void abortCurrentBattle(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/RandomFactory.java b/workspace_robo/robocode.api/src/main/java/robocode/control/RandomFactory.java deleted file mode 100644 index 28833f0..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/RandomFactory.java +++ /dev/null @@ -1,119 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control; - - -import static net.sf.robocode.io.Logger.logError; -import static net.sf.robocode.io.Logger.logWarning; - -import java.lang.reflect.Field; -import java.util.Random; - - -/** - * The RandomFactory is used for controlling the generation of random numbers, - * and supports generating random numbers that are deterministic, which is - * useful for testing purposes. - * - * @author Pavel Savara (original) - * - * @since 1.6.1 - */ -public class RandomFactory { - private static Random randomNumberGenerator; - - private static boolean warningNotSupportedLogged; - private static boolean isDeterministic; - - static { - randomNumberGenerator = new Random(); - } - - public boolean isDeterministic() { - return isDeterministic; - } - - /** - * Returns the random number generator used for generating a stream of - * random numbers. - * - * @return a {@link java.util.Random} instance. - * @see java.util.Random - */ - public static Random getRandom() { - if (randomNumberGenerator == null) { - try { - Math.random(); - final Field field = Math.class.getDeclaredField("randomNumberGenerator"); - final boolean savedFieldAccessible = field.isAccessible(); - - field.setAccessible(true); - randomNumberGenerator = (Random) field.get(null); - field.setAccessible(savedFieldAccessible); - } catch (NoSuchFieldException e) { - logWarningNotSupported(); - randomNumberGenerator = new Random(); - } catch (IllegalAccessException e) { - logError(e); - randomNumberGenerator = new Random(); - } - } - return randomNumberGenerator; - } - - /** - * Sets the random number generator instance used for generating a - * stream of random numbers. - * - * @param random a {@link java.util.Random} instance. - * @see java.util.Random - */ - public static void setRandom(Random random) { - randomNumberGenerator = random; - try { - Math.random(); - final Field field = Math.class.getDeclaredField("randomNumberGenerator"); - final boolean savedFieldAccessible = field.isAccessible(); - - field.setAccessible(true); - field.set(null, randomNumberGenerator); - field.setAccessible(savedFieldAccessible); - } catch (NoSuchFieldException e) { - logWarningNotSupported(); - } catch (IllegalAccessException e) { - logError(e); - } - - // TODO ZAMO using Robot classloader inject seed also for all instances being created by robots - } - - /** - * Resets the random number generator instance to be deterministic when - * generating random numbers. - * - * @param seed the seed to use for the new deterministic random generator. - */ - public static void resetDeterministic(long seed) { - setRandom(new Random(seed)); - isDeterministic = true; - } - - /** - * Logs a warning that the deterministic random feature is not supported by the JVM. - */ - private static void logWarningNotSupported() { - if (!(warningNotSupportedLogged || System.getProperty("RANDOMSEED", "none").equals("none"))) { - logWarning( - "The deterministic random generator feature is not supported by this JVM:\n" - + System.getProperty("java.vm.vendor") + " " + System.getProperty("java.vm.name") + " " - + System.getProperty("java.vm.version")); - - warningNotSupportedLogged = true; - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/RobocodeEngine.java b/workspace_robo/robocode.api/src/main/java/robocode/control/RobocodeEngine.java deleted file mode 100644 index 9166b33..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/RobocodeEngine.java +++ /dev/null @@ -1,364 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control; - - -import net.sf.robocode.battle.IBattleManagerBase; -import net.sf.robocode.core.ContainerBase; -import net.sf.robocode.gui.IWindowManagerBase; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.manager.IVersionManagerBase; -import net.sf.robocode.repository.IRepositoryManagerBase; -import net.sf.robocode.security.HiddenAccess; -import robocode.control.events.*; - -import java.io.File; -import java.util.ArrayList; -import java.util.List; - - -/** - * The RobocodeEngine is the interface provided for external applications - * in order to let these applications run battles within the Robocode application, - * and to get the results from these battles. - *

- * This class in the main entry class of the {@code robocode.control} package. - *

- * The RobocodeEngine is used by e.g. RoboRumble@Home client, which is integrated in - * Robocode. In addition, the RobocodeEngine is also used by the test units for - * testing the Robocode application itself. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - * @author Nathaniel Troutman (contributor) - * @author Joachim Hofer (contributor) - * @author Pavel Savara (contributor) - */ -public class RobocodeEngine implements IRobocodeEngine { - - private BattleObserver battleObserver; - private BattleSpecification battleSpecification; - private List listeners = new ArrayList(); - - /** - * Creates a new RobocodeEngine for controlling Robocode. - * In order for this constructor to work, the current working directory must be the - * home directory directory of Robocode, e.g. C:\Robocode - * - * @see #RobocodeEngine(File) - * @see #close() - * @since 1.6.2 - */ - public RobocodeEngine() { - init(null, (IBattleListener) null); - } - - /** - * Creates a new RobocodeEngine for controlling Robocode. - * - * @param robocodeHome the home directory of Robocode, e.g. C:\Robocode. - * @see #RobocodeEngine() - * @see #close() - * @since 1.6.2 - */ - public RobocodeEngine(File robocodeHome) { - init(robocodeHome, (IBattleListener) null); - } - - /** - * @deprecated Since 1.6.2. Use {@link #RobocodeEngine(File)} and - * {@link #addBattleListener(IBattleListener) addBattleListener()} instead. - *

- * Creates a new RobocodeEngine for controlling Robocode. - * - * @param robocodeHome the root directory of Robocode, e.g. C:\Robocode. - * @param listener the listener that must receive the callbacks from this - * RobocodeEngine. - * @see #RobocodeEngine() - * @see #RobocodeEngine(File) - * @see #close() - */ - @Deprecated - public RobocodeEngine(File robocodeHome, RobocodeListener listener) { - init(robocodeHome, listener); - } - - /** - * @deprecated Since 1.6.2. Use {@link #RobocodeEngine()} and - * {@link #addBattleListener(IBattleListener) addBattleListener()} instead. - *

- * Creates a new RobocodeEngine for controlling Robocode. The JAR file of - * Robocode is used to determine the root directory of Robocode. - * - * @param listener the listener that must receive the callbacks from this - * RobocodeEngine. - * @see #RobocodeEngine() - * @see #RobocodeEngine(File) - * @see #close() - */ - @Deprecated - public RobocodeEngine(RobocodeListener listener) { - init(null, listener); - } - - public RobocodeEngine(IBattleListener listener) { - init(null, listener); - } - - /** - * {@inheritDoc} - */ - @Override - protected void finalize() throws Throwable { - try { - // Make sure close() is called to prevent memory leaks - close(); - } finally { - super.finalize(); - } - } - - @SuppressWarnings("deprecation") // We must still support deprecated RobocodeListener - private void init(File robocodeHome, RobocodeListener listener) { - if (listener != null) { - battleObserver = new BattleObserver(); - battleObserver.listener = listener; - } - HiddenAccess.initContainerForRobotEngine(robocodeHome, battleObserver); - } - - private void init(File robocodeHome, IBattleListener listener) { - HiddenAccess.initContainerForRobotEngine(robocodeHome, listener); - } - - /** - * {@inheritDoc} - */ - public void addBattleListener(IBattleListener listener) { - listeners.add(listener); - ContainerBase.getComponent(IBattleManagerBase.class).addListener(listener); - } - - /** - * {@inheritDoc} - */ - public void removeBattleListener(IBattleListener listener) { - listeners.remove(listener); - ContainerBase.getComponent(IBattleManagerBase.class).removeListener(listener); - } - - /** - * {@inheritDoc} - */ - public void close() { - setVisible(false); - if (battleObserver != null) { - ContainerBase.getComponent(IBattleManagerBase.class).removeListener(battleObserver); - } - for (IBattleListener listener : listeners) { - ContainerBase.getComponent(IBattleManagerBase.class).removeListener(listener); - } - listeners.clear(); - HiddenAccess.cleanup(); - } - - /** - * {@inheritDoc} - */ - public String getVersion() { - return ContainerBase.getComponent(IVersionManagerBase.class).getVersion(); - } - - /** - * Returns the current working directory. - * - * @return a File for the current working directory. - * - * @since 1.7.1 - */ - public static File getCurrentWorkingDir() { - return FileUtil.getCwd(); - } - - /** - * Returns the directory containing the robots. - * - * @return a File for the robot directory containing all robots. - * - * @since 1.7.1 - */ - public static File getRobotsDir() { - return FileUtil.getRobotsDir(); - } - - /** - * {@inheritDoc} - */ - public void setVisible(boolean visible) { - IWindowManagerBase windowManager = ContainerBase.getComponent(IWindowManagerBase.class); - if (windowManager != null) { - windowManager.setVisibleForRobotEngine(visible); - } else { - Logger.logError( - "setVisible: No window manager was found.\n" - + "Perhaps you are missing the robocode.ui-1.x.x.x-jar file or the GUI has been disabled?"); - } - } - - /** - * {@inheritDoc} - */ - public RobotSpecification[] getLocalRepository() { - final IRepositoryManagerBase repository = ContainerBase.getComponent(IRepositoryManagerBase.class); - - repository.refresh(); // Bug fix [2972932] - return repository.getSpecifications(); - } - - /** - * {@inheritDoc} - */ - public RobotSpecification[] getLocalRepository(String selectedRobots) { - final IRepositoryManagerBase repository = ContainerBase.getComponent(IRepositoryManagerBase.class); - - repository.refresh(); // Bug fix [2972932] - return repository.loadSelectedRobots(selectedRobots); - } - - /** - * {@inheritDoc} - */ - public void runBattle(BattleSpecification battleSpecification) { - runBattle(battleSpecification, null, false); - } - - /** - * {@inheritDoc} - */ - public void runBattle(BattleSpecification battleSpecification, boolean waitTillOver) { - runBattle(battleSpecification, null, waitTillOver); - } - - /** - * {@inheritDoc} - */ - public void runBattle(BattleSpecification battleSpecification, String initialPositions, boolean waitTillOver) { - this.battleSpecification = battleSpecification; - ContainerBase.getComponent(IBattleManagerBase.class).startNewBattle(battleSpecification, initialPositions, - waitTillOver, false); - } - - /** - * {@inheritDoc} - */ - public void waitTillBattleOver() { - ContainerBase.getComponent(IBattleManagerBase.class).waitTillOver(); - } - - /** - * {@inheritDoc} - */ - public void abortCurrentBattle() { - ContainerBase.getComponent(IBattleManagerBase.class).stop(true); - } - - /** - * Prints out all running threads to standard system out. - * - * @since 1.6.2 - */ - public static void printRunningThreads() { - ThreadGroup currentGroup = Thread.currentThread().getThreadGroup(); - - if (currentGroup == null) { - return; - } - - while (currentGroup.getParent() != null) { - currentGroup = currentGroup.getParent(); - } - - ThreadGroup groups[] = new ThreadGroup[256]; - Thread threads[] = new Thread[256]; - - int numGroups = currentGroup.enumerate(groups, true); - - for (int i = 0; i < numGroups; i++) { - currentGroup = groups[i]; - if (currentGroup.isDaemon()) { - Logger.realOut.print(" "); - } else { - Logger.realOut.print("* "); - } - Logger.realOut.println("In group: " + currentGroup.getName()); - int numThreads = currentGroup.enumerate(threads); - - for (int j = 0; j < numThreads; j++) { - if (threads[j].isDaemon()) { - Logger.realOut.print(" "); - } else { - Logger.realOut.print("* "); - } - Logger.realOut.println(threads[j].getName()); - } - Logger.realOut.println("---------------"); - } - } - - /** - * Enables or disables messages and warnings logged to {@link System#out}. - * - * @param enable true if log messages must be enabled; false if log messages must be disabled. - * @see #setLogErrorsEnabled(boolean) - * @since 1.8.0.0 - */ - public static void setLogMessagesEnabled(boolean enable) { - System.setProperty("logMessages", "" + enable); - } - - /** - * Enables or disables errors logged to {@link System#err}. - * - * @param enable true if log errors must be enabled; false if log errors must be disabled. - * @see #setLogMessagesEnabled(boolean) - * @since 1.8.0.0 - */ - public static void setLogErrorsEnabled(boolean enable) { - System.setProperty("logErrors", "" + enable); - } - - /** - * Registered only if listener in not null. - */ - private class BattleObserver extends BattleAdaptor { - @SuppressWarnings("deprecation") // We must still support deprecated RobocodeListener - private RobocodeListener listener; - - @SuppressWarnings("deprecation") // We must still support deprecated RobocodeListener - @Override - public void onBattleFinished(BattleFinishedEvent event) { - if (event.isAborted()) { - listener.battleAborted(battleSpecification); - } - } - - @SuppressWarnings("deprecation") // We must still support deprecated RobocodeListener - @Override - public void onBattleCompleted(BattleCompletedEvent event) { - listener.battleComplete(battleSpecification, RobotResults.convertResults(event.getSortedResults())); - } - - @SuppressWarnings("deprecation") // We must still support deprecated RobocodeListener - @Override - public void onBattleMessage(BattleMessageEvent event) { - listener.battleMessage(event.getMessage()); - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/RobocodeListener.java b/workspace_robo/robocode.api/src/main/java/robocode/control/RobocodeListener.java deleted file mode 100644 index 8b6e5d3..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/RobocodeListener.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control; - - -import robocode.control.events.IBattleListener; - - -/** - * @deprecated Since 1.6.2. Use the {@link IBattleListener} instead. - *

- * A listener interface for receiving callbacks from the {@link RobocodeEngine}. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * - * @see IBattleListener - */ -@Deprecated -public interface RobocodeListener { - - /** - * @deprecated Since 1.6.2. Use the - * {@link IBattleListener#onBattleCompleted(robocode.control.events.BattleCompletedEvent) - * IBattleListener.onBattleCompleted()} instead. - *

- * This method is called when a battle completes successfully. - * - * @param battle information about the battle that completed - * @param results an array containing the results for the individual robot - */ - @Deprecated - void battleComplete(BattleSpecification battle, RobotResults[] results); - - /** - * @deprecated Since 1.6.2. Use the - * {@link IBattleListener#onBattleFinished(robocode.control.events.BattleFinishedEvent) - * IBattleListener.onBattleFinished()} instead. - *

- * This method is called when a battle has been aborted. - * - * @param battle information about the battle that was aborted - */ - @Deprecated - void battleAborted(BattleSpecification battle); - - /** - * @deprecated Since 1.6.2. Use the - * {@link IBattleListener#onBattleMessage(robocode.control.events.BattleMessageEvent) - * IBattleListener.onBattleMessage()} instead. - *

- * This method is called when the game logs messages that is normally - * written out to the console. - * - * @param message the message logged by the game - */ - @Deprecated - void battleMessage(String message); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/RobotResults.java b/workspace_robo/robocode.api/src/main/java/robocode/control/RobotResults.java deleted file mode 100644 index 2d315cf..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/RobotResults.java +++ /dev/null @@ -1,188 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control; - - -import robocode.BattleResults; - - -/** - * Contains the battle results for an individual robot - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class RobotResults extends BattleResults { - - private static final long serialVersionUID = 2L; - - private final RobotSpecification robot; - - /** - * Constructs a new RobotResults. - * - * @param robot is the robot these results are for - * @param teamLeaderName is the team name - * @param rank is the rank of the robot in the battle - * @param score is the total score for the robot in the battle - * @param survival is the survival score for the robot in the battle - * @param lastSurvivorBonus is the last survivor bonus for the robot in the battle - * @param bulletDamage is the bullet damage score for the robot in the battle - * @param bulletDamageBonus is the bullet damage bonus for the robot in the battle - * @param ramDamage is the ramming damage for the robot in the battle - * @param ramDamageBonus is the ramming damage bonus for the robot in the battle - * @param firsts is the number of rounds this robot placed first - * @param seconds is the number of rounds this robot placed second - * @param thirds is the number of rounds this robot placed third - */ - public RobotResults( - RobotSpecification robot, - String teamLeaderName, - int rank, - double score, - double survival, - double lastSurvivorBonus, - double bulletDamage, - double bulletDamageBonus, - double ramDamage, - double ramDamageBonus, - int firsts, - int seconds, - int thirds - ) { - super(teamLeaderName, rank, score, survival, lastSurvivorBonus, bulletDamage, bulletDamageBonus, ramDamage, - ramDamageBonus, firsts, seconds, thirds); - this.robot = robot; - } - - /** - * Constructs new RobotResults based on a {@link RobotSpecification} and {@link robocode.BattleResults - * BattleResults}. - * - * @param robot the robot these results are for - * @param results the battle results for the robot - */ - public RobotResults( - RobotSpecification robot, - BattleResults results) { - super(results.getTeamLeaderName(), results.getRank(), results.getScore(), results.getSurvival(), - results.getLastSurvivorBonus(), results.getBulletDamage(), results.getBulletDamageBonus(), - results.getRamDamage(), results.getRamDamageBonus(), results.getFirsts(), results.getSeconds(), - results.getThirds()); - this.robot = robot; - } - - /** - * Returns the robot these results are meant for. - * - * @return the robot these results are meant for. - */ - public RobotSpecification getRobot() { - return robot; - } - - /** - * Converts an array of {@link BattleResults} into an array of {@link RobotResults}. - * - * @param results an array of BattleResults to convert. - * @return an array of RobotResults converted from BattleResults. - * @since 1.6.2 - */ - public static RobotResults[] convertResults(BattleResults[] results) { - RobotResults[] resultsConv = new RobotResults[results.length]; - - for (int i = 0; i < results.length; i++) { - resultsConv[i] = (RobotResults) results[i]; - } - return resultsConv; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - - temp = Double.doubleToLongBits(bulletDamage); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(bulletDamageBonus); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + firsts; - temp = Double.doubleToLongBits(lastSurvivorBonus); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(ramDamage); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(ramDamageBonus); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + rank; - temp = Double.doubleToLongBits(score); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + seconds; - temp = Double.doubleToLongBits(survival); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + ((teamLeaderName == null) ? 0 : teamLeaderName.hashCode()); - result = prime * result + thirds; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - RobotResults other = (RobotResults) obj; - - if (Double.doubleToLongBits(bulletDamage) != Double.doubleToLongBits(other.bulletDamage)) { - return false; - } - if (Double.doubleToLongBits(bulletDamageBonus) != Double.doubleToLongBits(other.bulletDamageBonus)) { - return false; - } - if (firsts != other.firsts) { - return false; - } - if (Double.doubleToLongBits(lastSurvivorBonus) != Double.doubleToLongBits(other.lastSurvivorBonus)) { - return false; - } - if (Double.doubleToLongBits(ramDamage) != Double.doubleToLongBits(other.ramDamage)) { - return false; - } - if (Double.doubleToLongBits(ramDamageBonus) != Double.doubleToLongBits(other.ramDamageBonus)) { - return false; - } - if (rank != other.rank) { - return false; - } - if (Double.doubleToLongBits(score) != Double.doubleToLongBits(other.score)) { - return false; - } - if (seconds != other.seconds) { - return false; - } - if (Double.doubleToLongBits(survival) != Double.doubleToLongBits(other.survival)) { - return false; - } - if (teamLeaderName == null) { - if (other.teamLeaderName != null) { - return false; - } - } else if (!teamLeaderName.equals(other.teamLeaderName)) { - return false; - } - if (thirds != other.thirds) { - return false; - } - return true; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/RobotSetup.java b/workspace_robo/robocode.api/src/main/java/robocode/control/RobotSetup.java deleted file mode 100644 index 05c7b81..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/RobotSetup.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control; - - -/** - * Contains the initial position and heading for a robot. - * - * @author Flemming N. Larsen (original) - * - * @since 1.9.2.0 - */ -public class RobotSetup implements java.io.Serializable { - - private static final long serialVersionUID = 1L; - - private final Double x; - private final Double y; - private final Double heading; - - /** - * Constructs a new RobotSetup. - * - * @param x is the x coordinate, where {@code null} means random. - * @param y is the y coordinate, where {@code null} means random. - * @param heading is the heading in degrees of the body, gun, and radar, where {@code null} means random. - */ - public RobotSetup(Double x, Double y, Double heading) { - this.x = x; - this.y = y; - this.heading = heading; - } - - /** - * Returns the x coordinate. - * @return the x coordinate, where {@code null} means unspecified (random). - */ - public Double getX() { - return x; - } - - /** - * Returns the y coordinate. - * @return the y coordinate, where {@code null} means unspecified (random). - */ - public Double getY() { - return y; - } - - /** - * Returns the body, gun, and radar heading (in degrees). - * @return the heading (in degrees), where {@code null} means unspecified (random). - */ - public Double getHeading() { - return heading; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/RobotSpecification.java b/workspace_robo/robocode.api/src/main/java/robocode/control/RobotSpecification.java deleted file mode 100644 index 77aa4a9..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/RobotSpecification.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control; - - -import java.io.File; - -import net.sf.robocode.security.IHiddenSpecificationHelper; - - -/** - * Defines the properties of a robot, which is returned from - * {@link RobocodeEngine#getLocalRepository()}. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class RobotSpecification implements java.io.Serializable { - - private static final long serialVersionUID = 1L; - - private final Object fileSpecification; - private final String name; - private final String author; - private final String webpage; - private final String version; - private final String robocodeVersion; - private final String jarFile; - private final String fullClassName; - private final String description; - private String teamId; - - private RobotSpecification(Object fileSpecification, String name, String author, String webpage, String version, String robocodeVersion, String jarFile, String fullClassName, String description) { - this.fileSpecification = fileSpecification; - this.name = name; - this.author = author; - this.webpage = webpage; - this.version = version; - this.robocodeVersion = robocodeVersion; - this.jarFile = jarFile; - this.fullClassName = fullClassName; - this.description = description; - } - - /** - * Returns the name of this robot or team. - * - * @return the name of this robot or team. - * @see #getVersion() - * @see #getNameAndVersion() - */ - public String getName() { - return name; - } - - /** - * Returns the version of this robot or team. - * - * @return the version of this robot or team. - * @see #getName() - * @see #getNameAndVersion() - */ - public String getVersion() { - return version; - } - - /** - * Returns the name and version of this robot or team. - * - * @return the name and version of this robot or team. - * @see #getName() - * @see #getVersion() - * @since 1.3 - */ - public String getNameAndVersion() { - String nameAndVersion = getName(); - String version = getVersion(); - - if (version != null && version.trim().length() > 0) { - nameAndVersion += ' ' + version.trim(); - } - return nameAndVersion; - } - - /** - * Returns the full class name of this robot or team. - * - * @return the full class name of this robot or team. - */ - public String getClassName() { - return fullClassName; - } - - /** - * Returns the JAR file containing this robot or team, or {@code null} if it - * does not come from a JAR file (could be class files instead). - * - * @return the JAR file containing this robot or team, or {@code null} if it - * does not come from a JAR file (could be class files instead). - */ - public File getJarFile() { - return new File(jarFile); - } - - /** - * Returns the description provided by the author of this robot or team. - * - * @return the description provided by the author of this robot or team. - */ - public String getDescription() { - return description; - } - - /** - * Returns the version of Robocode this robot or team was build with. - * - * @return the version of Robocode this robot or team was build with. - */ - public String getRobocodeVersion() { - return robocodeVersion; - } - - /** - * Returns the link to the web page for this robot or team. - * - * @return the link to the web page for this robot or team. - */ - public String getWebpage() { - return webpage; - } - - /** - * Returns the name of the author of this robot or team. - * - * @return the name of the author of this robot or team. - */ - public String getAuthorName() { - return author; - } - - /** - * Returns id of the team in current battle. - * - * @return id of the team in current battle. - */ - public String getTeamId() { - return teamId != null ? teamId : getNameAndVersion(); - } - - static IHiddenSpecificationHelper createHiddenHelper() { - return new HiddenHelper(); - } - - private static class HiddenHelper implements IHiddenSpecificationHelper { - - public RobotSpecification createSpecification(Object fileSpecification, String name, String author, String webpage, String version, String robocodeVersion, String jarFile, String fullClassName, String description) { - return new RobotSpecification(fileSpecification, name, author, webpage, version, robocodeVersion, jarFile, - fullClassName, description); - } - - public Object getFileSpecification(RobotSpecification specification) { - return specification.fileSpecification; - } - - public void setTeamName(RobotSpecification specification, String teamName) { - specification.teamId = teamName; - } - - public String getTeamName(RobotSpecification specification) { - return specification.teamId; - } - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleAdaptor.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleAdaptor.java deleted file mode 100644 index 0588e0d..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleAdaptor.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -/** - * An abstract adapter class for receiving battle events by implementing the {@link IBattleListener}. - * The methods in this class are empty. This class exists as convenience for creating listener objects. - *

- * This is handy class to use when implementing the IBattleListener. - * It saves you from implementing empty handlers for battle events you are not interested in handling. - *

- * Example: - *

- *   private class BattleObserver extends BattleAdaptor {
- *       boolean isReplay;
- *
- *       public void onBattleStarted(BattleStartedEvent event) {
- *           isReplay = event.isReplay();
- *       }
- *
- *       public void onBattleCompleted(BattleCompletedEvent event) {
- *       if (!isReplay) {
- *           printResultsData(event);
- *       }
- *   }
- * 
- * - * @see IBattleListener - * - * @author Flemming N. Larsen (original) - * - * @since 1.6.2 - */ -public abstract class BattleAdaptor implements IBattleListener { - - /** - * Creates a BattleAdaptor. - */ - public BattleAdaptor() {} - - /** - * {@inheritDoc} - */ - public void onBattleStarted(final BattleStartedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onBattleFinished(final BattleFinishedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onBattleCompleted(final BattleCompletedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onBattlePaused(final BattlePausedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onBattleResumed(final BattleResumedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onRoundStarted(final RoundStartedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onRoundEnded(final RoundEndedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onTurnStarted(final TurnStartedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onTurnEnded(final TurnEndedEvent event) {} - - /** - * {@inheritDoc} - */ - public void onBattleMessage(final BattleMessageEvent event) {} - - /** - * {@inheritDoc} - */ - public void onBattleError(final BattleErrorEvent event) {} -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleCompletedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleCompletedEvent.java deleted file mode 100644 index e21a614..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleCompletedEvent.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -import robocode.BattleResults; -import robocode.BattleRules; - -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -/** - * A BattleCompletedEvent is sent to {@link IBattleListener#onBattleCompleted(BattleCompletedEvent) - * onBattleCompleted()} when the battle is completed successfully and results are available. This event - * will not occur if the battle is terminated or aborted by the user before the battle is completed. - * - * @see IBattleListener - * @see IBattleListener#onBattleCompleted(BattleCompletedEvent) - * @see BattleStartedEvent - * @see BattleFinishedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class BattleCompletedEvent extends BattleEvent { - private final BattleRules battleRules; - private final BattleResults[] results; - - /** - * Called by the game to create a new BattleCompletedEvent. - * Please don't use this constructor as it might change. - * - * @param battleRules the rules that was used in the battle. - * @param results the indexed results of the battle. These are unsorted, but using robot indexes. - */ - public BattleCompletedEvent(BattleRules battleRules, BattleResults[] results) { - super(); - this.battleRules = battleRules; - this.results = results; - } - - /** - * Returns the rules used in the battle. - * - * @return the rules used in the battle. - */ - public BattleRules getBattleRules() { - return battleRules; - } - - /** - * Returns the battle results sorted on score. - * Note that the robot index cannot be used to determine the score with the sorted results. - * - * @return an array of sorted BattleResults, where the results with the bigger score are placed first in the list. - * @see #getIndexedResults() - */ - public BattleResults[] getSortedResults() { - List copy = new ArrayList(Arrays.asList(results)); - - Collections.sort(copy); - Collections.reverse(copy); - return copy.toArray(new BattleResults[copy.size()]); - } - - /** - * Returns the battle results that can be used to determine the score for the individual robot based - * on the robot index. - * - * @return an array of indexed BattleResults, where each index matches an index of a specific robot. - * @see #getSortedResults() - */ - public BattleResults[] getIndexedResults() { - BattleResults[] copy = new BattleResults[results.length]; - - System.arraycopy(results, 0, copy, 0, results.length); - return copy; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleErrorEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleErrorEvent.java deleted file mode 100644 index bce294a..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleErrorEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -/** - * A BattleErrorEvent is sent to {@link IBattleListener#onBattleError(BattleErrorEvent) - * onBattleError()} when an error message is sent from the game in the during the battle. - * - * @see IBattleListener - * @see BattleMessageEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class BattleErrorEvent extends BattleEvent { - private final String error; - - /** - * Called by the game to create a new BattleErrorEvent. - * Please don't use this constructor as it might change. - * - * @param error the error message from the game. - */ - public BattleErrorEvent(String error) { - super(); - this.error = error; - } - - /** - * Returns the error message. - * - * @return the error message that was sent from the game during the battle. - */ - public String getError() { - return error; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleEvent.java deleted file mode 100644 index 68fc7eb..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleEvent.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -/** - * This is the base class of all battle events. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public abstract class BattleEvent { - - /** - * Creates a new BattleEvent. - */ - public BattleEvent() { - super(); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleFinishedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleFinishedEvent.java deleted file mode 100644 index d9e3985..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleFinishedEvent.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -/** - * A BattleFinishedEvent is sent to {@link IBattleListener#onBattleFinished(BattleFinishedEvent) - * onBattleFinished()} when the battle is finished. This event is always sent as the last battle event, - * both when the battle is completed successfully, terminated due to an error, or aborted by the user. - * Hence, this events is well-suited for cleanup after the battle. - * - * @see IBattleListener - * @see BattleStartedEvent - * @see BattleCompletedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class BattleFinishedEvent extends BattleEvent { - private final boolean isAborted; - - /** - * Called by the game to create a new BattleFinishedEvent. - * Please don't use this constructor as it might change. - * - * @param isAborted a flag specifying if the battle was aborted: - * {@code true} if the battle was aborted; {@code false} otherwise. - */ - public BattleFinishedEvent(boolean isAborted) { - super(); - this.isAborted = isAborted; - } - - /** - * Checks if the battle was aborted. - * - * @return {@code true} if the battle was aborted; {@code false} otherwise. - */ - public boolean isAborted() { - return isAborted; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleMessageEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleMessageEvent.java deleted file mode 100644 index 58d7e34..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleMessageEvent.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -/** - * A BattleMessageEvent is sent to {@link IBattleListener#onBattleMessage(BattleMessageEvent) - * onBattleMessage()} when an informal message is sent from the game in the during the battle. - * - * @see IBattleListener - * @see BattleErrorEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class BattleMessageEvent extends BattleEvent { - private final String message; - - /** - * Called by the game to create a new BattleMessageEvent. - * Please don't use this constructor as it might change. - * - * @param message the informal message from the game. - */ - public BattleMessageEvent(String message) { - super(); - this.message = message; - } - - /** - * Returns the informal message. - * - * @return the informal message that was sent from the game during the battle. - */ - public String getMessage() { - return message; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattlePausedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattlePausedEvent.java deleted file mode 100644 index deefdaf..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattlePausedEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -/** - * A BattlePausedEvent is sent to {@link IBattleListener#onBattlePaused(BattlePausedEvent) - * onBattlePaused()} when a battle has been paused. - * - * @see IBattleListener - * @see BattleResumedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class BattlePausedEvent extends BattleEvent { - - /** - * Called by the game to create a new BattlePausedEvent. - * Please don't use this constructor as it might change. - */ - public BattlePausedEvent() { - super(); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleResumedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleResumedEvent.java deleted file mode 100644 index 2ca10a7..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleResumedEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -/** - * A BattleResumedEvent is sent to {@link IBattleListener#onBattleResumed(BattleResumedEvent) - * onBattleResumed()} when a battle has been resumed (after having been paused). - * - * @see IBattleListener - * @see BattlePausedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class BattleResumedEvent extends BattleEvent { - - /** - * Called by the game to create a new BattleResumedEvent. - * Please don't use this constructor as it might change. - */ - public BattleResumedEvent() { - super(); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleStartedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleStartedEvent.java deleted file mode 100644 index a7ca33b..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/BattleStartedEvent.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -import robocode.BattleRules; - - -/** - * A BattleStartedEvent is sent to {@link IBattleListener#onBattleStarted(BattleStartedEvent) - * onBattleStarted()} when a new battle is started. - * - * @see IBattleListener - * @see BattleCompletedEvent - * @see BattleFinishedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class BattleStartedEvent extends BattleEvent { - private final BattleRules battleRules; - private final boolean isReplay; - private final int robotsCount; - - /** - * Called by the game to create a new BattleStartedEvent. - * Please don't use this constructor as it might change. - * - * @param battleRules the rules that will be used in the battle. - * @param robotsCount the number of robots participating in the battle. - * @param isReplay a flag specifying if this battle is a replay or real battle: - * {@code true} if the battle is a replay; {@code false} otherwise. - */ - public BattleStartedEvent(BattleRules battleRules, int robotsCount, boolean isReplay) { - super(); - this.battleRules = battleRules; - this.isReplay = isReplay; - this.robotsCount = robotsCount; - } - - /** - * Returns the rules that will be used in the battle. - * - * @return the rules that will be used in the battle. - */ - public BattleRules getBattleRules() { - return battleRules; - } - - /** - * Returns the number of robots participating in the battle. - * - * @return the number of robots participating in the battle. - */ - public int getRobotsCount() { - return robotsCount; - } - - /** - * Checks if this battle is a replay or a new battle. - * - * @return {@code true} if the battle is a replay; {@code false} otherwise. - */ - public boolean isReplay() { - return isReplay; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/IBattleListener.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/IBattleListener.java deleted file mode 100644 index dd19597..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/IBattleListener.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -/** - * The listener interface for receiving "interesting" battle events from the game, e.g. when a battle, - * round or turn is started or ended. - *

- * When implementing this battle listener you should implement the {@link BattleAdaptor} in order to - * only implement the event handler methods you are interested in. - * - * @see BattleAdaptor - * - * @author Flemming N. Larsen (original) - * - * @since 1.6.2 - */ -public interface IBattleListener { - - /** - * This method is called when a new battle has started. - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see BattleStartedEvent - * @see #onBattleCompleted(BattleCompletedEvent) - * @see #onBattleFinished(BattleFinishedEvent) - * - * @param event the event details. - */ - void onBattleStarted(final BattleStartedEvent event); - - /** - * This method is called when the battle has finished. This event is always sent as the last battle event, - * both when the battle is completed successfully, terminated due to an error, or aborted by the user. - * Hence, this events is well-suited for cleanup after the battle. - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see BattleFinishedEvent - * @see #onBattleStarted(BattleStartedEvent) - * @see #onBattleCompleted(BattleCompletedEvent) - * - * @param event the event details. - */ - void onBattleFinished(final BattleFinishedEvent event); - - /** - * This method is called when the battle has completed successfully and results are available. - * This event will not occur if the battle is terminated or aborted by the user before the battle is completed. - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see BattleCompletedEvent - * @see #onBattleStarted(BattleStartedEvent) - * @see #onBattleFinished(BattleFinishedEvent) - * - * @param event the event details. - */ - void onBattleCompleted(final BattleCompletedEvent event); - - /** - * This method is called when the battle has been paused, either by the user or the game. - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see BattlePausedEvent - * @see #onBattleResumed(BattleResumedEvent) - * - * @param event the event details. - */ - void onBattlePaused(final BattlePausedEvent event); - - /** - * This method is called when the battle has been resumed (after having been paused). - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see BattleResumedEvent - * @see #onBattlePaused(BattlePausedEvent) - * - * @param event the event details. - */ - void onBattleResumed(final BattleResumedEvent event); - - /** - * This method is called when a new round in a battle has started. - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see RoundEndedEvent - * @see #onRoundEnded(RoundEndedEvent) - * - * @param event the event details. - */ - void onRoundStarted(final RoundStartedEvent event); - - /** - * This method is called when the current round of a battle has ended. - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see RoundEndedEvent - * @see #onRoundStarted(RoundStartedEvent) - * - * @param event the event details. - */ - void onRoundEnded(final RoundEndedEvent event); - - /** - * This method is called when a new turn in a battle round has started. - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see TurnStartedEvent - * @see #onTurnEnded(TurnEndedEvent) - * - * @param event the event details. - */ - void onTurnStarted(final TurnStartedEvent event); - - /** - * This method is called when the current turn in a battle round is ended. - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see TurnEndedEvent - * @see #onTurnStarted(TurnStartedEvent) - * - * @param event the event details. - */ - void onTurnEnded(final TurnEndedEvent event); - - /** - * This method is called when the game has sent a new information message. - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see BattleMessageEvent - * @see #onBattleError(BattleErrorEvent) - * - * @param event the event details. - */ - void onBattleMessage(final BattleMessageEvent event); - - /** - * This method is called when the game has sent an error message. - *

- * You must override this method in order to get informed about this event and receive the event details. - * - * @see BattleErrorEvent - * @see #onBattleMessage(BattleMessageEvent) - * - * @param event the event details. - */ - void onBattleError(final BattleErrorEvent event); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/RoundEndedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/RoundEndedEvent.java deleted file mode 100644 index 90a43fd..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/RoundEndedEvent.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -/** - * A RoundEndedEvent is sent to {@link IBattleListener#onRoundEnded(RoundEndedEvent) - * onRoundEnded()} when the current round of a battle has ended. - * - * @see IBattleListener - * @see RoundStartedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class RoundEndedEvent extends BattleEvent { - private final int round; - private final int turns; - private final int totalTurns; - - /** - * Called by the game to create a new RoundEndedEvent. - * Please don't use this constructor as it might change. - * - * @param round the round number that was ended (zero indexed). - * @param turns the number of turns that this round reached. - * @param totalTurns the total number of turns reached in the battle when this round ended. - */ - public RoundEndedEvent(int round, int turns, int totalTurns) { - super(); - this.round = round; - this.turns = turns; - this.totalTurns = totalTurns; - } - - /** - * Returns the round number that has ended. - * - * @return the round number that has ended, which is zero indexed. - */ - public int getRound() { - return round; - } - - /** - * Returns the number of turns that this round reached. - * - * @return the number of turns that this round reached. - * - * @see #getTotalTurns() - */ - public int getTurns() { - return turns; - } - - /** - * Returns the total number of turns reached in the battle when this round ended. - * - * @return the total number of turns reached in the battle when this round ended. - * - * @see #getTurns() - * - * @since 1.7.2 - */ - public int getTotalTurns() { - return totalTurns; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/RoundStartedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/RoundStartedEvent.java deleted file mode 100644 index 41ad245..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/RoundStartedEvent.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -import robocode.control.snapshot.ITurnSnapshot; - - -/** - * A RoundStartedEvent is sent to {@link IBattleListener#onRoundStarted(RoundStartedEvent) - * onRoundStarted()} when a new round in a battle is started. - * - * @see IBattleListener - * @see RoundEndedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class RoundStartedEvent extends BattleEvent { - private final ITurnSnapshot startSnapshot; - private final int round; - - /** - * Called by the game to create a new RoundStartedEvent. - * Please don't use this constructor as it might change. - * - * @param startSnapshot the start snapshot of the participating robots, initial starting positions etc. - * @param round the round number (zero indexed). - */ - public RoundStartedEvent(ITurnSnapshot startSnapshot, int round) { - super(); - this.startSnapshot = startSnapshot; - this.round = round; - } - - /** - * Returns the start snapshot of the participating robots, initial starting positions etc. - * - * @return a {@link robocode.control.snapshot.ITurnSnapshot} that serves as the start snapshot of - * the round. - */ - public ITurnSnapshot getStartSnapshot() { - return startSnapshot; - } - - /** - * Returns the round number. - * - * @return the round number, which is zero indexed. - */ - public int getRound() { - return round; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/TurnEndedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/TurnEndedEvent.java deleted file mode 100644 index eb4c906..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/TurnEndedEvent.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -import robocode.control.snapshot.ITurnSnapshot; - - -/** - * A TurnEndedEvent is sent to {@link IBattleListener#onTurnEnded(TurnEndedEvent) - * onTurnEnded()} when the current turn in a battle round is ended. - * - * @see IBattleListener - * @see TurnStartedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class TurnEndedEvent extends BattleEvent { - private final ITurnSnapshot turnSnapshot; - - /** - * Called by the game to create a new TurnEndedEvent. - * Please don't use this constructor as it might change. - * - * @param turnSnapshot a snapshot of the turn that has ended. - */ - public TurnEndedEvent(ITurnSnapshot turnSnapshot) { - super(); - this.turnSnapshot = turnSnapshot; - } - - /** - * Returns a snapshot of the turn that has ended. - * - * @return a snapshot of the turn that has ended. - */ - public ITurnSnapshot getTurnSnapshot() { - return turnSnapshot; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/TurnStartedEvent.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/TurnStartedEvent.java deleted file mode 100644 index 534b252..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/TurnStartedEvent.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.events; - - -/** - * A TurnStartedEvent is sent to {@link IBattleListener#onTurnStarted(TurnStartedEvent) - * onTurnStarted()} when a new turn in a battle round is started. - * - * @see IBattleListener - * @see TurnEndedEvent - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public class TurnStartedEvent extends BattleEvent { - - /** - * Called by the game to create a new TurnStartedEvent. - * Please don't use this constructor as it might change. - */ - public TurnStartedEvent() { - super(); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/events/package-info.java b/workspace_robo/robocode.api/src/main/java/robocode/control/events/package-info.java deleted file mode 100644 index ecd91d9..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/events/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - -/** - * Battle events that occurs during a game, and which are used for the - * robocode.control.IBattleListener class. - */ -package robocode.control.events; diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/package-info.java b/workspace_robo/robocode.api/src/main/java/robocode/control/package-info.java deleted file mode 100644 index 09b1006..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/package-info.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - -/** - * The Robocode Control API is used for controlling the Robocode - * application from another external application. Basically, it is possible - * to run battles between selected robots and retrieve the results. However, - * it is also possible to get detailed information as snapshots during the - * battles regarding e.g. the positions and headings of the individual robots - * and bullets at a specific time during a battle. - *

- * The main entry class is the Robocode.Control.RobocodeEngine class, which - * must be instantiated by the application controlling Robocode. With the - * RobocodeEngine, a battle specification must be provided in order to run a - * battle. The battle specification specify the size of the battlefield, and - * which rules that must be used. In addition, the participant robots must be - * selected, which must exist in the robot directory of Robocode in - * advantage. - * - *

Example

- *

- * Here is a simple application that runs a battle in Robocode for 5 rounds - * on the default battlefield of 800x600 pixels. The robots selected for the - * battle are sample.RamFire and sample.Corners. - * - *

- * import robocode.control.*;
- * import robocode.control.events.*;
- * 
- * //
- * // Application that demonstrates how to run two sample robots in Robocode using the
- * // RobocodeEngine from the robocode.control package.
- * //
- * // @author Flemming N. Larsen
- * //
- * public class BattleRunner {
- * 
- *     public static void main(String[] args) {
- * 
- *         // Disable log messages from Robocode
- *         RobocodeEngine.setLogMessagesEnabled(false);
- *
- *         // Create the RobocodeEngine
- *         //   RobocodeEngine engine = new RobocodeEngine(); // Run from current working directory
- *         RobocodeEngine engine = new RobocodeEngine(new java.io.File("C:/Robocode")); // Run from C:/Robocode
- * 
- *         // Add our own battle listener to the RobocodeEngine 
- *         engine.addBattleListener(new BattleObserver());
- * 
- *         // Show the Robocode battle view
- *         engine.setVisible(true);
- * 
- *         // Setup the battle specification
- * 
- *         int numberOfRounds = 5;
- *         BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600); // 800x600
- *         RobotSpecification[] selectedRobots = engine.getLocalRepository("sample.RamFire,sample.Corners");
- * 
- *         BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield, selectedRobots);
- * 
- *         // Run our specified battle and let it run till it is over
- *         engine.runBattle(battleSpec, true); // waits till the battle finishes
- * 
- *         // Cleanup our RobocodeEngine
- *         engine.close();
- * 
- *         // Make sure that the Java VM is shut down properly
- *         System.exit(0);
- *     }
- * }
- * 
- * //
- * // Our private battle listener for handling the battle event we are interested in.
- * //
- * class BattleObserver extends BattleAdaptor {
- * 
- *     // Called when the battle is completed successfully with battle results
- *     public void onBattleCompleted(BattleCompletedEvent e) {
- *         System.out.println("-- Battle has completed --");
- *         
- *         // Print out the sorted results with the robot names
- *         System.out.println("Battle results:");
- *         for (robocode.BattleResults result : e.getSortedResults()) {
- *             System.out.println("  " + result.getTeamLeaderName() + ": " + result.getScore());
- *         }
- *     }
- * 
- *     // Called when the game sends out an information message during the battle
- *     public void onBattleMessage(BattleMessageEvent e) {
- *         System.out.println("Msg> " + e.getMessage());
- *     }
- * 
- *     // Called when the game sends out an error message during the battle
- *     public void onBattleError(BattleErrorEvent e) {
- *         System.out.println("Err> " + e.getError());
- *     }
- * }
- * 
- */ -package robocode.control; diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/BulletState.java b/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/BulletState.java deleted file mode 100644 index 3443573..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/BulletState.java +++ /dev/null @@ -1,101 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.snapshot; - - -/** - * Defines a bullet state, which can be: just fired, moving somewhere, hitting a victim, - * hitting another bullet, hitting the wall, exploded, or inactive. - * - * @author Flemming N. Larsen (original) - * - * @since 1.6.2 - */ -public enum BulletState { - - /** The bullet has just been fired this turn and hence just been created. This state only last one turn. */ - FIRED(0), - - /** The bullet is now moving across the battlefield, but has not hit anything yet. */ - MOVING(1), - - /** The bullet has hit a robot victim. */ - HIT_VICTIM(2), - - /** The bullet has hit another bullet. */ - HIT_BULLET(3), - - /** The bullet has hit the wall, i.e. one of the four borders of the battlefield. */ - HIT_WALL(4), - - /** The bullet currently represents a robot explosion, i.e. a robot death. */ - EXPLODED(5), - - /** The bullet is currently inactive. Hence, it is not active or visible on the battlefield. */ - INACTIVE(6); - - private final int value; - - private BulletState(int value) { - this.value = value; - } - - /** - * Returns the state as an integer value. - * - * @return an integer value representing this state. - * - * @see #toState(int) - */ - public int getValue() { - return value; - } - - /** - * Returns a BulletState based on an integer value that represents a BulletState. - * - * @param value the integer value that represents a specific BulletState. - * @return a BulletState that corresponds to the specific integer value. - * - * @see #getValue() - * - * @throws IllegalArgumentException if the specified value does not correspond - * to a BulletState and hence is invalid. - */ - public static BulletState toState(int value) { - switch (value) { - case 0: - return FIRED; - - case 1: - return MOVING; - - case 2: - return HIT_VICTIM; - - case 3: - return HIT_BULLET; - - case 4: - return HIT_WALL; - - case 5: - return EXPLODED; - - case 6: - return INACTIVE; - - default: - throw new IllegalArgumentException("unknown value"); - } - } - - public boolean isActive() { - return this == FIRED || this == MOVING; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IBulletSnapshot.java b/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IBulletSnapshot.java deleted file mode 100644 index 874ddd6..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IBulletSnapshot.java +++ /dev/null @@ -1,131 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.snapshot; - - -/** - * Interface of a bullet snapshot at a specific time in a battle. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public interface IBulletSnapshot { - - /** - * Returns the bullet state. - * - * @return the bullet state. - */ - BulletState getState(); - - /** - * Returns the bullet power. - * - * @return the bullet power. - */ - double getPower(); - - /** - * Returns the X position of the bullet. - * - * @return the X position of the bullet. - */ - double getX(); - - /** - * Returns the Y position of the bullet. - * - * @return the Y position of the bullet. - */ - double getY(); - - /** - * Returns the X painting position of the bullet. - * Note that this is not necessarily equal to the X position of the bullet, even though - * it will be in most cases. The painting position of the bullet is needed as the bullet - * will "stick" to its victim when it has been hit, but only visually. - * - * @return the X painting position of the bullet. - */ - double getPaintX(); - - /** - * Returns the Y painting position of the bullet. - * Note that this is not necessarily equal to the Y position of the bullet, even though - * it will be in most cases. The painting position of the bullet is needed as the bullet - * will "stick" to its victim when it has been hit, but only visually. - * - * @return the Y painting position of the bullet. - */ - double getPaintY(); - - /** - * Returns the color of the bullet. - * - * @return an ARGB color value. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue) - * - * @see java.awt.Color#getRGB() - */ - int getColor(); - - /** - * Returns the current frame number to display, i.e. when the bullet explodes. - * - * @return the current frame number. - * - * @see #isExplosion() - * @see #getExplosionImageIndex() - */ - int getFrame(); - - /** - * Checks if the bullet has become an explosion, i.e. when it a robot or bullet has been hit. - * - * @return {@code true} if the bullet is an explosion; {@code false} otherwise. - * - * @see #getFrame() - * @see #getExplosionImageIndex() - */ - boolean isExplosion(); - - /** - * Returns the explosion image index, which is different depending on the type of explosion. - * E.g. if it is a small explosion on a robot that has been hit by this bullet, - * or a big explosion when a robot dies. - * - * @return the explosion image index. - * - * @see #isExplosion() - * @see #getExplosionImageIndex() - */ - int getExplosionImageIndex(); - - /** - * Returns the ID of the bullet used for identifying the bullet in a collection of bullets. - * - * @return the ID of the bullet. - */ - int getBulletId(); - - /** - * @return heading of the bullet - */ - double getHeading(); - - /** - * @return contestantIndex of the victim, or -1 if still in air - */ - int getVictimIndex(); - - /** - * @return contestantIndex of the owner - */ - int getOwnerIndex(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IDebugProperty.java b/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IDebugProperty.java deleted file mode 100644 index ed0a6fa..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IDebugProperty.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.snapshot; - - -/** - * Interface of a debug property, which is a key-value pair. - * - * @author Pavel Savara (original) - * - * @since 1.6.2 - */ -public interface IDebugProperty { - - /** - * Returns the key of the property. - * - * @return the key of the property. - */ - String getKey(); - - /** - * Returns the value of the property. - * - * @return the value of the property. - */ - String getValue(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IRobotSnapshot.java b/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IRobotSnapshot.java deleted file mode 100644 index a10ff4a..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IRobotSnapshot.java +++ /dev/null @@ -1,242 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.snapshot; - - -/** - * Interface of a robot snapshot at a specific time in a battle. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public interface IRobotSnapshot { - - /** - * Returns the name of the robot. - * - * @return the name of the robot. - */ - String getName(); - - /** - * Returns the short name of the robot. - * - * @return the short name of the robot. - */ - String getShortName(); - - /** - * Returns the very short name of the robot. - * - * @return the very short name of the robot. - */ - String getVeryShortName(); - - /** - * Returns the name of the team, which can be the name of a robot if the contestant is not a team, but a robot. - * - * @return the name of the team. - */ - String getTeamName(); - - /** - * Returns the index of the robot, which is unique for the specific robot and constant during a battle. - * - * @return the robot index. - * - * @since 1.7.4 - * - * @see #getTeamIndex() - */ - int getRobotIndex(); - - /** - * Returns the index of the team that this robot is a member of, which is unique for the specific team and constant - * during a battle. - * - * @return the team index or -1 if the robot is not a member of a team. - * - * @since 1.7.4 - * - * @see #getRobotIndex() - */ - int getTeamIndex(); - - /** - * Returns the contestant index, which is unique for each robot or team participating in a battle. - * Note: If a team of robots is participating in a battle, this method will return the team index (see - * {@link #getTeamIndex()}); otherwise the robot index (see {@link #getRobotIndex()}) is used instead. - * This method is used for the battle results as scores are calculated for either a team of robots or individual - * robot. - * - * @return the contestant index of the robot or team. - * - * @see #getRobotIndex() - * @see #getTeamIndex() - */ - int getContestantIndex(); - - /** - * Returns the robot state. - * - * @return the robot state. - */ - RobotState getState(); - - /** - * Returns the energy level of the robot. - * - * @return the energy level of the robot. - */ - double getEnergy(); - - /** - * Returns the velocity of the robot. - * - * @return the velocity of the robot. - */ - double getVelocity(); - - /** - * Returns the body heading of the robot in radians. - * - * @return the body heading of the robot in radians. - */ - double getBodyHeading(); - - /** - * Returns the gun heading of the robot in radians. - * - * @return the gun heading of the robot in radians. - */ - double getGunHeading(); - - /** - * Returns the radar heading of the robot in radians. - * - * @return the radar heading of the robot in radians. - */ - double getRadarHeading(); - - /** - * Returns the gun heat of the robot. - * - * @return the gun heat of the robot. - */ - double getGunHeat(); - - /** - * Returns the X position of the robot. - * - * @return the X position of the robot. - */ - double getX(); - - /** - * Returns the Y position of the robot. - * - * @return the Y position of the robot. - */ - double getY(); - - /** - * Returns the color of the body. - * - * @return an ARGB color value. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue) - * - * @see java.awt.Color#getRGB() - */ - int getBodyColor(); - - /** - * Returns the color of the gun. - * - * @return an ARGB color value. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue) - * - * @see java.awt.Color#getRGB() - */ - int getGunColor(); - - /** - * Returns the color of the radar. - * - * @return an ARGB color value. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue) - * - * @see java.awt.Color#getRGB() - */ - int getRadarColor(); - - /** - * Returns the color of the scan arc. - * - * @return an ARGB color value. (Bits 24-31 are alpha, 16-23 are red, 8-15 are green, 0-7 are blue) - * - * @see java.awt.Color#getRGB() - */ - int getScanColor(); - - /** - * Checks if this robot is a {@link robocode.Droid Droid}. - * - * @return {@code true} if this robot is a Droid; {@code false} otherwise. - */ - boolean isDroid(); - - /** - * Checks if this robot is a {@link robocode.BorderSentry BorderSentry}. - * - * @return {@code true} if this robot is a BorderSentry; {@code false} otherwise. - * - * @since 1.9.0.0 - */ - boolean isSentryRobot(); - - /** - * Checks if this robot is a {@link robocode.robotinterfaces.IPaintRobot IPaintRobot} or is invoking getGraphics() - * - * @return {@code true} if this robot is a painting; {@code false} otherwise. - */ - boolean isPaintRobot(); - - /** - * Checks if painting is enabled for this robot. - * - * @return {@code true} if painting is enabled for this robot; {@code false} otherwise. - */ - boolean isPaintEnabled(); - - /** - * Checks if RobocodeSG painting (the point (0,0) is in the upper left corner) is enabled for this robot. - * - * @return {@code true} if RobocodeSG painting is enabled for this robot; {@code false} otherwise. - */ - boolean isSGPaintEnabled(); - - /** - * Returns a snapshot of debug properties. - * - * @return a snapshot of debug properties. - */ - IDebugProperty[] getDebugProperties(); - - /** - * Returns a snapshot of the output print stream for this robot. - * - * @return a string containing the snapshot of the output print stream. - */ - String getOutputStreamSnapshot(); - - /** - * Returns a snapshot of the current score for this robot. - * - * @return a snapshot of the current score for this robot. - */ - IScoreSnapshot getScoreSnapshot(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IScoreSnapshot.java b/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IScoreSnapshot.java deleted file mode 100644 index 00ca3a4..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/IScoreSnapshot.java +++ /dev/null @@ -1,146 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.snapshot; - - -/** - * Interface of a score snapshot at a specific time in a battle. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public interface IScoreSnapshot extends Comparable { - - /** - * Returns the name of the contestant, i.e. a robot or team. - * - * @return the name of the contestant, i.e. a robot or team. - */ - String getName(); - - /** - * Returns the total score. - * - * @return the total score. - */ - double getTotalScore(); - - /** - * Returns the total survival score. - * - * @return the total survival score. - */ - double getTotalSurvivalScore(); - - /** - * Returns the total last survivor score. - * - * @return the total last survivor score. - */ - double getTotalLastSurvivorBonus(); - - /** - * Returns the total bullet damage score. - * - * @return the total bullet damage score. - */ - double getTotalBulletDamageScore(); - - /** - * Returns the total bullet kill bonus. - * - * @return the total bullet kill bonus. - */ - double getTotalBulletKillBonus(); - - /** - * Returns the total ramming damage score. - * - * @return the total ramming damage score. - */ - double getTotalRammingDamageScore(); - - /** - * Returns the total ramming kill bonus. - * - * @return the total ramming kill bonus. - */ - double getTotalRammingKillBonus(); - - /** - * Returns the total number of first places. - * - * @return the total number of first places. - */ - int getTotalFirsts(); - - /** - * Returns the total number of second places. - * - * @return the total number of second places. - */ - int getTotalSeconds(); - - /** - * Returns the total number of third places. - * - * @return the total number of third places. - */ - int getTotalThirds(); - - /** - * Returns the current score. - * - * @return the current score. - */ - double getCurrentScore(); - - /** - * Returns the current survival score. - * - * @return the current survival score. - */ - double getCurrentSurvivalScore(); - - /** - * Returns the current survival bonus. - * - * @return the current survival bonus. - */ - double getCurrentSurvivalBonus(); - - /** - * Returns the current bullet damage score. - * - * @return the current bullet damage score. - */ - double getCurrentBulletDamageScore(); - - /** - * Returns the current bullet kill bonus. - * - * @return the current bullet kill bonus. - */ - double getCurrentBulletKillBonus(); - - /** - * Returns the current ramming damage score. - * - * @return the current ramming damage score. - */ - double getCurrentRammingDamageScore(); - - /** - * Returns the current ramming kill bonus. - * - * @return the current ramming kill bonus. - */ - double getCurrentRammingKillBonus(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/ITurnSnapshot.java b/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/ITurnSnapshot.java deleted file mode 100644 index abe369c..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/ITurnSnapshot.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.snapshot; - - -/** - * Interface of a battle turn snapshot at a specific time in a battle. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.2 - */ -public interface ITurnSnapshot { - - /** - * Returns a list of snapshots for the robots participating in the battle. - * - * @return a list of snapshots for the robots participating in the battle. - */ - IRobotSnapshot[] getRobots(); - - /** - * Returns a list of snapshots for the bullets that are currently on the battlefield. - * - * @return a list of snapshots for the bullets that are currently on the battlefield. - */ - IBulletSnapshot[] getBullets(); - - /** - * Returns the current TPS (turns per second) rate. - * - * @return the current TPS (turns per second) rate. - */ - int getTPS(); - - /** - * Returns the current round of the battle. - * - * @return the current round of the battle. - */ - int getRound(); - - /** - * Returns the current turn in the battle round. - * - * @return the current turn in the battle round. - */ - int getTurn(); - - /** - * Returns an array of sorted scores grouped by teams, ordered by position. - * Note that the team index cannot be used to determine the score with the sorted scores. - * - * @return an array of sorted IScoreSnapshots, where the bigger scores are placed first in the list. - * - * @see #getIndexedTeamScores() - */ - IScoreSnapshot[] getSortedTeamScores(); - - /** - * Returns an array of indexed scores grouped by teams that can be used to determine the score - * for the individual team based on the team index. - * - * @return an array of indexed IScoreSnapshots, where each index matches an index of a specific team. - * - * @see #getSortedTeamScores() - */ - IScoreSnapshot[] getIndexedTeamScores(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/RobotState.java b/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/RobotState.java deleted file mode 100644 index 887cf69..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/RobotState.java +++ /dev/null @@ -1,122 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.control.snapshot; - - -/** - * Defines a robot state, which can be: active on the battlefield, hitting a wall or robot this turn, or dead. - * - * @author Flemming N. Larsen (original) - * - * @since 1.6.2 - */ -public enum RobotState { - - /** The robot is active on the battlefield and has not hit the wall or a robot at this turn. */ - ACTIVE(0), - - /** The robot has hit a wall, i.e. one of the four borders, at this turn. This state only last one turn. */ - HIT_WALL(1), - - /** The robot has hit another robot at this turn. This state only last one turn. */ - HIT_ROBOT(2), - - /** The robot is dead. */ - DEAD(3); - - private final int value; - - private RobotState(int value) { - this.value = value; - } - - /** - * Returns the state as an integer value. - * - * @return an integer value representing this state. - * - * @see #toState(int) - */ - public int getValue() { - return value; - } - - /** - * Returns a RobotState based on an integer value that represents a RobotState. - * - * @param value the integer value that represents a specific RobotState. - * @return a RobotState that corresponds to the specific integer value. - * - * @see #getValue() - * - * @throws IllegalArgumentException if the specified value does not correspond - * to a RobotState and hence is invalid. - */ - public static RobotState toState(int value) { - switch (value) { - case 0: - return ACTIVE; - - case 1: - return HIT_WALL; - - case 2: - return HIT_ROBOT; - - case 3: - return DEAD; - - default: - throw new IllegalArgumentException("unknown value"); - } - } - - /** - * Checks if the robot is alive. - * - * @return {@code true} if the robot is alive; {@code false} otherwise. - * - * @see #isDead() - */ - public boolean isAlive() { - return this != DEAD; - } - - /** - * Checks if the robot is dead. - * - * @return {@code true} if the robot is dead; {@code false} otherwise. - * - * @see #isAlive() - */ - public boolean isDead() { - return this == DEAD; - } - - /** - * Checks if the robot has hit another robot. - * - * @return {@code true} if the robot has hit a robot; {@code false} otherwise. - * - * @see #isHitWall() - */ - public boolean isHitRobot() { - return this == HIT_ROBOT; - } - - /** - * Checks if the robot has hit the wall, i.e. one of the four borders. - * - * @return {@code true} if the robot has hit the wall; {@code false} otherwise. - * - * @see #isHitRobot() - */ - public boolean isHitWall() { - return this == HIT_WALL; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/package-info.java b/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/package-info.java deleted file mode 100644 index ea5ebb5..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/control/snapshot/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - -/** - * Snapshots of the battle turns, robots, bullets, scores etc. - */ -package robocode.control.snapshot; diff --git a/workspace_robo/robocode.api/src/main/java/robocode/exception/AbortedException.java b/workspace_robo/robocode.api/src/main/java/robocode/exception/AbortedException.java deleted file mode 100644 index 3531ca8..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/exception/AbortedException.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.exception; - - -/** - * @author Pavel Savara (original) - * - * @since 1.6.1 - */ -public class AbortedException extends Error { // Must be an Error! - // From viewpoint of the Robot, an Error is a JVM error: - // Robot died, their CPU exploded, the JVM for the robot's brain has an error. - private static final long serialVersionUID = 1L; - - public AbortedException() { - super(); - } - - public AbortedException(String message) { - super(message); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/exception/DeathException.java b/workspace_robo/robocode.api/src/main/java/robocode/exception/DeathException.java deleted file mode 100644 index 5f18f0e..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/exception/DeathException.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.exception; - - -/** - * @author Mathew A. Nelson (original) - */ -public class DeathException extends Error { // Must be an Error! - // From viewpoint of the Robot, an Error is a JVM error: - // Robot died, their CPU exploded, the JVM for the robot's brain has an error. - private static final long serialVersionUID = 1L; - - public DeathException() { - super(); - } - - public DeathException(String message) { - super(message); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/exception/DisabledException.java b/workspace_robo/robocode.api/src/main/java/robocode/exception/DisabledException.java deleted file mode 100644 index 24435f1..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/exception/DisabledException.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.exception; - - -/** - * @author Mathew A. Nelson (original) - */ -public class DisabledException extends Error { // Must be an Error! - private static final long serialVersionUID = 1L; - - public DisabledException() { - super(); - } - - public DisabledException(String s) { - super(s); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/exception/EventInterruptedException.java b/workspace_robo/robocode.api/src/main/java/robocode/exception/EventInterruptedException.java deleted file mode 100644 index 0d7ccd0..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/exception/EventInterruptedException.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.exception; - - -/** - * @author Mathew A. Nelson (original) - */ -public class EventInterruptedException extends Error { // Must be an Error! - private static final long serialVersionUID = 1L; - - private int priority = Integer.MIN_VALUE; - - public EventInterruptedException(int priority) { - this.priority = priority; - } - - public int getPriority() { - return priority; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/exception/RobotException.java b/workspace_robo/robocode.api/src/main/java/robocode/exception/RobotException.java deleted file mode 100644 index 93e331f..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/exception/RobotException.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.exception; - - -/** - * @author Mathew A. Nelson (original) - */ -public class RobotException extends Error { // Must be an Error! - private static final long serialVersionUID = 1L; - - public RobotException() { - super(); - } - - public RobotException(String s) { - super(s); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/exception/WinException.java b/workspace_robo/robocode.api/src/main/java/robocode/exception/WinException.java deleted file mode 100644 index 478f165..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/exception/WinException.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.exception; - - -/** - * @author Mathew A. Nelson (original) - */ -public class WinException extends Error { // Must be an Error! - private static final long serialVersionUID = 1L; - - public WinException() { - super(); - } - - public WinException(String s) { - super(s); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/exception/package-info.java b/workspace_robo/robocode.api/src/main/java/robocode/exception/package-info.java deleted file mode 100644 index cc56bbd..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/exception/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - -/** - * Contains exceptions that occur inside a robot thrown by the game. - */ -package robocode.exception; diff --git a/workspace_robo/robocode.api/src/main/java/robocode/package-info.java b/workspace_robo/robocode.api/src/main/java/robocode/package-info.java deleted file mode 100644 index deb1c88..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - -/** - * Robot API used for writing robots for Robocode. - */ -package robocode; diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/EllipseGL.java b/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/EllipseGL.java deleted file mode 100644 index 550f5fd..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/EllipseGL.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robocodeGL; - - -import java.awt.Color; - -import gl4java.GLFunc; - - -/** - * Dummy class that stub out RobocodeGL 0.1.4 functionality. - * - * Original author is David Alves for RobocodeGL. - */ -public class EllipseGL extends RenderElement { - - public EllipseGL() {} - - public EllipseGL(double x, double y, double width, double height) {} - - public EllipseGL(double x, double y, double width, double height, Color color, double lineWidth) {} - - public void setFrame(double x, double y, double width, double height) {} - - public void setLineWidth(double lineWidth) {} - - public void setFilled(boolean filled) {} - - public void setColor(Color c) {} - - public void setLocation(double x, double y) {} - - public void setSize(double width, double height) {} - - public void draw(GLFunc gl) {} - - public float getStringX() { - return 0f; - } - - public float getStringY() { - return 0f; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/LabelGL.java b/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/LabelGL.java deleted file mode 100644 index 09d4ad5..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/LabelGL.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robocodeGL; - - -/** - * Dummy class that stub out RobocodeGL 0.1.4 functionality. - * - * Original author is David Alves for RobocodeGL. - */ -public class LabelGL { - - public LabelGL(String s) {} - - public synchronized void setString(String s) {} - - public synchronized String toString() { - return ""; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/LineGL.java b/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/LineGL.java deleted file mode 100644 index 217cf72..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/LineGL.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robocodeGL; - - -import java.awt.Color; - -import gl4java.GLFunc; - - -/** - * Dummy class that stub out RobocodeGL 0.1.4 functionality. - * - * Original author is David Alves for RobocodeGL. - */ -public class LineGL extends RenderElement { - - public LineGL() {} - - public LineGL(double x1, double y1, double x2, double y2) {} - - public void setLine(double x1, double y1, double x2, double y2) {} - - public void setWidth(double lineWidth) {} - - public void setColor(Color c) {} - - public void draw(GLFunc gl) {} - - public float getStringX() { - return 0f; - } - - public float getStringY() { - return 0f; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/PointGL.java b/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/PointGL.java deleted file mode 100644 index d7a543a..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/PointGL.java +++ /dev/null @@ -1,37 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robocodeGL; - - -import gl4java.GLFunc; -import java.awt.Color; - - -/** - * Dummy class that stub out RobocodeGL 0.1.4 functionality. - * - * Original author is David Alves for RobocodeGL. - */ -public class PointGL extends RenderElement { - - public void setSize(float size) {} - - public synchronized void setPosition(double x, double y) {} - - public void setColor(Color c) {} - - public float getStringX() { - return 0f; - } - - public float getStringY() { - return 0f; - } - - public void draw(GLFunc gl) {} -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/RectangleGL.java b/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/RectangleGL.java deleted file mode 100644 index 8def061..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/RectangleGL.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robocodeGL; - - -import gl4java.GLFunc; -import java.awt.Color; - - -/** - * Dummy class that stub out RobocodeGL 0.1.4 functionality. - * - * Original author is David Alves for RobocodeGL. - */ -public class RectangleGL extends RenderElement { - - public RectangleGL() {} - - public RectangleGL(double x, double y, double width, double height) {} - - public RectangleGL(double x, double y, double width, double height, Color c, double lineWidth) {} - - public void setBounds(double x, double y, double width, double height) {} - - public void setLineWidth(double lineWidth) {} - - public void setColor(Color color) {} - - public void setFilled(boolean filled) {} - - public void setLocation(double x, double y) {} - - public void setSize(double width, double height) {} - - public void draw(GLFunc gl) {} - - public float getStringX() { - return 0f; - } - - public float getStringY() { - return 0f; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/RenderElement.java b/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/RenderElement.java deleted file mode 100644 index 17be2d8..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/RenderElement.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robocodeGL; - - -import gl4java.GLFont; -import gl4java.GLFunc; - - -/** - * Dummy class that stub out RobocodeGL 0.1.4 functionality. - * - * Original author is David Alves for RobocodeGL. - */ -public abstract class RenderElement { - - public static void init(GLFont glf) {} - - public RenderElement() {} - - public synchronized void addLabel(LabelGL l) {} - - public synchronized void removeLabel(LabelGL l) {} - - public synchronized void remove() {} - - public synchronized boolean isRemoved() { - return false; - } - - public synchronized void drawStrings(GLFunc gl) {} - - public abstract void draw(GLFunc gl); - - public float getStringX() { - return 0f; - } - - public float getStringY() { - return 0f; - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/system/GLRenderer.java b/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/system/GLRenderer.java deleted file mode 100644 index 30be5ee..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robocodeGL/system/GLRenderer.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robocodeGL.system; - - -import robocode.robocodeGL.RenderElement; - - -/** - * Dummy class that stub out RobocodeGL 0.1.4 functionality. - * - * Original author is David Alves for RobocodeGL. - */ -public class GLRenderer { - - public static GLRenderer getInstance() { - return new GLRenderer(); - } - - public void addRenderElement(RenderElement e) {} -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IAdvancedEvents.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IAdvancedEvents.java deleted file mode 100644 index 2ee2574..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IAdvancedEvents.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -import robocode.CustomEvent; -import robocode.SkippedTurnEvent; - - -/** - * An event interface for receiving advanced robot events with an - * {@link IAdvancedRobot}. - * - * @see IAdvancedRobot - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IAdvancedEvents { - - /** - * This method is called if the robot is using too much time between - * actions. When this event occur, the robot's turn is skipped, meaning that - * it cannot take action anymore in this turn. - *

- * If you receive 30 skipped turn event, your robot will be removed from the - * round and loose the round. - *

- * You will only receive this event after taking an action. So a robot in an - * infinite loop will not receive any events, and will simply be stopped. - *

- * No correctly working, reasonable robot should ever receive this event - * unless it is using too many CPU cycles. - * - * @param event the skipped turn event set by the game - * @see robocode.SkippedTurnEvent - * @see robocode.Event - */ - void onSkippedTurn(SkippedTurnEvent event); - - /** - * This method is called when a custom condition is met. - *

- * See the sample robots for examples of use, e.g. the {@code sample.Target} - * robot. - * - * @param event the custom event that occurred - * @see robocode.AdvancedRobot#addCustomEvent - * @see robocode.CustomEvent - * @see robocode.Event - */ - void onCustomEvent(CustomEvent event); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IAdvancedRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IAdvancedRobot.java deleted file mode 100644 index 39c6c90..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IAdvancedRobot.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -/** - * A robot interface for creating a more advanced type of robot like - * {@link robocode.AdvancedRobot} that is able to handle advanced robot events. - * An advanced robot allows non-blocking calls, custom events, get notifications - * about skipped turns, and also allow writes to the file system. - * - * @see robocode.AdvancedRobot - * @see IBasicRobot - * @see IJuniorRobot - * @see IInteractiveRobot - * @see ITeamRobot - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IAdvancedRobot extends IBasicRobot { - - /** - * This method is called by the game to notify this robot about advanced - * robot event. Hence, this method must be implemented so it returns your - * {@link IAdvancedEvents} listener. - * - * @return listener to advanced events or {@code null} if this robot should - * not receive the notifications. - * @since 1.6 - */ - IAdvancedEvents getAdvancedEventListener(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicEvents.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicEvents.java deleted file mode 100644 index 3e9a2ce..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicEvents.java +++ /dev/null @@ -1,278 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -import robocode.*; - - -/** - * An event interface for receiving basic robot events with an - * {@link IBasicRobot}. - * - * @see IBasicRobot - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IBasicEvents { - - /** - * This method is called every turn in a battle round in order to provide - * the robot status as a complete snapshot of the robot's current state at - * that specific time. - *

- * The main benefit of this method is that you'll automatically receive all - * current data values of the robot like e.g. the x and y coordinate, - * heading, gun heat etc., which are grouped into the exact same time/turn. - *

- * This is the only way to map the robots data values to a specific time. - * For example, it is not possible to determine the exact time of the - * robot's heading by calling first calling {@link Robot#getTime()} and then - * {@link Robot#getHeading()} afterwards, as the time might change - * after between the {@link Robot#getTime()} and {@link Robot#getHeading()} - * call. - * - * @param event the event containing the robot status at the time it occurred. - * @see StatusEvent - * @see Event - * @since 1.5 - */ - void onStatus(StatusEvent event); - - /** - * This method is called when one of your bullets hits another robot. - * You should override it in your robot if you want to be informed of this - * event. - *

- * Example: - *

-	 *   public void onBulletHit(BulletHitEvent event) {
-	 *       out.println("I hit " + event.getName() + "!");
-	 *   }
-	 * 
- * - * @param event the bullet-hit event set by the game - * @see BulletHitEvent - * @see Event - */ - void onBulletHit(BulletHitEvent event); - - /** - * This method is called when one of your bullets hits another bullet. - * You should override it in your robot if you want to be informed of this - * event. - *

- * Example: - *

-	 *   public void onBulletHitBullet(BulletHitBulletEvent event) {
-	 *       out.println("I hit a bullet fired by " + event.getBullet().getName() + "!");
-	 *   }
-	 * 
- * - * @param event the bullet-hit-bullet event set by the game - * @see BulletHitBulletEvent - * @see Event - */ - void onBulletHitBullet(BulletHitBulletEvent event); - - /** - * This method is called when one of your bullets misses, i.e. hits a wall. - * You should override it in your robot if you want to be informed of this - * event. - *

- * Example: - *

-	 *   public void onBulletMissed(BulletMissedEvent event) {
-	 *       out.println("Drat, I missed.");
-	 *   }
-	 * 
- * - * @param event the bullet-missed event set by the game - * @see BulletMissedEvent - * @see Event - */ - void onBulletMissed(BulletMissedEvent event); - - /** - * This method is called if your robot dies. - *

- * You should override it in your robot if you want to be informed of this - * event. Actions will have no effect if called from this section. The - * intent is to allow you to perform calculations or print something out - * when the robot is killed. - * - * @param event the death event set by the game - * @see DeathEvent - * @see WinEvent - * @see RoundEndedEvent - * @see BattleEndedEvent - * @see Event - */ - public void onDeath(DeathEvent event); - - /** - * This method is called when your robot is hit by a bullet. - * You should override it in your robot if you want to be informed of this - * event. - *

- * Example: - *

-	 *   void onHitByBullet(HitByBulletEvent event) {
-	 *       out.println(event.getRobotName() + " hit me!");
-	 *   }
-	 * 
- * - * @param event the hit-by-bullet event set by the game - * @see HitByBulletEvent - * @see Event - */ - void onHitByBullet(HitByBulletEvent event); - - /** - * This method is called when your robot collides with another robot. - * You should override it in your robot if you want to be informed of this - * event. - *

- * Example: - *

-	 *   void onHitRobot(HitRobotEvent event) {
-	 *       if (event.getBearing() > -90 && event.getBearing() <= 90) {
-	 *           back(100);
-	 *       } else {
-	 *           ahead(100);
-	 *       }
-	 *   }
-	 * 

- * -- or perhaps, for a more advanced robot -- - *

- * public void onHitRobot(HitRobotEvent event) { - * if (event.getBearing() > -90 && event.getBearing() <= 90) { - * setBack(100); - * } else { - * setAhead(100); - * } - * } - *

- *

- * The angle is relative to your robot's facing. So 0 is straight ahead of - * you. - *

- * This event can be generated if another robot hits you, in which case - * {@link HitRobotEvent#isMyFault() event.isMyFault()} will return - * {@code false}. In this case, you will not be automatically stopped by the - * game -- but if you continue moving toward the robot you will hit it (and - * generate another event). If you are moving away, then you won't hit it. - * - * @param event the hit-robot event set by the game - * @see HitRobotEvent - * @see Event - */ - void onHitRobot(HitRobotEvent event); - - /** - * This method is called when your robot collides with a wall. - * You should override it in your robot if you want to be informed of this - * event. - *

- * The wall at the top of the screen is 0 degrees, right is 90 degrees, - * bottom is 180 degrees, left is 270 degrees. But this event is relative to - * your heading, so: The bearing is such that {@link Robot#turnRight(double) - * turnRight} {@link HitWallEvent#getBearing() (event.getBearing())} will - * point you perpendicular to the wall. - *

- * Example: - *

-	 *   void onHitWall(HitWallEvent event) {
-	 *       out.println("Ouch, I hit a wall bearing " + event.getBearing() + " degrees.");
-	 *   }
-	 * 
- * - * @param event the hit-wall event set by the game - * @see HitWallEvent - * @see Event - */ - void onHitWall(HitWallEvent event); - - /** - * This method is called when your robot sees another robot, i.e. when the - * robot's radar scan "hits" another robot. - * You should override it in your robot if you want to be informed of this - * event. (Almost all robots should override this!) - *

- * This event is automatically called if there is a robot in range of your - * radar. - *

- * Note that the robot's radar can only see robot within the range defined - * by {@link Rules#RADAR_SCAN_RADIUS} (1200 pixels). - *

- * Also not that the bearing of the scanned robot is relative to your - * robot's heading. - *

- * Example: - *

-	 *   void onScannedRobot(ScannedRobotEvent event) {
-	 *       // Assuming radar and gun are aligned...
-	 *       if (event.getDistance() < 100) {
-	 *           fire(3);
-	 *       } else {
-	 *           fire(1);
-	 *       }
-	 *   }
-	 * 
- *

- * Note:
- * The game assists Robots in firing, as follows: - *

    - *
  • If the gun and radar are aligned (and were aligned last turn), - *
  • and the event is current, - *
  • and you call fire() before taking any other actions, {@link - * Robot#fire(double) fire()} will fire directly at the robot. - *
- *

- * In essence, this means that if you can see a robot, and it doesn't move, - * then fire will hit it. - *

- * AdvancedRobots will NOT be assisted in this manner, and are expected to - * examine the event to determine if {@link Robot#fire(double) fire()} would - * hit. (i.e. you are spinning your gun around, but by the time you get the - * event, your gun is 5 degrees past the robot). - * - * @param event the scanned-robot event set by the game - * @see ScannedRobotEvent - * @see Event - * @see Rules#RADAR_SCAN_RADIUS - */ - void onScannedRobot(ScannedRobotEvent event); - - /** - * This method is called when another robot dies. - * You should override it in your robot if you want to be informed of this - * event. - * - * @param event The robot-death event set by the game - * @see RobotDeathEvent - * @see Event - */ - void onRobotDeath(RobotDeathEvent event); - - /** - * This method is called if your robot wins a battle. - *

- * Your robot could perform a victory dance here! :-) - * - * @param event the win event set by the game - * @see DeathEvent - * @see RoundEndedEvent - * @see BattleEndedEvent - * @see Event - */ - void onWin(WinEvent event); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicEvents2.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicEvents2.java deleted file mode 100644 index e737569..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicEvents2.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -import robocode.BattleEndedEvent; -import robocode.RoundEndedEvent; - - -/** - * First extended version of the {@link IBasicEvents} interface. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -public interface IBasicEvents2 extends IBasicEvents { - - /** - * This method is called after the end of the battle, even when the battle is aborted. - * You should override it in your robot if you want to be informed of this event. - *

- * Example: - *

-	 *   public void onBattleEnded(BattleEndedEvent event) {
-	 *       out.println("The battle has ended");
-	 *   }
-	 * 
- * - * @param event the BattleEndedEvent set by the game - * @see BattleEndedEvent - * @see IBasicEvents3#onRoundEnded(RoundEndedEvent) - * @see robocode.WinEvent - * @see robocode.DeathEvent - * @see robocode.Event - * - * @since 1.6.1 - */ - void onBattleEnded(BattleEndedEvent event); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicEvents3.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicEvents3.java deleted file mode 100644 index 6396c1e..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicEvents3.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -import robocode.BattleEndedEvent; -import robocode.RoundEndedEvent; - - -/** - * Second extended version of the {@link IBasicEvents} interface. - * - * @author Flemming N. Larsen (original) - * - * @since 1.7.2 - */ -public interface IBasicEvents3 extends IBasicEvents2 { - - /** - * This method is called after the end of a round. - * You should override it in your robot if you want to be informed of this event. - *

- * Example: - *

-	 *   public void onRoundEnded(RoundEndedEvent event) {
-	 *       out.println("The round has ended");
-	 *   }
-	 * 
- * - * @param event the RoundEndedEvent event set by the game - * @see RoundEndedEvent - * @see #onBattleEnded(BattleEndedEvent) - * @see robocode.WinEvent - * @see robocode.DeathEvent - * @see robocode.Event - * - * @since 1.7.2 - */ - void onRoundEnded(RoundEndedEvent event); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicRobot.java deleted file mode 100644 index d61ddfb..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IBasicRobot.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -import robocode.robotinterfaces.peer.IBasicRobotPeer; - - -/** - * A robot interface for creating a basic type of robot like {@link robocode.Robot} - * that is able to receive common robot events, but not interactive events as - * with the {@link robocode.Robot} class. - * A basic robot allows blocking calls only and cannot handle custom events nor - * writes to the file system like an advanced robot. - * - * @see robocode.Robot - * @see IJuniorRobot - * @see IInteractiveRobot - * @see IAdvancedRobot - * @see ITeamRobot - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IBasicRobot { - - /** - * This method is called by the game to invoke the - * {@link java.lang.Runnable#run() run()} method of your robot, where the program - * of your robot is implemented. - * - * @return a runnable implementation - * @see java.lang.Runnable#run() - * @since 1.6 - */ - Runnable getRobotRunnable(); - - /** - * This method is called by the game to notify this robot about basic - * robot event. Hence, this method must be implemented so it returns your - * {@link IBasicEvents} listener. - * - * @return listener to basic events or {@code null} if this robot should - * not receive the notifications. - * @since 1.6 - */ - IBasicEvents getBasicEventListener(); - - /** - * Do not call this method! Your robot will simply stop interacting with - * the game. - *

- * This method is called by the game. A robot peer is the object that deals - * with game mechanics and rules, and makes sure your robot abides by them. - * - * @param peer the robot peer supplied by the game - */ - void setPeer(IBasicRobotPeer peer); - - /** - * Do not call this method! - *

- * This method is called by the game when setting the output stream for your - * robot. - * - * @param out the new output print stream for this robot - * @since 1.6 - */ - void setOut(java.io.PrintStream out); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IInteractiveEvents.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IInteractiveEvents.java deleted file mode 100644 index f249dc9..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IInteractiveEvents.java +++ /dev/null @@ -1,223 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseWheelEvent; - - -/** - * An event interface for receiving interactive events with an - * {@link IInteractiveRobot}. - * - * @see IInteractiveRobot - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IInteractiveEvents { - - /** - * This method is called when a key has been pressed. - *

- * See the {@code sample.Interactive} robot for an example of how to use - * key events. - * - * @param event holds details about current event - * @see java.awt.event.KeyListener#keyPressed(KeyEvent) - * @see #onKeyReleased(KeyEvent) - * @see #onKeyTyped(KeyEvent) - * @since 1.3.4 - */ - void onKeyPressed(KeyEvent event); - - /** - * This method is called when a key has been released. - *

- * See the {@code sample.Interactive} robot for an example of how to use - * key events. - * - * @param event holds details about current event - * @see java.awt.event.KeyListener#keyReleased(KeyEvent) - * @see #onKeyPressed(KeyEvent) - * @see #onKeyTyped(KeyEvent) - * @since 1.3.4 - */ - void onKeyReleased(KeyEvent event); - - /** - * This method is called when a key has been typed (pressed and released). - *

- * See the {@code sample.Interactive} robot for an example of how to use - * key events. - * - * @param event holds details about current event - * @see java.awt.event.KeyListener#keyTyped(KeyEvent) - * @see #onKeyPressed(KeyEvent) - * @see #onKeyReleased(KeyEvent) - * @since 1.3.4 - */ - void onKeyTyped(KeyEvent event); - - /** - * This method is called when a mouse button has been clicked (pressed and - * released). - *

- * See the {@code sample.Interactive} robot for an example of how to use - * mouse events. - * - * @param event holds details about current event - * @see java.awt.event.MouseListener#mouseClicked(MouseEvent) - * @see #onMouseMoved(MouseEvent) - * @see #onMousePressed(MouseEvent) - * @see #onMouseReleased(MouseEvent) - * @see #onMouseEntered(MouseEvent) - * @see #onMouseExited(MouseEvent) - * @see #onMouseDragged(MouseEvent) - * @see #onMouseWheelMoved(MouseWheelEvent) - * @since 1.3.4 - */ - void onMouseClicked(MouseEvent event); - - /** - * This method is called when the mouse has entered the battle view. - *

- * See the {@code sample.Interactive} robot for an example of how to use - * mouse events. - * - * @param event holds details about current event - * @see java.awt.event.MouseListener#mouseEntered(MouseEvent) - * @see #onMouseMoved(MouseEvent) - * @see #onMousePressed(MouseEvent) - * @see #onMouseReleased(MouseEvent) - * @see #onMouseClicked(MouseEvent) - * @see #onMouseExited(MouseEvent) - * @see #onMouseDragged(MouseEvent) - * @see #onMouseWheelMoved(MouseWheelEvent) - * @since 1.3.4 - */ - void onMouseEntered(MouseEvent event); - - /** - * This method is called when the mouse has exited the battle view. - *

- * See the {@code sample.Interactive} robot for an example of how to use - * mouse events. - * - * @param event holds details about current event - * @see java.awt.event.MouseListener#mouseExited(MouseEvent) - * @see #onMouseMoved(MouseEvent) - * @see #onMousePressed(MouseEvent) - * @see #onMouseReleased(MouseEvent) - * @see #onMouseClicked(MouseEvent) - * @see #onMouseEntered(MouseEvent) - * @see #onMouseDragged(MouseEvent) - * @see #onMouseWheelMoved(MouseWheelEvent) - * @since 1.3.4 - */ - void onMouseExited(MouseEvent event); - - /** - * This method is called when a mouse button has been pressed. - *

- * See the {@code sample.Interactive} robot for an example of how to use - * mouse events. - * - * @param event holds details about current event - * @see java.awt.event.MouseListener#mousePressed(MouseEvent) - * @see #onMouseMoved(MouseEvent) - * @see #onMouseReleased(MouseEvent) - * @see #onMouseClicked(MouseEvent) - * @see #onMouseEntered(MouseEvent) - * @see #onMouseExited(MouseEvent) - * @see #onMouseDragged(MouseEvent) - * @see #onMouseWheelMoved(MouseWheelEvent) - * @since 1.3.4 - */ - void onMousePressed(MouseEvent event); - - /** - * This method is called when a mouse button has been released. - *

- * See the {@code sample.Interactive} robot for an example of how to use - * mouse events. - * - * @param event holds details about current event - * @see java.awt.event.MouseListener#mouseReleased(MouseEvent) - * @see #onMouseMoved(MouseEvent) - * @see #onMousePressed(MouseEvent) - * @see #onMouseClicked(MouseEvent) - * @see #onMouseEntered(MouseEvent) - * @see #onMouseExited(MouseEvent) - * @see #onMouseDragged(MouseEvent) - * @see #onMouseWheelMoved(MouseWheelEvent) - * @since 1.3.4 - */ - void onMouseReleased(MouseEvent event); - - /** - * This method is called when the mouse has been moved. - *

- * See the {@code sample.Interactive} robot for an example of how to use - * mouse events. - * - * @param event holds details about current event - * @see java.awt.event.MouseMotionListener#mouseMoved(MouseEvent) - * @see #onMousePressed(MouseEvent) - * @see #onMouseReleased(MouseEvent) - * @see #onMouseClicked(MouseEvent) - * @see #onMouseEntered(MouseEvent) - * @see #onMouseExited(MouseEvent) - * @see #onMouseDragged(MouseEvent) - * @see #onMouseWheelMoved(MouseWheelEvent) - * @since 1.3.4 - */ - void onMouseMoved(MouseEvent event); - - /** - * This method is called when a mouse button has been pressed and then - * dragged. - *

- * See the {@code sample.Interactive} robot for an example of how to use - * mouse events. - * - * @param event holds details about current event - * @see java.awt.event.MouseMotionListener#mouseDragged(MouseEvent) - * @see #onMouseMoved(MouseEvent) - * @see #onMousePressed(MouseEvent) - * @see #onMouseReleased(MouseEvent) - * @see #onMouseClicked(MouseEvent) - * @see #onMouseEntered(MouseEvent) - * @see #onMouseExited(MouseEvent) - * @see #onMouseWheelMoved(MouseWheelEvent) - * @since 1.3.4 - */ - void onMouseDragged(MouseEvent event); - - /** - * This method is called when the mouse wheel has been rotated. - *

- * See the {@code sample.Interactive} robot for an example of how to use - * mouse events. - * - * @param event holds details about current event - * @see java.awt.event.MouseWheelListener#mouseWheelMoved(MouseWheelEvent) - * @see #onMouseMoved(MouseEvent) - * @see #onMousePressed(MouseEvent) - * @see #onMouseReleased(MouseEvent) - * @see #onMouseClicked(MouseEvent) - * @see #onMouseEntered(MouseEvent) - * @see #onMouseExited(MouseEvent) - * @see #onMouseDragged(MouseEvent) - */ - void onMouseWheelMoved(MouseWheelEvent event); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IInteractiveRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IInteractiveRobot.java deleted file mode 100644 index 3ed501b..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IInteractiveRobot.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -/** - * A robot interface for creating an interactive type of robot like - * {@link robocode.Robot} and {@link robocode.AdvancedRobot} that is able to - * receive interactive events from the keyboard or mouse. - * If a robot is directly inherited from this class it will behave as similar to - * a {@link IBasicRobot}. If you need it to behave similar to a - * {@link IAdvancedRobot} or {@link ITeamRobot}, you should inherit from these - * interfaces instead, as these are inherited from this interface. - * - * @see robocode.Robot - * @see robocode.AdvancedRobot - * @see IBasicRobot - * @see IJuniorRobot - * @see IAdvancedRobot - * @see ITeamRobot - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (javadoc) - * - * @since 1.6 - */ -public interface IInteractiveRobot extends IBasicRobot { - - /** - * This method is called by the game to notify this robot about interactive - * events, i.e. keyboard and mouse events. Hence, this method must be - * implemented so it returns your {@link IInteractiveEvents} listener. - * - * @return listener to interactive events or {@code null} if this robot - * should not receive the notifications. - * @since 1.6 - */ - IInteractiveEvents getInteractiveEventListener(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IJuniorRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IJuniorRobot.java deleted file mode 100644 index 892b8c7..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IJuniorRobot.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -/** - * A robot interface for creating the most primitive robot type, which is a - * {@link robocode.JuniorRobot}. A junior robot is simpler than the - * {@link robocode.Robot} class. - *

- * A junior robot has a simplified model, in purpose of teaching programming - * skills to inexperienced in programming students. - * The simplified robot model will keep player from overwhelming of Robocode's - * rules, programming syntax and programming concept. - *

- * Instead of using getters and setters, public fields are provided for - * receiving information like the last scanned robot, the coordinate of the - * robot etc. - *

- * All methods on a junior robot are blocking calls, i.e. they do not return - * before their action has been completed and will at least take one turn to - * execute. - * - * @see robocode.JuniorRobot - * @see IBasicRobot - * @see IAdvancedRobot - * @see IInteractiveRobot - * @see ITeamRobot - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IJuniorRobot extends IBasicRobot {} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IPaintEvents.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IPaintEvents.java deleted file mode 100644 index 2df2662..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IPaintEvents.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -import java.awt.*; - - -/** - * An event interface for receiving paint events with an - * {@link robocode.robotinterfaces.IPaintRobot}. - * - * @see robocode.robotinterfaces.IPaintRobot - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IPaintEvents { - - /** - * This method is called every time the robot is painted. You should - * override this method if you want to draw items for your robot on the - * battle field, e.g. targets, virtual bullets etc. - *

- * This method is very useful for debugging your robot. - *

- * Note that the robot will only be painted if the "Paint" is enabled on the - * robot's console window; otherwise the robot will never get painted (the - * reason being that all robots might have graphical items that must be - * painted, and then you might not be able to tell what graphical items that - * have been painted for your robot). - *

- * Also note that the coordinate system for the graphical context where you - * paint items fits for the Robocode coordinate system where (0, 0) is at - * the bottom left corner of the battlefield, where X is towards right and Y - * is upwards. - * - * @param g the graphics context to use for painting graphical items for the - * robot. - * - * @see java.awt.Graphics2D - * - * @since 1.1 - */ - void onPaint(Graphics2D g); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IPaintRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IPaintRobot.java deleted file mode 100644 index 03c5db1..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/IPaintRobot.java +++ /dev/null @@ -1,31 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -/** - * A robot interface that makes it possible for a robot to receive paint events. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IPaintRobot extends IBasicRobot { - - /** - * This method is called by the game to notify this robot about painting - * events. Hence, this method must be implemented so it returns your - * {@link IPaintEvents} listener. - * - * @return listener to paint events or {@code null} if this robot should - * not receive the notifications. - * @since 1.6 - */ - IPaintEvents getPaintEventListener(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/ITeamEvents.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/ITeamEvents.java deleted file mode 100644 index f1498ae..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/ITeamEvents.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -import robocode.MessageEvent; - - -/** - * An event interface for receiving robot team events with an - * {@link ITeamRobot}. - * - * @see ITeamRobot - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface ITeamEvents { - - /** - * This method is called when your robot receives a message from a teammate. - * You should override it in your robot if you want to be informed of this - * event. - *

- * Example: - *

-	 *   public void onMessageReceived(MessageEvent event) {
-	 *       out.println(event.getSender() + " sent me: " + event.getMessage());
-	 *   }
-	 * 
- * - * @param event the message event sent by the game - * @see robocode.MessageEvent - * @see robocode.Event - */ - void onMessageReceived(MessageEvent event); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/ITeamRobot.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/ITeamRobot.java deleted file mode 100644 index e1ebf8f..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/ITeamRobot.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces; - - -/** - * A robot interface for creating a team robot like {@link robocode.TeamRobot} - * that is able to receive team events. - * A team robot is an advanced type of robot that supports sending messages - * between teammates that participates in a team. - * - * @see robocode.TeamRobot - * @see IBasicRobot - * @see IJuniorRobot - * @see IInteractiveRobot - * @see IAdvancedRobot - * @see ITeamRobot - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface ITeamRobot extends IAdvancedRobot { - - /** - * This method is called by the game to notify this robot about team events. - * Hence, this method must be implemented so it returns your - * {@link ITeamEvents} listener. - * - * @return listener to team events or {@code null} if this robot should - * not receive the notifications. - */ - ITeamEvents getTeamEventListener(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/package-info.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/package-info.java deleted file mode 100644 index 9d4aa43..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - -/** - * Robot Interfaces used for creating new robot types, e.g. with other programming languages. - */ -package robocode.robotinterfaces; diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IAdvancedRobotPeer.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IAdvancedRobotPeer.java deleted file mode 100644 index 1dcb879..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IAdvancedRobotPeer.java +++ /dev/null @@ -1,751 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces.peer; - - -import robocode.*; - -import java.io.File; -import java.util.List; - - -/** - * The advanced robot peer for advanced robot types like - * {@link robocode.AdvancedRobot} and {@link robocode.TeamRobot}. - *

- * A robot peer is the object that deals with game mechanics and rules, and - * makes sure your robot abides by them. - * - * @see IBasicRobotPeer - * @see IStandardRobotPeer - * @see ITeamRobotPeer - * @see IJuniorRobotPeer - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IAdvancedRobotPeer extends IStandardRobotPeer { - - /** - * Checks if the gun is set to adjust for the robot turning, i.e. to turn - * independent from the robot's body turn. - *

- * This call returns {@code true} if the gun is set to turn independent of - * the turn of the robot's body. Otherwise, {@code false} is returned, - * meaning that the gun is set to turn with the robot's body turn. - * - * @return {@code true} if the gun is set to turn independent of the robot - * turning; {@code false} if the gun is set to turn with the robot - * turning - * @see #setAdjustGunForBodyTurn(boolean) setAdjustGunForBodyTurn(boolean) - * @see #isAdjustRadarForBodyTurn() - * @see #isAdjustRadarForGunTurn() - */ - boolean isAdjustGunForBodyTurn(); - - /** - * Checks if the radar is set to adjust for the robot turning, i.e. to turn - * independent from the robot's body turn. - *

- * This call returns {@code true} if the radar is set to turn independent of - * the turn of the robot. Otherwise, {@code false} is returned, meaning that - * the radar is set to turn with the robot's turn. - * - * @return {@code true} if the radar is set to turn independent of the robot - * turning; {@code false} if the radar is set to turn with the robot - * turning - * @see #setAdjustRadarForBodyTurn(boolean) setAdjustRadarForBodyTurn(boolean) - * @see #isAdjustGunForBodyTurn() - * @see #isAdjustRadarForGunTurn() - */ - boolean isAdjustRadarForGunTurn(); - - /** - * Checks if the radar is set to adjust for the gun turning, i.e. to turn - * independent from the gun's turn. - *

- * This call returns {@code true} if the radar is set to turn independent of - * the turn of the gun. Otherwise, {@code false} is returned, meaning that - * the radar is set to turn with the gun's turn. - * - * @return {@code true} if the radar is set to turn independent of the gun - * turning; {@code false} if the radar is set to turn with the gun - * turning - * @see #setAdjustRadarForGunTurn(boolean) setAdjustRadarForGunTurn(boolean) - * @see #isAdjustGunForBodyTurn() - * @see #isAdjustRadarForBodyTurn() - */ - boolean isAdjustRadarForBodyTurn(); - - /** - * This call is identical to {@link IStandardRobotPeer#stop(boolean) - * stop(boolean)}, but returns immediately, and will not execute until you - * call {@link IBasicRobotPeer#execute() execute()} or take an action that executes. - *

- * If there is already movement saved from a previous stop, you can - * overwrite it by calling {@code setStop(true)}. - * - * @param overwrite {@code true} if the movement saved from a previous stop - * should be overwritten; {@code false} otherwise. - * @see IStandardRobotPeer#stop(boolean) stop(boolean) - * @see IStandardRobotPeer#resume() resume() - * @see #setResume() - * @see IBasicRobotPeer#execute() execute() - */ - void setStop(boolean overwrite); - - /** - * Sets the robot to resume the movement stopped by - * {@link IStandardRobotPeer#stop(boolean) stop(boolean)} or - * {@link #setStop(boolean)}, if any. - *

- * This call returns immediately, and will not execute until you call - * {@link IBasicRobotPeer#execute() execute()} or take an action that executes. - * - * @see IStandardRobotPeer#resume() resume() - * @see IStandardRobotPeer#stop(boolean) stop(boolean) - * @see #setStop(boolean) - * @see IBasicRobotPeer#execute() execute() - */ - void setResume(); - - /** - * Sets the robot to move forward or backward by distance measured in pixels - * when the next execution takes place. - *

- * This call returns immediately, and will not execute until you call - * {@link IBasicRobotPeer#execute() execute()} or take an action that executes. - *

- * Note that both positive and negative values can be given as input, where - * positive values means that the robot is set to move forward, and negative - * values means that the robot is set to move backward. If 0 is given as - * input, the robot will stop its movement, but will have to decelerate - * till it stands still, and will thus not be able to stop its movement - * immediately, but eventually. - *

- * Example: - *

-	 *   // Set the robot to move 50 pixels forward
-	 *   setMove(50);
-	 *
-	 *   // Set the robot to move 100 pixels backward
-	 *   // (overrides the previous order)
-	 *   setMove(-100);
-	 *
-	 *   ...
-	 *   // Executes the last setMove()
-	 *   execute();
-	 * 
- * - * @param distance the distance to move measured in pixels. - * If {@code distance} > 0 the robot is set to move forward. - * If {@code distance} < 0 the robot is set to move backward. - * If {@code distance} = 0 the robot is set to stop its movement. - * @see IBasicRobotPeer#move(double) move(double) - * @see #setMaxVelocity(double) - * @see #setTurnBody(double) - * @see #setTurnGun(double) - * @see #setTurnRadar(double) - */ - void setMove(double distance); - - /** - * Sets the robot's body to turn right or left by radians when the next - * execution takes place. - *

- * This call returns immediately, and will not execute until you call - * {@link IBasicRobotPeer#execute() execute()} or take an action that - * executes. - *

- * Note that both positive and negative values can be given as input, where - * positive values means that the robot's body is set to turn right, and - * negative values means that the robot's body is set to turn left. - * If 0 is given as input, the robot's body will stop turning. - *

- * Example: - *

-	 *   // Set the robot's body to turn 180 degrees to the right
-	 *   setTurnBody(Math.PI);
-	 *
-	 *   // Set the robot's body to turn 90 degrees to the left instead of right
-	 *   // (overrides the previous order)
-	 *   setTurnBody(-Math.PI / 2);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnBody()
-	 *   execute();
-	 * 
- * - * @param radians the amount of radians to turn the robot's body. - * If {@code radians} > 0 the robot's body is set to turn right. - * If {@code radians} < 0 the robot's body is set to turn left. - * If {@code radians} = 0 the robot's body is set to stop turning. - * @see IBasicRobotPeer#turnBody(double) turnBody(double) - * @see #setTurnGun(double) - * @see #setTurnRadar(double) - * @see #setMaxTurnRate(double) - * @see #setMove(double) - */ - void setTurnBody(double radians); - - /** - * Sets the robot's gun to turn right or left by radians when the next - * execution takes place. - *

- * This call returns immediately, and will not execute until you call - * {@link IBasicRobotPeer#execute() execute()} or take an action that - * executes. - *

- * Note that both positive and negative values can be given as input, where - * positive values means that the robot's gun is set to turn right, and - * negative values means that the robot's gun is set to turn left. - * If 0 is given as input, the robot's gun will stop turning. - *

- * Example: - *

-	 *   // Set the robot's gun to turn 180 degrees to the right
-	 *   setTurnGun(Math.PI);
-	 *
-	 *   // Set the robot's gun to turn 90 degrees to the left instead of right
-	 *   // (overrides the previous order)
-	 *   setTurnGun(-Math.PI / 2);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnFun()
-	 *   execute();
-	 * 
- * - * @param radians the amount of radians to turn the robot's gun. - * If {@code radians} > 0 the robot's gun is set to turn right. - * If {@code radians} < 0 the robot's gun is set to turn left. - * If {@code radians} = 0 the robot's gun is set to stop turning. - * @see IBasicRobotPeer#turnGun(double) turnGun(double) - * @see #setTurnBody(double) - * @see #setTurnRadar(double) - * @see #setMove(double) - */ - void setTurnGun(double radians); - - /** - * Sets the robot's radar to turn right or left by radians when the next - * execution takes place. - *

- * This call returns immediately, and will not execute until you call - * {@link IBasicRobotPeer#execute() execute()} or take an action that - * executes. - *

- * Note that both positive and negative values can be given as input, where - * positive values means that the robot's radar is set to turn right, and - * negative values means that the robot's radar is set to turn left. - * If 0 is given as input, the robot's radar will stop turning. - *

- * Example: - *

-	 *   // Set the robot's radar to turn 180 degrees to the right
-	 *   setTurnRadar(Math.PI);
-	 *
-	 *   // Set the robot's radar to turn 90 degrees to the left instead of right
-	 *   // (overrides the previous order)
-	 *   setTurnRadar(-Math.PI / 2);
-	 *
-	 *   ...
-	 *   // Executes the last setTurnRadar()
-	 *   execute();
-	 * 
- * - * @param radians the amount of radians to turn the robot's radar. - * If {@code radians} > 0 the robot's radar is set to turn right. - * If {@code radians} < 0 the robot's radar is set to turn left. - * If {@code radians} = 0 the robot's radar is set to stop turning. - * @see IStandardRobotPeer#turnRadar(double) turnRadar(double) - * @see #setTurnBody(double) - * @see #setTurnGun(double) - * @see #setMove(double) - */ - void setTurnRadar(double radians); - - /** - * Sets the maximum turn rate of the robot measured in degrees if the robot - * should turn slower than {@link Rules#MAX_TURN_RATE} (10 degress/turn). - * - * @param newMaxTurnRate the new maximum turn rate of the robot measured in - * degrees. Valid values are 0 - {@link Rules#MAX_TURN_RATE} - * @see IBasicRobotPeer#turnBody(double) turnBody(double) - * @see #setTurnBody(double) - * @see #setMaxVelocity(double) - */ - void setMaxTurnRate(double newMaxTurnRate); - - /** - * Sets the maximum velocity of the robot measured in pixels/turn if the - * robot should move slower than {@link Rules#MAX_VELOCITY} (8 pixels/turn). - * - * @param newMaxVelocity the new maximum turn rate of the robot measured in - * pixels/turn. Valid values are 0 - {@link Rules#MAX_VELOCITY} - * @see IBasicRobotPeer#move(double) move(double) - * @see #setMove(double) - * @see #setMaxTurnRate(double) - */ - void setMaxVelocity(double newMaxVelocity); - - /** - * Does not return until a condition is met, i.e. when a - * {@link Condition#test()} returns {@code true}. - *

- * This call executes immediately. - *

- * See the {@code sample.Crazy} robot for how this method can be used. - * - * @param condition the condition that must be met before this call returns - * @see Condition - * @see Condition#test() - */ - void waitFor(Condition condition); - - /** - * Call this during an event handler to allow new events of the same - * priority to restart the event handler. - *

- *

Example: - *

-	 *   public void onScannedRobot(ScannedRobotEvent e) {
-	 *       fire(1);
-	 *       setInterruptible(true);
-	 *       move(100);  // If you see a robot while moving ahead,
-	 *                   // this handler will start from the top
-	 *                   // Without setInterruptible(true), we wouldn't
-	 *                   // receive scan events at all!
-	 *       // We'll only get here if we don't see a robot during the move.
-	 *       getOut().println("Ok, I can't see anyone");
-	 *   }
-	 * 
- * - * @param interruptible {@code true} if the event handler should be - * interrupted if new events of the same priority occurs; {@code false} - * otherwise - * @see #setEventPriority(String, int) - * @see robocode.robotinterfaces.IBasicEvents#onScannedRobot(ScannedRobotEvent) - * onScannedRobot(ScannedRobotEvent) - */ - void setInterruptible(boolean interruptible); - - /** - * Sets the priority of a class of events. - *

- * Events are sent to the onXXX handlers in order of priority. - * Higher priority events can interrupt lower priority events. - * For events with the same priority, newer events are always sent first. - * Valid priorities are 0 - 99, where 100 is reserved and 80 is the default - * priority. - *

- * Example: - *

-	 *   setEventPriority("RobotDeathEvent", 15);
-	 * 
- *

- * The default priorities are, from highest to lowest: - *

-	 *   {@link RoundEndedEvent}:      100 (reserved)
-	 *   {@link BattleEndedEvent}:     100 (reserved)
-	 *   {@link WinEvent}:             100 (reserved)
-	 *   {@link SkippedTurnEvent}:     100 (reserved)
-	 *   {@link StatusEvent}:           99
-	 *   Key and mouse events:  98
-	 *   {@link CustomEvent}:           80 (default value)
-	 *   {@link MessageEvent}:          75
-	 *   {@link RobotDeathEvent}:       70
-	 *   {@link BulletMissedEvent}:     60
-	 *   {@link BulletHitBulletEvent}:  55
-	 *   {@link BulletHitEvent}:        50
-	 *   {@link HitByBulletEvent}:      40
-	 *   {@link HitWallEvent}:          30
-	 *   {@link HitRobotEvent}:         20
-	 *   {@link ScannedRobotEvent}:     10
-	 *   {@link PaintEvent}:             5
-	 *   {@link DeathEvent}:            -1 (reserved)
-	 * 
- *

- * Note that you cannot change the priority for events with the special - * priority value -1 or 100 (reserved) as these event are system events. - * Also note that you cannot change the priority of CustomEvent. - * Instead you must change the priority of the condition(s) for your custom - * event(s). - * - * @param eventClass the name of the event class (string) to set the - * priority for - * @param priority the new priority for that event class - * @see #getEventPriority(String) - * @see #setInterruptible(boolean) - * @since 1.5, the priority of DeathEvent was changed from 100 to -1 in - * order to let robots process pending events on its event queue before - * it dies. When the robot dies, it will not be able to process events. - */ - void setEventPriority(String eventClass, int priority); - - /** - * Returns the current priority of a class of events. - * An event priority is a value from 0 - 99. The higher value, the higher - * priority. - *

- * Example: - *

-	 *   int myHitRobotPriority = getEventPriority("HitRobotEvent");
-	 * 
- *

- * The default priorities are, from highest to lowest: - *

-	 *   {@link RoundEndedEvent}:      100 (reserved)
-	 *   {@link BattleEndedEvent}:     100 (reserved)
-	 *   {@link WinEvent}:             100 (reserved)
-	 *   {@link SkippedTurnEvent}:     100 (reserved)
-	 *   {@link StatusEvent}:           99
-	 *   Key and mouse events:  98
-	 *   {@link CustomEvent}:           80 (default value)
-	 *   {@link MessageEvent}:          75
-	 *   {@link RobotDeathEvent}:       70
-	 *   {@link BulletMissedEvent}:     60
-	 *   {@link BulletHitBulletEvent}:  55
-	 *   {@link BulletHitEvent}:        50
-	 *   {@link HitByBulletEvent}:      40
-	 *   {@link HitWallEvent}:          30
-	 *   {@link HitRobotEvent}:         20
-	 *   {@link ScannedRobotEvent}:     10
-	 *   {@link PaintEvent}:             5
-	 *   {@link DeathEvent}:            -1 (reserved)
-	 * 
- * - * @param eventClass the name of the event class (string) - * @return the current priority of a class of events - * @see #setEventPriority(String, int) - */ - int getEventPriority(String eventClass); - - /** - * Registers a custom event to be called when a condition is met. - * When you are finished with your condition or just want to remove it you - * must call {@link #removeCustomEvent(Condition)}. - *

- * Example: - *

-	 *   // Create the condition for our custom event
-	 *   Condition triggerHitCondition = new Condition("triggerhit") {
-	 *       public boolean test() {
-	 *           return (getEnergy() <= trigger);
-	 *       };
-	 *   }
-	 *
-	 *   // Add our custom event based on our condition
-	 *   addCustomEvent(triggerHitCondition);
-	 * 
- * - * @param condition the condition that must be met. - * @throws NullPointerException if the condition parameter has been set to - * {@code null}. - * @see Condition - * @see #removeCustomEvent(Condition) - */ - void addCustomEvent(Condition condition); - - /** - * Removes a custom event that was previously added by calling - * {@link #addCustomEvent(Condition)}. - *

- * Example: - *

-	 *   // Create the condition for our custom event
-	 *   Condition triggerHitCondition = new Condition("triggerhit") {
-	 *       public boolean test() {
-	 *           return (getEnergy() <= trigger);
-	 *       };
-	 *   }
-	 *
-	 *   // Add our custom event based on our condition
-	 *   addCustomEvent(triggerHitCondition);
-	 *   ...
-	 *   do something with your robot
-	 *   ...
-	 *   // Remove the custom event based on our condition
-	 *   removeCustomEvent(triggerHitCondition);
-	 * 
- * - * @param condition the condition that was previous added and that must be - * removed now. - * @throws NullPointerException if the condition parameter has been set to - * {@code null}. - * @see Condition - * @see #addCustomEvent(Condition) - */ - void removeCustomEvent(Condition condition); - - /** - * Clears out any pending events in the robot's event queue immediately. - * - * @see #getAllEvents() - */ - void clearAllEvents(); - - /** - * Returns a vector containing all events currently in the robot's queue. - * You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (Event event : getAllEvents()) {
-	 *       if (event instanceof HitRobotEvent) {
-	 *           // do something with the event
-	 *       } else if (event instanceof HitByBulletEvent) {
-	 *           // do something with the event
-	 *       }
-	 *   }
-	 * 
- * - * @return a vector containing all events currently in the robot's queue - * @see Event - * @see #clearAllEvents() - * @see #getStatusEvents() - * @see #getScannedRobotEvents() - * @see #getBulletHitEvents() - * @see #getBulletMissedEvents() - * @see #getBulletHitBulletEvents() - * @see #getRobotDeathEvents() - */ - java.util.List getAllEvents(); - - /** - * Returns a vector containing all StatusEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (StatusEvent event : getStatusEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all StatusEvents currently in the robot's - * queue - * @see robocode.robotinterfaces.IBasicEvents#onStatus(StatusEvent) - * onStatus(StatusEvent) - * @see StatusEvent - * @see #getAllEvents() - * @since 1.6.1 - */ - List getStatusEvents(); - - /** - * Returns a vector containing all BulletMissedEvents currently in the - * robot's queue. You might, for example, call this while processing another - * event. - *

- * Example: - *

-	 *   for (BulletMissedEvent event : getBulletMissedEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all BulletMissedEvents currently in the - * robot's queue - * @see robocode.robotinterfaces.IBasicEvents#onBulletMissed(BulletMissedEvent) - * onBulletMissed(BulletMissedEvent) - * @see BulletMissedEvent - * @see #getAllEvents() - */ - List getBulletMissedEvents(); - - /** - * Returns a vector containing all BulletHitBulletEvents currently in the - * robot's queue. You might, for example, call this while processing another - * event. - *

- * Example: - *

-	 *   for (BulletHitBulletEvent event : getBulletHitBulletEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all BulletHitBulletEvents currently in the - * robot's queue - * @see robocode.robotinterfaces.IBasicEvents#onBulletHitBullet(BulletHitBulletEvent) - * onBulletHitBullet(BulletHitBulletEvent) - * @see BulletHitBulletEvent - * @see #getAllEvents() - */ - List getBulletHitBulletEvents(); - - /** - * Returns a vector containing all BulletHitEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (BulletHitEvent event: getBulletHitEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all BulletHitEvents currently in the robot's - * queue - * @see robocode.robotinterfaces.IBasicEvents#onBulletHit(BulletHitEvent) - * onBulletHit(BulletHitEvent) - * @see BulletHitEvent - * @see #getAllEvents() - */ - List getBulletHitEvents(); - - /** - * Returns a vector containing all HitByBulletEvents currently in the - * robot's queue. You might, for example, call this while processing - * another event. - *

- * Example: - *

-	 *   for (HitByBulletEvent event : getHitByBulletEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all HitByBulletEvents currently in the - * robot's queue - * @see robocode.robotinterfaces.IBasicEvents#onHitByBullet(HitByBulletEvent) - * onHitByBullet(HitByBulletEvent) - * @see HitByBulletEvent - * @see #getAllEvents() - */ - List getHitByBulletEvents(); - - /** - * Returns a vector containing all HitRobotEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (HitRobotEvent event : getHitRobotEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all HitRobotEvents currently in the robot's - * queue - * @see robocode.robotinterfaces.IBasicEvents#onHitRobot(HitRobotEvent) - * onHitRobot(HitRobotEvent) - * @see HitRobotEvent - * @see #getAllEvents() - */ - List getHitRobotEvents(); - - /** - * Returns a vector containing all HitWallEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (HitWallEvent event : getHitWallEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all HitWallEvents currently in the robot's - * queue - * @see robocode.robotinterfaces.IBasicEvents#onHitWall(HitWallEvent) - * onHitWall(HitWallEvent) - * @see HitWallEvent - * @see #getAllEvents() - */ - List getHitWallEvents(); - - /** - * Returns a vector containing all RobotDeathEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (RobotDeathEvent event : getRobotDeathEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all RobotDeathEvents currently in the robot's - * queue - * @see robocode.robotinterfaces.IBasicEvents#onRobotDeath(RobotDeathEvent) - * onRobotDeath(RobotDeathEvent) - * @see RobotDeathEvent - * @see #getAllEvents() - */ - List getRobotDeathEvents(); - - /** - * Returns a vector containing all ScannedRobotEvents currently in the - * robot's queue. You might, for example, call this while processing another - * event. - *

- * Example: - *

-	 *   for (ScannedRobotEvent event : getScannedRobotEvents()) {
-	 *       // do something with the event
-	 *   }
-	 * 
- * - * @return a vector containing all ScannedRobotEvents currently in the - * robot's queue - * @see robocode.robotinterfaces.IBasicEvents#onScannedRobot(ScannedRobotEvent) - * onScannedRobot(ScannedRobotEvent) - * @see ScannedRobotEvent - * @see #getAllEvents() - */ - List getScannedRobotEvents(); - - /** - * Returns a file representing a data directory for the robot, which can be - * written to using {@link RobocodeFileOutputStream} or - * {@link RobocodeFileWriter}. - *

- * The system will automatically create the directory for you, so you do not - * need to create it by yourself. - * - * @return a file representing the data directory for your robot - * @see #getDataFile(String) - * @see RobocodeFileOutputStream - * @see RobocodeFileWriter - */ - File getDataDirectory(); - - /** - * Returns a file in your data directory that you can write to using - * {@link RobocodeFileOutputStream} or {@link RobocodeFileWriter}. - *

- * The system will automatically create the directory for you, so you do not - * need to create it by yourself. - *

- * Please notice that the max. size of your data file is set to 200000 - * (~195 KB). - *

- * See the {@code sample.SittingDuck} to see an example of how to use this - * method. - * - * @param filename the file name of the data file for your robot - * @return a file representing the data file for your robot - * @see #getDataDirectory() - * @see RobocodeFileOutputStream - * @see RobocodeFileWriter - */ - File getDataFile(String filename); - - /** - * Returns the data quota available in your data directory, i.e. the amount - * of bytes left in the data directory for the robot. - * - * @return the amount of bytes left in the robot's data directory - * @see #getDataDirectory() - * @see #getDataFile(String) - */ - long getDataQuotaAvailable(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IBasicRobotPeer.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IBasicRobotPeer.java deleted file mode 100644 index 103945f..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IBasicRobotPeer.java +++ /dev/null @@ -1,738 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces.peer; - - -import robocode.*; -import robocode.robotinterfaces.IBasicEvents; - -import java.awt.*; - - -/** - * The basic robot peer for all robot types.

- * - * NOTE: This is private interface. You should build any external component (or robot) - * based on it's current methods because it will change in the future.

- * - * A robot peer is the object that deals with game mechanics and rules, and - * makes sure your robot abides by them. - * - * @see IStandardRobotPeer - * @see IAdvancedRobotPeer - * @see ITeamRobotPeer - * @see IJuniorRobotPeer - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IBasicRobotPeer { - - /** - * Returns the robot's name. - * - * @return the robot's name. - */ - String getName(); - - /** - * Returns the game time of the current round, where the time is equal to - * the current turn in the round. - *

- * A battle consists of multiple rounds. - *

- * Time is reset to 0 at the beginning of every round. - * - * @return the game time/turn of the current round. - */ - long getTime(); - - /** - * Returns the robot's current energy. - * - * @return the robot's current energy. - */ - double getEnergy(); - - /** - * Returns the X position of the robot. (0,0) is at the bottom left of the - * battlefield. - * - * @return the X position of the robot. - * @see #getY() - */ - double getX(); - - /** - * Returns the Y position of the robot. (0,0) is at the bottom left of the - * battlefield. - * - * @return the Y position of the robot. - * @see #getX() - */ - double getY(); - - /** - * Returns the velocity of the robot measured in pixels/turn. - *

- * The maximum velocity of a robot is defined by - * {@link Rules#MAX_VELOCITY} (8 pixels / turn). - * - * @return the velocity of the robot measured in pixels/turn. - * @see Rules#MAX_VELOCITY - */ - double getVelocity(); - - /** - * Returns the direction that the robot's body is facing, in radians. - * The value returned will be between 0 and 2 * PI (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * PI / 2 means East, PI means South, and 3 * PI / 2 means West. - * - * @return the direction that the robot's body is facing, in radians. - * @see #getGunHeading() - * @see #getRadarHeading() - */ - double getBodyHeading(); - - /** - * Returns the direction that the robot's gun is facing, in radians. - * The value returned will be between 0 and 2 * PI (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * PI / 2 means East, PI means South, and 3 * PI / 2 means West. - * - * @return the direction that the robot's gun is facing, in radians. - * @see #getBodyHeading() - * @see #getRadarHeading() - */ - double getGunHeading(); - - /** - * Returns the direction that the robot's radar is facing, in radians. - * The value returned will be between 0 and 2 * PI (is excluded). - *

- * Note that the heading in Robocode is like a compass, where 0 means North, - * PI / 2 means East, PI means South, and 3 * PI / 2 means West. - * - * @return the direction that the robot's radar is facing, in radians. - * @see #getBodyHeading() - * @see #getGunHeading() - */ - double getRadarHeading(); - - /** - * Returns the current heat of the gun. The gun cannot fire unless this is - * 0. (Calls to fire will succeed, but will not actually fire unless - * getGunHeat() == 0). - *

- * The amount of gun heat generated when the gun is fired is - * 1 + (firePower / 5). Each turn the gun heat drops by the amount returned - * by {@link #getGunCoolingRate()}, which is a battle setup. - *

- * Note that all guns are "hot" at the start of each round, where the gun - * heat is 3. - * - * @return the current gun heat - * @see #getGunCoolingRate() - * @see #setFire(double) - */ - double getGunHeat(); - - /** - * Returns the width of the current battlefield measured in pixels. - * - * @return the width of the current battlefield measured in pixels. - */ - double getBattleFieldWidth(); - - /** - * Returns the height of the current battlefield measured in pixels. - * - * @return the height of the current battlefield measured in pixels. - */ - double getBattleFieldHeight(); - - /** - * Returns how many opponents that are left in the current round. - * - * @return how many opponents that are left in the current round. - * @see #getNumSentries() - */ - int getOthers(); - - /** - * Returns how many sentry robots that are left in the current round. - * - * @return how many sentry robots that are left in the current round. - * @see #getOthers() - * @since 1.9.1.0 - */ - int getNumSentries(); - - /** - * Returns the number of rounds in the current battle. - * - * @return the number of rounds in the current battle. - * @see #getRoundNum() - */ - int getNumRounds(); - - /** - * Returns the number of the current round (0 to {@link #getNumRounds()} - 1) - * in the battle. - * - * @return the number of the current round in the battle (zero indexed). - * @see #getNumRounds() - */ - int getRoundNum(); - - /** - * Returns the sentry border size for a {@link robocode.BorderSentry BorderSentry} that defines the how - * far a BorderSentry is allowed to move from the border edges measured in units.
- * Hence, the sentry border size defines the width/range of the border area surrounding the battlefield that - * BorderSentrys cannot leave (sentry robots robots must stay in the border area), but it also define the - * distance from the border edges where BorderSentrys are allowed/able to make damage to robots entering this - * border area. - * - * @return the border size in units/pixels. - * - * @since 1.9.0.0 - */ - int getSentryBorderSize(); - - /** - * Returns the rate at which the gun will cool down, i.e. the amount of heat - * the gun heat will drop per turn. - *

- * The gun cooling rate is default 0.1 / turn, but can be changed by the - * battle setup. So don't count on the cooling rate being 0.1! - * - * @return the gun cooling rate - * @see #getGunHeat() - * @see #setFire(double) - */ - double getGunCoolingRate(); - - /** - * Returns the distance remaining in the robot's current move measured in - * pixels. - *

- * This call returns both positive and negative values. Positive values - * means that the robot is currently moving forwards. Negative values means - * that the robot is currently moving backwards. If the returned value is 0, - * the robot currently stands still. - * - * @return the distance remaining in the robot's current move measured in - * pixels. - * @see #getBodyTurnRemaining() - * @see #getGunTurnRemaining() - * @see #getRadarTurnRemaining() - */ - double getDistanceRemaining(); - - /** - * Returns the angle remaining in the robot's turn, in radians. - *

- * This call returns both positive and negative values. Positive values - * means that the robot is currently turning to the right. Negative values - * means that the robot is currently turning to the left. - * - * @return the angle remaining in the robot's turn, in radians - * @see #getDistanceRemaining() - * @see #getGunTurnRemaining() - * @see #getRadarTurnRemaining() - */ - double getBodyTurnRemaining(); - - /** - * Returns the angle remaining in the gun's turn, in radians. - *

- * This call returns both positive and negative values. Positive values - * means that the gun is currently turning to the right. Negative values - * means that the gun is currently turning to the left. - * - * @return the angle remaining in the gun's turn, in radians - * @see #getDistanceRemaining() - * @see #getBodyTurnRemaining() - * @see #getRadarTurnRemaining() - */ - double getGunTurnRemaining(); - - /** - * Returns the angle remaining in the radar's turn, in radians. - *

- * This call returns both positive and negative values. Positive values - * means that the radar is currently turning to the right. Negative values - * means that the radar is currently turning to the left. - * - * @return the angle remaining in the radar's turn, in radians - * @see #getDistanceRemaining() - * @see #getBodyTurnRemaining() - * @see #getGunTurnRemaining() - */ - double getRadarTurnRemaining(); - - /** - * Executes any pending actions, or continues executing actions that are - * in process. This call returns after the actions have been started. - *

- * Note that advanced robots must call this function in order to - * execute pending set* calls like e.g. {@link - * IAdvancedRobotPeer#setMove(double) setMove(double)}, - * {@link IAdvancedRobotPeer#setFire(double) setFire(double)}, {@link - * IAdvancedRobotPeer#setTurnBody(double) setTurnBody(double)} etc. - * Otherwise, these calls will never get executed. - *

- * In this example the robot will move while turning: - *

-	 *   setTurnBody(90);
-	 *   setMove(100);
-	 *   execute();
-	 * 

- * while (getDistanceRemaining() > 0 && getTurnRemaining() > 0) { - * execute(); - * } - *

- */ - void execute(); - - /** - * Immediately moves your robot forward or backward by distance measured in - * pixels. - *

- * This call executes immediately, and does not return until it is complete, - * i.e. when the remaining distance to move is 0. - *

- * If the robot collides with a wall, the move is complete, meaning that the - * robot will not move any further. If the robot collides with another - * robot, the move is complete if you are heading toward the other robot. - *

- * Note that both positive and negative values can be given as input, where - * positive values means that the robot is set to move forward, and negative - * values means that the robot is set to move backward. - *

- * Example: - *

-	 *   // Move the robot 100 pixels forward
-	 *   ahead(100);
-	 * 

- * // Afterwards, move the robot 50 pixels backward - * ahead(-50); - *

- * - * @param distance the distance to move measured in pixels. - * If {@code distance} > 0 the robot is set to move forward. - * If {@code distance} < 0 the robot is set to move backward. - * If {@code distance} = 0 the robot will not move anywhere, but just - * finish its turn. - * @see robocode.robotinterfaces.IBasicEvents#onHitWall(robocode.HitWallEvent) - * @see robocode.robotinterfaces.IBasicEvents#onHitRobot(robocode.HitRobotEvent) - */ - void move(double distance); - - /** - * Immediately turns the robot's body to the right or left by radians. - * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the body's turn is 0. - *

- * Note that both positive and negative values can be given as input, where - * positive values means that the robot's body is set to turn right, and - * negative values means that the robot's body is set to turn left. - * If 0 is given as input, the robot's body will stop turning. - *

- * Example: - *

-	 *   // Turn the robot's body 180 degrees to the right
-	 *   turnBody(Math.PI);
-	 * 

- * // Afterwards, turn the robot's body 90 degrees to the left - * turnBody(-Math.PI / 2); - *

- * - * @param radians the amount of radians to turn the robot's body. - * If {@code radians} > 0 the robot's body is set to turn right. - * If {@code radians} < 0 the robot's body is set to turn left. - * If {@code radians} = 0 the robot's body is set to stop turning. - * @see #turnGun(double) - * @see IStandardRobotPeer#turnRadar(double) turnRadar(double) - * @see #move(double) - */ - void turnBody(double radians); - - /** - * Immediately turns the robot's gun to the right or left by radians. - * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the gun's turn is 0. - *

- * Note that both positive and negative values can be given as input, where - * positive values means that the robot's gun is set to turn right, and - * negative values means that the robot's gun is set to turn left. - * If 0 is given as input, the robot's gun will stop turning. - *

- * Example: - *

-	 *   // Turn the robot's gun 180 degrees to the right
-	 *   turnGun(Math.PI);
-	 * 

- * // Afterwards, turn the robot's gun 90 degrees to the left - * turnGun(-Math.PI / 2); - *

- * - * @param radians the amount of radians to turn the robot's gun. - * If {@code radians} > 0 the robot's gun is set to turn right. - * If {@code radians} < 0 the robot's gun is set to turn left. - * If {@code radians} = 0 the robot's gun is set to stop turning. - * @see #turnBody(double) - * @see IStandardRobotPeer#turnRadar(double) turnRadar(double) - * @see #move(double) - */ - void turnGun(double radians); - - /** - * Immediately fires a bullet. The bullet will travel in the direction the - * gun is pointing. - *

- * The specified bullet power is an amount of energy that will be taken from - * the robot's energy. Hence, the more power you want to spend on the - * bullet, the more energy is taken from your robot. - *

- * The bullet will do (4 * power) damage if it hits another robot. If power - * is greater than 1, it will do an additional 2 * (power - 1) damage. - * You will get (3 * power) back if you hit the other robot. You can call - * {@link Rules#getBulletDamage(double)} for getting the damage that a - * bullet with a specific bullet power will do. - *

- * The specified bullet power should be between - * {@link Rules#MIN_BULLET_POWER} and {@link Rules#MAX_BULLET_POWER}. - *

- * Note that the gun cannot fire if the gun is overheated, meaning that - * {@link #getGunHeat()} returns a value > 0. - *

- * A event is generated when the bullet hits a robot - * ({@link BulletHitEvent}), wall ({@link BulletMissedEvent}), or another - * bullet ({@link BulletHitBulletEvent}). - *

- * Example: - *

-	 *   // Fire a bullet with maximum power if the gun is ready
-	 *   if (getGunHeat() == 0) {
-	 *       Bullet bullet = fire(Rules.MAX_BULLET_POWER);
-	 * 

- * // Get the velocity of the bullet - * if (bullet != null) { - * double bulletVelocity = bullet.getVelocity(); - * } - * } - *

- * - * @param power the amount of energy given to the bullet, and subtracted - * from the robot's energy. - * @return a {@link Bullet} that contains information about the bullet if it - * was actually fired, which can be used for tracking the bullet after it - * has been fired. If the bullet was not fired, {@code null} is returned. - * @see #setFire(double) - * @see Bullet - * @see #getGunHeat() - * @see #getGunCoolingRate() - * @see robocode.robotinterfaces.IBasicEvents#onBulletHit(BulletHitEvent) - * onBulletHit(BulletHitEvent) - * @see robocode.robotinterfaces.IBasicEvents#onBulletHitBullet(BulletHitBulletEvent) - * onBulletHitBullet(BulletHitBulletEvent) - * @see robocode.robotinterfaces.IBasicEvents#onBulletMissed(BulletMissedEvent) - * onBulletMissed(BulletMissedEvent) - */ - Bullet fire(double power); - - /** - * Sets the gun to fire a bullet when the next execution takes place. - * The bullet will travel in the direction the gun is pointing. - *

- * This call returns immediately, and will not execute until you call - * execute() or take an action that executes. - *

- * The specified bullet power is an amount of energy that will be taken from - * the robot's energy. Hence, the more power you want to spend on the - * bullet, the more energy is taken from your robot. - *

- * The bullet will do (4 * power) damage if it hits another robot. If power - * is greater than 1, it will do an additional 2 * (power - 1) damage. - * You will get (3 * power) back if you hit the other robot. You can call - * {@link Rules#getBulletDamage(double)} for getting the damage that a - * bullet with a specific bullet power will do. - *

- * The specified bullet power should be between - * {@link Rules#MIN_BULLET_POWER} and {@link Rules#MAX_BULLET_POWER}. - *

- * Note that the gun cannot fire if the gun is overheated, meaning that - * {@link #getGunHeat()} returns a value > 0. - *

- * A event is generated when the bullet hits a robot - * ({@link BulletHitEvent}), wall ({@link BulletMissedEvent}), or another - * bullet ({@link BulletHitBulletEvent}). - *

- * Example: - *

-	 *   Bullet bullet = null;
-	 * 

- * // Fire a bullet with maximum power if the gun is ready - * if (getGunHeat() == 0) { - * bullet = setFireBullet(Rules.MAX_BULLET_POWER); - * } - * ... - * execute(); - * ... - * // Get the velocity of the bullet - * if (bullet != null) { - * double bulletVelocity = bullet.getVelocity(); - * } - *

- * - * @param power the amount of energy given to the bullet, and subtracted - * from the robot's energy. - * @return a {@link Bullet} that contains information about the bullet if it - * was actually fired, which can be used for tracking the bullet after it - * has been fired. If the bullet was not fired, {@code null} is returned. - * @see #fire(double) - * @see Bullet - * @see #getGunHeat() - * @see #getGunCoolingRate() - * @see robocode.robotinterfaces.IBasicEvents#onBulletHit(BulletHitEvent) - * onBulletHit(BulletHitEvent) - * @see robocode.robotinterfaces.IBasicEvents#onBulletHitBullet(BulletHitBulletEvent) - * onBulletHitBullet(BulletHitBulletEvent) - * @see robocode.robotinterfaces.IBasicEvents#onBulletMissed(BulletMissedEvent) - * onBulletMissed(BulletMissedEvent) - */ - Bullet setFire(double power); - - /** - * Sets the color of the robot's body. - *

- * A {@code null} indicates the default (blue) color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 * 

- * public void run() { - * setBodyColor(Color.BLACK); - * ... - * } - *

- * - * @param color the new body color - * @see #setGunColor(Color) - * @see #setRadarColor(Color) - * @see #setBulletColor(Color) - * @see #setScanColor(Color) - * @see Color - * @since 1.1.2 - */ - void setBodyColor(Color color); - - /** - * Sets the color of the robot's gun. - *

- * A {@code null} indicates the default (blue) color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 * 

- * public void run() { - * setGunColor(Color.RED); - * ... - * } - *

- * - * @param color the new gun color - * @see #setBodyColor(Color) - * @see #setRadarColor(Color) - * @see #setBulletColor(Color) - * @see #setScanColor(Color) - * @see Color - * @since 1.1.2 - */ - void setGunColor(Color color); - - /** - * Sets the color of the robot's radar. - *

- * A {@code null} indicates the default (blue) color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 * 

- * public void run() { - * setRadarColor(Color.YELLOW); - * ... - * } - *

- * - * @param color the new radar color - * @see #setBodyColor(Color) - * @see #setGunColor(Color) - * @see #setBulletColor(Color) - * @see #setScanColor(Color) - * @see Color - * @since 1.1.2 - */ - void setRadarColor(Color color); - - /** - * Sets the color of the robot's bullets. - *

- * A {@code null} indicates the default white color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 * 

- * public void run() { - * setBulletColor(Color.GREEN); - * ... - * } - *

- * - * @param color the new bullet color - * @see #setBodyColor(Color) - * @see #setGunColor(Color) - * @see #setRadarColor(Color) - * @see #setScanColor(Color) - * @see Color - * @since 1.1.2 - */ - void setBulletColor(Color color); - - /** - * Sets the color of the robot's scan arc. - *

- * A {@code null} indicates the default (blue) color. - *

- *

-	 * Example:
-	 *   // Don't forget to import java.awt.Color at the top...
-	 *   import java.awt.Color;
-	 *   ...
-	 * 

- * public void run() { - * setScanColor(Color.WHITE); - * ... - * } - *

- * - * @param color the new scan arc color - * @see #setBodyColor(Color) - * @see #setGunColor(Color) - * @see #setRadarColor(Color) - * @see #setBulletColor(Color) - * @see Color - * @since 1.1.2 - */ - void setScanColor(Color color); - - /** - * This call must be made from a robot call to inform the game - * that the robot made a {@code get*} call like e.g. {@link #getX()} or - * {@link #getVelocity()}. - *

- * This method is used by the game to determine if the robot is inactive or - * not. Note: You should only make this call once in a {@code get*} method! - * - * @see #setCall() - */ - void getCall(); - - /** - * This call must be made from a robot call to inform the game - * that the robot made a {@code set*} call like e.g. {@link - * #setFire(double)} or {@link #setBodyColor(Color)}. - *

- * This method is used by the game to determine if the robot is inactive or - * not. Note: You should only make this call once in a {@code set*} method! - * - * @see #getCall() - */ - void setCall(); - - /** - * Returns a graphics context used for painting graphical items for the robot. - *

- * This method is very useful for debugging your robot. - *

- * Note that the robot will only be painted if the "Paint" is enabled on the - * robot's console window; otherwise the robot will never get painted (the - * reason being that all robots might have graphical items that must be - * painted, and then you might not be able to tell what graphical items that - * have been painted for your robot). - *

- * Also note that the coordinate system for the graphical context where you - * paint items fits for the Robocode coordinate system where (0, 0) is at - * the bottom left corner of the battlefield, where X is towards right and Y - * is upwards. - * - * @return a graphics context used for painting graphical items for the robot. - * @see robocode.robotinterfaces.IPaintEvents#onPaint(Graphics2D) - * @since 1.6.1 - */ - Graphics2D getGraphics(); - - /** - * Sets the debug property with the specified key to the specified value. - *

- * This method is very useful when debugging or reviewing your robot as you - * will be able to see this property displayed in the robot console for your - * robots under the Debug Properties tab page. - * - * @param key the name/key of the debug property. - * @param value the new value of the debug property, where {@code null} or - * the empty string is used for removing this debug property. - * @since 1.6.2 - */ - void setDebugProperty(String key, String value); - - /** - * Rescan for other robots. This method is called automatically by the game, - * as long as the robot is moving, turning its body, turning its gun, or - * turning its radar. - *

- * Rescan will cause {@link IBasicEvents#onScannedRobot(ScannedRobotEvent) - * onScannedRobot(ScannedRobotEvent)} to be called if you see a robot. - *

- * There are 2 reasons to call {@code rescan()} manually: - *

    - *
  1. You want to scan after you stop moving. - *
  2. You want to interrupt the {@code onScannedRobot} event. This is more - * likely. If you are in {@code onScannedRobot} and call {@code scan()}, - * and you still see a robot, then the system will interrupt your - * {@code onScannedRobot} event immediately and start it from the top. - *
- *

- * This call executes immediately. - * - * @see IBasicEvents#onScannedRobot(ScannedRobotEvent) - * onScannedRobot(ScannedRobotEvent) - * @see ScannedRobotEvent - * - * @since 1.7.2 - */ - void rescan(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IJuniorRobotPeer.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IJuniorRobotPeer.java deleted file mode 100644 index 300ece1..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IJuniorRobotPeer.java +++ /dev/null @@ -1,67 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces.peer; - - -/** - * The junior robot peer for junior robot types like {@link robocode.JuniorRobot}. - *

- * A robot peer is the object that deals with game mechanics and rules, and - * makes sure your robot abides by them. - * - * @see IBasicRobotPeer - * @see IStandardRobotPeer - * @see IAdvancedRobotPeer - * @see ITeamRobotPeer - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IJuniorRobotPeer extends IBasicRobotPeer { - - /** - * Moves this robot forward or backwards by pixels and turns this robot - * right or left by degrees at the same time. The robot will move in a curve - * that follows a perfect circle, and the moving and turning will end at - * exactly the same time. - *

- * Note that the max. velocity and max. turn rate is automatically adjusted, - * which means that the robot will move slower the sharper the turn is - * compared to the distance. - *

- * Note that both positive and negative values can be given as input: - *

    - *
  • If the {@code distance} parameter is set to a positive value, it - * means that the robot is set to move forward, and a negative value means - * that the robot is set to move backward. If set to 0, the robot will not - * move, but will be able to turn. - *
  • If the {@code radians} parameter is set to a positive value, it means - * that the robot is set to turn to the right, and a negative value means - * that the robot is set to turn to the left. If set to 0, the robot will - * not turn, but will be able to move. - *
- * - * @param distance the distance to move measured in pixels. - * If {@code distance} > 0 the robot is set to move forward. - * If {@code distance} < 0 the robot is set to move backward. - * If {@code distance} = 0 the robot will not move anywhere, but just - * finish its turn. - * @param radians the amount of radians to turn the robot's body. - * If {@code radians} > 0 the robot's body is set to turn right. - * If {@code radians} < 0 the robot's body is set to turn left. - * If {@code radians} = 0 the robot's body is set to stop turning. - * @see IBasicRobotPeer#move(double) move(double) - * @see IBasicRobotPeer#turnBody(double) turnBody(double) - * @see IBasicRobotPeer#getBodyHeading() getBodyHeading() - * @see IBasicRobotPeer#getX() getX() - * @see IBasicRobotPeer#getY() getY() - */ - void turnAndMove(double distance, double radians); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IStandardRobotPeer.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IStandardRobotPeer.java deleted file mode 100644 index dd29d3c..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/IStandardRobotPeer.java +++ /dev/null @@ -1,205 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces.peer; - - -/** - * The standard robot peer for standard robot types like {@link robocode.Robot}, - * {@link robocode.AdvancedRobot}, and {@link robocode.TeamRobot}. - *

- * A robot peer is the object that deals with game mechanics and rules, and - * makes sure your robot abides by them. - * - * @see IBasicRobotPeer - * @see IAdvancedRobotPeer - * @see ITeamRobotPeer - * @see IJuniorRobotPeer - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface IStandardRobotPeer extends IBasicRobotPeer { - - /** - * Immediately stops all movement, and saves it for a call to - * {@link #resume()}. If there is already movement saved from a previous - * stop, you can overwrite it by calling {@code stop(true)}. - * - * @param overwrite If there is already movement saved from a previous stop, - * you can overwrite it by calling {@code stop(true)}. - * @see #resume() - */ - void stop(boolean overwrite); - - /** - * Immediately resumes the movement you stopped by {@link #stop(boolean)}, - * if any. - *

- * This call executes immediately, and does not return until it is complete. - * - * @see #stop(boolean) - */ - void resume(); - - /** - * Immediately turns the robot's radar to the right or left by radians. - * This call executes immediately, and does not return until it is complete, - * i.e. when the angle remaining in the radar's turn is 0. - *

- * Note that both positive and negative values can be given as input, where - * positive values means that the robot's radar is set to turn right, and - * negative values means that the robot's radar is set to turn left. - * If 0 is given as input, the robot's radar will stop turning. - *

- * Example: - *

-	 *   // Turn the robot's radar 180 degrees to the right
-	 *   turnRadar(Math.PI);
-	 *
-	 *   // Afterwards, turn the robot's radar 90 degrees to the left
-	 *   turnRadar(-Math.PI / 2);
-	 * 
- * - * @param radians the amount of radians to turn the robot's radar. - * If {@code radians} > 0 the robot's radar is set to turn right. - * If {@code radians} < 0 the robot's radar is set to turn left. - * If {@code radians} = 0 the robot's radar is set to stop turning. - * @see #turnBody(double) - * @see #turnGun(double) - * @see #move(double) - */ - void turnRadar(double radians); - - /** - * Sets the gun to turn independent from the robot's turn. - *

- * Ok, so this needs some explanation: The gun is mounted on the robot's - * body. So, normally, if the robot turns 90 degrees to the right, then the - * gun will turn with it as it is mounted on top of the robot's body. To - * compensate for this, you can call {@code setAdjustGunForBodyTurn(true)}. - * When this is set, the gun will turn independent from the robot's turn, - * i.e. the gun will compensate for the robot's body turn. - *

- * Note: This method is additive until you reach the maximum the gun can - * turn. The "adjust" is added to the amount you set for turning the robot, - * then capped by the physics of the game. If you turn infinite, then the - * adjust is ignored (and hence overridden). - *

- * Example, assuming both the robot and gun start out facing up (0 degrees): - *

-	 *   // Set gun to turn with the robot's turn
-	 *   setAdjustGunForBodyTurn(false); // This is the default
-	 *   turnBodyRight(Math.PI / 2);
-	 *   // At this point, both the robot and gun are facing right (90 degrees)
-	 *   turnBodyLeft(Math.PI / 2);
-	 *   // Both are back to 0 degrees
-	 *
-	 *   -- or --
-	 *
-	 *   // Set gun to turn independent from the robot's turn
-	 *   setAdjustGunForBodyTurn(true);
-	 *   turnBodyRight(Math.PI / 2);
-	 *   // At this point, the robot is facing right (90 degrees), but the gun is still facing up.
-	 *   turnBodyLeft(Math.PI / 2);
-	 *   // Both are back to 0 degrees.
-	 * 
- *

- * Note: The gun compensating this way does count as "turning the gun". - * See {@link #setAdjustRadarForGunTurn(boolean)} for details. - * - * @param independent {@code true} if the gun must turn independent from the - * robot's turn; {@code false} if the gun must turn with the robot's turn. - * @see #setAdjustRadarForGunTurn(boolean) - */ - void setAdjustGunForBodyTurn(boolean independent); - - /** - * Sets the radar to turn independent from the gun's turn. - *

- * Ok, so this needs some explanation: The radar is mounted on the robot's - * gun. So, normally, if the gun turns 90 degrees to the right, then the - * radar will turn with it as it is mounted on top of the gun. To compensate - * for this, you can call {@code setAdjustRadarForGunTurn(true)}. When this - * is set, the radar will turn independent from the robot's turn, i.e. the - * radar will compensate for the gun's turn. - *

- * Note: This method is additive until you reach the maximum the radar can - * turn. The "adjust" is added to the amount you set for turning the robot, - * then capped by the physics of the game. If you turn infinite, then the - * adjust is ignored (and hence overridden). - *

- * Example, assuming both the gun and radar start out facing up (0 degrees): - *

-	 *   // Set radar to turn with the gun's turn
-	 *   setAdjustRadarForGunTurn(false); // This is the default
-	 *   turnGunRight(Math.PI / 2);
-	 *   // At this point, both the radar and gun are facing right (90 degrees);
-	 *
-	 *   -- or --
-	 *
-	 *   // Set radar to turn independent from the gun's turn
-	 *   setAdjustRadarForGunTurn(true);
-	 *   turnGunRight(Math.PI / 2);
-	 *   // At this point, the gun is facing right (90 degrees), but the radar is still facing up.
-	 * 
- * Note: Calling {@code setAdjustRadarForGunTurn(boolean)} will - * automatically call {@link #setAdjustRadarForBodyTurn(boolean)} with the - * same value, unless you have already called it earlier. This behavior is - * primarily for backward compatibility with older Robocode robots. - * - * @param independent {@code true} if the radar must turn independent from - * the gun's turn; {@code false} if the radar must turn with the gun's - * turn. - * @see #setAdjustRadarForBodyTurn(boolean) - * @see #setAdjustGunForBodyTurn(boolean) - */ - void setAdjustRadarForGunTurn(boolean independent); - - /** - * Sets the radar to turn independent from the robot's turn. - *

- * Ok, so this needs some explanation: The radar is mounted on the gun, and - * the gun is mounted on the robot's body. So, normally, if the robot turns - * 90 degrees to the right, the gun turns, as does the radar. Hence, if the - * robot turns 90 degrees to the right, then the gun and radar will turn - * with it as the radar is mounted on top of the gun. To compensate for - * this, you can call {@code setAdjustRadarForBodyTurn(true)}. When this is - * set, the radar will turn independent from the robot's turn, i.e. the - * radar will compensate for the robot's turn. - *

- * Note: This method is additive until you reach the maximum the radar can - * turn. The "adjust" is added to the amount you set for turning the gun, - * then capped by the physics of the game. If you turn infinite, then the - * adjust is ignored (and hence overridden). - *

- * Example, assuming the robot, gun, and radar all start out facing up (0 - * degrees): - *

-	 *   // Set radar to turn with the robots's turn
-	 *   setAdjustRadarForBodyTurn(false); // This is the default
-	 *   turnRight(Math.PI / 2);
-	 *   // At this point, the body, gun, and radar are all facing right (90 degrees);
-	 *
-	 *   -- or --
-	 *
-	 *   // Set radar to turn independent from the robot's turn
-	 *   setAdjustRadarForBodyTurn(true);
-	 *   turnRight(Math.PI / 2);
-	 *   // At this point, the robot and gun are facing right (90 degrees), but the radar is still facing up.
-	 * 
- * - * @param independent {@code true} if the radar must turn independent from - * the robots's turn; {@code false} if the radar must turn with the robot's - * turn. - * @see #setAdjustGunForBodyTurn(boolean) - * @see #setAdjustRadarForGunTurn(boolean) - */ - void setAdjustRadarForBodyTurn(boolean independent); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/ITeamRobotPeer.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/ITeamRobotPeer.java deleted file mode 100644 index 4bc8400..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/ITeamRobotPeer.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.robotinterfaces.peer; - - -import robocode.MessageEvent; - -import java.io.IOException; -import java.io.Serializable; -import java.util.List; - - -/** - * The team robot peer for team robots like {@link robocode.TeamRobot}. - *

- * A robot peer is the object that deals with game mechanics and rules, and - * makes sure your robot abides by them. - * - * @see IBasicRobotPeer - * @see IStandardRobotPeer - * @see IAdvancedRobotPeer - * @see IJuniorRobotPeer - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6 - */ -public interface ITeamRobotPeer extends IAdvancedRobotPeer { - - /** - * Returns the names of all teammates, or {@code null} there is no - * teammates. - *

- * Example: - *

-	 *   public void run() {
-	 *       // Prints out all teammates
-	 *       String[] teammates = getTeammates();
-	 *       if (teammates != null) {
-	 *           for (String member : teammates) {
-	 *               out.println(member);
-	 *           }
-	 *       }
-	 *   }
-	 * 
- * - * @return a String array containing the names of all your teammates, or - * {@code null} if there is no teammates. The length of the String array - * is equal to the number of teammates. - * @see #isTeammate(String) - * @see #broadcastMessage(Serializable) - * @see #sendMessage(String, Serializable) - */ - String[] getTeammates(); - - /** - * Checks if a given robot name is the name of one of your teammates. - *

- * Example: - *

-	 *   public void onScannedRobot(ScannedRobotEvent e) {
-	 *       if (isTeammate(e.getName()) {
-	 *           return;
-	 *       }
-	 *       fire(1);
-	 *   }
-	 * 
- * - * @param name the robot name to check - * @return {@code true} if the specified name belongs to one of your - * teammates; {@code false} otherwise. - * @see #getTeammates() - * @see #broadcastMessage(Serializable) - * @see #sendMessage(String, Serializable) - */ - boolean isTeammate(String name); - - /** - * Broadcasts a message to all teammates. - *

- * Example: - *

-	 *   public void run() {
-	 *       broadcastMessage("I'm here!");
-	 *   }
-	 * 
- * - * @param message the message to broadcast to all teammates - * @throws IOException if the message could not be broadcasted to the - * teammates - * @see #isTeammate(String) - * @see #getTeammates() - * @see #sendMessage(String, Serializable) - */ - void broadcastMessage(Serializable message) throws IOException; - - /** - * Sends a message to one (or more) teammates. - *

- * Example: - *

-	 *   public void run() {
-	 *       sendMessage("sample.DroidBot", "I'm here!");
-	 *   }
-	 * 
- * - * @param name the name of the intended recipient of the message - * @param message the message to send - * @throws IOException if the message could not be sent - * @see #isTeammate(String) - * @see #getTeammates() - * @see #broadcastMessage(Serializable) - */ - void sendMessage(String name, Serializable message) throws IOException; - - /** - * Returns a vector containing all MessageEvents currently in the robot's - * queue. You might, for example, call this while processing another event. - *

- * Example: - *

-	 *   for (MessageEvent e : getMessageEvents()) {
-	 *      // do something with e
-	 *   }
-	 * 
- * - * @return a vector containing all MessageEvents currently in the robot's - * queue - * @see robocode.robotinterfaces.ITeamEvents#onMessageReceived(MessageEvent) - * onMessageReceived(MessageEvent) - * @see MessageEvent - * @since 1.2.6 - */ - List getMessageEvents(); -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/package-info.java b/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/package-info.java deleted file mode 100644 index a0d2b8f..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/robotinterfaces/peer/package-info.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - -/** - * Robot peers available for implementing new robot types based on the Robot Interfaces. - */ -package robocode.robotinterfaces.peer; diff --git a/workspace_robo/robocode.api/src/main/java/robocode/util/Utils.java b/workspace_robo/robocode.api/src/main/java/robocode/util/Utils.java deleted file mode 100644 index 2b0f87a..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/util/Utils.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode.util; - - -import robocode.control.RandomFactory; - -import static java.lang.Math.PI; -import java.util.Random; - - -/** - * Utility class that provide methods for normalizing angles. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class Utils { - - private final static double TWO_PI = 2 * PI; - private final static double THREE_PI_OVER_TWO = 3 * PI / 2; - private final static double PI_OVER_TWO = PI / 2; - public static final double NEAR_DELTA = .00001; - - // Hide the default constructor as this class only provides static method - private Utils() {} - - /** - * Normalizes an angle to an absolute angle. - * The normalized angle will be in the range from 0 to 2*PI, where 2*PI - * itself is not included. - * - * @param angle the angle to normalize - * @return the normalized angle that will be in the range of [0,2*PI[ - */ - public static double normalAbsoluteAngle(double angle) { - return (angle %= TWO_PI) >= 0 ? angle : (angle + TWO_PI); - } - - /** - * Normalizes an angle to an absolute angle. - * The normalized angle will be in the range from 0 to 360, where 360 - * itself is not included. - * - * @param angle the angle to normalize - * @return the normalized angle that will be in the range of [0,360[ - */ - public static double normalAbsoluteAngleDegrees(double angle) { - return (angle %= 360) >= 0 ? angle : (angle + 360); - } - - /** - * Normalizes an angle to a relative angle. - * The normalized angle will be in the range from -PI to PI, where PI - * itself is not included. - * - * @param angle the angle to normalize - * @return the normalized angle that will be in the range of [-PI,PI[ - */ - public static double normalRelativeAngle(double angle) { - return (angle %= TWO_PI) >= 0 ? (angle < PI) ? angle : angle - TWO_PI : (angle >= -PI) ? angle : angle + TWO_PI; - } - - /** - * Normalizes an angle to a relative angle. - * The normalized angle will be in the range from -180 to 180, where 180 - * itself is not included. - * - * @param angle the angle to normalize - * @return the normalized angle that will be in the range of [-180,180[ - */ - public static double normalRelativeAngleDegrees(double angle) { - return (angle %= 360) >= 0 ? (angle < 180) ? angle : angle - 360 : (angle >= -180) ? angle : angle + 360; - } - - /** - * Normalizes an angle to be near an absolute angle. - * The normalized angle will be in the range from 0 to 360, where 360 - * itself is not included. - * If the normalized angle is near to 0, 90, 180, 270 or 360, that - * angle will be returned. The {@link #isNear(double, double) isNear} - * method is used for defining when the angle is near one of angles listed - * above. - * - * @param angle the angle to normalize - * @return the normalized angle that will be in the range of [0,360[ - * @see #normalAbsoluteAngle(double) - * @see #isNear(double, double) - */ - public static double normalNearAbsoluteAngleDegrees(double angle) { - angle = (angle %= 360) >= 0 ? angle : (angle + 360); - - if (isNear(angle, 180)) { - return 180; - } else if (angle < 180) { - if (isNear(angle, 0)) { - return 0; - } else if (isNear(angle, 90)) { - return 90; - } - } else { - if (isNear(angle, 270)) { - return 270; - } else if (isNear(angle, 360)) { - return 0; - } - } - return angle; - } - - /** - * Normalizes an angle to be near an absolute angle. - * The normalized angle will be in the range from 0 to 2*PI, where 2*PI - * itself is not included. - * If the normalized angle is near to 0, PI/2, PI, 3*PI/2 or 2*PI, that - * angle will be returned. The {@link #isNear(double, double) isNear} - * method is used for defining when the angle is near one of angles listed - * above. - * - * @param angle the angle to normalize - * @return the normalized angle that will be in the range of [0,2*PI[ - * @see #normalAbsoluteAngle(double) - * @see #isNear(double, double) - */ - public static double normalNearAbsoluteAngle(double angle) { - angle = (angle %= TWO_PI) >= 0 ? angle : (angle + TWO_PI); - - if (isNear(angle, PI)) { - return PI; - } else if (angle < PI) { - if (isNear(angle, 0)) { - return 0; - } else if (isNear(angle, PI_OVER_TWO)) { - return PI_OVER_TWO; - } - } else { - if (isNear(angle, THREE_PI_OVER_TWO)) { - return THREE_PI_OVER_TWO; - } else if (isNear(angle, TWO_PI)) { - return 0; - } - } - return angle; - } - - /** - * Tests if the two {@code double} values are near to each other. - * It is recommended to use this method instead of testing if the two - * doubles are equal using an this expression: {@code value1 == value2}. - * The reason being, that this expression might never become - * {@code true} due to the precision of double values. - * Whether or not the specified doubles are near to each other is defined by - * the following expression: - * {@code (Math.abs(value1 - value2) < .00001)} - * - * @param value1 the first double value - * @param value2 the second double value - * @return {@code true} if the two doubles are near to each other; - * {@code false} otherwise. - */ - public static boolean isNear(double value1, double value2) { - return (Math.abs(value1 - value2) < NEAR_DELTA); - } - - /** - * Returns random number generator. It might be configured for repeatable behavior by setting -DRANDOMSEED option. - * - * @return random number generator - */ - public static Random getRandom() { - return RandomFactory.getRandom(); - } -} diff --git a/workspace_robo/robocode.api/src/main/java/robocode/util/package-info.java b/workspace_robo/robocode.api/src/main/java/robocode/util/package-info.java deleted file mode 100644 index 03e6838..0000000 --- a/workspace_robo/robocode.api/src/main/java/robocode/util/package-info.java +++ /dev/null @@ -1,13 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ - -/** - * Utility classes that can be used when writing robots. - * Kept for compatibility with legacy robots. - */ -package robocode.util; diff --git a/workspace_robo/robocode.battle/.classpath b/workspace_robo/robocode.battle/.classpath deleted file mode 100644 index 3ae3e5a..0000000 --- a/workspace_robo/robocode.battle/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.battle/.project b/workspace_robo/robocode.battle/.project deleted file mode 100644 index ef333f5..0000000 --- a/workspace_robo/robocode.battle/.project +++ /dev/null @@ -1,19 +0,0 @@ - - - robocode.battle - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.api - robocode.core - robocode.host - robocode.repository - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.battle/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.battle/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.battle/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.battle/pom.xml b/workspace_robo/robocode.battle/pom.xml deleted file mode 100644 index d0df636..0000000 --- a/workspace_robo/robocode.battle/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - 4.0.0 - robocode.battle - Robocode Battle - - net.sf.robocode - robocode - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - net.sf.robocode - robocode.core - ${project.version} - - - net.sf.robocode - robocode.host - ${project.version} - - - net.sf.robocode - robocode.repository - ${project.version} - runtime - - - diff --git a/workspace_robo/robocode.battle/robocode.battle.iml b/workspace_robo/robocode.battle/robocode.battle.iml deleted file mode 100644 index 5fa5b24..0000000 --- a/workspace_robo/robocode.battle/robocode.battle.iml +++ /dev/null @@ -1,85 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/BaseBattle.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/BaseBattle.java deleted file mode 100644 index eded632..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/BaseBattle.java +++ /dev/null @@ -1,475 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -import net.sf.robocode.battle.events.BattleEventDispatcher; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.URLJarCollector; -import static net.sf.robocode.io.Logger.logError; -import static net.sf.robocode.io.Logger.logMessage; -import net.sf.robocode.settings.ISettingsManager; -import robocode.BattleRules; -import robocode.control.events.BattlePausedEvent; -import robocode.control.events.BattleResumedEvent; - -import java.util.Queue; -import java.util.concurrent.ConcurrentLinkedQueue; -import java.util.concurrent.atomic.AtomicBoolean; - - -/** - * @author Pavel Savara (original) - */ -public abstract class BaseBattle implements IBattle, Runnable { - - private final static int MAX_TPS = 10000; - - // Maximum turns to display the battle when battle ended - protected final static int TURNS_DISPLAYED_AFTER_ENDING = 30; - - // Objects we use - private Thread battleThread; - IBattleManager battleManager; - protected final BattleEventDispatcher eventDispatcher; - private final ISettingsManager properties; - - // rules - protected BattleRules battleRules; - - // Current round items - private int roundNum; - protected int currentTime; - protected int totalTurns; - - protected int endTimer; - - // TPS (turns per second) calculation stuff - private int tps; - private long turnStartTime; - private long measuredTurnStartTime; - private int measuredTurnCounter; - - // Battle state - private final AtomicBoolean isRunning = new AtomicBoolean(false); - protected boolean isAborted; - - // Battle control - protected boolean isPaused; - private int stepCount; - private boolean runBackward; - private boolean roundOver; - private final Queue pendingCommands = new ConcurrentLinkedQueue(); - - protected BaseBattle(ISettingsManager properties, IBattleManager battleManager, BattleEventDispatcher eventDispatcher) { - stepCount = 0; - - this.properties = properties; - this.eventDispatcher = eventDispatcher; - - this.battleManager = battleManager; - } - - public void setBattleThread(Thread newBattleThread) { - battleThread = newBattleThread; - } - - /** - * Sets the roundNum. - * - * @param roundNum The roundNum to set - */ - public void setRoundNum(int roundNum) { - this.roundNum = roundNum; - } - - /** - * Gets the roundNum. - * - * @return Returns a int - */ - public int getRoundNum() { - return roundNum; - } - - public int getNumRounds() { - return battleRules.getNumRounds(); - } - - public Thread getBattleThread() { - return battleThread; - } - - public int getTime() { - return currentTime; - } - - public int getTotalTurns() { - return totalTurns; - } - - public boolean isLastRound() { - return (roundNum + 1 == getNumRounds()); - } - - public int getTPS() { - return tps; - } - - /** - * Informs on whether the battle is running or not. - * - * @return true if the battle is running, false otherwise - */ - public boolean isRunning() { - return isRunning.get(); - } - - /** - * Informs on whether the battle is aborted or not. - * - * @return true if the battle is aborted, false otherwise - */ - public boolean isAborted() { - return isAborted; - } - - public void cleanup() { - battleRules = null; - if (pendingCommands != null) { - pendingCommands.clear(); - // don't pendingCommands = null; - } - URLJarCollector.enableGc(true); - URLJarCollector.gc(); - } - - public void waitTillStarted() { - synchronized (isRunning) { - while (!isRunning.get()) { - try { - isRunning.wait(); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - - return; // Break out - } - } - } - } - - public void waitTillOver() { - synchronized (isRunning) { - while (isRunning.get()) { - try { - isRunning.wait(); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - - return; // Break out - } - } - } - } - - /** - * When an object implementing interface {@code Runnable} is used - * to create a thread, starting the thread causes the object's - * {@code run()} method to be called in that separately executing - * thread. - *

- * The general contract of the method {@code run()} is that it may - * take any action whatsoever. - * - * @see java.lang.Thread#run() - */ - public void run() { - try { - initializeBattle(); - - while (!isAborted && roundNum < getNumRounds()) { - try { - preloadRound(); - initializeRound(); - runRound(); - } catch (Exception e) { - logError("Exception running a battle round", e); - isAborted = true; - } finally { - finalizeRound(); - cleanupRound(); - } - roundNum++; - } - } finally { - finalizeBattle(); - cleanup(); - } - } - - protected void initializeBattle() { - URLJarCollector.enableGc(false); - roundNum = 0; - totalTurns = 0; - - // Notify that the battle is now running - synchronized (isRunning) { - isRunning.set(true); - isRunning.notifyAll(); - } - } - - protected void finalizeBattle() { - // Notify that the battle is over - synchronized (isRunning) { - isRunning.set(false); - isRunning.notifyAll(); - } - } - - protected void preloadRound() { - logMessage("----------------------"); - Logger.logMessage("Round " + (roundNum + 1) + " initializing..", false); - } - - protected void initializeRound() { - logMessage(""); - logMessage("Let the games begin!"); - - roundOver = false; - endTimer = 0; - currentTime = 0; - } - - private void runRound() { - - while (!roundOver) { - processCommand(); - - if (shouldPause() && !shouldStep()) { - shortSleep(); - continue; - } - - initializeTurn(); - - runTurn(); - - roundOver = isRoundOver(); - - finalizeTurn(); - } - } - - protected boolean isRoundOver() { - return (endTimer > 5 * TURNS_DISPLAYED_AFTER_ENDING); - } - - protected void finalizeRound() {} - - private void cleanupRound() { - logMessage("Round " + (roundNum + 1) + " cleaning up."); - } - - protected void initializeTurn() { - turnStartTime = System.nanoTime(); - } - - protected void runTurn() { - if (runBackward) { - currentTime--; - totalTurns--; - if (currentTime == 0 && !isPaused) { - pauseImpl(); - } - } else { - currentTime++; - totalTurns++; - } - } - - protected void shutdownTurn() { - endTimer++; - } - - protected void finalizeTurn() { - synchronizeTPS(); - calculateTPS(); - } - - private void synchronizeTPS() { - // Let the battle sleep is the GUI is enabled and is not minimized - // in order to keep the desired TPS - - if (battleManager.isManagedTPS()) { - long delay = 0; - - if (!isAborted() && endTimer < TURNS_DISPLAYED_AFTER_ENDING) { - int desiredTPS = properties.getOptionsBattleDesiredTPS(); - - if (desiredTPS < MAX_TPS) { - long deltaTime = System.nanoTime() - turnStartTime; - - delay = Math.max(1000000000 / desiredTPS - deltaTime, 0); - } - } - if (delay > 500000) { // sleep granularity is worse than 500000 - try { - Thread.sleep(delay / 1000000, (int) (delay % 1000000)); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - } - } - } - } - - private void calculateTPS() { - // Calculate the current turns per second (TPS) - - if (measuredTurnCounter++ == 0) { - measuredTurnStartTime = turnStartTime; - } - - long deltaTime = System.nanoTime() - measuredTurnStartTime; - - if (deltaTime / 500000000 >= 1) { - tps = (int) (measuredTurnCounter * 1000000000L / deltaTime); - measuredTurnCounter = 0; - } - } - - private boolean shouldPause() { - return (isPaused && !isAborted); - } - - private boolean shouldStep() { - if (stepCount > 0) { - stepCount--; - return true; - } - return false; - } - - // -------------------------------------------------------------------------- - // Processing and maintaining robot and battle controls - // -------------------------------------------------------------------------- - - protected void sendCommand(Command command) { - pendingCommands.add(command); - } - - private void processCommand() { - Command command = pendingCommands.poll(); - - while (command != null) { - try { - command.execute(); - } catch (Exception e) { - logError(e); - } - command = pendingCommands.poll(); - } - } - - public void stop(boolean waitTillEnd) { - sendCommand(new AbortCommand()); - - if (waitTillEnd) { - waitTillOver(); - } - } - - public void pause() { - sendCommand(new PauseCommand()); - } - - public void resume() { - sendCommand(new ResumeCommand()); - } - - public void step() { - sendCommand(new StepCommand()); - } - - protected void stepBack() { - sendCommand(new StepBackCommand()); - } - - private class PauseCommand extends Command { - public void execute() { - pauseImpl(); - } - - } - - private void pauseImpl() { - isPaused = true; - stepCount = 0; - eventDispatcher.onBattlePaused(new BattlePausedEvent()); - } - - private class ResumeCommand extends Command { - public void execute() { - isPaused = false; - stepCount = 0; - eventDispatcher.onBattleResumed(new BattleResumedEvent()); - } - } - - - private class StepCommand extends Command { - public void execute() { - runBackward = false; - if (isPaused) { - stepCount++; - } - } - } - - - private class StepBackCommand extends Command { - public void execute() { - runBackward = true; - if (isPaused) { - stepCount++; - } - } - } - - - private class AbortCommand extends Command { - public void execute() { - isAborted = true; - } - } - - - protected class RobotCommand extends Command { - protected final int robotIndex; - - protected RobotCommand(int robotIndex) { - this.robotIndex = robotIndex; - } - } - - // - // Utility - // - - private void shortSleep() { - try { - Thread.sleep(100); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - } - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/Battle.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/Battle.java deleted file mode 100644 index c70727a..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/Battle.java +++ /dev/null @@ -1,886 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -import net.sf.robocode.battle.events.BattleEventDispatcher; -import net.sf.robocode.battle.peer.BulletPeer; -import net.sf.robocode.battle.peer.ContestantPeer; -import net.sf.robocode.battle.peer.RobotPeer; -import net.sf.robocode.battle.peer.TeamPeer; -import net.sf.robocode.battle.snapshot.TurnSnapshot; -import net.sf.robocode.host.ICpuManager; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.RobocodeProperties; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.security.HiddenAccess; -import net.sf.robocode.settings.ISettingsManager; -import robocode.*; -import robocode.control.RandomFactory; -import robocode.control.RobotResults; -import robocode.control.RobotSetup; -import robocode.control.RobotSpecification; -import robocode.control.events.*; -import robocode.control.events.RoundEndedEvent; -import robocode.control.snapshot.BulletState; -import robocode.control.snapshot.ITurnSnapshot; - -import java.util.*; -import java.util.concurrent.CopyOnWriteArrayList; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - - -/** - * The {@code Battle} class is used for controlling a battle. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Luis Crespo (contributor) - * @author Robert D. Maupin (contributor) - * @author Titus Chen (contributor) - * @author Nathaniel Troutman (contributor) - * @author Julian Kent (contributor) - * @author Pavel Savara (contributor) - */ -public final class Battle extends BaseBattle { - - private static final int DEBUG_TURN_WAIT_MILLIS = 10 * 60 * 1000; // 10 seconds - - private final IHostManager hostManager; - private final long cpuConstant; - - // Inactivity related items - private int inactiveTurnCount; - private double inactivityEnergy; - - // Turn skip related items - private boolean parallelOn; - private long millisWait; - private int nanoWait; - - // Objects in the battle - private int robotsCount; - private List robots = new ArrayList(); - private List contestants = new ArrayList(); - private final List bullets = new CopyOnWriteArrayList(); - - // Robot counters - private int activeParticipants; - private int activeSentries; - - // Death events - private final List deathRobots = new CopyOnWriteArrayList(); - - // Initial robot setups (if any) - private RobotSetup[] initialRobotSetups; - - public Battle(ISettingsManager properties, IBattleManager battleManager, IHostManager hostManager, ICpuManager cpuManager, BattleEventDispatcher eventDispatcher) { // NO_UCD (unused code) - super( - properties, battleManager, eventDispatcher); - this.hostManager = hostManager; - this.cpuConstant = cpuManager.getCpuConstant(); - } - - void setup(RobotSpecification[] battlingRobotsList, BattleProperties battleProps, boolean paused) { - isPaused = paused; - battleRules = HiddenAccess.createRules(battleProps.getBattlefieldWidth(), battleProps.getBattlefieldHeight(), - battleProps.getNumRounds(), battleProps.getGunCoolingRate(), battleProps.getInactivityTime(), - battleProps.getHideEnemyNames(), battleProps.getSentryBorderSize()); - robotsCount = battlingRobotsList.length; - computeInitialPositions(battleProps.getInitialPositions()); - createPeers(battlingRobotsList); - } - - private void createPeers(RobotSpecification[] battlingRobotsList) { - // create teams - Map countedNames = new HashMap(); - List teams = new ArrayList(); - List teamDuplicates = new ArrayList(); - List robotDuplicates = new ArrayList(); - - // count duplicate robots, enumerate teams, enumerate team members - for (RobotSpecification specification : battlingRobotsList) { - final String name = ((IRobotItem) HiddenAccess.getFileSpecification(specification)).getUniqueFullClassNameWithVersion(); - - if (countedNames.containsKey(name)) { - int value = countedNames.get(name); - - countedNames.put(name, value == 1 ? 3 : value + 1); - } else { - countedNames.put(name, 1); - } - - String teamFullName = HiddenAccess.getRobotTeamName(specification); - - if (teamFullName != null) { - if (!teams.contains(teamFullName)) { - teams.add(teamFullName); - String teamName = teamFullName.substring(0, teamFullName.length() - 6); - - if (countedNames.containsKey(teamName)) { - int value = countedNames.get(teamName); - - countedNames.put(teamName, value == 1 ? 3 : value + 1); - } else { - countedNames.put(teamName, 1); - } - } - } - } - - Map> teamMembers = new HashMap>(); - - // name teams - for (int i = teams.size() - 1; i >= 0; i--) { - String teamFullName = teams.get(i); - String name = teamFullName.substring(0, teamFullName.length() - 6); - Integer order = countedNames.get(name); - String newTeamName = name; - - if (order > 1) { - newTeamName = name + " (" + (order - 1) + ")"; - } - teamDuplicates.add(0, newTeamName); - teamMembers.put(teamFullName, new ArrayList()); - countedNames.put(name, order - 1); - } - - // name robots - for (int i = battlingRobotsList.length - 1; i >= 0; i--) { - RobotSpecification specification = battlingRobotsList[i]; - String name = ((IRobotItem) HiddenAccess.getFileSpecification(specification)).getUniqueFullClassNameWithVersion(); - Integer order = countedNames.get(name); - int duplicate = -1; - - String newName = name; - - if (order > 1) { - duplicate = (order - 2); - newName = name + " (" + (order - 1) + ")"; - } - countedNames.put(name, (order - 1)); - robotDuplicates.add(0, duplicate); - - String teamFullName = HiddenAccess.getRobotTeamName(specification); - - if (teamFullName != null) { - List members = teamMembers.get(teamFullName); - - members.add(newName); - } - } - - // create teams - Map namedTeams = new HashMap(); - - // create robots - for (int i = 0; i < battlingRobotsList.length; i++) { - RobotSpecification specification = battlingRobotsList[i]; - TeamPeer team = null; - - String teamFullName = HiddenAccess.getRobotTeamName(specification); - - // The team index and robot index depends on current sizes of the contestant list and robot list - int teamIndex = contestants.size(); - int robotIndex = robots.size(); - - if (teamFullName != null) { - if (!namedTeams.containsKey(teamFullName)) { - String newTeamName = teamDuplicates.get(teams.indexOf(teamFullName)); - - team = new TeamPeer(newTeamName, teamMembers.get(teamFullName), teamIndex); - - namedTeams.put(teamFullName, team); - contestants.add(team); - - } else { - team = namedTeams.get(teamFullName); - if (team != null) { - teamIndex = team.getTeamIndex(); - } - } - } - Integer duplicate = robotDuplicates.get(i); - RobotPeer robotPeer = new RobotPeer(this, hostManager, specification, duplicate, team, robotIndex); - - robots.add(robotPeer); - if (team == null) { - contestants.add(robotPeer); - } - } - } - - public void registerDeathRobot(RobotPeer r) { - deathRobots.add(r); - } - - public BattleRules getBattleRules() { - return battleRules; - } - - public int getRobotsCount() { - return robotsCount; - } - - public boolean isDebugging() { - return RobocodeProperties.isDebuggingOn(); - } - - public void addBullet(BulletPeer bullet) { - bullets.add(bullet); - } - - public void resetInactiveTurnCount(double energyLoss) { - if (energyLoss < 0) { - return; - } - inactivityEnergy += energyLoss; - while (inactivityEnergy >= 10) { - inactivityEnergy -= 10; - inactiveTurnCount = 0; - } - } - - /** - * Returns the number of active participants. - * - * @return the number of active participants. - */ - public int countActiveParticipants() { - return activeParticipants; - } - - /** - * Returns the number of active sentry robots. - * - * @return the number of active sentry robots. - */ - public int countActiveSentries() { - return activeSentries; - } - - @Override - public void cleanup() { - - if (contestants != null) { - contestants.clear(); - contestants = null; - } - - if (robots != null) { - robots.clear(); - robots = null; - } - - super.cleanup(); - - battleManager = null; - - // Request garbage collecting - for (int i = 4; i >= 0; i--) { // Make sure it is run - System.gc(); - } - } - - @Override - protected void initializeBattle() { - super.initializeBattle(); - - parallelOn = System.getProperty("PARALLEL", "false").equals("true"); - if (parallelOn) { - // how could robots share CPUs ? - double parallelConstant = robots.size() / Runtime.getRuntime().availableProcessors(); - - // four CPUs can't run two single threaded robot faster than two CPUs - if (parallelConstant < 1) { - parallelConstant = 1; - } - final long waitTime = (long) (cpuConstant * parallelConstant); - - millisWait = waitTime / 1000000; - nanoWait = (int) (waitTime % 1000000); - } else { - millisWait = cpuConstant / 1000000; - nanoWait = (int) (cpuConstant % 1000000); - } - if (nanoWait == 0) { - nanoWait = 1; - } - } - - @Override - protected void finalizeBattle() { - eventDispatcher.onBattleFinished(new BattleFinishedEvent(isAborted())); - - if (!isAborted()) { - eventDispatcher.onBattleCompleted(new BattleCompletedEvent(battleRules, computeBattleResults())); - } - - for (RobotPeer robotPeer : robots) { - robotPeer.cleanup(); - } - hostManager.resetThreadManager(); - - super.finalizeBattle(); - } - - @Override - protected void preloadRound() { - super.preloadRound(); - - computeActiveRobots(); // Used for robotPeer.initializeRound() - - // At this point the unsafe loader thread will now set itself to wait for a notify - - for (RobotPeer robotPeer : robots) { - robotPeer.initializeRound(robots, initialRobotSetups); - robotPeer.println("========================="); - robotPeer.println("Round " + (getRoundNum() + 1) + " of " + getNumRounds()); - robotPeer.println("========================="); - } - - if (getRoundNum() == 0) { - eventDispatcher.onBattleStarted(new BattleStartedEvent(battleRules, robots.size(), false)); - if (isPaused) { - eventDispatcher.onBattlePaused(new BattlePausedEvent()); - } - } - - computeActiveRobots(); // Used for RoundEnded check hostManager.resetThreadManager(); - } - - @Override - protected void initializeRound() { - super.initializeRound(); - - inactiveTurnCount = 0; - - // Start robots - - long waitMillis; - int waitNanos; - - if (isDebugging()) { - waitMillis = DEBUG_TURN_WAIT_MILLIS; - waitNanos = 0; - } else { - long waitTime = Math.min(300 * cpuConstant, 10000000000L); - - waitMillis = waitTime / 1000000; - waitNanos = (int) (waitTime % 1000000); - } - - for (RobotPeer robotPeer : getRobotsAtRandom()) { - robotPeer.startRound(waitMillis, waitNanos); - } - - Logger.logMessage(""); // puts in a new-line in the log message - - final ITurnSnapshot snapshot = new TurnSnapshot(this, robots, bullets, false); - - eventDispatcher.onRoundStarted(new RoundStartedEvent(snapshot, getRoundNum())); - } - - @Override - protected void finalizeRound() { - super.finalizeRound(); - - for (RobotPeer robotPeer : robots) { - robotPeer.waitForStop(); - } - bullets.clear(); - - eventDispatcher.onRoundEnded(new RoundEndedEvent(getRoundNum(), currentTime, totalTurns)); - } - - @Override - protected void initializeTurn() { - super.initializeTurn(); - - eventDispatcher.onTurnStarted(new TurnStartedEvent()); - } - - @Override - protected void runTurn() { - super.runTurn(); - - loadCommands(); - - updateBullets(); - - updateRobots(); - - handleDeadRobots(); - - if (isAborted() || oneTeamRemaining()) { - shutdownTurn(); - } - - inactiveTurnCount++; - - computeActiveRobots(); - - publishStatuses(); - - // Robot time! - wakeupRobots(); - } - - @Override - protected void shutdownTurn() { - if (endTimer == 0) { - if (isAborted()) { - for (RobotPeer robotPeer : getRobotsAtRandom()) { - if (robotPeer.isAlive()) { - robotPeer.println("SYSTEM: game aborted."); - } - } - } else if (oneTeamRemaining()) { - boolean leaderFirsts = false; - TeamPeer winningTeam = null; - - robocode.RoundEndedEvent roundEndedEvent = new robocode.RoundEndedEvent(getRoundNum(), currentTime, - totalTurns); - - for (RobotPeer robotPeer : getRobotsAtRandom()) { - robotPeer.addEvent(roundEndedEvent); - if (robotPeer.isAlive() && !robotPeer.isWinner() && !robotPeer.isSentryRobot()) { - robotPeer.getRobotStatistics().scoreLastSurvivor(); - robotPeer.setWinner(true); - robotPeer.println("SYSTEM: " + robotPeer.getNameForEvent(robotPeer) + " wins the round."); - robotPeer.addEvent(new WinEvent()); - if (robotPeer.getTeamPeer() != null) { - if (robotPeer.isTeamLeader()) { - leaderFirsts = true; - } else { - winningTeam = robotPeer.getTeamPeer(); - } - } - } - // Generate totals as round has ended, but first when the last scores has been calculated - robotPeer.getRobotStatistics().generateTotals(); - } - if (!leaderFirsts && winningTeam != null) { - winningTeam.getTeamLeader().getRobotStatistics().scoreFirsts(); - } - } - if (isAborted() || isLastRound()) { - List orderedRobots = new ArrayList(robots); - Collections.sort(orderedRobots); - Collections.reverse(orderedRobots); - - for (int rank = 0; rank < robots.size(); rank++) { - RobotPeer robotPeer = orderedRobots.get(rank); - robotPeer.getStatistics().setRank(rank + 1); - BattleResults battleResults = robotPeer.getStatistics().getFinalResults(); - robotPeer.addEvent(new BattleEndedEvent(isAborted(), battleResults)); - } - } - } - - if (endTimer > 4 * TURNS_DISPLAYED_AFTER_ENDING) { - for (RobotPeer robotPeer : robots) { - robotPeer.setHalt(true); - } - } - - super.shutdownTurn(); - } - - @Override - protected void finalizeTurn() { - eventDispatcher.onTurnEnded(new TurnEndedEvent(new TurnSnapshot(this, robots, bullets, true))); - - super.finalizeTurn(); - } - - private BattleResults[] computeBattleResults() { - ArrayList results = new ArrayList(); - for (int i = 0; i < contestants.size(); i++) { - results.add(null); - } - for (int rank = 0; rank < contestants.size(); rank++) { - ContestantPeer contestant = contestants.get(rank); - contestant.getStatistics().setRank(rank + 1); - BattleResults battleResults = contestant.getStatistics().getFinalResults(); - - RobotSpecification robotSpec = null; - if (contestant instanceof RobotPeer) { - robotSpec = ((RobotPeer) contestant).getRobotSpecification(); - } else if (contestant instanceof TeamPeer) { - robotSpec = ((TeamPeer) contestant).getTeamLeader().getRobotSpecification(); - } - results.set(rank, new RobotResults(robotSpec, battleResults)); - } - return results.toArray(new BattleResults[results.size()]); - } - - /** - * Returns a list of all robots in random order. This method is used to gain fair play in Robocode, - * so that a robot placed before another robot in the list will not gain any benefit when the game - * checks if a robot has won, is dead, etc. - * This method was introduced as two equal robots like sample.RamFire got different scores even - * though the code was exactly the same. - * - * @return a list of robot peers. - */ - private List getRobotsAtRandom() { - List shuffledList = new ArrayList(robots); - - Collections.shuffle(shuffledList, RandomFactory.getRandom()); - return shuffledList; - } - - /** - * Returns a list of all bullets in random order. This method is used to gain fair play in Robocode. - * - * @return a list of bullet peers. - */ - private List getBulletsAtRandom() { - List shuffledList = new ArrayList(bullets); - - Collections.shuffle(shuffledList, RandomFactory.getRandom()); - return shuffledList; - } - - /** - * Returns a list of all death robots in random order. This method is used to gain fair play in Robocode. - * - * @return a list of robot peers. - */ - private List getDeathRobotsAtRandom() { - List shuffledList = new ArrayList(deathRobots); - - Collections.shuffle(shuffledList, RandomFactory.getRandom()); - return shuffledList; - } - - private void loadCommands() { - // this will load commands, including bullets from last turn - for (RobotPeer robotPeer : robots) { - robotPeer.performLoadCommands(); - } - } - - private void updateBullets() { - for (BulletPeer bullet : getBulletsAtRandom()) { - bullet.update(getRobotsAtRandom(), getBulletsAtRandom()); - if (bullet.getState() == BulletState.INACTIVE) { - bullets.remove(bullet); - } - } - } - - private void updateRobots() { - boolean zap = (inactiveTurnCount > battleRules.getInactivityTime()); - - final double zapEnergy = isAborted() ? 5 : zap ? .1 : 0; - - // Move all bots - for (RobotPeer robotPeer : getRobotsAtRandom()) { - robotPeer.performMove(getRobotsAtRandom(), zapEnergy); - } - - // Scan after moved all - for (RobotPeer robotPeer : getRobotsAtRandom()) { - robotPeer.performScan(getRobotsAtRandom()); - } - } - - private void handleDeadRobots() { - - for (RobotPeer deadRobot : getDeathRobotsAtRandom()) { - // Compute scores for dead robots - if (deadRobot.getTeamPeer() == null) { - deadRobot.getRobotStatistics().scoreRobotDeath(getActiveContestantCount(deadRobot)); - } else { - boolean teammatesalive = false; - - for (RobotPeer tm : robots) { - if (tm.getTeamPeer() == deadRobot.getTeamPeer() && tm.isAlive()) { - teammatesalive = true; - break; - } - } - if (!teammatesalive) { - deadRobot.getRobotStatistics().scoreRobotDeath(getActiveContestantCount(deadRobot)); - } - } - - // Publish death to live robots - for (RobotPeer robotPeer : getRobotsAtRandom()) { - if (robotPeer.isAlive()) { - robotPeer.addEvent(new RobotDeathEvent(robotPeer.getNameForEvent(deadRobot))); - - if (robotPeer.getTeamPeer() == null || robotPeer.getTeamPeer() != deadRobot.getTeamPeer()) { - robotPeer.getRobotStatistics().scoreSurvival(); - } - } - } - } - - deathRobots.clear(); - } - - private void publishStatuses() { - for (RobotPeer robotPeer : robots) { - robotPeer.publishStatus(currentTime); - } - } - - private void computeActiveRobots() { - int countActiveParticipants = 0; - int countActiveSentries = 0; - - for (RobotPeer robot : robots) { - if (robot.isAlive()) { // robot must be alive in order to be active - if (robot.isSentryRobot()) { - countActiveSentries++; - } else { - countActiveParticipants++; - } - } - } - this.activeParticipants = countActiveParticipants; - this.activeSentries = countActiveSentries; - } - - private void wakeupRobots() { - // Wake up all robot threads - final List robotsAtRandom = getRobotsAtRandom(); - - if (parallelOn) { - wakeupParallel(robotsAtRandom); - } else { - wakeupSerial(robotsAtRandom); - } - } - - private void wakeupSerial(List robotsAtRandom) { - for (RobotPeer robotPeer : robotsAtRandom) { - if (robotPeer.isRunning()) { - // This call blocks until the robot's thread actually wakes up. - robotPeer.waitWakeup(); - - if (robotPeer.isAlive()) { - if (isDebugging() || robotPeer.isPaintEnabled()) { - robotPeer.waitSleeping(DEBUG_TURN_WAIT_MILLIS, 1); - } else if (currentTime == 1) { - robotPeer.waitSleeping(millisWait * 10, 1); - } else { - robotPeer.waitSleeping(millisWait, nanoWait); - } - } - } - } - } - - private void wakeupParallel(List robotsAtRandom) { - for (RobotPeer robotPeer : robotsAtRandom) { - if (robotPeer.isRunning()) { - // This call blocks until the robot's thread actually wakes up. - robotPeer.waitWakeup(); - } - } - for (RobotPeer robotPeer : robotsAtRandom) { - if (robotPeer.isRunning() && robotPeer.isAlive()) { - if (isDebugging() || robotPeer.isPaintEnabled()) { - robotPeer.waitSleeping(DEBUG_TURN_WAIT_MILLIS, 1); - } else if (currentTime == 1) { - robotPeer.waitSleeping(millisWait * 10, 1); - } else { - robotPeer.waitSleeping(millisWait, nanoWait); - } - } - } - } - - private int getActiveContestantCount(RobotPeer peer) { - int count = 0; - - for (ContestantPeer c : contestants) { - if (c instanceof RobotPeer) { - RobotPeer robot = (RobotPeer) c; - if (!robot.isSentryRobot() && robot.isAlive()) { - count++; - } - } else if (c instanceof TeamPeer && c != peer.getTeamPeer()) { - for (RobotPeer robot: (TeamPeer) c) { - if (!robot.isSentryRobot() && robot.isAlive()) { - count++; - break; - } - } - } - } - return count; - } - - private void computeInitialPositions(String initialPositions) { - initialRobotSetups = null; - - if (initialPositions == null || initialPositions.trim().length() == 0) { - return; - } - - List positions = new ArrayList(); - - Pattern pattern = Pattern.compile("([^,(]*[(][^)]*[)])?[^,]*,?"); - Matcher matcher = pattern.matcher(initialPositions); - - while (matcher.find()) { - String pos = matcher.group(); - if (pos.length() > 0) { - positions.add(pos); - } - } - if (positions.size() == 0) { - return; - } - - initialRobotSetups = new RobotSetup[positions.size()]; - - String[] coords; - double x, y, heading; - - for (int i = 0; i < positions.size(); i++) { - coords = positions.get(i).split(","); - - Random random = RandomFactory.getRandom(); - - x = RobotPeer.WIDTH + random.nextDouble() * (battleRules.getBattlefieldWidth() - 2 * RobotPeer.WIDTH); - y = RobotPeer.HEIGHT + random.nextDouble() * (battleRules.getBattlefieldHeight() - 2 * RobotPeer.HEIGHT); - heading = 2 * Math.PI * random.nextDouble(); - - int len = coords.length; - - if (len >= 1 && coords[0].trim().length() > 0) { - try { - x = Double.parseDouble(coords[0].replaceAll("[^0-9.]", "")); - } catch (NumberFormatException ignore) {// Could be the '?', which is fine - } - if (len >= 2 && coords[1].trim().length() > 0) { - try { - y = Double.parseDouble(coords[1].replaceAll("[^0-9.]", "")); - } catch (NumberFormatException ignore) {// Could be the '?', which is fine - } - if (len >= 3 && coords[2].trim().length() > 0) { - try { - heading = Math.toRadians(Double.parseDouble(coords[2].replaceAll("[^0-9.]", ""))); - } catch (NumberFormatException ignore) {// Could be the '?', which is fine - } - } - } - } - initialRobotSetups[i] = new RobotSetup(x, y, heading); - } - } - - private boolean oneTeamRemaining() { - if (countActiveParticipants() <= 1) { - return true; - } - - boolean found = false; - TeamPeer currentTeam = null; - - for (RobotPeer currentRobot : robots) { - if (currentRobot.isAlive()) { - if (!found) { - found = true; - currentTeam = currentRobot.getTeamPeer(); - } else { - if (currentTeam == null && currentRobot.getTeamPeer() == null) { - return false; - } - if (currentTeam != currentRobot.getTeamPeer()) { - return false; - } - } - } - } - return true; - } - - // -------------------------------------------------------------------------- - // Processing and maintaining robot and battle controls - // -------------------------------------------------------------------------- - - void killRobot(int robotIndex) { - sendCommand(new KillRobotCommand(robotIndex)); - } - - public void setPaintEnabled(int robotIndex, boolean enable) { - sendCommand(new EnableRobotPaintCommand(robotIndex, enable)); - } - - void setSGPaintEnabled(int robotIndex, boolean enable) { - sendCommand(new EnableRobotSGPaintCommand(robotIndex, enable)); - } - - void sendInteractiveEvent(Event e) { - sendCommand(new SendInteractiveEventCommand(e)); - } - - private class KillRobotCommand extends RobotCommand { - KillRobotCommand(int robotIndex) { - super(robotIndex); - } - - public void execute() { - robots.get(robotIndex).kill(); - } - } - - - private class EnableRobotPaintCommand extends RobotCommand { - final boolean enablePaint; - - EnableRobotPaintCommand(int robotIndex, boolean enablePaint) { - super(robotIndex); - this.enablePaint = enablePaint; - } - - public void execute() { - robots.get(robotIndex).setPaintEnabled(enablePaint); - } - } - - - private class EnableRobotSGPaintCommand extends RobotCommand { - final boolean enableSGPaint; - - EnableRobotSGPaintCommand(int robotIndex, boolean enableSGPaint) { - super(robotIndex); - this.enableSGPaint = enableSGPaint; - } - - public void execute() { - robots.get(robotIndex).setSGPaintEnabled(enableSGPaint); - } - } - - - private class SendInteractiveEventCommand extends Command { - public final Event event; - - SendInteractiveEventCommand(Event event) { - this.event = event; - } - - public void execute() { - for (RobotPeer robotPeer : robots) { - if (robotPeer.isInteractiveRobot()) { - robotPeer.addEvent(event); - } - } - } - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/BattleManager.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/BattleManager.java deleted file mode 100644 index 413c0ac..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/BattleManager.java +++ /dev/null @@ -1,404 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -import net.sf.robocode.battle.events.BattleEventDispatcher; -import net.sf.robocode.core.Container; -import net.sf.robocode.host.ICpuManager; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.RobocodeProperties; -import static net.sf.robocode.io.Logger.logError; -import static net.sf.robocode.io.Logger.logMessage; -import net.sf.robocode.recording.BattlePlayer; -import net.sf.robocode.recording.IRecordManager; -import net.sf.robocode.repository.IRepositoryManager; -import net.sf.robocode.settings.ISettingsManager; -import robocode.Event; -import robocode.control.BattleSpecification; -import robocode.control.RandomFactory; -import robocode.control.RobotSetup; -import robocode.control.RobotSpecification; -import robocode.control.events.BattlePausedEvent; -import robocode.control.events.BattleResumedEvent; -import robocode.control.events.IBattleListener; - -import java.io.*; -import java.util.concurrent.atomic.AtomicBoolean; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Luis Crespo (contributor) - * @author Robert D. Maupin (contributor) - * @author Nathaniel Troutman (contributor) - * @author Pavel Savara (contributor) - */ -public class BattleManager implements IBattleManager { - private final ISettingsManager properties; - private final IHostManager hostManager; - private final ICpuManager cpuManager; - private final IRecordManager recordManager; - private final IRepositoryManager repositoryManager; - - private volatile IBattle battle; - private Thread battleThread; - private BattleProperties battleProperties = new BattleProperties(); - - private final BattleEventDispatcher battleEventDispatcher; - - private String battleFilename; - private String battlePath; - - private int pauseCount = 0; - private final AtomicBoolean isManagedTPS = new AtomicBoolean(false); - - public BattleManager(ISettingsManager properties, IRepositoryManager repositoryManager, IHostManager hostManager, ICpuManager cpuManager, BattleEventDispatcher battleEventDispatcher, IRecordManager recordManager) { // NO_UCD (unused code) - this.properties = properties; - this.recordManager = recordManager; - this.repositoryManager = repositoryManager; - this.cpuManager = cpuManager; - this.hostManager = hostManager; - this.battleEventDispatcher = battleEventDispatcher; - Logger.setLogListener(battleEventDispatcher); - } - - public synchronized void cleanup() { - if (battle != null) { - battle.waitTillOver(); - battle.cleanup(); - } - battle = null; - } - - // Called when starting a new battle from GUI - public void startNewBattle(BattleProperties battleProperties, boolean waitTillOver, boolean enableCLIRecording) { - this.battleProperties = battleProperties; - final RobotSpecification[] robots = repositoryManager.loadSelectedRobots(battleProperties.getSelectedRobots()); - - startNewBattleImpl(robots, waitTillOver, enableCLIRecording); - } - - // Called from the RobocodeEngine - public void startNewBattle(BattleSpecification spec, String initialPositions, boolean waitTillOver, boolean enableCLIRecording) { - battleProperties = new BattleProperties(); - battleProperties.setBattlefieldWidth(spec.getBattlefield().getWidth()); - battleProperties.setBattlefieldHeight(spec.getBattlefield().getHeight()); - battleProperties.setGunCoolingRate(spec.getGunCoolingRate()); - battleProperties.setInactivityTime(spec.getInactivityTime()); - battleProperties.setNumRounds(spec.getNumRounds()); - battleProperties.setHideEnemyNames(spec.getHideEnemyNames()); - battleProperties.setSentryBorderSize(spec.getSentryBorderSize()); - battleProperties.setSelectedRobots(spec.getRobots()); - - final RobotSetup[] initialSetups = spec.getInitialSetups(); - if (initialSetups != null) { - battleProperties.setInitialPositions(initialSetups); - } else { - battleProperties.setInitialPositions(initialPositions); - } - - final RobotSpecification[] robots = repositoryManager.loadSelectedRobots(spec.getRobots()); - - startNewBattleImpl(robots, waitTillOver, enableCLIRecording); - } - - private void startNewBattleImpl(RobotSpecification[] battlingRobotsList, boolean waitTillOver, boolean enableCLIRecording) { - stop(true); - - logMessage("Preparing battle..."); - - final boolean recording = (properties.getOptionsCommonEnableReplayRecording() - && System.getProperty("TESTING", "none").equals("none")) - || enableCLIRecording; - - if (recording) { - recordManager.attachRecorder(battleEventDispatcher); - } else { - recordManager.detachRecorder(); - } - - // resets seed for deterministic behavior of Random - final String seed = System.getProperty("RANDOMSEED", "none"); - - if (!seed.equals("none")) { - // init soon as it reads random - cpuManager.getCpuConstant(); - - RandomFactory.resetDeterministic(Long.valueOf(seed)); - } - - Battle realBattle = Container.createComponent(Battle.class); - realBattle.setup(battlingRobotsList, battleProperties, isPaused()); - - battle = realBattle; - - battleThread = new Thread(Thread.currentThread().getThreadGroup(), realBattle); - battleThread.setPriority(Thread.NORM_PRIORITY); - battleThread.setName("Battle Thread"); - realBattle.setBattleThread(battleThread); - - if (RobocodeProperties.isSecurityOn()) { - hostManager.addSafeThread(battleThread); - } - - // Start the realBattle thread - battleThread.start(); - - // Wait until the realBattle is running and ended. - // This must be done as a new realBattle could be started immediately after this one causing - // multiple realBattle threads to run at the same time, which must be prevented! - realBattle.waitTillStarted(); - if (waitTillOver) { - realBattle.waitTillOver(); - } - } - - public void waitTillOver() { - if (battle != null) { - battle.waitTillOver(); - } - } - - private void replayBattle() { - if (!recordManager.hasRecord()) { - return; - } - logMessage("Preparing replay..."); - - if (battle != null && battle.isRunning()) { - battle.stop(true); - } - - Logger.setLogListener(battleEventDispatcher); - - recordManager.detachRecorder(); - battle = Container.createComponent(BattlePlayer.class); - - Thread battleThread = new Thread(Thread.currentThread().getThreadGroup(), battle); - - battleThread.setPriority(Thread.NORM_PRIORITY); - battleThread.setName("BattlePlayer Thread"); - - // Start the battlePlayer thread - battleThread.start(); - } - - public String getBattleFilename() { - return battleFilename; - } - - public void setBattleFilename(String newBattleFilename) { - if (newBattleFilename != null) { - battleFilename = newBattleFilename.replace((File.separatorChar == '/') ? '\\' : '/', File.separatorChar); - - if (battleFilename.indexOf(File.separatorChar) < 0) { - try { - battleFilename = FileUtil.getBattlesDir().getCanonicalPath() + File.separatorChar + battleFilename; - } catch (IOException ignore) {} - } - if (!battleFilename.endsWith(".battle")) { - battleFilename += ".battle"; - } - } - } - - public String getBattlePath() { - if (battlePath == null) { - battlePath = System.getProperty("BATTLEPATH"); - if (battlePath == null) { - battlePath = "battles"; - } - battlePath = new File(FileUtil.getCwd(), battlePath).getAbsolutePath(); - } - return battlePath; - } - - public void saveBattleProperties() { - if (battleProperties == null) { - logError("Cannot save null battle properties"); - return; - } - if (battleFilename == null) { - logError("Cannot save battle to null path, use setBattleFilename()"); - return; - } - FileOutputStream out = null; - - try { - out = new FileOutputStream(battleFilename); - - battleProperties.store(out, "Battle Properties"); - } catch (IOException e) { - logError("IO Exception saving battle properties: " + e); - } finally { - FileUtil.cleanupStream(out); - } - } - - public BattleProperties loadBattleProperties() { - BattleProperties res = new BattleProperties(); - FileInputStream in = null; - try { - in = new FileInputStream(getBattleFilename()); - res.load(in); - } catch (FileNotFoundException e) { - logError("No file " + battleFilename + " found, using defaults."); - } catch (IOException e) { - logError("Error while reading " + getBattleFilename() + ": " + e); - } finally { - FileUtil.cleanupStream(in); - } - return res; - } - - public BattleProperties getBattleProperties() { - if (battleProperties == null) { - battleProperties = new BattleProperties(); - } - return battleProperties; - } - - public void setDefaultBattleProperties() { - battleProperties = new BattleProperties(); - } - - public boolean isManagedTPS() { - return isManagedTPS.get(); - } - - public void setManagedTPS(boolean value) { - isManagedTPS.set(value); - } - - public synchronized void addListener(IBattleListener listener) { - battleEventDispatcher.addListener(listener); - } - - public synchronized void removeListener(IBattleListener listener) { - battleEventDispatcher.removeListener(listener); - } - - public synchronized void stop(boolean waitTillEnd) { - if (battle != null && battle.isRunning()) { - battle.stop(waitTillEnd); - } - if (hostManager != null && battleThread != null) { - hostManager.removeSafeThread(battleThread); - } - battleThread = null; - } - - public synchronized void restart() { - // Start new battle. The old battle is automatically stopped - startNewBattle(battleProperties, false, false); - } - - public synchronized void replay() { - replayBattle(); - } - - private boolean isPaused() { - return (pauseCount != 0); - } - - public synchronized void togglePauseResumeBattle() { - if (isPaused()) { - resumeBattle(); - } else { - pauseBattle(); - } - } - - public synchronized void pauseBattle() { - if (++pauseCount == 1) { - if (battle != null && battle.isRunning()) { - battle.pause(); - } else { - battleEventDispatcher.onBattlePaused(new BattlePausedEvent()); - } - } - } - - public synchronized void pauseIfResumedBattle() { - if (pauseCount == 0) { - pauseCount++; - if (battle != null && battle.isRunning()) { - battle.pause(); - } else { - battleEventDispatcher.onBattlePaused(new BattlePausedEvent()); - } - } - } - - public synchronized void resumeIfPausedBattle() { - if (pauseCount == 1) { - pauseCount--; - if (battle != null && battle.isRunning()) { - battle.resume(); - } else { - battleEventDispatcher.onBattleResumed(new BattleResumedEvent()); - } - } - } - - public synchronized void resumeBattle() { - if (--pauseCount < 0) { - pauseCount = 0; - logError("SYSTEM: pause game bug!"); - } else if (pauseCount == 0) { - if (battle != null && battle.isRunning()) { - battle.resume(); - } else { - battleEventDispatcher.onBattleResumed(new BattleResumedEvent()); - } - } - } - - /** - * Steps for a single turn, then goes back to paused - */ - public synchronized void nextTurn() { - if (battle != null && battle.isRunning()) { - battle.step(); - } - } - - public synchronized void prevTurn() { - if (battle != null && battle.isRunning() && battle instanceof BattlePlayer) { - ((BattlePlayer) battle).stepBack(); - } - } - - public synchronized void killRobot(int robotIndex) { - if (battle != null && battle.isRunning() && battle instanceof Battle) { - ((Battle) battle).killRobot(robotIndex); - } - } - - public synchronized void setPaintEnabled(int robotIndex, boolean enable) { - if (battle != null && battle.isRunning()) { - battle.setPaintEnabled(robotIndex, enable); - } - } - - public synchronized void setSGPaintEnabled(int robotIndex, boolean enable) { - if (battle != null && battle.isRunning() && battle instanceof Battle) { - ((Battle) battle).setSGPaintEnabled(robotIndex, enable); - } - } - - public synchronized void sendInteractiveEvent(Event event) { - if (battle != null && battle.isRunning() && !isPaused() && battle instanceof Battle) { - ((Battle) battle).sendInteractiveEvent(event); - } - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/BoundingRectangle.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/BoundingRectangle.java deleted file mode 100644 index 5257252..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/BoundingRectangle.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -/* - * Class exists to fix two bugs, both related to bug# 4320890 referenced below - * 1. intersectsLine can cause an infinite loop in Java 1.3 - * -- This is why the outcode() method is here, below - * 2. The problem still exists with Rectangle2D.Double as of Java 1.4, - * -- This is why we're using Rectangle2D.Float - * - * @author Mathew A. Nelson (original) - */ -@SuppressWarnings("serial") -public class BoundingRectangle extends java.awt.geom.Rectangle2D.Float { - - public BoundingRectangle() { - super(); - } - - public BoundingRectangle(double x, double y, double w, double h) { - super((float) x, (float) y, (float) w, (float) h); - } - - @Override - public int outcode(double x, double y) { - - /* - * Note on casts to double below. If the arithmetic of - * x+w or y+h is done in float, then some bits may be - * lost if the binary exponents of x/y and w/h are not - * similar. By converting to double before the addition - * we force the addition to be carried out in double to - * avoid rounding error in the comparison. - * - * See bug 4320890 for problems that this inaccuracy causes. - */ - int out = 0; - - if (this.width <= 0) { - out |= OUT_LEFT | OUT_RIGHT; - } else if (x < this.x) { - out |= OUT_LEFT; - } else if (x > this.x + (double) this.width) { - out |= OUT_RIGHT; - } - if (this.height <= 0) { - out |= OUT_TOP | OUT_BOTTOM; - } else if (y < this.y) { - out |= OUT_TOP; - } else if (y > this.y + (double) this.height) { - out |= OUT_BOTTOM; - } - return out; - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/Command.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/Command.java deleted file mode 100644 index 054c152..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/Command.java +++ /dev/null @@ -1,14 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -abstract class Command { - - public void execute() {} -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/IBattle.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/IBattle.java deleted file mode 100644 index 8a35a86..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/IBattle.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -/** - * @author Pavel Savara (original) - */ -interface IBattle extends Runnable { - void cleanup(); - - boolean isRunning(); - - void stop(boolean waitTillEnd); - - void pause(); - - void resume(); - - void step(); - - void waitTillStarted(); - - void waitTillOver(); - - void setPaintEnabled(int robotIndex, boolean enable); -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/Module.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/Module.java deleted file mode 100644 index bc78da0..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/Module.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -import net.sf.robocode.battle.events.BattleEventDispatcher; -import net.sf.robocode.core.Container; -import net.sf.robocode.recording.BattlePlayer; -import net.sf.robocode.recording.IRecordManager; -import net.sf.robocode.recording.RecordManager; - - -/** - * @author Pavel Savara (original) - */ -public class Module { - static { - Container.cache.addComponent(IBattleManager.class, BattleManager.class); - Container.cache.addComponent(BattleEventDispatcher.class); - Container.cache.addComponent(IRecordManager.class, RecordManager.class); - - Container.factory.addComponent(Battle.class); - Container.factory.addComponent(BattlePlayer.class); - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/BulletPeer.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/BulletPeer.java deleted file mode 100644 index c07ad4a..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/BulletPeer.java +++ /dev/null @@ -1,372 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.peer; - - -import net.sf.robocode.peer.BulletStatus; -import robocode.*; -import robocode.control.snapshot.BulletState; - -import java.awt.geom.Line2D; -import static java.lang.Math.cos; -import static java.lang.Math.sin; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Luis Crespo (contributor) - * @author Robert D. Maupin (contributor) - * @author Titus Chen (constributor) - * @author Pavel Savara (constributor) - */ -public class BulletPeer { - - private static final int EXPLOSION_LENGTH = 17; - - private static final int RADIUS = 3; - - protected final RobotPeer owner; - - private final BattleRules battleRules; - private final int bulletId; - - protected RobotPeer victim; - - protected BulletState state; - - private double heading; - - protected double x; - protected double y; - - private double lastX; - private double lastY; - - protected double power; - - private double deltaX; - private double deltaY; - - private final Line2D.Double boundingLine = new Line2D.Double(); - - protected int frame; // Do not set to -1 - - private final int color; - - protected int explosionImageIndex; // Do not set to -1 - - BulletPeer(RobotPeer owner, BattleRules battleRules, int bulletId) { - super(); - this.owner = owner; - this.battleRules = battleRules; - this.bulletId = bulletId; - state = BulletState.FIRED; - color = owner.getBulletColor(); // Store current bullet color set on robot - } - - private void checkBulletCollision(List bullets) { - for (BulletPeer b : bullets) { - if (b != null && b != this && b.isActive() && intersect(b.boundingLine)) { - // Check if one of the bullets belongs to a sentry robot and is within the safe zone - if (owner.isSentryRobot() || b.getOwner().isSentryRobot()) { - int sentryBorderSize = battleRules.getSentryBorderSize(); - if (x > sentryBorderSize && x < (battleRules.getBattlefieldWidth() - sentryBorderSize) - && y > sentryBorderSize && y < (battleRules.getBattlefieldHeight() - sentryBorderSize)) { - - continue; // Continue, as the sentry should not interfere with bullets in the safe zone - } - } - - state = BulletState.HIT_BULLET; - frame = 0; - x = lastX; - y = lastY; - - b.state = BulletState.HIT_BULLET; - b.frame = 0; - b.x = b.lastX; - b.y = b.lastY; - - // Bugfix #366 - owner.addEvent(new BulletHitBulletEvent(createBullet(false), b.createBullet(true))); - b.owner.addEvent(new BulletHitBulletEvent(b.createBullet(false), createBullet(true))); - break; - } - } - } - - private Bullet createBullet(boolean hideOwnerName) { - String ownerName = (owner == null) ? null : (hideOwnerName ? getNameForEvent(owner) : owner.getName()); - String victimName = (victim == null) ? null : (hideOwnerName ? victim.getName() : getNameForEvent(victim)); - - return new Bullet(heading, x, y, power, ownerName, victimName, isActive(), bulletId); - } - - private BulletStatus createStatus() { - return new BulletStatus(bulletId, x, y, victim == null ? null : getNameForEvent(victim), isActive()); - } - - private String getNameForEvent(RobotPeer otherRobot) { - if (battleRules.getHideEnemyNames() && !owner.isTeamMate(otherRobot)) { - return otherRobot.getAnnonymousName(); - } - return otherRobot.getName(); - } - - // Workaround for http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6457965 - private boolean intersect(Line2D.Double line) { - double x1 = line.x1, x2 = line.x2, x3 = boundingLine.x1, x4 = boundingLine.x2; - double y1 = line.y1, y2 = line.y2, y3 = boundingLine.y1, y4 = boundingLine.y2; - - double dx13 = (x1 - x3), dx21 = (x2 - x1), dx43 = (x4 - x3); - double dy13 = (y1 - y3), dy21 = (y2 - y1), dy43 = (y4 - y3); - - double dn = dy43 * dx21 - dx43 * dy21; - - double ua = (dx43 * dy13 - dy43 * dx13) / dn; - double ub = (dx21 * dy13 - dy21 * dx13) / dn; - - return (ua >= 0 && ua <= 1) && (ub >= 0 && ub <= 1); - } - - private void checkRobotCollision(List robots) { - for (RobotPeer otherRobot : robots) { - if (!(otherRobot == null || otherRobot == owner || otherRobot.isDead()) - && otherRobot.getBoundingBox().intersectsLine(boundingLine)) { - - state = BulletState.HIT_VICTIM; - frame = 0; - victim = otherRobot; - - double damage = Rules.getBulletDamage(power); - - if (owner.isSentryRobot()) { - if (victim.isSentryRobot()) { - damage = 0; - } else { - int range = battleRules.getSentryBorderSize(); - if (x > range && x < (battleRules.getBattlefieldWidth() - range) && y > range - && y < (battleRules.getBattlefieldHeight() - range)) { - damage = 0; - } - } - } - - double score = damage; - if (score > otherRobot.getEnergy()) { - score = otherRobot.getEnergy(); - } - otherRobot.updateEnergy(-damage); - - boolean teamFire = (owner.getTeamPeer() != null && owner.getTeamPeer() == otherRobot.getTeamPeer()); - - if (!teamFire && !otherRobot.isSentryRobot()) { - owner.getRobotStatistics().scoreBulletDamage(otherRobot.getName(), score); - } - - if (otherRobot.getEnergy() <= 0 && otherRobot.isAlive()) { - otherRobot.kill(); - if (!teamFire && !otherRobot.isSentryRobot()) { - double bonus = owner.getRobotStatistics().scoreBulletKill(otherRobot.getName()); - if (bonus > 0) { - owner.println( - "SYSTEM: Bonus for killing " - + (owner.getNameForEvent(otherRobot) + ": " + (int) (bonus + .5))); - } - } - } - - if (!victim.isSentryRobot()) { - owner.updateEnergy(Rules.getBulletHitBonus(power)); - } - - otherRobot.addEvent( - new HitByBulletEvent( - robocode.util.Utils.normalRelativeAngle(heading + Math.PI - otherRobot.getBodyHeading()), - createBullet(true))); // Bugfix #366 - - owner.addEvent( - new BulletHitEvent(owner.getNameForEvent(otherRobot), otherRobot.getEnergy(), createBullet(false))); // Bugfix #366 - - double newX, newY; - - if (otherRobot.getBoundingBox().contains(lastX, lastY)) { - newX = lastX; - newY = lastY; - - setX(newX); - setY(newY); - } else { - newX = x; - newY = y; - } - - deltaX = newX - otherRobot.getX(); - deltaY = newY - otherRobot.getY(); - - break; - } - } - } - - private void checkWallCollision() { - if ((x - RADIUS <= 0) || (y - RADIUS <= 0) || (x + RADIUS >= battleRules.getBattlefieldWidth()) - || (y + RADIUS >= battleRules.getBattlefieldHeight())) { - state = BulletState.HIT_WALL; - frame = 0; - owner.addEvent(new BulletMissedEvent(createBullet(false))); // Bugfix #366 - } - } - - public int getBulletId() { - return bulletId; - } - - public int getFrame() { - return frame; - } - - public double getHeading() { - return heading; - } - - public RobotPeer getOwner() { - return owner; - } - - public double getPower() { - return power; - } - - public double getVelocity() { - return Rules.getBulletSpeed(power); - } - - public RobotPeer getVictim() { - return victim; - } - - public double getX() { - return x; - } - - public double getY() { - return y; - } - - public double getPaintX() { - return (state == BulletState.HIT_VICTIM && victim != null) ? victim.getX() + deltaX : x; - } - - public double getPaintY() { - return (state == BulletState.HIT_VICTIM && victim != null) ? victim.getY() + deltaY : y; - } - - public boolean isActive() { - return state.isActive(); - } - - public BulletState getState() { - return state; - } - - public int getColor() { - return color; - } - - public void setHeading(double newHeading) { - heading = newHeading; - } - - public void setPower(double newPower) { - power = newPower; - } - - public void setVictim(RobotPeer newVictim) { - victim = newVictim; - } - - public void setX(double newX) { - x = lastX = newX; - } - - public void setY(double newY) { - y = lastY = newY; - } - - public void setState(BulletState newState) { - state = newState; - } - - public void update(List robots, List bullets) { - frame++; - if (isActive()) { - updateMovement(); - checkWallCollision(); - if (isActive()) { - checkRobotCollision(robots); - } - if (isActive() && bullets != null) { - checkBulletCollision(bullets); - } - } - updateBulletState(); - owner.addBulletStatus(createStatus()); - } - - protected void updateBulletState() { - switch (state) { - case FIRED: - // Note that the bullet must be in the FIRED state before it goes to the MOVING state - if (frame > 0) { - state = BulletState.MOVING; - } - break; - - case HIT_BULLET: - case HIT_VICTIM: - case HIT_WALL: - case EXPLODED: - // Note that the bullet explosion must be ended before it goes into the INACTIVE state - if (frame >= getExplosionLength()) { - state = BulletState.INACTIVE; - } - break; - - default: - } - } - - private void updateMovement() { - lastX = x; - lastY = y; - - double v = getVelocity(); - - x += v * sin(heading); - y += v * cos(heading); - - boundingLine.setLine(lastX, lastY, x, y); - } - - public int getExplosionImageIndex() { - return explosionImageIndex; - } - - protected int getExplosionLength() { - return EXPLOSION_LENGTH; - } - - @Override - public String toString() { - return getOwner().getName() + " V" + getVelocity() + " *" + (int) power + " X" + (int) x + " Y" + (int) y + " H" - + heading + " " + state.toString(); - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/ContestantPeer.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/ContestantPeer.java deleted file mode 100644 index 8030135..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/ContestantPeer.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.peer; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public interface ContestantPeer extends Comparable { - String getName(); - - int getRobotIndex(); - int getTeamIndex(); - - ContestantStatistics getStatistics(); - - String toString(); -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/ContestantStatistics.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/ContestantStatistics.java deleted file mode 100644 index 73d61e0..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/ContestantStatistics.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.peer; - - -import robocode.BattleResults; - - -/** - * @author Mathew A. Nelson (original) - * @author Luis Crespo (contributor) - * @author Flemming N. Larsen (contributor) - */ -public interface ContestantStatistics { // NO_UCD (use default) - double getTotalScore(); - - double getTotalSurvivalScore(); - - double getTotalLastSurvivorBonus(); - - double getTotalBulletDamageScore(); - - double getTotalBulletKillBonus(); - - double getTotalRammingDamageScore(); - - double getTotalRammingKillBonus(); - - int getTotalFirsts(); - - int getTotalSeconds(); - - int getTotalThirds(); - - double getCurrentScore(); - - double getCurrentSurvivalScore(); - - double getCurrentSurvivalBonus(); - - double getCurrentBulletDamageScore(); - - double getCurrentBulletKillBonus(); - - double getCurrentRammingDamageScore(); - - double getCurrentRammingKillBonus(); - - BattleResults getFinalResults(); - - void setRank(int rank); -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/ExplosionPeer.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/ExplosionPeer.java deleted file mode 100644 index e2c470c..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/ExplosionPeer.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.peer; - - -import robocode.BattleRules; -import robocode.control.snapshot.BulletState; - -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Luis Crespo (contributor) - * @author Flemming N. Larsen (contributor) - * @author Titus Chen (contributor) - */ -public class ExplosionPeer extends BulletPeer { - - private static final int EXPLOSION_LENGTH = 71; - - ExplosionPeer(RobotPeer owner, BattleRules battleRules) { - super(owner, battleRules, 0); - frame = 0; - x = owner.getX(); - y = owner.getY(); - victim = owner; - power = 1; - state = BulletState.EXPLODED; - explosionImageIndex = 1; - } - - @Override - public final void update(List robots, List bullets) { - frame++; - - x = owner.getX(); - y = owner.getY(); - - updateBulletState(); - } - - @Override - protected int getExplosionLength() { - return EXPLOSION_LENGTH; - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/IRobotPeerBattle.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/IRobotPeerBattle.java deleted file mode 100644 index 18a9d85..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/IRobotPeerBattle.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.peer; - - -import robocode.Event; -import robocode.control.RobotSetup; - -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -interface IRobotPeerBattle extends ContestantPeer { - void setSGPaintEnabled(boolean enabled); - - RobotStatistics getRobotStatistics(); - - TeamPeer getTeamPeer(); - - void publishStatus(long currentTurn); - - void addEvent(Event event); - - void setPaintEnabled(boolean enabled); - - void kill(); - - void cleanup(); - - boolean isDead(); - - boolean isAlive(); - - boolean isRunning(); - - boolean isWinner(); - - boolean isTeamLeader(); - - void setHalt(boolean value); - - void println(String s); - - void waitWakeup(); - - void waitSleeping(long millisWait, int nanosWait); - - void waitForStop(); - - void setWinner(boolean newWinner); - - void initializeRound(List robots, RobotSetup[] initialRobotPositions); - - void startRound(long millisWait, int nanosWait); - - void checkSkippedTurn(); - - void performLoadCommands(); - - void performMove(List robots, double zapEnergy); - - void performScan(List robots); -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/RobotPeer.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/RobotPeer.java deleted file mode 100644 index c41d9fe..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/RobotPeer.java +++ /dev/null @@ -1,1764 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.peer; - - -import static net.sf.robocode.io.Logger.logMessage; -import net.sf.robocode.battle.Battle; -import net.sf.robocode.battle.BoundingRectangle; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.host.RobotStatics; -import net.sf.robocode.host.events.EventManager; -import net.sf.robocode.host.events.EventQueue; -import net.sf.robocode.host.proxies.IHostingRobotProxy; -import net.sf.robocode.io.Logger; -import net.sf.robocode.peer.*; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.security.HiddenAccess; -import net.sf.robocode.serialization.RbSerializer; -import robocode.*; -import robocode.control.RandomFactory; -import robocode.control.RobotSetup; -import robocode.control.RobotSpecification; -import robocode.control.snapshot.BulletState; -import robocode.control.snapshot.RobotState; -import robocode.exception.AbortedException; -import robocode.exception.DeathException; -import robocode.exception.WinException; -import static robocode.util.Utils.*; - -import java.awt.geom.Arc2D; -import java.awt.geom.Rectangle2D; -import java.io.IOException; - -import static java.lang.Math.*; - -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.Random; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; - - -/** - * RobotPeer is an object that deals with game mechanics and rules, and makes - * sure that robots abides the rules. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Luis Crespo (contributor) - * @author Titus Chen (contributor) - * @author Robert D. Maupin (contributor) - * @author Nathaniel Troutman (contributor) - * @author Pavel Savara (contributor) - * @author Patrick Cupka (contributor) - * @author Julian Kent (contributor) - * @author "Positive" (contributor) - * @author "BD123" (contributor) - */ -public final class RobotPeer implements IRobotPeerBattle, IRobotPeer { - - public static final int - WIDTH = 36, - HEIGHT = 36; - - private static final int - HALF_WIDTH_OFFSET = WIDTH / 2, - HALF_HEIGHT_OFFSET = HEIGHT / 2; - - private static final int MAX_SKIPPED_TURNS = 30; - private static final int MAX_SKIPPED_TURNS_WITH_IO = 240; - - private Battle battle; - private RobotStatistics statistics; - private final TeamPeer teamPeer; - private final RobotSpecification robotSpecification; - - private IHostingRobotProxy robotProxy; - private AtomicReference status = new AtomicReference(); - private AtomicReference commands = new AtomicReference(); - private AtomicReference events = new AtomicReference(new EventQueue()); - private AtomicReference> teamMessages = new AtomicReference>( - new ArrayList()); - private AtomicReference> bulletUpdates = new AtomicReference>( - new ArrayList()); - - // thread is running - private final AtomicBoolean isRunning = new AtomicBoolean(false); - - private final StringBuilder battleText = new StringBuilder(1024); - private final StringBuilder proxyText = new StringBuilder(1024); - private RobotStatics statics; - private BattleRules battleRules; - - // for battle thread, during robots processing - private ExecCommands currentCommands; - private double lastHeading; - private double lastGunHeading; - private double lastRadarHeading; - - private double energy; - private double velocity; - private double bodyHeading; - private double radarHeading; - private double gunHeading; - private double gunHeat; - private double x; - private double y; - - private boolean scan; - private boolean turnedRadarWithGun; // last round - - private boolean isIORobot; - private boolean isPaintEnabled; - private boolean sgPaintEnabled; - - // waiting for next tick - private final AtomicBoolean isSleeping = new AtomicBoolean(false); - private final AtomicBoolean halt = new AtomicBoolean(false); - - // last and current execution time and detecting skipped turns - private int lastExecutionTime = -1; - private int currentExecutionTime; - - private boolean isExecFinishedAndDisabled; - private boolean isEnergyDrained; - private boolean isWinner; - private boolean inCollision; - private boolean isOverDriving; - - private RobotState state; - private final Arc2D scanArc; - private final BoundingRectangle boundingBox; - private final RbSerializer rbSerializer; - - public RobotPeer(Battle battle, IHostManager hostManager, RobotSpecification robotSpecification, int duplicate, TeamPeer team, int robotIndex) { - super(); - - this.battle = battle; - this.robotSpecification = robotSpecification; - - this.rbSerializer = new RbSerializer(); - - this.boundingBox = new BoundingRectangle(); - this.scanArc = new Arc2D.Double(); - this.teamPeer = team; - this.state = RobotState.ACTIVE; - this.battleRules = battle.getBattleRules(); - - if (team != null) { - team.add(this); - } - String teamName; - List teamMembers; - boolean isTeamLeader; - int teamIndex; - - if (teamPeer == null) { - teamName = null; - teamMembers = null; - isTeamLeader = false; - teamIndex = -1; // Must be set to -1 when robot is not in a team - } else { - teamName = team.getName(); - teamMembers = team.getMemberNames(); - isTeamLeader = team.size() == 1; // That is current team size, more might follow later. First robot is leader - teamIndex = team.getTeamIndex(); - } - - this.statics = new RobotStatics(robotSpecification, duplicate, isTeamLeader, battleRules, teamName, teamMembers, - robotIndex, teamIndex); - this.statistics = new RobotStatistics(this, battle.getRobotsCount()); - - this.robotProxy = (IHostingRobotProxy) hostManager.createRobotProxy(robotSpecification, statics, this); - } - - public void println(String s) { - synchronized (proxyText) { - battleText.append(s); - battleText.append("\n"); - } - } - - private void print(String s) { - synchronized (proxyText) { - proxyText.append(s); - } - } - - public String readOutText() { - synchronized (proxyText) { - final String robotText = battleText.toString() + proxyText.toString(); - - battleText.setLength(0); - proxyText.setLength(0); - return robotText; - } - } - - public RobotStatistics getRobotStatistics() { - return statistics; - } - - public ContestantStatistics getStatistics() { - return statistics; - } - - public RobotSpecification getRobotSpecification() { - return robotSpecification; - } - - // ------------------- - // statics - // ------------------- - - public boolean isJuniorRobot() { - return statics.isJuniorRobot(); - } - - public boolean isAdvancedRobot() { - return statics.isAdvancedRobot(); - } - - public boolean isTeamRobot() { - return statics.isTeamRobot(); - } - - public boolean isDroid() { - return statics.isDroid(); - } - - public boolean isSentryRobot() { - return statics.isSentryRobot(); - } - - public boolean isInteractiveRobot() { - return statics.isInteractiveRobot(); - } - - public boolean isPaintRobot() { - return statics.isPaintRobot(); - } - - public String getName() { - return statics.getName(); - } - - public String getAnnonymousName() { - return statics.getAnnonymousName(); - } - - public String getShortName() { - return statics.getShortName(); - } - - public String getVeryShortName() { - return statics.getVeryShortName(); - } - - public int getRobotIndex() { - return statics.getRobotIndex(); - } - - public int getTeamIndex() { - return statics.getTeamIndex(); - } - - public int getContestantIndex() { - return getTeamIndex() >= 0 ? getTeamIndex() : getRobotIndex(); - } - - // ------------------- - // status - // ------------------- - - public void setPaintEnabled(boolean enabled) { - isPaintEnabled = enabled; - } - - public boolean isPaintEnabled() { - return isPaintEnabled; - } - - public void setSGPaintEnabled(boolean enabled) { - sgPaintEnabled = enabled; - } - - public boolean isSGPaintEnabled() { - return sgPaintEnabled; - } - - public RobotState getState() { - return state; - } - - public void setState(RobotState state) { - this.state = state; - } - - public boolean isDead() { - return state == RobotState.DEAD; - } - - public boolean isAlive() { - return state != RobotState.DEAD; - } - - public boolean isWinner() { - return isWinner; - } - - public boolean isRunning() { - return isRunning.get(); - } - - public boolean isSleeping() { - return isSleeping.get(); - } - - public boolean isHalt() { - return halt.get(); - } - - public void setHalt(boolean value) { - halt.set(value); - } - - public BoundingRectangle getBoundingBox() { - return boundingBox; - } - - public Arc2D getScanArc() { - return scanArc; - } - - // ------------------- - // robot space - // ------------------- - - public double getGunHeading() { - return gunHeading; - } - - public double getBodyHeading() { - return bodyHeading; - } - - public double getRadarHeading() { - return radarHeading; - } - - public double getVelocity() { - return velocity; - } - - public double getX() { - return x; - } - - public double getY() { - return y; - } - - public double getEnergy() { - return energy; - } - - public double getGunHeat() { - return gunHeat; - } - - public int getBodyColor() { - return commands.get().getBodyColor(); - } - - public int getRadarColor() { - return commands.get().getRadarColor(); - } - - public int getGunColor() { - return commands.get().getGunColor(); - } - - public int getBulletColor() { - return commands.get().getBulletColor(); - } - - public int getScanColor() { - return commands.get().getScanColor(); - } - - // ------------ - // team - // ------------ - - public TeamPeer getTeamPeer() { - return teamPeer; - } - - public String getTeamName() { - return statics.getTeamName(); - } - - public boolean isTeamLeader() { - return statics.isTeamLeader(); - } - - boolean isTeamMate(RobotPeer otherRobot) { - if (getTeamPeer() != null) { - for (RobotPeer mate : getTeamPeer()) { - if (otherRobot == mate) { - return true; - } - } - } - return false; - } - - // ----------- - // execute - // ----------- - - private ByteBuffer bidirectionalBuffer; - - public void setupBuffer(ByteBuffer bidirectionalBuffer) { - this.bidirectionalBuffer = bidirectionalBuffer; - } - - public void setupThread() { - Thread.currentThread().setName(getName()); - } - - public void executeImplSerial() throws IOException { - ExecCommands commands = (ExecCommands) rbSerializer.deserialize(bidirectionalBuffer); - - final ExecResults results = executeImpl(commands); - - bidirectionalBuffer.clear(); - rbSerializer.serializeToBuffer(bidirectionalBuffer, RbSerializer.ExecResults_TYPE, results); - } - - public void waitForBattleEndImplSerial() throws IOException { - ExecCommands commands = (ExecCommands) rbSerializer.deserialize(bidirectionalBuffer); - - final ExecResults results = waitForBattleEndImpl(commands); - - bidirectionalBuffer.clear(); - rbSerializer.serializeToBuffer(bidirectionalBuffer, RbSerializer.ExecResults_TYPE, results); - } - - public final ExecResults executeImpl(ExecCommands newCommands) { - validateCommands(newCommands); - - if (!isExecFinishedAndDisabled) { - // from robot to battle - commands.set(new ExecCommands(newCommands, true)); - print(newCommands.getOutputText()); - } else { - // slow down spammer - try { - Thread.sleep(100); - } catch (InterruptedException e) { - Thread.currentThread().interrupt(); - } - } - - // If we are stopping, yet the robot took action (in onWin or onDeath), stop now. - if (battle.isAborted()) { - isExecFinishedAndDisabled = true; - throw new AbortedException(); - } - if (isDead()) { - isExecFinishedAndDisabled = true; - throw new DeathException(); - } - if (isHalt()) { - isExecFinishedAndDisabled = true; - if (isWinner) { - throw new WinException(); - } else { - throw new AbortedException(); - } - } - - waitForNextTurn(); - - checkSkippedTurn(); - - // from battle to robot - final ExecCommands resCommands = new ExecCommands(this.commands.get(), false); - final RobotStatus resStatus = status.get(); - - final boolean shouldWait = battle.isAborted() || (battle.isLastRound() && isWinner()); - - return new ExecResults(resCommands, resStatus, readoutEvents(), readoutTeamMessages(), readoutBullets(), - isHalt(), shouldWait, isPaintEnabled()); - } - - public final ExecResults waitForBattleEndImpl(ExecCommands newCommands) { - if (!isHalt()) { - // from robot to battle - commands.set(new ExecCommands(newCommands, true)); - print(newCommands.getOutputText()); - - waitForNextTurn(); - } - // from battle to robot - final ExecCommands resCommands = new ExecCommands(this.commands.get(), false); - final RobotStatus resStatus = status.get(); - - final boolean shouldWait = battle.isAborted() || (battle.isLastRound() && !isWinner()); - - readoutTeamMessages(); // throw away - - return new ExecResults(resCommands, resStatus, readoutEvents(), new ArrayList(), readoutBullets(), - isHalt(), shouldWait, false); - } - - private void validateCommands(ExecCommands newCommands) { - if (Double.isNaN(newCommands.getMaxTurnRate())) { - println("You cannot setMaxTurnRate to: " + newCommands.getMaxTurnRate()); - } - newCommands.setMaxTurnRate(Math.min(abs(newCommands.getMaxTurnRate()), Rules.MAX_TURN_RATE_RADIANS)); - - if (Double.isNaN(newCommands.getMaxVelocity())) { - println("You cannot setMaxVelocity to: " + newCommands.getMaxVelocity()); - } - newCommands.setMaxVelocity(Math.min(abs(newCommands.getMaxVelocity()), Rules.MAX_VELOCITY)); - } - - private List readoutEvents() { - return events.getAndSet(new EventQueue()); - } - - private List readoutTeamMessages() { - return teamMessages.getAndSet(new ArrayList()); - } - - private List readoutBullets() { - return bulletUpdates.getAndSet(new ArrayList()); - } - - private void waitForNextTurn() { - synchronized (isSleeping) { - // Notify the battle that we are now asleep. - // This ends any pending wait() call in battle.runRound(). - // Should not actually take place until we release the lock in wait(), below. - isSleeping.set(true); - isSleeping.notifyAll(); - // Notifying battle that we're asleep - // Sleeping and waiting for battle to wake us up. - try { - isSleeping.wait(); - } catch (InterruptedException e) { - // We are expecting this to happen when a round is ended! - - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - } - isSleeping.set(false); - // Notify battle thread, which is waiting in - // our wakeup() call, to return. - // It's quite possible, by the way, that we'll be back in sleep (above) - // before the battle thread actually wakes up - isSleeping.notifyAll(); - } - } - - // ----------- - // called on battle thread - // ----------- - - public void waitWakeup() { - synchronized (isSleeping) { - if (isSleeping()) { - // Wake up the thread - isSleeping.notifyAll(); - try { - isSleeping.wait(10000); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - } - } - } - } - - private void waitWakeupNoWait() { - synchronized (isSleeping) { - if (isSleeping()) { - // Wake up the thread - isSleeping.notifyAll(); - } - } - } - - public void waitSleeping(long millisWait, int nanosWait) { - synchronized (isSleeping) { - // It's quite possible for simple robots to - // complete their processing before we get here, - // so we test if the robot is already asleep. - - if (!isSleeping()) { - try { - for (long i = millisWait; i > 0 && !isSleeping() && isRunning(); i--) { - isSleeping.wait(0, 999999); - } - if (!isSleeping() && isRunning()) { - isSleeping.wait(0, nanosWait); - } - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - - logMessage("Wait for " + getName() + " interrupted."); - } - } - } - } - - public void checkSkippedTurn() { - // Store last and current execution time for detecting skipped turns - lastExecutionTime = currentExecutionTime; - currentExecutionTime = battle.getTime(); - - int numSkippedTurns = (currentExecutionTime - lastExecutionTime) - 1; - if (numSkippedTurns >= 1) { - events.get().clear(false); - - if (isAlive()) { - for (int skippedTurn = lastExecutionTime + 1; skippedTurn < currentExecutionTime; skippedTurn++) { - addEvent(new SkippedTurnEvent(skippedTurn)); - println("SYSTEM: " + getShortName() + " skipped turn " + skippedTurn); - } - } - - if ((!isIORobot && (numSkippedTurns > MAX_SKIPPED_TURNS)) - || (isIORobot && (numSkippedTurns > MAX_SKIPPED_TURNS_WITH_IO))) { - println("SYSTEM: " + getShortName() + " has not performed any actions in a reasonable amount of time."); - println("SYSTEM: No score will be generated."); - setHalt(true); - waitWakeupNoWait(); - punishBadBehavior(BadBehavior.SKIPPED_TOO_MANY_TURNS); - robotProxy.forceStopThread(); - } - } - } - - public void initializeRound(List robots, RobotSetup[] initialRobotSetups) { - boolean valid = false; - - if (initialRobotSetups != null) { - int robotIndex = statics.getRobotIndex(); - - if (robotIndex >= 0 && robotIndex < initialRobotSetups.length) { - RobotSetup setup = initialRobotSetups[robotIndex]; - if (setup != null) { - x = setup.getX(); - y = setup.getY(); - bodyHeading = gunHeading = radarHeading = setup.getHeading(); - - updateBoundingBox(); - valid = validSpot(robots); - } - } - } - - if (!valid) { - final Random random = RandomFactory.getRandom(); - - double maxWidth = battleRules.getBattlefieldWidth() - RobotPeer.WIDTH; - double maxHeight = battleRules.getBattlefieldHeight() - RobotPeer.HEIGHT; - - double halfRobotWidth = RobotPeer.WIDTH / 2; - double halfRobotHeight = RobotPeer.HEIGHT / 2; - - int sentryBorderSize = battle.getBattleRules().getSentryBorderSize(); - int sentryBorderMoveWidth = sentryBorderSize - RobotPeer.WIDTH; - int sentryBorderMoveHeight = sentryBorderSize - RobotPeer.HEIGHT; - - for (int j = 0; j < 1000; j++) { - double rndX = random.nextDouble(); - double rndY = random.nextDouble(); - - if (isSentryRobot()) { - boolean placeOnHorizontalBar = random.nextDouble() - <= ((double) battleRules.getBattlefieldWidth() - / (battleRules.getBattlefieldWidth() + battleRules.getBattlefieldHeight())); - - if (placeOnHorizontalBar) { - x = halfRobotWidth + rndX * maxWidth; - y = halfRobotHeight + (sentryBorderMoveHeight * (rndY * 2.0 - 1.0) + maxHeight) % maxHeight; - } else { - y = halfRobotHeight + rndY * maxHeight; - x = halfRobotWidth + (sentryBorderMoveWidth * (rndX * 2.0 - 1.0) + maxWidth) % maxWidth; - } - } else { - if (battle.countActiveSentries() > 0) { - int safeZoneWidth = battleRules.getBattlefieldWidth() - 2 * sentryBorderSize; - int safeZoneHeight = battleRules.getBattlefieldHeight() - 2 * sentryBorderSize; - - x = sentryBorderSize + RobotPeer.WIDTH + rndX * (safeZoneWidth - 2 * RobotPeer.WIDTH); - y = sentryBorderSize + RobotPeer.HEIGHT + rndY * (safeZoneHeight - 2 * RobotPeer.HEIGHT); - } else { - x = RobotPeer.WIDTH + rndX * (battleRules.getBattlefieldWidth() - 2 * RobotPeer.WIDTH); - y = RobotPeer.HEIGHT + rndY * (battleRules.getBattlefieldHeight() - 2 * RobotPeer.HEIGHT); - } - } - - bodyHeading = 2 * Math.PI * random.nextDouble(); - gunHeading = radarHeading = bodyHeading; - updateBoundingBox(); - - if (validSpot(robots)) { - break; - } - } - } - - setState(RobotState.ACTIVE); - - isWinner = false; - velocity = 0; - - energy = 100; - if (statics.isSentryRobot()) { - energy += 400; - } - if (statics.isTeamLeader()) { - energy += 100; - } - if (statics.isDroid()) { - energy += 20; - } - - gunHeat = 3; - - setHalt(false); - isExecFinishedAndDisabled = false; - isEnergyDrained = false; - - scan = false; - - inCollision = false; - - scanArc.setAngleStart(0); - scanArc.setAngleExtent(0); - scanArc.setFrame(-100, -100, 1, 1); - - lastExecutionTime = -1; - - status = new AtomicReference(); - - readoutEvents(); - readoutTeamMessages(); - readoutBullets(); - - battleText.setLength(0); - proxyText.setLength(0); - - // Prepare new execution commands, but copy the colors from the last commands. - // Bugfix [2628217] - Robot Colors don't stick between rounds. - ExecCommands newExecCommands = new ExecCommands(); - - newExecCommands.copyColors(commands.get()); - commands = new AtomicReference(newExecCommands); - } - - private boolean validSpot(List robots) { - for (RobotPeer otherRobot : robots) { - if (otherRobot != null && otherRobot != this) { - if (getBoundingBox().intersects(otherRobot.getBoundingBox())) { - return false; - } - } - } - return true; - } - - public void startRound(long waitMillis, int waitNanos) { - Logger.logMessage(".", false); - - statistics.reset(); - - ExecCommands newExecCommands = new ExecCommands(); - - // Copy the colors from the last commands. - // Bugfix [2628217] - Robot Colors don't stick between rounds. - newExecCommands.copyColors(commands.get()); - - currentCommands = newExecCommands; - - int others = battle.countActiveParticipants() - (isAlive() ? 1 : 0); - int numSentries = battle.countActiveSentries(); - - RobotStatus stat = HiddenAccess.createStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, - currentCommands.getBodyTurnRemaining(), currentCommands.getRadarTurnRemaining(), - currentCommands.getGunTurnRemaining(), currentCommands.getDistanceRemaining(), gunHeat, others, numSentries, - battle.getRoundNum(), battle.getNumRounds(), battle.getTime()); - - status.set(stat); - robotProxy.startRound(currentCommands, stat); - - synchronized (isSleeping) { - try { - // Wait for the robot to go to sleep (take action) - isSleeping.wait(waitMillis, waitNanos); - } catch (InterruptedException e) { - logMessage("Wait for " + getName() + " interrupted."); - - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - } - } - if (!isSleeping() && !battle.isDebugging()) { - logMessage("\n" + getName() + " still has not started after " + waitMillis + " ms... giving up."); - } - } - - public void performLoadCommands() { - currentCommands = commands.get(); - - fireBullets(currentCommands.getBullets()); - - if (currentCommands.isScan()) { - scan = true; - } - - if (currentCommands.isIORobot()) { - isIORobot = true; - } - - if (currentCommands.isMoved()) { - currentCommands.setMoved(false); - } - } - - private void fireBullets(List bulletCommands) { - BulletPeer newBullet = null; - - for (BulletCommand bulletCmd : bulletCommands) { - if (Double.isNaN(bulletCmd.getPower())) { - println("SYSTEM: You cannot call fire(NaN)"); - continue; - } - if (gunHeat > 0 || energy == 0) { - return; - } - - double firePower = min(energy, - min(max(bulletCmd.getPower(), Rules.MIN_BULLET_POWER), Rules.MAX_BULLET_POWER)); - - updateEnergy(-firePower); - - gunHeat += Rules.getGunHeat(firePower); - - newBullet = new BulletPeer(this, battleRules, bulletCmd.getBulletId()); - - newBullet.setPower(firePower); - if (!turnedRadarWithGun || !bulletCmd.isFireAssistValid() || statics.isAdvancedRobot()) { - newBullet.setHeading(gunHeading); - } else { - newBullet.setHeading(bulletCmd.getFireAssistAngle()); - } - newBullet.setX(x); - newBullet.setY(y); - } - // there is only last bullet in one turn - if (newBullet != null) { - // newBullet.update(robots, bullets); - battle.addBullet(newBullet); - } - } - - public final void performMove(List robots, double zapEnergy) { - - // Reset robot state to active if it is not dead - if (isDead()) { - return; - } - - setState(RobotState.ACTIVE); - - updateGunHeat(); - - lastHeading = bodyHeading; - lastGunHeading = gunHeading; - lastRadarHeading = radarHeading; - final double lastX = x; - final double lastY = y; - - if (!inCollision) { - updateHeading(); - } - - updateGunHeading(); - updateRadarHeading(); - updateMovement(); - - // At this point, robot has turned then moved. - // We could be touching a wall or another bot... - - // First and foremost, we can never go through a wall: - checkWallCollision(); - - // If this robot is a border sentry robot then check if it hits its "range border" - if (isSentryRobot()) { - checkSentryOutsideBorder(); - } - - // Now check for robot collision - checkRobotCollision(robots); - - // Scan false means robot did not call scan() manually. - // But if we're moving, scan - if (!scan) { - scan = (lastHeading != bodyHeading || lastGunHeading != gunHeading || lastRadarHeading != radarHeading - || lastX != x || lastY != y); - } - - if (isDead()) { - return; - } - - // zap - if (zapEnergy != 0) { - zap(zapEnergy); - } - } - - public void performScan(List robots) { - if (isDead()) { - return; - } - - turnedRadarWithGun = false; - // scan - if (scan) { - scan(lastRadarHeading, robots); - turnedRadarWithGun = (lastGunHeading == lastRadarHeading) && (gunHeading == radarHeading); - scan = false; - } - - // dispatch messages - if (statics.isTeamRobot() && teamPeer != null) { - for (TeamMessage teamMessage : currentCommands.getTeamMessages()) { - for (RobotPeer member : teamPeer) { - if (checkDispatchToMember(member, teamMessage.recipient)) { - member.addTeamMessage(teamMessage); - } - } - } - } - currentCommands = null; - lastHeading = -1; - lastGunHeading = -1; - lastRadarHeading = -1; - } - - private void addTeamMessage(TeamMessage message) { - final List queue = teamMessages.get(); - - queue.add(message); - } - - private boolean checkDispatchToMember(RobotPeer member, String recipient) { - if (member.isAlive()) { - if (recipient == null) { - if (member != this) { - return true; - } - } else { - final int nl = recipient.length(); - final String currentName = member.statics.getName(); - - if ((currentName.length() >= nl && currentName.substring(0, nl).equals(recipient))) { - return true; - } - - final String currentClassName = member.statics.getFullClassName(); - - if ((currentClassName.length() >= nl && currentClassName.substring(0, nl).equals(recipient))) { - return true; - } - - } - } - return false; - } - - public String getNameForEvent(RobotPeer otherRobot) { - if (battleRules.getHideEnemyNames() && !isTeamMate(otherRobot)) { - return otherRobot.getAnnonymousName(); - } - return otherRobot.getName(); - } - - private void checkRobotCollision(List robots) { - inCollision = false; - - for (RobotPeer otherRobot : robots) { - if (!(otherRobot == null || otherRobot == this || otherRobot.isDead()) - && boundingBox.intersects(otherRobot.boundingBox)) { - // Bounce back - double angle = atan2(otherRobot.x - x, otherRobot.y - y); - - double movedx = velocity * sin(bodyHeading); - double movedy = velocity * cos(bodyHeading); - - boolean atFault; - double bearing = normalRelativeAngle(angle - bodyHeading); - - if ((velocity > 0 && bearing > -PI / 2 && bearing < PI / 2) - || (velocity < 0 && (bearing < -PI / 2 || bearing > PI / 2))) { - - inCollision = true; - atFault = true; - velocity = 0; - currentCommands.setDistanceRemaining(0); - x -= movedx; - y -= movedy; - - boolean teamFire = (teamPeer != null && teamPeer == otherRobot.teamPeer); - - if (!teamFire && !otherRobot.isSentryRobot()) { - statistics.scoreRammingDamage(otherRobot.getName()); - } - - this.updateEnergy(-Rules.ROBOT_HIT_DAMAGE); - otherRobot.updateEnergy(-Rules.ROBOT_HIT_DAMAGE); - - if (otherRobot.energy == 0) { - if (otherRobot.isAlive()) { - otherRobot.kill(); - if (!teamFire && !otherRobot.isSentryRobot()) { - final double bonus = statistics.scoreRammingKill(otherRobot.getName()); - - if (bonus > 0) { - println( - "SYSTEM: Ram bonus for killing " + this.getNameForEvent(otherRobot) + ": " - + (int) (bonus + .5)); - } - } - } - } - addEvent( - new HitRobotEvent(getNameForEvent(otherRobot), normalRelativeAngle(angle - bodyHeading), - otherRobot.energy, atFault)); - otherRobot.addEvent( - new HitRobotEvent(getNameForEvent(this), - normalRelativeAngle(PI + angle - otherRobot.getBodyHeading()), energy, false)); - } - } - } - if (inCollision) { - setState(RobotState.HIT_ROBOT); - } - } - - private void checkWallCollision() { - int minX = 0 + HALF_WIDTH_OFFSET; - int minY = 0 + HALF_HEIGHT_OFFSET; - int maxX = (int) getBattleFieldWidth() - HALF_WIDTH_OFFSET; - int maxY = (int) getBattleFieldHeight() - HALF_HEIGHT_OFFSET; - - boolean hitWall = false; - double adjustX = 0, adjustY = 0; - double angle = 0; - - if (x < minX) { - hitWall = true; - adjustX = minX - x; - angle = normalRelativeAngle(3 * PI / 2 - bodyHeading); - - } else if (x > maxX) { - hitWall = true; - adjustX = maxX - x; - angle = normalRelativeAngle(PI / 2 - bodyHeading); - - } else if (y < minY) { - hitWall = true; - adjustY = minY - y; - angle = normalRelativeAngle(PI - bodyHeading); - - } else if (y > maxY) { - hitWall = true; - adjustY = maxY - y; - angle = normalRelativeAngle(-bodyHeading); - } - - if (hitWall) { - addEvent(new HitWallEvent(angle)); - - // only fix both x and y values if hitting wall at an angle - if ((bodyHeading % (Math.PI / 2)) != 0) { - double tanHeading = tan(bodyHeading); - - // if it hits bottom or top wall - if (adjustX == 0) { - adjustX = adjustY * tanHeading; - } // if it hits a side wall - else if (adjustY == 0) { - adjustY = adjustX / tanHeading; - } // if the robot hits 2 walls at the same time (rare, but just in case) - else if (abs(adjustX / tanHeading) > abs(adjustY)) { - adjustY = adjustX / tanHeading; - } else if (abs(adjustY * tanHeading) > abs(adjustX)) { - adjustX = adjustY * tanHeading; - } - } - x += adjustX; - y += adjustY; - - if (x < minX) { - x = minX; - } else if (x > maxX) { - x = maxX; - } - if (y < minY) { - y = minY; - } else if (y > maxY) { - y = maxY; - } - - // Update energy, but do not reset inactiveTurnCount - if (statics.isAdvancedRobot()) { - setEnergy(energy - Rules.getWallHitDamage(velocity), false); - } - - updateBoundingBox(); - - currentCommands.setDistanceRemaining(0); - velocity = 0; - - setState(RobotState.HIT_WALL); - } - } - - private void checkSentryOutsideBorder() { - int range = battle.getBattleRules().getSentryBorderSize(); - - int minX = range - HALF_WIDTH_OFFSET; - int minY = range - HALF_HEIGHT_OFFSET; - int maxX = (int) getBattleFieldWidth() - range + HALF_WIDTH_OFFSET; - int maxY = (int) getBattleFieldHeight() - range + HALF_HEIGHT_OFFSET; - - boolean hitWall = false; - double adjustX = 0, adjustY = 0; - double angle = 0; - - boolean isOutsideBorder = x > minX && x < maxX && y > minY && y < maxY; - - if (isOutsideBorder) { - if ((x - minX) <= Rules.MAX_VELOCITY) { - hitWall = true; - adjustX = minX - x; - angle = normalRelativeAngle(PI / 2 - bodyHeading); - - } else if ((maxX - x) <= Rules.MAX_VELOCITY) { - hitWall = true; - adjustX = maxX - x; - angle = normalRelativeAngle(3 * PI / 2 - bodyHeading); - - } else if ((y - minY) <= Rules.MAX_VELOCITY) { - hitWall = true; - adjustY = minY - y; - angle = normalRelativeAngle(-bodyHeading); - - } else if ((maxY - y) <= Rules.MAX_VELOCITY) { - hitWall = true; - adjustY = maxY - y; - angle = normalRelativeAngle(PI - bodyHeading); - } - } - - if (hitWall) { - addEvent(new HitWallEvent(angle)); - - // only fix both x and y values if hitting wall at an angle - if ((bodyHeading % (Math.PI / 2)) != 0) { - double tanHeading = tan(bodyHeading); - - // if it hits bottom or top wall - if (adjustX == 0) { - adjustX = adjustY * tanHeading; - } // if it hits a side wall - else if (adjustY == 0) { - adjustY = adjustX / tanHeading; - } // if the robot hits 2 walls at the same time (rare, but just in case) - else if (abs(adjustX / tanHeading) > abs(adjustY)) { - adjustY = adjustX / tanHeading; - } else if (abs(adjustY * tanHeading) > abs(adjustX)) { - adjustX = adjustY * tanHeading; - } - } - - x += adjustX; - y += adjustY; - - if (isOutsideBorder) { - if ((x - minX) <= Rules.MAX_VELOCITY) { - x = minX; - } else if ((maxX - x) <= Rules.MAX_VELOCITY) { - x = maxX; - } - if ((y - minY) <= Rules.MAX_VELOCITY) { - y = minY; - } else if ((maxY - y) <= Rules.MAX_VELOCITY) { - y = maxY; - } - } - - // Update energy, but do not reset inactiveTurnCount - if (statics.isAdvancedRobot()) { - setEnergy(energy - Rules.getWallHitDamage(velocity), false); - } - - updateBoundingBox(); - - currentCommands.setDistanceRemaining(0); - velocity = 0; - - setState(RobotState.HIT_WALL); - } - } - - private double getBattleFieldHeight() { - return battleRules.getBattlefieldHeight(); - } - - private double getBattleFieldWidth() { - return battleRules.getBattlefieldWidth(); - } - - private void updateBoundingBox() { - boundingBox.setRect(x - HALF_WIDTH_OFFSET, y - HALF_HEIGHT_OFFSET, WIDTH, HEIGHT); - } - - // TODO: Only add events to robots that are alive? + Remove checks if the Robot is alive before adding the event? - public void addEvent(Event event) { - if (isRunning()) { - final EventQueue queue = events.get(); - - if ((queue.size() > EventManager.MAX_QUEUE_SIZE) - && !(event instanceof DeathEvent || event instanceof WinEvent || event instanceof SkippedTurnEvent)) { - println( - "Not adding to " + statics.getShortName() + "'s queue, exceeded " + EventManager.MAX_QUEUE_SIZE - + " events in queue."); - // clean up old stuff - queue.clear(battle.getTime() - EventManager.MAX_EVENT_STACK); - } else { - queue.add(event); - } - } - } - - private void updateGunHeading() { - if (currentCommands.getGunTurnRemaining() > 0) { - if (currentCommands.getGunTurnRemaining() < Rules.GUN_TURN_RATE_RADIANS) { - gunHeading += currentCommands.getGunTurnRemaining(); - radarHeading += currentCommands.getGunTurnRemaining(); - if (currentCommands.isAdjustRadarForGunTurn()) { - currentCommands.setRadarTurnRemaining( - currentCommands.getRadarTurnRemaining() - currentCommands.getGunTurnRemaining()); - } - currentCommands.setGunTurnRemaining(0); - } else { - gunHeading += Rules.GUN_TURN_RATE_RADIANS; - radarHeading += Rules.GUN_TURN_RATE_RADIANS; - currentCommands.setGunTurnRemaining(currentCommands.getGunTurnRemaining() - Rules.GUN_TURN_RATE_RADIANS); - if (currentCommands.isAdjustRadarForGunTurn()) { - currentCommands.setRadarTurnRemaining( - currentCommands.getRadarTurnRemaining() - Rules.GUN_TURN_RATE_RADIANS); - } - } - } else if (currentCommands.getGunTurnRemaining() < 0) { - if (currentCommands.getGunTurnRemaining() > -Rules.GUN_TURN_RATE_RADIANS) { - gunHeading += currentCommands.getGunTurnRemaining(); - radarHeading += currentCommands.getGunTurnRemaining(); - if (currentCommands.isAdjustRadarForGunTurn()) { - currentCommands.setRadarTurnRemaining( - currentCommands.getRadarTurnRemaining() - currentCommands.getGunTurnRemaining()); - } - currentCommands.setGunTurnRemaining(0); - } else { - gunHeading -= Rules.GUN_TURN_RATE_RADIANS; - radarHeading -= Rules.GUN_TURN_RATE_RADIANS; - currentCommands.setGunTurnRemaining(currentCommands.getGunTurnRemaining() + Rules.GUN_TURN_RATE_RADIANS); - if (currentCommands.isAdjustRadarForGunTurn()) { - currentCommands.setRadarTurnRemaining( - currentCommands.getRadarTurnRemaining() + Rules.GUN_TURN_RATE_RADIANS); - } - } - } - gunHeading = normalAbsoluteAngle(gunHeading); - } - - private void updateHeading() { - boolean normalizeHeading = true; - - double turnRate = min(currentCommands.getMaxTurnRate(), - (.4 + .6 * (1 - (abs(velocity) / Rules.MAX_VELOCITY))) * Rules.MAX_TURN_RATE_RADIANS); - - if (currentCommands.getBodyTurnRemaining() > 0) { - if (currentCommands.getBodyTurnRemaining() < turnRate) { - bodyHeading += currentCommands.getBodyTurnRemaining(); - gunHeading += currentCommands.getBodyTurnRemaining(); - radarHeading += currentCommands.getBodyTurnRemaining(); - if (currentCommands.isAdjustGunForBodyTurn()) { - currentCommands.setGunTurnRemaining( - currentCommands.getGunTurnRemaining() - currentCommands.getBodyTurnRemaining()); - } - if (currentCommands.isAdjustRadarForBodyTurn()) { - currentCommands.setRadarTurnRemaining( - currentCommands.getRadarTurnRemaining() - currentCommands.getBodyTurnRemaining()); - } - currentCommands.setBodyTurnRemaining(0); - } else { - bodyHeading += turnRate; - gunHeading += turnRate; - radarHeading += turnRate; - currentCommands.setBodyTurnRemaining(currentCommands.getBodyTurnRemaining() - turnRate); - if (currentCommands.isAdjustGunForBodyTurn()) { - currentCommands.setGunTurnRemaining(currentCommands.getGunTurnRemaining() - turnRate); - } - if (currentCommands.isAdjustRadarForBodyTurn()) { - currentCommands.setRadarTurnRemaining(currentCommands.getRadarTurnRemaining() - turnRate); - } - } - } else if (currentCommands.getBodyTurnRemaining() < 0) { - if (currentCommands.getBodyTurnRemaining() > -turnRate) { - bodyHeading += currentCommands.getBodyTurnRemaining(); - gunHeading += currentCommands.getBodyTurnRemaining(); - radarHeading += currentCommands.getBodyTurnRemaining(); - if (currentCommands.isAdjustGunForBodyTurn()) { - currentCommands.setGunTurnRemaining( - currentCommands.getGunTurnRemaining() - currentCommands.getBodyTurnRemaining()); - } - if (currentCommands.isAdjustRadarForBodyTurn()) { - currentCommands.setRadarTurnRemaining( - currentCommands.getRadarTurnRemaining() - currentCommands.getBodyTurnRemaining()); - } - currentCommands.setBodyTurnRemaining(0); - } else { - bodyHeading -= turnRate; - gunHeading -= turnRate; - radarHeading -= turnRate; - currentCommands.setBodyTurnRemaining(currentCommands.getBodyTurnRemaining() + turnRate); - if (currentCommands.isAdjustGunForBodyTurn()) { - currentCommands.setGunTurnRemaining(currentCommands.getGunTurnRemaining() + turnRate); - } - if (currentCommands.isAdjustRadarForBodyTurn()) { - currentCommands.setRadarTurnRemaining(currentCommands.getRadarTurnRemaining() + turnRate); - } - } - } else { - normalizeHeading = false; - } - - if (normalizeHeading) { - if (currentCommands.getBodyTurnRemaining() == 0) { - bodyHeading = normalNearAbsoluteAngle(bodyHeading); - } else { - bodyHeading = normalAbsoluteAngle(bodyHeading); - } - } - if (Double.isNaN(bodyHeading)) { - Logger.realErr.println("HOW IS HEADING NAN HERE"); - } - } - - private void updateRadarHeading() { - if (currentCommands.getRadarTurnRemaining() > 0) { - if (currentCommands.getRadarTurnRemaining() < Rules.RADAR_TURN_RATE_RADIANS) { - radarHeading += currentCommands.getRadarTurnRemaining(); - currentCommands.setRadarTurnRemaining(0); - } else { - radarHeading += Rules.RADAR_TURN_RATE_RADIANS; - currentCommands.setRadarTurnRemaining( - currentCommands.getRadarTurnRemaining() - Rules.RADAR_TURN_RATE_RADIANS); - } - } else if (currentCommands.getRadarTurnRemaining() < 0) { - if (currentCommands.getRadarTurnRemaining() > -Rules.RADAR_TURN_RATE_RADIANS) { - radarHeading += currentCommands.getRadarTurnRemaining(); - currentCommands.setRadarTurnRemaining(0); - } else { - radarHeading -= Rules.RADAR_TURN_RATE_RADIANS; - currentCommands.setRadarTurnRemaining( - currentCommands.getRadarTurnRemaining() + Rules.RADAR_TURN_RATE_RADIANS); - } - } - - radarHeading = normalAbsoluteAngle(radarHeading); - } - - /** - * Updates the robots movement. - * - * This is Nat Pavasants method described here: - * http://robowiki.net/wiki/User:Positive/Optimal_Velocity#Nat.27s_updateMovement - */ - private void updateMovement() { - double distance = currentCommands.getDistanceRemaining(); - - if (Double.isNaN(distance)) { - distance = 0; - } - - velocity = getNewVelocity(velocity, distance); - - // If we are over-driving our distance and we are now at velocity=0 - // then we stopped. - if (isNear(velocity, 0) && isOverDriving) { - currentCommands.setDistanceRemaining(0); - distance = 0; - isOverDriving = false; - } - - // If we are moving normally and the breaking distance is more - // than remaining distance, enabled the overdrive flag. - if (Math.signum(distance * velocity) != -1) { - if (getDistanceTraveledUntilStop(velocity) > Math.abs(distance)) { - isOverDriving = true; - } else { - isOverDriving = false; - } - } - - currentCommands.setDistanceRemaining(distance - velocity); - - if (velocity != 0) { - x += velocity * sin(bodyHeading); - y += velocity * cos(bodyHeading); - updateBoundingBox(); - } - } - - private double getDistanceTraveledUntilStop(double velocity) { - double distance = 0; - - velocity = Math.abs(velocity); - while (velocity > 0) { - distance += (velocity = getNewVelocity(velocity, 0)); - } - return distance; - } - - /** - * Returns the new velocity based on the current velocity and distance to move. - * - * @param velocity the current velocity - * @param distance the distance to move - * @return the new velocity based on the current velocity and distance to move - * - * This is Patrick Cupka (aka Voidious), Julian Kent (aka Skilgannon), and Positive's method described here: - * http://robowiki.net/wiki/User:Voidious/Optimal_Velocity#Hijack_2 - */ - private double getNewVelocity(double velocity, double distance) { - if (distance < 0) { - // If the distance is negative, then change it to be positive - // and change the sign of the input velocity and the result - return -getNewVelocity(-velocity, -distance); - } - - final double goalVel; - - if (distance == Double.POSITIVE_INFINITY) { - goalVel = currentCommands.getMaxVelocity(); - } else { - goalVel = Math.min(getMaxVelocity(distance), currentCommands.getMaxVelocity()); - } - - if (velocity >= 0) { - return Math.max(velocity - Rules.DECELERATION, Math.min(goalVel, velocity + Rules.ACCELERATION)); - } - // else - return Math.max(velocity - Rules.ACCELERATION, Math.min(goalVel, velocity + maxDecel(-velocity))); - } - - private final static double getMaxVelocity(double distance) { - final double decelTime = Math.max(1, Math.ceil(// sum of 0... decelTime, solving for decelTime using quadratic formula - (Math.sqrt((4 * 2 / Rules.DECELERATION) * distance + 1) - 1) / 2)); - - if (decelTime == Double.POSITIVE_INFINITY) { - return Rules.MAX_VELOCITY; - } - - final double decelDist = (decelTime / 2.0) * (decelTime - 1) // sum of 0..(decelTime-1) - * Rules.DECELERATION; - - return ((decelTime - 1) * Rules.DECELERATION) + ((distance - decelDist) / decelTime); - } - - private static double maxDecel(double speed) { - double decelTime = speed / Rules.DECELERATION; - double accelTime = (1 - decelTime); - - return Math.min(1, decelTime) * Rules.DECELERATION + Math.max(0, accelTime) * Rules.ACCELERATION; - } - - private void updateGunHeat() { - gunHeat -= battleRules.getGunCoolingRate(); - if (gunHeat < 0) { - gunHeat = 0; - } - } - - private void scan(double lastRadarHeading, List robots) { - if (statics.isDroid()) { - return; - } - - double startAngle = lastRadarHeading; - double scanRadians = getRadarHeading() - startAngle; - - // Check if we passed through 360 - if (scanRadians < -PI) { - scanRadians = 2 * PI + scanRadians; - } else if (scanRadians > PI) { - scanRadians = scanRadians - 2 * PI; - } - - // In our coords, we are scanning clockwise, with +y up - // In java coords, we are scanning counterclockwise, with +y down - // All we need to do is adjust our angle by -90 for this to work. - startAngle -= PI / 2; - - startAngle = normalAbsoluteAngle(startAngle); - - scanArc.setArc(x - Rules.RADAR_SCAN_RADIUS, y - Rules.RADAR_SCAN_RADIUS, 2 * Rules.RADAR_SCAN_RADIUS, - 2 * Rules.RADAR_SCAN_RADIUS, 180.0 * startAngle / PI, 180.0 * scanRadians / PI, Arc2D.PIE); - - for (RobotPeer otherRobot : robots) { - if (!(otherRobot == null || otherRobot == this || otherRobot.isDead()) - && intersects(scanArc, otherRobot.boundingBox)) { - double dx = otherRobot.x - x; - double dy = otherRobot.y - y; - double angle = atan2(dx, dy); - double dist = Math.hypot(dx, dy); - - final ScannedRobotEvent event = new ScannedRobotEvent(getNameForEvent(otherRobot), otherRobot.energy, - normalRelativeAngle(angle - getBodyHeading()), dist, otherRobot.getBodyHeading(), - otherRobot.getVelocity(), otherRobot.isSentryRobot()); - - addEvent(event); - } - } - } - - private boolean intersects(Arc2D arc, Rectangle2D rect) { - return (rect.intersectsLine(arc.getCenterX(), arc.getCenterY(), arc.getStartPoint().getX(), - arc.getStartPoint().getY())) - || arc.intersects(rect); - } - - private void zap(double zapAmount) { - if (energy == 0) { - kill(); - return; - } - energy -= abs(zapAmount); - if (energy < .1) { - energy = 0; - currentCommands.setDistanceRemaining(0); - currentCommands.setBodyTurnRemaining(0); - } - } - - public void setRunning(boolean value) { - isRunning.set(value); - } - - public void drainEnergy() { - setEnergy(0, true); - isEnergyDrained = true; - } - - public void punishBadBehavior(BadBehavior badBehavior) { - kill(); // Bug fix [2828479] - Missed onRobotDeath events - - statistics.setInactive(); - - final IRobotItem repositoryItem = (IRobotItem) HiddenAccess.getFileSpecification(robotSpecification); - - StringBuffer message = new StringBuffer(getName()).append(' '); - - boolean disableInRepository = false; // Per default, robots are not disabled in the repository - - switch (badBehavior) { - case CANNOT_START: - message.append("could not be started or loaded."); - disableInRepository = true; // Disable in repository when it cannot be started anyways - break; - - case UNSTOPPABLE: - message.append("cannot be stopped."); - break; - - case SKIPPED_TOO_MANY_TURNS: - message.append("has skipped too many turns."); - break; - - case SECURITY_VIOLATION: - message.append("has caused a security violation."); - disableInRepository = true; // No mercy here! - break; - } - - if (disableInRepository) { - repositoryItem.setValid(false); - message.append(" This ").append(repositoryItem.isTeam() ? "team" : "robot").append( - " has been banned and will not be allowed to participate in battles."); - } - - logMessage(message.toString()); - } - - void updateEnergy(double delta) { - if ((!isExecFinishedAndDisabled && !isEnergyDrained) || delta < 0) { - setEnergy(energy + delta, true); - } - } - - private void setEnergy(double newEnergy, boolean resetInactiveTurnCount) { - if (resetInactiveTurnCount && (energy != newEnergy)) { - battle.resetInactiveTurnCount(energy - newEnergy); - } - energy = newEnergy; - if (energy < .01) { - energy = 0; - ExecCommands localCommands = commands.get(); - - localCommands.setDistanceRemaining(0); - localCommands.setBodyTurnRemaining(0); - } - } - - public void setWinner(boolean newWinner) { - isWinner = newWinner; - } - - public void kill() { - battle.resetInactiveTurnCount(10.0); - if (isAlive()) { - addEvent(new DeathEvent()); - if (statics.isTeamLeader()) { - for (RobotPeer teammate : teamPeer) { - if (teammate.isAlive() && teammate != this) { - teammate.updateEnergy(-30); - - BulletPeer sBullet = new BulletPeer(this, battleRules, 0); - sBullet.setState(BulletState.HIT_VICTIM); - sBullet.setX(teammate.x); - sBullet.setY(teammate.y); - sBullet.setVictim(teammate); - sBullet.setPower(4); - battle.addBullet(sBullet); - } - } - } - battle.registerDeathRobot(this); - - // 'fake' bullet for explosion on self - final ExplosionPeer fake = new ExplosionPeer(this, battleRules); - - battle.addBullet(fake); - } - updateEnergy(-energy); - - setState(RobotState.DEAD); - } - - public void waitForStop() { - robotProxy.waitForStopThread(); - } - - /** - * Clean things up removing all references to the robot. - */ - public void cleanup() { - battle = null; - - if (robotProxy != null) { - robotProxy.cleanup(); - robotProxy = null; - } - - if (statistics != null) { - statistics.cleanup(); - statistics = null; - } - - status = null; - commands = null; - events = null; - teamMessages = null; - bulletUpdates = null; - battleText.setLength(0); - proxyText.setLength(0); - statics = null; - battleRules = null; - } - - public Object getGraphicsCalls() { - return commands.get().getGraphicsCalls(); - } - - public boolean isTryingToPaint() { - return commands.get().isTryingToPaint(); - } - - public List getDebugProperties() { - return commands.get().getDebugProperties(); - } - - public void publishStatus(long currentTurn) { - - final ExecCommands currentCommands = commands.get(); - - int others = battle.countActiveParticipants() - (isDead() || isSentryRobot() ? 0 : 1); - int numSentries = battle.countActiveSentries(); - - RobotStatus stat = HiddenAccess.createStatus(energy, x, y, bodyHeading, gunHeading, radarHeading, velocity, - currentCommands.getBodyTurnRemaining(), currentCommands.getRadarTurnRemaining(), - currentCommands.getGunTurnRemaining(), currentCommands.getDistanceRemaining(), gunHeat, others, numSentries, - battle.getRoundNum(), battle.getNumRounds(), battle.getTime()); - - status.set(stat); - } - - void addBulletStatus(BulletStatus bulletStatus) { - if (isAlive()) { - bulletUpdates.get().add(bulletStatus); - } - } - - public int compareTo(ContestantPeer cp) { - double myScore = statistics.getTotalScore(); - double hisScore = cp.getStatistics().getTotalScore(); - - if (statistics.isInRound()) { - myScore += statistics.getCurrentScore(); - hisScore += cp.getStatistics().getCurrentScore(); - } - if (myScore < hisScore) { - return -1; - } - if (myScore > hisScore) { - return 1; - } - return 0; - } - - @Override - public String toString() { - return statics.getShortName() + "(" + (int) energy + ") X" + (int) x + " Y" + (int) y + " " + state.toString() - + (isSleeping() ? " sleeping " : "") + (isRunning() ? " running" : "") + (isHalt() ? " halted" : ""); - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/RobotStatistics.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/RobotStatistics.java deleted file mode 100644 index 0cb9c3f..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/RobotStatistics.java +++ /dev/null @@ -1,298 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.peer; - - -import robocode.BattleResults; -import java.util.Map; -import java.util.HashMap; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Luis Crespo (contributor) - * @author Titus Chen (contributor) - * @author Robert D. Maupin (contributor) - * @author Nathaniel Troutman (contributor) - */ -public class RobotStatistics implements ContestantStatistics { - - private final RobotPeer robotPeer; - private int rank; - private final int numberOfRobots; - private boolean isActive; - private boolean isInRound; - - private double survivalScore; - private double lastSurvivorBonus; - private double bulletDamageScore; - private double bulletKillBonus; - private double rammingDamageScore; - private double rammingKillBonus; - - private Map robotDamageMap; - - private double totalScore; - private double totalSurvivalScore; - private double totalLastSurvivorBonus; - private double totalBulletDamageScore; - private double totalBulletKillBonus; - private double totalRammingDamageScore; - private double totalRammingKillBonus; - - private int totalFirsts; - private int totalSeconds; - private int totalThirds; - - RobotStatistics(RobotPeer robotPeer, int numberOfRobots) { - super(); - this.robotPeer = robotPeer; - this.numberOfRobots = numberOfRobots; - } - - public void setRank(int rank) { - this.rank = rank; - } - - void reset() { - resetScores(); - - isActive = true; - isInRound = true; - } - - private void resetScores() { - robotDamageMap = null; - survivalScore = 0; - lastSurvivorBonus = 0; - bulletDamageScore = 0; - bulletKillBonus = 0; - rammingDamageScore = 0; - rammingKillBonus = 0; - } - - public void generateTotals() { - totalSurvivalScore += survivalScore; - totalLastSurvivorBonus += lastSurvivorBonus; - totalBulletDamageScore += bulletDamageScore; - totalBulletKillBonus += bulletKillBonus; - totalRammingDamageScore += rammingDamageScore; - totalRammingKillBonus += rammingKillBonus; - - totalScore = robotPeer.isSentryRobot() - ? 0 - : totalBulletDamageScore + totalRammingDamageScore + totalSurvivalScore + totalRammingKillBonus - + totalBulletKillBonus + totalLastSurvivorBonus; - - isInRound = false; - } - - public double getTotalScore() { - return totalScore; - } - - public double getTotalSurvivalScore() { - return totalSurvivalScore; - } - - public double getTotalLastSurvivorBonus() { - return totalLastSurvivorBonus; - } - - public double getTotalBulletDamageScore() { - return totalBulletDamageScore; - } - - public double getTotalBulletKillBonus() { - return totalBulletKillBonus; - } - - public double getTotalRammingDamageScore() { - return totalRammingDamageScore; - } - - public double getTotalRammingKillBonus() { - return totalRammingKillBonus; - } - - public int getTotalFirsts() { - return totalFirsts; - } - - public int getTotalSeconds() { - return totalSeconds; - } - - public int getTotalThirds() { - return totalThirds; - } - - public double getCurrentScore() { - return robotPeer.isSentryRobot() - ? 0 - : (bulletDamageScore + rammingDamageScore + survivalScore + rammingKillBonus + bulletKillBonus - + lastSurvivorBonus); - } - - public double getCurrentSurvivalScore() { - return survivalScore; - } - - public double getCurrentSurvivalBonus() { - return lastSurvivorBonus; - } - - public double getCurrentBulletDamageScore() { - return bulletDamageScore; - } - - public double getCurrentBulletKillBonus() { - return bulletKillBonus; - } - - public double getCurrentRammingDamageScore() { - return rammingDamageScore; - } - - public double getCurrentRammingKillBonus() { - return rammingKillBonus; - } - - public void scoreSurvival() { - if (isActive && !robotPeer.isSentryRobot()) { - survivalScore += 50; - } - } - - public void scoreLastSurvivor() { - if (isActive && !robotPeer.isSentryRobot()) { - int enemyCount = numberOfRobots - 1; - - if (robotPeer.getTeamPeer() != null) { - enemyCount -= (robotPeer.getTeamPeer().size() - 1); - } - - lastSurvivorBonus += 10 * enemyCount; - - if ((robotPeer.getTeamPeer() == null || robotPeer.isTeamLeader())) { - totalFirsts++; - } - } - } - - void scoreBulletDamage(String robot, double damage) { - if (isActive) { - incrementRobotDamage(robot, damage); - bulletDamageScore += damage; - } - } - - double scoreBulletKill(String robot) { - if (isActive) { - double bonus; - - if (robotPeer.getTeamPeer() == null) { - bonus = getRobotDamage(robot) * 0.20; - } else { - bonus = 0; - for (RobotPeer teammate : robotPeer.getTeamPeer()) { - bonus += teammate.getRobotStatistics().getRobotDamage(robot) * 0.20; - } - } - - bulletKillBonus += bonus; - return bonus; - } - return 0; - } - - void scoreRammingDamage(String robot) { - if (isActive) { - incrementRobotDamage(robot, robocode.Rules.ROBOT_HIT_DAMAGE); - rammingDamageScore += robocode.Rules.ROBOT_HIT_BONUS; - } - } - - double scoreRammingKill(String robot) { - if (isActive) { - double bonus; - - if (robotPeer.getTeamPeer() == null) { - bonus = getRobotDamage(robot) * 0.30; - } else { - bonus = 0; - for (RobotPeer teammate : robotPeer.getTeamPeer()) { - bonus += teammate.getRobotStatistics().getRobotDamage(robot) * 0.30; - } - } - rammingKillBonus += bonus; - return bonus; - } - return 0; - } - - public void scoreRobotDeath(int enemiesRemaining) { - if (!robotPeer.isSentryRobot()) { - switch (enemiesRemaining) { - case 0: - if (!robotPeer.isWinner()) { - totalFirsts++; - } - break; - - case 1: - totalSeconds++; - break; - - case 2: - totalThirds++; - break; - } - } - } - - public void scoreFirsts() { - if (isActive && !robotPeer.isSentryRobot()) { - totalFirsts++; - } - } - - void setInactive() { - resetScores(); - isActive = false; - } - - public BattleResults getFinalResults() { - return new BattleResults(robotPeer.getTeamName(), rank, totalScore, totalSurvivalScore, totalLastSurvivorBonus, - totalBulletDamageScore, totalBulletKillBonus, totalRammingDamageScore, totalRammingKillBonus, totalFirsts, - totalSeconds, totalThirds); - } - - private double getRobotDamage(String robot) { - if (robotDamageMap == null) { - robotDamageMap = new HashMap(); - } - Double damage = robotDamageMap.get(robot); - - return (damage != null) ? damage : 0; - } - - private void incrementRobotDamage(String robot, double damage) { - double newDamage = getRobotDamage(robot) + damage; - - robotDamageMap.put(robot, newDamage); - } - - void cleanup() {// Do nothing, for now - } - - public boolean isInRound() { - return isInRound; - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/TeamPeer.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/TeamPeer.java deleted file mode 100644 index 7e384bb..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/TeamPeer.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.peer; - - -import java.util.ArrayList; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - * @author Pavel Savara (contributor) - */ -@SuppressWarnings("serial") -public class TeamPeer extends ArrayList implements ContestantPeer { - - private final List memberNames; - private final String name; - private final int teamIndex; - private RobotPeer teamLeader; - private final TeamStatistics teamStatistics; - - public TeamPeer(String name, List memberNames, int teamIndex) { - this.name = name; - this.teamIndex = teamIndex; - this.memberNames = memberNames; - this.teamStatistics = new TeamStatistics(this); - } - - public int compareTo(ContestantPeer cp) { - double myScore = teamStatistics.getTotalScore(); - double hisScore = cp.getStatistics().getTotalScore(); - - if (teamLeader != null && teamLeader.getRobotStatistics().isInRound()) { - myScore += teamStatistics.getCurrentScore(); - hisScore += cp.getStatistics().getCurrentScore(); - } - if (myScore < hisScore) { - return -1; - } - if (myScore > hisScore) { - return 1; - } - return 0; - } - - public ContestantStatistics getStatistics() { - return teamStatistics; - } - - public String getName() { - return name; - } - - public int getRobotIndex() { - return -1; - } - - public int getTeamIndex() { - return teamIndex; - } - - public int getContestantIndex() { - return teamIndex; // This contestant is always a team for this TeamPeer - } - - public List getMemberNames() { - return memberNames; - } - - public RobotPeer getTeamLeader() { - return teamLeader; - } - - @Override - public boolean add(RobotPeer r) { - if (teamLeader == null) { - teamLeader = r; - } - return super.add(r); - } - - @Override - public String toString() { - return " [" + size() + "] " + getName(); - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/TeamStatistics.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/TeamStatistics.java deleted file mode 100644 index 18316bf..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/peer/TeamStatistics.java +++ /dev/null @@ -1,191 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.peer; - - -import robocode.BattleResults; - - -/** - * @author Mathew A. Nelson (original) - * @author Luis Crespo (contributor) - * @author Flemming N. Larsen (contributor) - */ -class TeamStatistics implements ContestantStatistics { - - private final TeamPeer teamPeer; - private int rank; - - TeamStatistics(TeamPeer teamPeer) { - this.teamPeer = teamPeer; - } - - public void setRank(int rank) { - this.rank = rank; - } - - public double getTotalScore() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getTotalScore(); - } - return d; - } - - public double getTotalSurvivalScore() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getTotalSurvivalScore(); - } - return d; - } - - public double getTotalLastSurvivorBonus() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getTotalLastSurvivorBonus(); - } - return d; - } - - public double getTotalBulletDamageScore() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getTotalBulletDamageScore(); - } - return d; - } - - public double getTotalBulletKillBonus() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getTotalBulletKillBonus(); - } - return d; - } - - public double getTotalRammingDamageScore() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getTotalRammingDamageScore(); - } - return d; - } - - public double getTotalRammingKillBonus() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getTotalRammingKillBonus(); - } - return d; - } - - public int getTotalFirsts() { - int d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getTotalFirsts(); - } - return d; - } - - public int getTotalSeconds() { - int d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getTotalSeconds(); - } - return d; - } - - public int getTotalThirds() { - int d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getTotalThirds(); - } - return d; - } - - public double getCurrentScore() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getCurrentScore(); - } - return d; - } - - public double getCurrentSurvivalScore() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getCurrentSurvivalScore(); - } - return d; - } - - public double getCurrentSurvivalBonus() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getCurrentSurvivalBonus(); - } - return d; - } - - public double getCurrentBulletDamageScore() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getCurrentBulletDamageScore(); - } - return d; - } - - public double getCurrentBulletKillBonus() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getCurrentBulletKillBonus(); - } - return d; - } - - public double getCurrentRammingDamageScore() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getCurrentRammingDamageScore(); - } - return d; - } - - public double getCurrentRammingKillBonus() { - double d = 0; - - for (RobotPeer teammate : teamPeer) { - d += teammate.getRobotStatistics().getCurrentRammingKillBonus(); - } - return d; - } - - public BattleResults getFinalResults() { - return new BattleResults(teamPeer.getName(), rank, getTotalScore(), getTotalSurvivalScore(), - getTotalLastSurvivorBonus(), getTotalBulletDamageScore(), getTotalBulletKillBonus(), - getTotalRammingDamageScore(), getTotalRammingKillBonus(), getTotalFirsts(), getTotalSeconds(), - getTotalThirds()); - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/BulletSnapshot.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/BulletSnapshot.java deleted file mode 100644 index 14fcfa9..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/BulletSnapshot.java +++ /dev/null @@ -1,360 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.snapshot; - - -import net.sf.robocode.battle.peer.BulletPeer; -import net.sf.robocode.battle.peer.ExplosionPeer; -import net.sf.robocode.battle.peer.RobotPeer; -import net.sf.robocode.peer.ExecCommands; -import net.sf.robocode.serialization.IXmlSerializable; -import net.sf.robocode.serialization.XmlReader; -import net.sf.robocode.serialization.SerializableOptions; -import net.sf.robocode.serialization.XmlWriter; -import robocode.control.snapshot.BulletState; -import robocode.control.snapshot.IBulletSnapshot; - -import java.io.IOException; - - -/** - * A snapshot of a bullet at a specific time instant in a battle. - * The snapshot contains a snapshot of the bullet data at that specific time. - * - * @author Flemming N. Larsen (original) - * @author Pavel Savara (contributor) - * - * @since 1.6.1 - */ -final class BulletSnapshot implements java.io.Serializable, IXmlSerializable, IBulletSnapshot { - - private static final long serialVersionUID = 2L; - - /** The bullet state */ - private BulletState state; - - /** The bullet power */ - private double power; - - /** The x position */ - private double x; - - /** The y position */ - private double y; - - /** The x painting position (due to offset on robot when bullet hits a robot) */ - private double paintX; - - /** The y painting position (due to offset on robot when bullet hits a robot) */ - private double paintY; - - /** The ARGB color of the bullet */ - private int color = ExecCommands.defaultBulletColor; - - /** The current frame number to display, i.e. when the bullet explodes */ - private int frame; - - /** Flag specifying if this bullet has turned into an explosion */ - private boolean isExplosion; - - /** Index to which explosion image that must be rendered */ - private int explosionImageIndex; - - private int bulletId; - - private int victimIndex = -1; - - private int ownerIndex; - - private double heading; - - /** - * Creates a snapshot of a bullet that must be filled out with data later. - */ - public BulletSnapshot() { - state = BulletState.INACTIVE; - ownerIndex = -1; - victimIndex = -1; - explosionImageIndex = -1; - heading = Double.NaN; - power = Double.NaN; - } - - /** - * Creates a snapshot of a bullet. - * - * @param bullet the bullet to make a snapshot of. - */ - BulletSnapshot(BulletPeer bullet) { - state = bullet.getState(); - - power = bullet.getPower(); - - x = bullet.getX(); - y = bullet.getY(); - - paintX = bullet.getPaintX(); - paintY = bullet.getPaintY(); - - color = bullet.getColor(); - - frame = bullet.getFrame(); - - isExplosion = (bullet instanceof ExplosionPeer); - explosionImageIndex = bullet.getExplosionImageIndex(); - - bulletId = bullet.getBulletId(); - - final RobotPeer victim = bullet.getVictim(); - - if (victim != null) { - victimIndex = victim.getRobotIndex(); - } - - ownerIndex = bullet.getOwner().getRobotIndex(); - - heading = bullet.getHeading(); - } - - @Override - public String toString() { - return ownerIndex + "-" + bulletId + " (" + (int) power + ") X" + (int) x + " Y" + (int) y + " " - + state.toString(); - } - - /** - * {@inheritDoc} - */ - public int getBulletId() { - return bulletId; - } - - /** - * {@inheritDoc} - */ - public BulletState getState() { - return state; - } - - /** - * {@inheritDoc} - */ - public double getPower() { - return power; - } - - /** - * {@inheritDoc} - */ - public double getX() { - return x; - } - - /** - * {@inheritDoc} - */ - public double getY() { - return y; - } - - /** - * {@inheritDoc} - */ - public double getPaintX() { - return paintX; - } - - /** - * {@inheritDoc} - */ - public double getPaintY() { - return paintY; - } - - /** - * {@inheritDoc} - */ - public int getColor() { - return color; - } - - /** - * {@inheritDoc} - */ - public int getFrame() { - return frame; - } - - /** - * {@inheritDoc} - */ - public boolean isExplosion() { - return isExplosion; - } - - /** - * {@inheritDoc} - */ - public int getExplosionImageIndex() { - return explosionImageIndex; - } - - /** - * {@inheritDoc} - */ - public double getHeading() { - return heading; - } - - /** - * {@inheritDoc} - */ - public int getVictimIndex() { - return victimIndex; - } - - /** - * {@inheritDoc} - */ - public int getOwnerIndex() { - return ownerIndex; - } - - /** - * {@inheritDoc} - */ - public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException { - writer.startElement(options.shortAttributes ? "b" : "bullet"); { - writer.writeAttribute("id", ownerIndex + "-" + bulletId); - if (!options.skipExploded || state != BulletState.MOVING) { - writer.writeAttribute(options.shortAttributes ? "s" : "state", state.toString()); - writer.writeAttribute(options.shortAttributes ? "p" : "power", power, options.trimPrecision); - } - if (state == BulletState.HIT_VICTIM) { - writer.writeAttribute(options.shortAttributes ? "v" : "victim", victimIndex); - } - if (state == BulletState.FIRED) { - writer.writeAttribute(options.shortAttributes ? "o" : "owner", ownerIndex); - writer.writeAttribute(options.shortAttributes ? "h" : "heading", heading, options.trimPrecision); - } - writer.writeAttribute("x", paintX, options.trimPrecision); - writer.writeAttribute("y", paintY, options.trimPrecision); - if (!options.skipNames) { - if (color != ExecCommands.defaultBulletColor) { - writer.writeAttribute(options.shortAttributes ? "c" : "color", - Integer.toHexString(color).toUpperCase()); - } - } - if (!options.skipExploded) { - if (frame != 0) { - writer.writeAttribute("frame", frame); - } - if (isExplosion) { - writer.writeAttribute("isExplosion", true); - writer.writeAttribute("explosion", explosionImageIndex); - } - } - if (!options.skipVersion) { - writer.writeAttribute("ver", serialVersionUID); - } - } - writer.endElement(); - } - - /** - * {@inheritDoc} - */ - public XmlReader.Element readXml(XmlReader reader) { - return reader.expect("bullet", "b", new XmlReader.Element() { - public IXmlSerializable read(XmlReader reader) { - final BulletSnapshot snapshot = new BulletSnapshot(); - - reader.expect("id", new XmlReader.Attribute() { - public void read(String value) { - String[] parts = value.split("-"); - - snapshot.ownerIndex = Integer.parseInt(parts[0]); - snapshot.bulletId = Integer.parseInt(parts[1]); - } - }); - - reader.expect("state", "s", new XmlReader.Attribute() { - public void read(String value) { - snapshot.state = BulletState.valueOf(value); - } - }); - - reader.expect("power", "p", new XmlReader.Attribute() { - public void read(String value) { - snapshot.power = Double.parseDouble(value); - } - }); - - reader.expect("heading", "h", new XmlReader.Attribute() { - public void read(String value) { - snapshot.heading = Double.parseDouble(value); - } - }); - - reader.expect("victim", "v", new XmlReader.Attribute() { - public void read(String value) { - snapshot.victimIndex = Integer.parseInt(value); - } - }); - - reader.expect("owner", "o", new XmlReader.Attribute() { - public void read(String value) { - snapshot.ownerIndex = Integer.parseInt(value); - } - }); - - reader.expect("x", new XmlReader.Attribute() { - public void read(String value) { - snapshot.x = Double.parseDouble(value); - snapshot.paintX = snapshot.x; - } - }); - - reader.expect("y", new XmlReader.Attribute() { - public void read(String value) { - snapshot.y = Double.parseDouble(value); - snapshot.paintY = snapshot.y; - } - }); - - reader.expect("color", "c", new XmlReader.Attribute() { - public void read(String value) { - snapshot.color = Long.valueOf(value.toUpperCase(), 16).intValue(); - } - }); - - reader.expect("isExplosion", new XmlReader.Attribute() { - public void read(String value) { - snapshot.isExplosion = Boolean.parseBoolean(value); - if (snapshot.isExplosion && snapshot.state == null) { - snapshot.state = BulletState.EXPLODED; - } - } - }); - - reader.expect("explosion", new XmlReader.Attribute() { - public void read(String value) { - snapshot.explosionImageIndex = Integer.parseInt(value); - } - }); - - reader.expect("frame", new XmlReader.Attribute() { - public void read(String value) { - snapshot.frame = Integer.parseInt(value); - } - }); - return snapshot; - } - }); - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/RobotSnapshot.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/RobotSnapshot.java deleted file mode 100644 index c83404d..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/RobotSnapshot.java +++ /dev/null @@ -1,729 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.snapshot; - - -import net.sf.robocode.battle.peer.RobotPeer; -import net.sf.robocode.peer.DebugProperty; -import net.sf.robocode.peer.ExecCommands; -import net.sf.robocode.serialization.IXmlSerializable; -import net.sf.robocode.serialization.XmlReader; -import net.sf.robocode.serialization.SerializableOptions; -import net.sf.robocode.serialization.XmlWriter; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.control.snapshot.IScoreSnapshot; -import robocode.control.snapshot.RobotState; - -import java.awt.geom.Arc2D; -import java.io.IOException; -import java.io.Serializable; -import java.util.List; -import java.util.Map; - - -/** - * A snapshot of a robot at a specific time instant in a battle. - * The snapshot contains a snapshot of the robot data at that specific time. - * - * @author Flemming N. Larsen (original) - * @author Pavel Savara (contributor) - * - * @since 1.6.1 - */ -public final class RobotSnapshot implements Serializable, IXmlSerializable, IRobotSnapshot { - - private static final long serialVersionUID = 2L; - - /** The name of the robot */ - private String name; - - /** The short name of the robot */ - private String shortName; - - /** Very short name of the robot */ - private String veryShortName; - - /** Very short name of the team leader robot (might be null) */ - private String teamName; - - /** The unique robot index */ - private int robotIndex; - - /** The team index for the robot */ - private int teamIndex; - - /** The robot state */ - private RobotState state; - - /** The energy level of the robot */ - private double energy; - - /** The velocity of the robot */ - private double velocity; - - /** The gun heat level of the robot */ - private double gunHeat; - - /** The body heading in radians */ - private double bodyHeading; - - /** The gun heading in radians */ - private double gunHeading; - - /** The radar heading in radians */ - private double radarHeading; - - /** The X position */ - private double x; - - /** The Y position */ - private double y; - - /** The ARGB color of the body */ - private int bodyColor = ExecCommands.defaultBodyColor; - - /** The ARGB color of the gun */ - private int gunColor = ExecCommands.defaultGunColor; - - /** The ARGB color of the radar */ - private int radarColor = ExecCommands.defaultRadarColor; - - /** The ARGB color of the scan arc */ - private int scanColor = ExecCommands.defaultScanColor; - - /** Flag specifying if this robot is a Droid */ - private boolean isDroid; - - /** Flag specifying if this robot is a SentryRobot */ - private boolean isSentryRobot; - - /** Flag specifying if this robot is a IPaintRobot or is invoking getGraphics() */ - private boolean isPaintRobot; - - /** Flag specifying if painting is enabled for this robot */ - private boolean isPaintEnabled; - - /** Flag specifying if RobocodeSG painting is enabled for this robot */ - private boolean isSGPaintEnabled; - - /** Snapshot of the scan arc */ - private SerializableArc scanArc; - - /** Snapshot of the object with queued calls for Graphics object */ - private Object graphicsCalls; - - /** Snapshot of debug properties */ - private DebugProperty[] debugProperties; - - /** Snapshot of the output print stream for this robot */ - private String outputStreamSnapshot; - - /** Snapshot of score of the robot */ - private IScoreSnapshot robotScoreSnapshot; - - /** - * Creates a snapshot of a robot that must be filled out with data later. - */ - public RobotSnapshot() { - state = RobotState.ACTIVE; - } - - /** - * Creates a snapshot of a robot. - * - * @param robot the robot to make a snapshot of. - * @param readoutText {@code true} if the output text from the robot must be included in the snapshot; - * {@code false} otherwise. - */ - RobotSnapshot(RobotPeer robot, boolean readoutText) { - name = robot.getName(); - shortName = robot.getShortName(); - veryShortName = robot.getVeryShortName(); - teamName = robot.getTeamName(); - - robotIndex = robot.getRobotIndex(); - teamIndex = robot.getTeamIndex(); - - state = robot.getState(); - - energy = robot.getEnergy(); - velocity = robot.getVelocity(); - gunHeat = robot.getGunHeat(); - - bodyHeading = robot.getBodyHeading(); - gunHeading = robot.getGunHeading(); - radarHeading = robot.getRadarHeading(); - - x = robot.getX(); - y = robot.getY(); - - bodyColor = robot.getBodyColor(); - gunColor = robot.getGunColor(); - radarColor = robot.getRadarColor(); - scanColor = robot.getScanColor(); - - isDroid = robot.isDroid(); - isPaintRobot = robot.isPaintRobot() || robot.isTryingToPaint(); - isPaintEnabled = robot.isPaintEnabled(); - isSGPaintEnabled = robot.isSGPaintEnabled(); - - scanArc = robot.getScanArc() != null ? new SerializableArc((Arc2D.Double) robot.getScanArc()) : null; - - graphicsCalls = robot.getGraphicsCalls(); - - final List dp = robot.getDebugProperties(); - - debugProperties = dp != null ? dp.toArray(new DebugProperty[dp.size()]) : null; - - if (readoutText) { - outputStreamSnapshot = robot.readOutText(); - } - - robotScoreSnapshot = new ScoreSnapshot(robot.getName(), robot.getRobotStatistics()); - } - - @Override - public String toString() { - return shortName + " (" + (int) energy + ") X" + (int) x + " Y" + (int) y + " " + state.toString(); - } - - /** - * {@inheritDoc} - */ - // Used to identify buttons - // TODO: Fix this so that getRobotIndex() is used instead - public String getName() { - return name; - } - - /** - * {@inheritDoc} - */ - // Used for text on buttons - public String getShortName() { - return shortName; - } - - /** - * {@inheritDoc} - */ - // Used for drawing the name of the robot on the battle view - public String getVeryShortName() { - return veryShortName; - } - - /** - * {@inheritDoc} - */ - public String getTeamName() { - return teamName; - } - - /** - * {@inheritDoc} - */ - public int getContestantIndex() { - return teamIndex >= 0 ? teamIndex : robotIndex; - } - - /** - * {@inheritDoc} - */ - public int getRobotIndex() { - return robotIndex; - } - - /** - * {@inheritDoc} - */ - public int getTeamIndex() { - return teamIndex; - } - - /** - * {@inheritDoc} - */ - public RobotState getState() { - return state; - } - - /** - * {@inheritDoc} - */ - public double getEnergy() { - return energy; - } - - /** - * {@inheritDoc} - */ - public double getVelocity() { - return velocity; - } - - /** - * {@inheritDoc} - */ - public double getBodyHeading() { - return bodyHeading; - } - - /** - * {@inheritDoc} - */ - public double getGunHeading() { - return gunHeading; - } - - /** - * {@inheritDoc} - */ - public double getRadarHeading() { - return radarHeading; - } - - /** - * {@inheritDoc} - */ - public double getGunHeat() { - return gunHeat; - } - - /** - * {@inheritDoc} - */ - public double getX() { - return x; - } - - /** - * {@inheritDoc} - */ - public double getY() { - return y; - } - - /** - * {@inheritDoc} - */ - public int getBodyColor() { - return bodyColor; - } - - /** - * {@inheritDoc} - */ - public int getGunColor() { - return gunColor; - } - - /** - * {@inheritDoc} - */ - public int getRadarColor() { - return radarColor; - } - - /** - * {@inheritDoc} - */ - public int getScanColor() { - return scanColor; - } - - /** - * {@inheritDoc} - */ - public boolean isDroid() { - return isDroid; - } - - /** - * {@inheritDoc} - */ - public boolean isSentryRobot() { - return isSentryRobot; - } - - /** - * {@inheritDoc} - */ - public boolean isPaintRobot() { - return isPaintRobot; - } - - /** - * {@inheritDoc} - */ - public boolean isPaintEnabled() { - return isPaintEnabled; - } - - /** - * Sets the flag specifying if painting is enabled for the robot. - * - * @param isPaintEnabled {@code true} if painting must be enabled; - * {@code false} otherwise. - */ - public void setPaintEnabled(boolean isPaintEnabled) { - this.isPaintEnabled = isPaintEnabled; - } - - /** - * {@inheritDoc} - */ - public boolean isSGPaintEnabled() { - return isSGPaintEnabled; - } - - /** - * {@inheritDoc} - */ - public DebugProperty[] getDebugProperties() { - return debugProperties; - } - - /** - * {@inheritDoc} - */ - public String getOutputStreamSnapshot() { - return outputStreamSnapshot; - } - - /** - * Sets the snapshot of the output print stream for this robot. - * - * @param outputStreamSnapshot new output print stream snapshot. - */ - public void setOutputStreamSnapshot(String outputStreamSnapshot) { - this.outputStreamSnapshot = outputStreamSnapshot; - } - - void stripDetails(SerializableOptions options) { - if (options.skipDebug) { - graphicsCalls = null; - debugProperties = null; - outputStreamSnapshot = null; - isPaintEnabled = false; - isSGPaintEnabled = false; - } - if (options.skipNames) { - name = veryShortName; - shortName = veryShortName; - teamName = veryShortName; - } - } - - /** - * {@inheritDoc} - */ - public IScoreSnapshot getScoreSnapshot() { - return robotScoreSnapshot; - } - - /** - * Returns the scan arc snapshot for the robot. - * - * @return the scan arc snapshot for the robot. - */ - public Arc2D getScanArc() { - return scanArc != null ? scanArc.create() : null; - } - - /** - * Returns the object with queued calls for Graphics object. - * - * @return the object with queued calls for Graphics object. - */ - public Object getGraphicsCalls() { - return graphicsCalls; - } - - /** - * {@inheritDoc} - */ - public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException { - writer.startElement(options.shortAttributes ? "r" : "robot"); { - writer.writeAttribute("id", robotIndex); - if (!options.skipNames) { - writer.writeAttribute("vsName", veryShortName); - } - if (!options.skipExploded || state != RobotState.ACTIVE) { - writer.writeAttribute(options.shortAttributes ? "s" : "state", state.toString()); - } - writer.writeAttribute(options.shortAttributes ? "e" : "energy", energy, options.trimPrecision); - writer.writeAttribute("x", x, options.trimPrecision); - writer.writeAttribute("y", y, options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "b" : "bodyHeading", bodyHeading, options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "g" : "gunHeading", gunHeading, options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "r" : "radarHeading", radarHeading, options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "h" : "gunHeat", gunHeat, options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "v" : "velocity", velocity, options.trimPrecision); - if (!options.skipNames) { - writer.writeAttribute("teamName", teamName); - writer.writeAttribute("name", name); - writer.writeAttribute("sName", shortName); - if (isDroid) { - writer.writeAttribute("isDroid", true); - } - if (bodyColor != ExecCommands.defaultBodyColor) { - writer.writeAttribute("bodyColor", Integer.toHexString(bodyColor).toUpperCase()); - } - if (gunColor != ExecCommands.defaultGunColor) { - writer.writeAttribute("gunColor", Integer.toHexString(gunColor).toUpperCase()); - } - if (radarColor != ExecCommands.defaultRadarColor) { - writer.writeAttribute("radarColor", Integer.toHexString(radarColor).toUpperCase()); - } - if (scanColor != ExecCommands.defaultScanColor) { - writer.writeAttribute("scanColor", Integer.toHexString(scanColor).toUpperCase()); - } - } - if (!options.skipVersion) { - writer.writeAttribute("ver", serialVersionUID); - } - if (!options.skipDebug) { - if (outputStreamSnapshot != null && outputStreamSnapshot.length() != 0) { - writer.writeAttribute("out", outputStreamSnapshot); - } - if (debugProperties != null) { - writer.startElement("debugProperties"); { - for (DebugProperty prop : debugProperties) { - prop.writeXml(writer, options); - } - } - writer.endElement(); - } - } - - ((ScoreSnapshot) robotScoreSnapshot).writeXml(writer, options); - } - writer.endElement(); - - } - - // allows loading of minimalistic XML - RobotSnapshot(String robotName, int robotIndex, RobotState state) { - this.robotIndex = robotIndex; - this.state = state; - this.name = robotName; - this.teamName = robotName; - this.shortName = robotName; - this.veryShortName = robotName; - this.robotScoreSnapshot = new ScoreSnapshot(robotName); - } - - /** - * {@inheritDoc} - */ - public XmlReader.Element readXml(XmlReader reader) { - return reader.expect("robot", "r", new XmlReader.Element() { - public IXmlSerializable read(final XmlReader reader) { - final RobotSnapshot snapshot = new RobotSnapshot(); - - reader.expect("id", new XmlReader.Attribute() { - public void read(String value) { - snapshot.robotIndex = Integer.parseInt(value); - - // allows loading of minimalistic XML, which robot names for subsequent turns - Map context = reader.getContext(); - - if (context.containsKey(value)) { - String n = (String) context.get(value); - - if (snapshot.shortName == null) { - snapshot.name = n; - } - if (snapshot.shortName == null) { - snapshot.shortName = n; - } - if (snapshot.teamName == null) { - snapshot.teamName = n; - } - if (snapshot.veryShortName == null) { - snapshot.veryShortName = n; - } - } - } - }); - - reader.expect("name", new XmlReader.Attribute() { - public void read(String value) { - snapshot.name = value; - Map context = reader.getContext(); - - context.put(Integer.toString(snapshot.robotIndex), value); - if (snapshot.shortName == null) { - snapshot.shortName = value; - } - if (snapshot.teamName == null) { - snapshot.teamName = value; - } - if (snapshot.veryShortName == null) { - snapshot.veryShortName = value; - } - } - }); - - reader.expect("sName", new XmlReader.Attribute() { - public void read(String value) { - snapshot.shortName = value; - } - }); - - reader.expect("vsName", new XmlReader.Attribute() { - public void read(String value) { - snapshot.veryShortName = value; - } - }); - - reader.expect("teamName", new XmlReader.Attribute() { - public void read(String value) { - snapshot.teamName = value; - } - }); - - reader.expect("state", "s", new XmlReader.Attribute() { - public void read(String value) { - snapshot.state = RobotState.valueOf(value); - } - }); - - reader.expect("isDroid", new XmlReader.Attribute() { - public void read(String value) { - snapshot.isDroid = Boolean.valueOf(value); - } - }); - - reader.expect("bodyColor", new XmlReader.Attribute() { - public void read(String value) { - snapshot.bodyColor = (Long.valueOf(value.toUpperCase(), 16).intValue()); - } - }); - - reader.expect("gunColor", new XmlReader.Attribute() { - public void read(String value) { - snapshot.gunColor = Long.valueOf(value.toUpperCase(), 16).intValue(); - } - }); - - reader.expect("radarColor", new XmlReader.Attribute() { - public void read(String value) { - snapshot.radarColor = Long.valueOf(value.toUpperCase(), 16).intValue(); - } - }); - - reader.expect("scanColor", new XmlReader.Attribute() { - public void read(String value) { - snapshot.scanColor = Long.valueOf(value.toUpperCase(), 16).intValue(); - } - }); - - reader.expect("energy", "e", new XmlReader.Attribute() { - public void read(String value) { - snapshot.energy = Double.parseDouble(value); - } - }); - - reader.expect("velocity", "v", new XmlReader.Attribute() { - public void read(String value) { - snapshot.velocity = Double.parseDouble(value); - } - }); - - reader.expect("gunHeat", "h", new XmlReader.Attribute() { - public void read(String value) { - snapshot.gunHeat = Double.parseDouble(value); - } - }); - - reader.expect("bodyHeading", "b", new XmlReader.Attribute() { - public void read(String value) { - snapshot.bodyHeading = Double.parseDouble(value); - } - }); - - reader.expect("gunHeading", "g", new XmlReader.Attribute() { - public void read(String value) { - snapshot.gunHeading = Double.parseDouble(value); - } - }); - - reader.expect("radarHeading", "r", new XmlReader.Attribute() { - public void read(String value) { - snapshot.radarHeading = Double.parseDouble(value); - } - }); - - reader.expect("x", new XmlReader.Attribute() { - public void read(String value) { - snapshot.x = Double.parseDouble(value); - } - }); - - reader.expect("y", new XmlReader.Attribute() { - public void read(String value) { - snapshot.y = Double.parseDouble(value); - } - }); - - reader.expect("out", new XmlReader.Attribute() { - public void read(String value) { - if (value != null && value.length() != 0) { - snapshot.outputStreamSnapshot = value; - } - } - }); - - final XmlReader.Element element = (new ScoreSnapshot()).readXml(reader); - - reader.expect("score", "sc", new XmlReader.Element() { - public IXmlSerializable read(XmlReader reader) { - snapshot.robotScoreSnapshot = (IScoreSnapshot) element.read(reader); - return (ScoreSnapshot) snapshot.robotScoreSnapshot; - } - }); - - return snapshot; - } - }); - } - - /** - * Class used for serializing an Arc2D.double. - * The purpose of this class is to overcome various serialization problems with Arc2D to cope with bug in Java 6: - * Bug ID: 6522514. - * - * @author Pavel Savara - */ - private static class SerializableArc implements Serializable { - private static final long serialVersionUID = 1L; - - public final double x; - public final double y; - public final double w; - public final double h; - public final double start; - public final double extent; - public final int type; - - public SerializableArc(Arc2D.Double arc) { - x = arc.getX(); - y = arc.getY(); - w = arc.getWidth(); - h = arc.getHeight(); - start = arc.getAngleStart(); - extent = arc.getAngleExtent(); - type = arc.getArcType(); - } - - public Arc2D create() { - return new Arc2D.Double(x, y, w, h, start, extent, type); - } - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/ScoreSnapshot.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/ScoreSnapshot.java deleted file mode 100644 index 77c65bb..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/ScoreSnapshot.java +++ /dev/null @@ -1,562 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.snapshot; - - -import net.sf.robocode.battle.peer.RobotStatistics; -import net.sf.robocode.serialization.IXmlSerializable; -import net.sf.robocode.serialization.XmlReader; -import net.sf.robocode.serialization.SerializableOptions; -import net.sf.robocode.serialization.XmlWriter; -import robocode.control.snapshot.IScoreSnapshot; - -import java.io.IOException; -import java.io.Serializable; - - -/** - * A snapshot of a score at a specific time instant in a battle. - * The snapshot contains a snapshot of the score data at that specific time. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - * - * @since 1.6.1 - */ -final class ScoreSnapshot implements Serializable, IXmlSerializable, IScoreSnapshot { - - private static final long serialVersionUID = 1L; - - /** The name of the contestant, i.e. a robot or team */ - private String name; - - /** The total score */ - private double totalScore; - - /** The total survival score */ - private double totalSurvivalScore; - - /** The total last survivor score */ - private double totalLastSurvivorBonus; - - /** The total bullet damage score */ - private double totalBulletDamageScore; - - /** The total bullet kill bonus */ - private double totalBulletKillBonus; - - /** The total ramming damage score */ - private double totalRammingDamageScore; - - /** The total ramming kill bonus */ - private double totalRammingKillBonus; - - /** The total number of first places */ - private int totalFirsts; - - /** The total number of second places */ - private int totalSeconds; - - /** The total number of third places */ - private int totalThirds; - - /** The current score */ - private double currentScore; - - /** The current survival score */ - private double currentSurvivalScore; - - /** The current survival bonus */ - private double currentSurvivalBonus; - - /** The current bullet damage score */ - private double currentBulletDamageScore; - - /** The current bullet kill bonus */ - private double currentBulletKillBonus; - - /** The current ramming damage score */ - private double currentRammingDamageScore; - - /** The current ramming kill bonus */ - private double currentRammingKillBonus; - - /** - * Creates a snapshot of a score that must be filled out with data later. - */ - public ScoreSnapshot() {} - - /** - * Creates a snapshot of a score. - * - * @param score the contestant's score to take a snapshot of. - * @param contestantName the name of the contestant. - */ - ScoreSnapshot(String contestantName, RobotStatistics score) { - this.name = contestantName; - totalScore = score.getTotalScore(); - totalSurvivalScore = score.getTotalSurvivalScore(); - totalLastSurvivorBonus = score.getTotalLastSurvivorBonus(); - totalBulletDamageScore = score.getTotalBulletDamageScore(); - totalBulletKillBonus = score.getTotalBulletKillBonus(); - totalRammingDamageScore = score.getTotalRammingDamageScore(); - totalRammingKillBonus = score.getTotalRammingKillBonus(); - totalFirsts = score.getTotalFirsts(); - totalSeconds = score.getTotalSeconds(); - totalThirds = score.getTotalThirds(); - currentScore = score.getCurrentScore(); - currentBulletDamageScore = score.getCurrentBulletDamageScore(); - currentSurvivalScore = score.getCurrentSurvivalScore(); - currentSurvivalBonus = score.getCurrentSurvivalBonus(); - currentBulletKillBonus = score.getCurrentBulletKillBonus(); - currentRammingDamageScore = score.getCurrentRammingDamageScore(); - currentRammingKillBonus = score.getCurrentRammingKillBonus(); - } - - /** - * Creates a snapshot of a score based on two sets of scores that are added together. - * - * @param contestantName the name of the contestant. - * @param score1 the contestant's first set of scores to base this snapshot on. - * @param score2 the contestant's second set of scores that must be added to the first set of scores. - */ - ScoreSnapshot(String contestantName, IScoreSnapshot score1, IScoreSnapshot score2) { - this.name = contestantName; - totalScore = score1.getTotalScore() + score2.getTotalScore(); - totalSurvivalScore = score1.getTotalSurvivalScore() + score2.getTotalSurvivalScore(); - totalLastSurvivorBonus = score1.getTotalLastSurvivorBonus() + score2.getTotalLastSurvivorBonus(); - totalBulletDamageScore = score1.getTotalBulletDamageScore() + score2.getTotalBulletDamageScore(); - totalBulletKillBonus = score1.getTotalBulletKillBonus() + score2.getTotalBulletKillBonus(); - totalRammingDamageScore = score1.getTotalRammingDamageScore() + score2.getTotalRammingDamageScore(); - totalRammingKillBonus = score1.getTotalRammingKillBonus() + score2.getTotalRammingKillBonus(); - totalFirsts = score1.getTotalFirsts() + score2.getTotalFirsts(); - totalSeconds = score1.getTotalSeconds() + score2.getTotalSeconds(); - totalThirds = score1.getTotalThirds() + score2.getTotalThirds(); - currentScore = score1.getCurrentScore() + score2.getCurrentScore(); - currentSurvivalScore = score1.getCurrentSurvivalScore() + score2.getCurrentSurvivalScore(); - currentBulletDamageScore = score1.getCurrentBulletDamageScore() + score2.getCurrentBulletDamageScore(); - currentBulletKillBonus = score1.getCurrentBulletKillBonus() + score2.getCurrentBulletKillBonus(); - currentRammingDamageScore = score1.getCurrentRammingDamageScore() + score2.getCurrentRammingDamageScore(); - currentRammingKillBonus = score1.getCurrentBulletKillBonus() + score2.getCurrentBulletKillBonus(); - } - - @Override - public String toString() { - return this.totalScore + "/" + this.currentScore; - } - - /** - * {@inheritDoc} - */ - public String getName() { - return name; - } - - /** - * {@inheritDoc} - */ - public double getTotalScore() { - return totalScore; - } - - /** - * {@inheritDoc} - */ - public double getTotalSurvivalScore() { - return totalSurvivalScore; - } - - /** - * {@inheritDoc} - */ - public double getTotalLastSurvivorBonus() { - return totalLastSurvivorBonus; - } - - /** - * {@inheritDoc} - */ - public double getTotalBulletDamageScore() { - return totalBulletDamageScore; - } - - /** - * {@inheritDoc} - */ - public double getTotalBulletKillBonus() { - return totalBulletKillBonus; - } - - /** - * {@inheritDoc} - */ - public double getTotalRammingDamageScore() { - return totalRammingDamageScore; - } - - /** - * {@inheritDoc} - */ - public double getTotalRammingKillBonus() { - return totalRammingKillBonus; - } - - /** - * {@inheritDoc} - */ - public int getTotalFirsts() { - return totalFirsts; - } - - /** - * {@inheritDoc} - */ - public int getTotalSeconds() { - return totalSeconds; - } - - /** - * {@inheritDoc} - */ - public int getTotalThirds() { - return totalThirds; - } - - /** - * {@inheritDoc} - */ - public double getCurrentScore() { - return currentScore; - } - - /** - * {@inheritDoc} - */ - public double getCurrentSurvivalScore() { - return currentSurvivalScore; - } - - /** - * {@inheritDoc} - */ - public double getCurrentSurvivalBonus() { - return currentSurvivalBonus; - } - - /** - * {@inheritDoc} - */ - public double getCurrentBulletDamageScore() { - return currentBulletDamageScore; - } - - /** - * {@inheritDoc} - */ - public double getCurrentBulletKillBonus() { - return currentBulletKillBonus; - } - - /** - * {@inheritDoc} - */ - public double getCurrentRammingDamageScore() { - return currentRammingDamageScore; - } - - /** - * {@inheritDoc} - */ - public double getCurrentRammingKillBonus() { - return currentRammingKillBonus; - } - - /** - * {@inheritDoc} - */ - public int compareTo(Object obj) { - if (obj instanceof IScoreSnapshot) { - IScoreSnapshot scoreSnapshot = (IScoreSnapshot) obj; - - double myScore = getTotalScore() + getCurrentScore(); - double hisScore = scoreSnapshot.getTotalScore() + scoreSnapshot.getCurrentScore(); - - if (myScore < hisScore) { - return -1; - } - if (myScore > hisScore) { - return 1; - } - } - return 0; - } - - /** - * {@inheritDoc} - */ - public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException { - writer.startElement(options.shortAttributes ? "sc" : "score"); { - if (!options.skipNames) { - writer.writeAttribute("name", name); - } - if (!options.skipTotal) { - writer.writeAttribute(options.shortAttributes ? "t" : "totalScore", totalScore, options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "tss" : "totalSurvivalScore", totalSurvivalScore, - options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "tls" : "totalLastSurvivorBonus", totalLastSurvivorBonus, - options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "tbd" : "totalBulletDamageScore", totalBulletDamageScore, - options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "tbk" : "totalBulletKillBonus", totalBulletKillBonus, - options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "trd" : "totalRammingDamageScore", - totalRammingDamageScore, options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "trk" : "totalRammingKillBonus", totalRammingKillBonus, - options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "t1" : "totalFirsts", totalFirsts); - writer.writeAttribute(options.shortAttributes ? "t2" : "totalSeconds", totalSeconds); - writer.writeAttribute(options.shortAttributes ? "t3" : "totalThirds", totalThirds); - } - writer.writeAttribute(options.shortAttributes ? "c" : "currentScore", currentScore, options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "ss" : "currentSurvivalScore", currentSurvivalScore, - options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "bd" : "currentBulletDamageScore", currentBulletDamageScore, - options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "bk" : "currentBulletKillBonus", currentBulletKillBonus, - options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "rd" : "currentRammingDamageScore", - currentRammingDamageScore, options.trimPrecision); - writer.writeAttribute(options.shortAttributes ? "rk" : "currentRammingKillBonus", currentRammingKillBonus, - options.trimPrecision); - if (!options.skipVersion) { - writer.writeAttribute("ver", serialVersionUID); - } - - } - writer.endElement(); - } - - // allows loading of minimalistic XML - ScoreSnapshot(String contestantName) { - this.name = contestantName; - } - - /** - * {@inheritDoc} - */ - public XmlReader.Element readXml(XmlReader reader) { - return reader.expect("score", "sc", new XmlReader.Element() { - public IXmlSerializable read(XmlReader reader) { - final ScoreSnapshot snapshot = new ScoreSnapshot(); - - reader.expect("name", new XmlReader.Attribute() { - public void read(String value) { - snapshot.name = value; - } - }); - reader.expect("totalScore", "t", new XmlReader.Attribute() { - public void read(String value) { - snapshot.totalScore = Double.parseDouble(value); - } - }); - reader.expect("totalSurvivalScore", "tss", new XmlReader.Attribute() { - public void read(String value) { - snapshot.totalSurvivalScore = Double.parseDouble(value); - } - }); - reader.expect("totalLastSurvivorBonus", "tls", new XmlReader.Attribute() { - public void read(String value) { - snapshot.totalLastSurvivorBonus = Double.parseDouble(value); - } - }); - reader.expect("totalBulletDamageScore", "tbd", new XmlReader.Attribute() { - public void read(String value) { - snapshot.totalBulletDamageScore = Double.parseDouble(value); - } - }); - reader.expect("totalBulletKillBonus", "tbk", new XmlReader.Attribute() { - public void read(String value) { - snapshot.totalBulletKillBonus = Double.parseDouble(value); - } - }); - reader.expect("totalRammingDamageScore", "trd", new XmlReader.Attribute() { - public void read(String value) { - snapshot.totalRammingDamageScore = Double.parseDouble(value); - } - }); - reader.expect("totalRammingKillBonus", "trk", new XmlReader.Attribute() { - public void read(String value) { - snapshot.totalRammingKillBonus = Double.parseDouble(value); - } - }); - reader.expect("totalFirsts", "t1", new XmlReader.Attribute() { - public void read(String value) { - snapshot.totalFirsts = Integer.parseInt(value); - } - }); - reader.expect("totalSeconds", "t2", new XmlReader.Attribute() { - public void read(String value) { - snapshot.totalSeconds = Integer.parseInt(value); - } - }); - reader.expect("totalThirds", "t3", new XmlReader.Attribute() { - public void read(String value) { - snapshot.totalThirds = Integer.parseInt(value); - } - }); - reader.expect("currentScore", "c", new XmlReader.Attribute() { - public void read(String value) { - snapshot.currentScore = Double.parseDouble(value); - } - }); - reader.expect("currentSurvivalScore", "ss", new XmlReader.Attribute() { - public void read(String value) { - snapshot.currentSurvivalScore = Double.parseDouble(value); - } - }); - reader.expect("currentBulletDamageScore", "bd", new XmlReader.Attribute() { - public void read(String value) { - snapshot.currentBulletDamageScore = Double.parseDouble(value); - } - }); - reader.expect("currentBulletKillBonus", "bk", new XmlReader.Attribute() { - public void read(String value) { - snapshot.currentBulletKillBonus = Double.parseDouble(value); - } - }); - reader.expect("currentRammingDamageScore", "rd", new XmlReader.Attribute() { - public void read(String value) { - snapshot.currentRammingDamageScore = Double.parseDouble(value); - } - }); - reader.expect("currentRammingKillBonus", "rk", new XmlReader.Attribute() { - public void read(String value) { - snapshot.currentRammingKillBonus = Double.parseDouble(value); - } - }); - return snapshot; - } - }); - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - long temp; - - temp = Double.doubleToLongBits(currentBulletDamageScore); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(currentBulletKillBonus); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(currentRammingDamageScore); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(currentRammingKillBonus); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(currentScore); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(currentSurvivalBonus); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(currentSurvivalScore); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + ((name == null) ? 0 : name.hashCode()); - temp = Double.doubleToLongBits(totalBulletDamageScore); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(totalBulletKillBonus); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + totalFirsts; - temp = Double.doubleToLongBits(totalLastSurvivorBonus); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(totalRammingDamageScore); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(totalRammingKillBonus); - result = prime * result + (int) (temp ^ (temp >>> 32)); - temp = Double.doubleToLongBits(totalScore); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + totalSeconds; - temp = Double.doubleToLongBits(totalSurvivalScore); - result = prime * result + (int) (temp ^ (temp >>> 32)); - result = prime * result + totalThirds; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - ScoreSnapshot other = (ScoreSnapshot) obj; - - if (Double.doubleToLongBits(currentBulletDamageScore) != Double.doubleToLongBits(other.currentBulletDamageScore)) { - return false; - } - if (Double.doubleToLongBits(currentBulletKillBonus) != Double.doubleToLongBits(other.currentBulletKillBonus)) { - return false; - } - if (Double.doubleToLongBits(currentRammingDamageScore) - != Double.doubleToLongBits(other.currentRammingDamageScore)) { - return false; - } - if (Double.doubleToLongBits(currentRammingKillBonus) != Double.doubleToLongBits(other.currentRammingKillBonus)) { - return false; - } - if (Double.doubleToLongBits(currentScore) != Double.doubleToLongBits(other.currentScore)) { - return false; - } - if (Double.doubleToLongBits(currentSurvivalBonus) != Double.doubleToLongBits(other.currentSurvivalBonus)) { - return false; - } - if (Double.doubleToLongBits(currentSurvivalScore) != Double.doubleToLongBits(other.currentSurvivalScore)) { - return false; - } - if (name == null) { - if (other.name != null) { - return false; - } - } else if (!name.equals(other.name)) { - return false; - } - if (Double.doubleToLongBits(totalBulletDamageScore) != Double.doubleToLongBits(other.totalBulletDamageScore)) { - return false; - } - if (Double.doubleToLongBits(totalBulletKillBonus) != Double.doubleToLongBits(other.totalBulletKillBonus)) { - return false; - } - if (totalFirsts != other.totalFirsts) { - return false; - } - if (Double.doubleToLongBits(totalLastSurvivorBonus) != Double.doubleToLongBits(other.totalLastSurvivorBonus)) { - return false; - } - if (Double.doubleToLongBits(totalRammingDamageScore) != Double.doubleToLongBits(other.totalRammingDamageScore)) { - return false; - } - if (Double.doubleToLongBits(totalRammingKillBonus) != Double.doubleToLongBits(other.totalRammingKillBonus)) { - return false; - } - if (Double.doubleToLongBits(totalScore) != Double.doubleToLongBits(other.totalScore)) { - return false; - } - if (totalSeconds != other.totalSeconds) { - return false; - } - if (Double.doubleToLongBits(totalSurvivalScore) != Double.doubleToLongBits(other.totalSurvivalScore)) { - return false; - } - if (totalThirds != other.totalThirds) { - return false; - } - return true; - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/TurnSnapshot.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/TurnSnapshot.java deleted file mode 100644 index bba2b48..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/battle/snapshot/TurnSnapshot.java +++ /dev/null @@ -1,297 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.snapshot; - - -import net.sf.robocode.battle.Battle; -import net.sf.robocode.battle.peer.BulletPeer; -import net.sf.robocode.battle.peer.RobotPeer; -import net.sf.robocode.serialization.IXmlSerializable; -import net.sf.robocode.serialization.XmlReader; -import net.sf.robocode.serialization.SerializableOptions; -import net.sf.robocode.serialization.XmlWriter; -import robocode.control.snapshot.*; - -import java.io.IOException; -import java.util.*; - - -/** - * A snapshot of a battle turn at a specific time instant in a battle. - * The snapshot contains a snapshot of the battle turn data at that specific time. - * - * @author Flemming N. Larsen (original) - * @author Pavel Savara (contributor) - * - * @since 1.6.1 - */ -public final class TurnSnapshot implements java.io.Serializable, IXmlSerializable, ITurnSnapshot { - - private static final long serialVersionUID = 1L; - - /** List of snapshots for the robots participating in the battle */ - private List robots; - - /** List of snapshots for the bullets that are currently on the battlefield */ - private List bullets; - - /** Current TPS (turns per second) */ - private int tps; - - /** Current round in the battle */ - private int round; - - /** Current turn in the battle round */ - private int turn; - - /** - * Creates a snapshot of a battle turn that must be filled out with data later. - */ - public TurnSnapshot() {} - - /** - * Creates a snapshot of a battle turn. - * - * @param battle the battle to make a snapshot of. - * @param battleRobots the robots participating in the battle. - * @param battleBullets the current bullet on the battlefield. - * @param readoutText {@code true} if the output text from the robots must be included in the snapshot; - * {@code false} otherwise. - */ - public TurnSnapshot(Battle battle, List battleRobots, List battleBullets, boolean readoutText) { - robots = new ArrayList(); - bullets = new ArrayList(); - - for (RobotPeer robotPeer : battleRobots) { - robots.add(new RobotSnapshot(robotPeer, readoutText)); - } - - for (BulletPeer bulletPeer : battleBullets) { - bullets.add(new BulletSnapshot(bulletPeer)); - } - - tps = battle.getTPS(); - turn = battle.getTime(); - round = battle.getRoundNum(); - } - - @Override - public String toString() { - return this.round + "/" + turn + " (" + this.robots.size() + ")"; - } - - /** - * {@inheritDoc} - */ - public IRobotSnapshot[] getRobots() { - return robots.toArray(new IRobotSnapshot[robots.size()]); - } - - /** - * {@inheritDoc} - */ - public IBulletSnapshot[] getBullets() { - return bullets.toArray(new IBulletSnapshot[bullets.size()]); - } - - /** - * {@inheritDoc} - */ - public int getTPS() { - return tps; - } - - /** - * {@inheritDoc} - */ - public int getRound() { - return round; - } - - /** - * {@inheritDoc} - */ - public int getTurn() { - return turn; - } - - /** - * {@inheritDoc} - */ - public IScoreSnapshot[] getSortedTeamScores() { - List copy = new ArrayList(Arrays.asList(getIndexedTeamScores())); - - Collections.sort(copy); - Collections.reverse(copy); - return copy.toArray(new IScoreSnapshot[copy.size()]); - } - - /** - * {@inheritDoc} - */ - public IScoreSnapshot[] getIndexedTeamScores() { - // team scores are computed on demand from team scores to not duplicate data in the snapshot - - List results = new ArrayList(); - - // noinspection ForLoopReplaceableByForEach - for (int i = 0; i < robots.size(); i++) { - results.add(null); - } - for (IRobotSnapshot robot : robots) { - final int contestantIndex = robot.getContestantIndex(); - final IScoreSnapshot snapshot = results.get(contestantIndex); - - IScoreSnapshot score = (snapshot == null) - ? robot.getScoreSnapshot() - : new ScoreSnapshot(robot.getTeamName(), snapshot, robot.getScoreSnapshot()); - - results.set(contestantIndex, score); - } - List scores = new ArrayList(); - - for (IScoreSnapshot scoreSnapshot : results) { - if (scoreSnapshot != null) { - scores.add(scoreSnapshot); - } - } - - return scores.toArray(new IScoreSnapshot[scores.size()]); - } - - public void stripDetails(SerializableOptions options) { - for (IRobotSnapshot r : getRobots()) { - ((RobotSnapshot) r).stripDetails(options); - } - } - - /** - * {@inheritDoc} - */ - public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException { - writer.startElement(options.shortAttributes ? "t" : "turn"); { - writer.writeAttribute(options.shortAttributes ? "ro" : "round", round); - writer.writeAttribute(options.shortAttributes ? "tu" : "turn", turn); - if (!options.skipVersion) { - writer.writeAttribute("ver", serialVersionUID); - } - - writer.startElement(options.shortAttributes ? "rs" : "robots"); { - SerializableOptions op = options; - - if (turn == 0) { - op = new SerializableOptions(options); - op.skipNames = false; - } - for (IRobotSnapshot r : robots) { - final RobotSnapshot rs = (RobotSnapshot) r; - - if (!options.skipExploded || rs.getState() != RobotState.DEAD) { - rs.writeXml(writer, op); - } else { - boolean writeFirstExplosionFrame = false; - - for (IBulletSnapshot b : bullets) { - if (b.isExplosion() && b.getFrame() == 0 && b.getVictimIndex() == r.getRobotIndex()) { - writeFirstExplosionFrame = true; - break; - } - } - if (writeFirstExplosionFrame) { - rs.writeXml(writer, op); - } - } - } - } - writer.endElement(); - - writer.startElement(options.shortAttributes ? "bs" : "bullets"); { - for (IBulletSnapshot b : bullets) { - final BulletSnapshot bs = (BulletSnapshot) b; - final BulletState state = bs.getState(); - - if (!options.skipExploded - || (state != BulletState.EXPLODED && state != BulletState.INACTIVE - && (bs.getFrame() == 0 || state == BulletState.MOVING))) { - bs.writeXml(writer, options); - } - } - } - writer.endElement(); - } - writer.endElement(); - } - - /** - * {@inheritDoc} - */ - public XmlReader.Element readXml(final XmlReader reader) { - return reader.expect("turn", "t", new XmlReader.Element() { - public IXmlSerializable read(final XmlReader reader) { - final TurnSnapshot snapshot = new TurnSnapshot(); - - reader.expect("turn", "tu", new XmlReader.Attribute() { - public void read(String value) { - snapshot.turn = Integer.parseInt(value); - } - }); - reader.expect("round", "ro", new XmlReader.Attribute() { - public void read(String value) { - snapshot.round = Integer.parseInt(value); - } - }); - - reader.expect("robots", "rs", new XmlReader.ListElement() { - public IXmlSerializable read(XmlReader reader) { - snapshot.robots = new ArrayList(); - // prototype - return new RobotSnapshot(); - } - - public void add(IXmlSerializable child) { - snapshot.robots.add((RobotSnapshot) child); - } - - public void close() { - // allows loading of minimalistic XML, which skips dead robots, but GUI expects them - Map context = reader.getContext(); - Integer robotCount = (Integer) context.get("robots"); - boolean[] present = new boolean[robotCount]; - - for (IRobotSnapshot robot : snapshot.robots) { - present[robot.getRobotIndex()] = true; - } - for (int i = 0; i < robotCount; i++) { - if (!present[i]) { - String name = (String) context.get(Integer.toString(i)); - - snapshot.robots.add(new RobotSnapshot(name, i, RobotState.DEAD)); - } - } - } - }); - - reader.expect("bullets", "bs", new XmlReader.ListElement() { - public IXmlSerializable read(XmlReader reader) { - snapshot.bullets = new ArrayList(); - // prototype - return new BulletSnapshot(); - } - - public void add(IXmlSerializable child) { - snapshot.bullets.add((BulletSnapshot) child); - } - - public void close() {} - }); - - return snapshot; - } - }); - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/BattlePlayer.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/BattlePlayer.java deleted file mode 100644 index 3872b12..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/BattlePlayer.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.recording; - - -import net.sf.robocode.battle.BaseBattle; -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.battle.events.BattleEventDispatcher; -import net.sf.robocode.battle.snapshot.RobotSnapshot; -import net.sf.robocode.settings.ISettingsManager; -import robocode.BattleResults; -import robocode.control.events.*; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - -import java.util.List; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (original) - */ -public final class BattlePlayer extends BaseBattle { - - private final RecordManager recordManager; - private boolean[] paint; - - public BattlePlayer(ISettingsManager properties, IBattleManager battleManager, RecordManager recordManager, BattleEventDispatcher eventDispatcher) { // NO_UCD (unused code) - super( - properties, battleManager, eventDispatcher); - this.recordManager = recordManager; - } - - @Override - protected void initializeBattle() { - super.initializeBattle(); - - recordManager.prepareInputStream(); - - battleRules = recordManager.recordInfo.battleRules; - paint = new boolean[recordManager.recordInfo.robotCount]; - eventDispatcher.onBattleStarted(new BattleStartedEvent(battleRules, recordManager.recordInfo.robotCount, true)); - if (isPaused) { - eventDispatcher.onBattlePaused(new BattlePausedEvent()); - } - } - - @Override - protected void finalizeBattle() { - boolean aborted = recordManager.recordInfo.results == null || isAborted(); - - eventDispatcher.onBattleFinished(new BattleFinishedEvent(aborted)); - - if (!aborted) { - final List res = recordManager.recordInfo.results; - - eventDispatcher.onBattleCompleted( - new BattleCompletedEvent(battleRules, res.toArray(new BattleResults[res.size()]))); - } - - super.finalizeBattle(); - - cleanup(); - } - - @Override - protected void initializeRound() { - super.initializeRound(); - - final ITurnSnapshot snapshot = recordManager.readSnapshot(currentTime); - - if (snapshot != null) { - eventDispatcher.onRoundStarted(new RoundStartedEvent(snapshot, getRoundNum())); - } - } - - @Override - protected void finalizeRound() { - super.finalizeRound(); - - eventDispatcher.onRoundEnded(new RoundEndedEvent(getRoundNum(), getTime(), totalTurns)); - } - - @Override - protected void initializeTurn() { - super.initializeTurn(); - - eventDispatcher.onTurnStarted(new TurnStartedEvent()); - } - - @Override - protected void finalizeTurn() { - final ITurnSnapshot snapshot = recordManager.readSnapshot(currentTime); - - if (snapshot != null) { - final IRobotSnapshot[] robots = snapshot.getRobots(); - - for (int i = 0; i < robots.length; i++) { - RobotSnapshot robot = (RobotSnapshot) robots[i]; - - robot.setPaintEnabled(paint[i]); - } - eventDispatcher.onTurnEnded(new TurnEndedEvent(snapshot)); - } - - super.finalizeTurn(); - } - - @Override - protected boolean isRoundOver() { - final boolean end = getTime() >= recordManager.recordInfo.turnsInRounds[getRoundNum()] - 1; - - if (end) { - if (recordManager.recordInfo.turnsInRounds.length > getRoundNum() - && recordManager.recordInfo.turnsInRounds[getRoundNum()] == 0) { - isAborted = true; - } - } - return (isAborted || end); - } - - @Override - public void cleanup() { - super.cleanup(); - recordManager.cleanupStreams(); - } - - public void setPaintEnabled(int robotIndex, boolean enable) { - sendCommand(new EnableRobotPaintCommand(robotIndex, enable)); - } - - private class EnableRobotPaintCommand extends RobotCommand { - final boolean enablePaint; - - EnableRobotPaintCommand(int robotIndex, boolean enablePaint) { - super(robotIndex); - this.enablePaint = enablePaint; - } - - public void execute() { - paint[robotIndex] = enablePaint; - } - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/BattleRecordInfo.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/BattleRecordInfo.java deleted file mode 100644 index 9bab5c2..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/BattleRecordInfo.java +++ /dev/null @@ -1,330 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.recording; - - -import net.sf.robocode.battle.BattleProperties; -import net.sf.robocode.security.HiddenAccess; -import net.sf.robocode.serialization.IXmlSerializable; -import net.sf.robocode.serialization.SerializableOptions; -import net.sf.robocode.serialization.XmlReader; -import net.sf.robocode.serialization.XmlWriter; -import robocode.BattleResults; -import robocode.BattleRules; - -import java.io.IOException; -import java.io.Serializable; -import java.util.ArrayList; -import java.util.List; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (original) - */ -class BattleRecordInfo implements Serializable, IXmlSerializable { - private static final long serialVersionUID = 1L; - - int robotCount; - int roundsCount; - BattleRules battleRules; - Integer[] turnsInRounds; - List results; - - public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException { - writer.startElement("recordInfo"); { - writer.writeAttribute("robotCount", robotCount); - writer.writeAttribute("roundsCount", roundsCount); - if (!options.skipVersion) { - writer.writeAttribute("ver", serialVersionUID); - } - writer.startElement("rules"); { - writer.writeAttribute("battlefieldWidth", battleRules.getBattlefieldWidth()); - writer.writeAttribute("battlefieldHeight", battleRules.getBattlefieldHeight()); - writer.writeAttribute("numRounds", battleRules.getNumRounds()); - writer.writeAttribute("gunCoolingRate", battleRules.getGunCoolingRate(), options.trimPrecision); - writer.writeAttribute("inactivityTime", battleRules.getInactivityTime()); - writer.writeAttribute("ver", serialVersionUID); - } - writer.endElement(); - - writer.startElement("rounds"); { - for (int n : turnsInRounds) { - writer.startElement("turns"); { - writer.writeAttribute("value", Integer.toString(n)); - } - writer.endElement(); - } - } - writer.endElement(); - - if (results != null) { - writer.startElement("results"); { - for (BattleResults result : results) { - new BattleResultsWrapper(result).writeXml(writer, options); - } - } - writer.endElement(); - } - } - writer.endElement(); - } - - public XmlReader.Element readXml(XmlReader reader) { - return reader.expect("recordInfo", new XmlReader.Element() { - public IXmlSerializable read(XmlReader reader) { - final BattleRecordInfo recordInfo = new BattleRecordInfo(); - - reader.expect("robotCount", new XmlReader.Attribute() { - public void read(String value) { - recordInfo.robotCount = Integer.parseInt(value); - } - }); - reader.expect("roundsCount", new XmlReader.Attribute() { - public void read(String value) { - recordInfo.roundsCount = Integer.parseInt(value); - } - }); - - new BattleRulesWrapper(recordInfo).readXml(reader); - - reader.expect("rounds", new XmlReader.ListElement() { - final ArrayList ints = new ArrayList(); - - public IXmlSerializable read(XmlReader reader) { - // prototype - return new IntValue("turns"); - } - - public void add(IXmlSerializable child) { - ints.add(((IntValue) child).intValue); - } - - public void close() { - recordInfo.turnsInRounds = new Integer[ints.size()]; - ints.toArray(recordInfo.turnsInRounds); - } - }); - - reader.expect("results", new XmlReader.ListElement() { - - public IXmlSerializable read(XmlReader reader) { - recordInfo.results = new ArrayList(); - // prototype - return new BattleResultsWrapper(); - } - - public void add(IXmlSerializable child) { - recordInfo.results.add((BattleResults) child); - } - - public void close() {} - }); - return recordInfo; - } - }); - } - - private class IntValue implements IXmlSerializable { - private IntValue(String name) { - this.name = name; - } - private final String name; - private int intValue; - - public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException {} - - public XmlReader.Element readXml(XmlReader reader) { - return reader.expect(name, new XmlReader.Element() { - public IXmlSerializable read(XmlReader reader) { - final IntValue recordInfo = new IntValue(name); - - reader.expect("value", new XmlReader.Attribute() { - public void read(String value) { - recordInfo.intValue = Integer.parseInt(value); - } - }); - return recordInfo; - } - }); - } - } - - - /** - * This class is used for wrapping a robocode.BattleResults object and provides - * methods for XML serialization that are hidden from the BattleResults class, - * which is a part of the public Robot API for Robocode. - * - * @author Flemming N. Larsen (original) - */ - private class BattleResultsWrapper extends BattleResults implements IXmlSerializable { - - private static final long serialVersionUID = BattleResults.serialVersionUID; - - public BattleResultsWrapper() { - super(null, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0); - } - - private BattleResultsWrapper(BattleResults results) { - super(results.getTeamLeaderName(), results.getRank(), results.getScore(), results.getSurvival(), - results.getLastSurvivorBonus(), results.getBulletDamage(), results.getBulletDamageBonus(), - results.getRamDamage(), results.getRamDamageBonus(), results.getFirsts(), results.getSeconds(), - results.getThirds()); - } - - public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException { - writer.startElement("result"); { - writer.writeAttribute("teamLeaderName", teamLeaderName); - writer.writeAttribute("rank", rank); - writer.writeAttribute("score", score, options.trimPrecision); - writer.writeAttribute("survival", survival, options.trimPrecision); - writer.writeAttribute("lastSurvivorBonus", lastSurvivorBonus, options.trimPrecision); - writer.writeAttribute("bulletDamage", bulletDamage, options.trimPrecision); - writer.writeAttribute("bulletDamageBonus", bulletDamageBonus, options.trimPrecision); - writer.writeAttribute("ramDamage", ramDamage, options.trimPrecision); - writer.writeAttribute("ramDamageBonus", ramDamageBonus, options.trimPrecision); - writer.writeAttribute("firsts", firsts); - writer.writeAttribute("seconds", seconds); - writer.writeAttribute("thirds", thirds); - if (!options.skipVersion) { - writer.writeAttribute("ver", serialVersionUID); - } - } - writer.endElement(); - } - - public XmlReader.Element readXml(XmlReader reader) { - return reader.expect("result", new XmlReader.Element() { - public IXmlSerializable read(XmlReader reader) { - final BattleResultsWrapper rules = new BattleResultsWrapper(); - - reader.expect("teamLeaderName", new XmlReader.Attribute() { - public void read(String value) { - rules.teamLeaderName = value; - } - }); - - reader.expect("rank", new XmlReader.Attribute() { - public void read(String value) { - rules.rank = Integer.parseInt(value); - } - }); - reader.expect("score", new XmlReader.Attribute() { - public void read(String value) { - rules.score = Double.parseDouble(value); - } - }); - reader.expect("survival", new XmlReader.Attribute() { - public void read(String value) { - rules.survival = Double.parseDouble(value); - } - }); - reader.expect("lastSurvivorBonus", new XmlReader.Attribute() { - public void read(String value) { - rules.lastSurvivorBonus = Double.parseDouble(value); - } - }); - reader.expect("bulletDamage", new XmlReader.Attribute() { - public void read(String value) { - rules.bulletDamage = Double.parseDouble(value); - } - }); - reader.expect("bulletDamageBonus", new XmlReader.Attribute() { - public void read(String value) { - rules.bulletDamageBonus = Double.parseDouble(value); - } - }); - reader.expect("ramDamage", new XmlReader.Attribute() { - public void read(String value) { - rules.ramDamage = Double.parseDouble(value); - } - }); - reader.expect("ramDamageBonus", new XmlReader.Attribute() { - public void read(String value) { - rules.ramDamageBonus = Double.parseDouble(value); - } - }); - reader.expect("firsts", new XmlReader.Attribute() { - public void read(String value) { - rules.firsts = Integer.parseInt(value); - } - }); - reader.expect("seconds", new XmlReader.Attribute() { - public void read(String value) { - rules.seconds = Integer.parseInt(value); - } - }); - reader.expect("thirds", new XmlReader.Attribute() { - public void read(String value) { - rules.thirds = Integer.parseInt(value); - } - }); - - return rules; - } - }); - } - } - - - private static class BattleRulesWrapper implements IXmlSerializable { - BattleRulesWrapper(BattleRecordInfo recinfo) { - this.recinfo = recinfo; - } - - final BattleProperties props = new BattleProperties(); - final BattleRecordInfo recinfo; - - public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException {} - - public XmlReader.Element readXml(XmlReader reader) { - return reader.expect("rules", - new XmlReader.ElementClose() { - public IXmlSerializable read(XmlReader reader) { - - reader.expect("battlefieldWidth", new XmlReader.Attribute() { - public void read(String value) { - props.setBattlefieldWidth(Integer.parseInt(value)); - } - }); - reader.expect("battlefieldHeight", new XmlReader.Attribute() { - public void read(String value) { - props.setBattlefieldHeight(Integer.parseInt(value)); - } - }); - - reader.expect("numRounds", new XmlReader.Attribute() { - public void read(String value) { - props.setNumRounds(Integer.parseInt(value)); - } - }); - reader.expect("inactivityTime", new XmlReader.Attribute() { - public void read(String value) { - props.setInactivityTime(Integer.parseInt(value)); - } - }); - reader.expect("gunCoolingRate", new XmlReader.Attribute() { - public void read(String value) { - props.setGunCoolingRate(Double.parseDouble(value)); - } - }); - - return BattleRulesWrapper.this; - } - - public void close() { - recinfo.battleRules = HiddenAccess.createRules(props.getBattlefieldWidth(), - props.getBattlefieldHeight(), props.getNumRounds(), props.getGunCoolingRate(), - props.getInactivityTime(), props.getHideEnemyNames(), props.getSentryBorderSize()); - } - }); - } - } - -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/BattleRecorder.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/BattleRecorder.java deleted file mode 100644 index f7ad6cc..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/BattleRecorder.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.recording; - - -import net.sf.robocode.battle.events.BattleEventDispatcher; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.serialization.SerializableOptions; -import net.sf.robocode.settings.ISettingsManager; -import robocode.BattleResults; -import robocode.control.events.*; - -import java.io.File; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Arrays; -import java.util.Calendar; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (original) - */ -class BattleRecorder { - private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss"); - - private final RecordManager recordmanager; - private final ISettingsManager properties; - private BattleObserver battleObserver; - - BattleRecorder(RecordManager recordmanager, ISettingsManager properties) { - this.recordmanager = recordmanager; - this.properties = properties; - } - - void attachRecorder(BattleEventDispatcher battleEventDispatcher) { - if (battleObserver != null) { - battleObserver.dispose(); - } - battleObserver = new BattleObserver(battleEventDispatcher); - } - - void detachRecorder() { - if (battleObserver != null) { - battleObserver.dispose(); - } - } - - private class BattleObserver extends BattleAdaptor { - private final BattleEventDispatcher dispatcher; - - private int currentTurn; - private int currentRound; - - public BattleObserver(BattleEventDispatcher dispatcher) { - this.dispatcher = dispatcher; - dispatcher.addListener(this); - } - - public void dispose() { - dispatcher.removeListener(this); - recordmanager.cleanupStreams(); - } - - @Override - public void onBattleStarted(BattleStartedEvent event) { - recordmanager.cleanupStreams(); - recordmanager.createRecordInfo(event.getBattleRules(), event.getRobotsCount()); - - currentRound = 0; - currentTurn = 0; - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - recordmanager.cleanupStreams(); - } - - @Override - public void onBattleCompleted(BattleCompletedEvent event) { - recordmanager.updateRecordInfoResults(Arrays.asList(event.getIndexedResults())); - - if (properties.getOptionsCommonEnableAutoRecording()) { - writeAutoRecord(event); - } - } - - @Override - public void onRoundStarted(RoundStartedEvent event) { - currentRound = event.getRound(); - currentTurn = 0; - recordmanager.writeTurn(event.getStartSnapshot(), currentRound, currentTurn); - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - currentTurn = event.getTurnSnapshot().getTurn(); - recordmanager.writeTurn(event.getTurnSnapshot(), currentRound, currentTurn); - } - - private void writeAutoRecord(BattleCompletedEvent event) { - try { - final BattleResults[] results = event.getIndexedResults(); - StringBuilder name = new StringBuilder(); - - name.append(FileUtil.getBattlesDir().getCanonicalPath()); - name.append(File.separator); - - Calendar calendar = Calendar.getInstance(); - - name.append(dateFormat.format(calendar.getTime())); - name.append('-'); - for (BattleResults r : results) { - String teamLeaderName = r.getTeamLeaderName(); - - if (teamLeaderName.contains("*")) { // Development version of robot indicated with * in name - teamLeaderName = teamLeaderName.replace("*", ""); // Remove the star (*) - } - name.append(teamLeaderName); - name.append('-'); - } - name.setLength(name.length() - 1); - if (properties.getOptionsCommonAutoRecordingXML()) { - name.append(".xml.zip"); - recordmanager.saveRecord(name.toString(), BattleRecordFormat.XML_ZIP, new SerializableOptions(true)); - } else { - name.append(".zip.br"); - recordmanager.saveRecord(name.toString(), BattleRecordFormat.BINARY_ZIP, - new SerializableOptions(true)); - } - } catch (IOException e) { - Logger.logError(e); - } - } - } -} diff --git a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/RecordManager.java b/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/RecordManager.java deleted file mode 100644 index 82afc32..0000000 --- a/workspace_robo/robocode.battle/src/main/java/net/sf/robocode/recording/RecordManager.java +++ /dev/null @@ -1,448 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.recording; - - -import net.sf.robocode.battle.events.BattleEventDispatcher; -import net.sf.robocode.battle.snapshot.TurnSnapshot; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import static net.sf.robocode.io.Logger.logError; -import net.sf.robocode.serialization.IXmlSerializable; -import net.sf.robocode.serialization.SerializableOptions; -import net.sf.robocode.serialization.XmlReader; -import net.sf.robocode.serialization.XmlWriter; -import net.sf.robocode.settings.ISettingsManager; -import robocode.BattleResults; -import robocode.BattleRules; -import robocode.control.snapshot.ITurnSnapshot; - -import java.io.*; -import java.nio.charset.Charset; -import java.text.SimpleDateFormat; -import java.util.Calendar; -import java.util.List; -import java.util.zip.ZipEntry; -import java.util.zip.ZipInputStream; -import java.util.zip.ZipOutputStream; - - -/** - * @author Pavel Savara (original) - */ -public class RecordManager implements IRecordManager { - private static final SimpleDateFormat dateFormat = new SimpleDateFormat("yyyyMMdd-HHmmss"); - - private final ISettingsManager properties; - - private File tempFile; - private BattleRecorder recorder; - - BattleRecordInfo recordInfo; - private FileOutputStream fileWriteStream; - private BufferedOutputStream bufferedWriteStream; - private ObjectOutputStream objectWriteStream; - - private FileInputStream fileReadStream; - private BufferedInputStream bufferedReadStream; - private ObjectInputStream objectReadStream; - - public RecordManager(ISettingsManager properties) { // NO_UCD (unused code) - this.properties = properties; - recorder = new BattleRecorder(this, properties); - } - - protected void finalize() throws Throwable { - try { - cleanup(); - } finally { - super.finalize(); - } - } - - private void cleanup() { - cleanupStreams(); - if (tempFile != null && tempFile.exists()) { - if (tempFile.delete() == false) { - Logger.logError("Could not delete temp file"); - } - tempFile = null; - } - recordInfo = null; - } - - void cleanupStreams() { - FileUtil.cleanupStream(objectWriteStream); - objectWriteStream = null; - FileUtil.cleanupStream(bufferedWriteStream); - bufferedWriteStream = null; - FileUtil.cleanupStream(fileWriteStream); - fileWriteStream = null; - - FileUtil.cleanupStream(objectReadStream); - objectReadStream = null; - FileUtil.cleanupStream(bufferedReadStream); - bufferedReadStream = null; - FileUtil.cleanupStream(fileReadStream); - fileReadStream = null; - } - - public void attachRecorder(BattleEventDispatcher battleEventDispatcher) { - recorder.attachRecorder(battleEventDispatcher); - } - - public void detachRecorder() { - recorder.detachRecorder(); - } - - private void createTempFile() { - try { - if (tempFile == null) { - tempFile = File.createTempFile("robocode-battle-records", ".tmp"); - tempFile.deleteOnExit(); - } else { - if (!tempFile.delete()) { - Logger.logError("Could not delete temp file"); - } - if (!tempFile.createNewFile()) { - throw new Error("Temp file creation failed"); - } - } - } catch (IOException e) { - logError(e); - throw new Error("Temp file creation failed", e); - } - } - - void prepareInputStream() { - try { - fileReadStream = new FileInputStream(tempFile); - bufferedReadStream = new BufferedInputStream(fileReadStream); - objectReadStream = new ObjectInputStream(bufferedReadStream); - } catch (FileNotFoundException e) { - logError(e); - fileReadStream = null; - bufferedReadStream = null; - objectReadStream = null; - } catch (IOException e) { - logError(e); - fileReadStream = null; - bufferedReadStream = null; - objectReadStream = null; - } - } - - ITurnSnapshot readSnapshot(int currentTime) { - if (objectReadStream == null) { - return null; - } - try { - // TODO implement seek to currentTime, warn you. turns don't have same size in bytes - return (ITurnSnapshot) objectReadStream.readObject(); - } catch (EOFException e) { - logError(e); - return null; - } catch (Exception e) { - logError(e); - return null; - } - } - - public void loadRecord(String recordFilename, BattleRecordFormat format) { - FileInputStream fis = null; - BufferedInputStream bis = null; - ZipInputStream zis = null; - ObjectInputStream ois = null; - InputStream xis = null; - - FileOutputStream fos = null; - BufferedOutputStream bos = null; - ObjectOutputStream oos = null; - - try { - createTempFile(); - fis = new FileInputStream(recordFilename); - bis = new BufferedInputStream(fis, 1024 * 1024); - - if (format == BattleRecordFormat.BINARY) { - ois = new ObjectInputStream(bis); - } else if (format == BattleRecordFormat.BINARY_ZIP) { - zis = new ZipInputStream(bis); - zis.getNextEntry(); - ois = new ObjectInputStream(zis); - } else if (format == BattleRecordFormat.XML_ZIP) { - zis = new ZipInputStream(bis); - zis.getNextEntry(); - xis = zis; - } else if (format == BattleRecordFormat.XML) { - xis = bis; - } - if (format == BattleRecordFormat.BINARY || format == BattleRecordFormat.BINARY_ZIP) { - recordInfo = (BattleRecordInfo) ois.readObject(); - if (recordInfo.turnsInRounds != null) { - fos = new FileOutputStream(tempFile); - bos = new BufferedOutputStream(fos, 1024 * 1024); - oos = new ObjectOutputStream(bos); - - for (int i = 0; i < recordInfo.turnsInRounds.length; i++) { - for (int j = recordInfo.turnsInRounds[i] - 1; j >= 0; j--) { - try { - ITurnSnapshot turn = (ITurnSnapshot) ois.readObject(); - - oos.writeObject(turn); - } catch (ClassNotFoundException e) { - logError(e); - } - } - } - } - } else { - final RecordRoot root = new RecordRoot(); - - fos = new FileOutputStream(tempFile); - bos = new BufferedOutputStream(fos, 1024 * 1024); - root.oos = new ObjectOutputStream(bos); - XmlReader.deserialize(xis, root); - if (root.lastException != null) { - logError(root.lastException); - } - recordInfo = root.recordInfo; - } - } catch (IOException e) { - logError(e); - createTempFile(); - recordInfo = null; - } catch (ClassNotFoundException e) { - if (e.getMessage().contains("robocode.recording.BattleRecordInfo")) { - Logger.logError("Sorry, backward compatibility with record from version 1.6 is not provided."); - } else { - logError(e); - } - createTempFile(); - recordInfo = null; - } finally { - FileUtil.cleanupStream(oos); - FileUtil.cleanupStream(bos); - FileUtil.cleanupStream(fos); - FileUtil.cleanupStream(ois); - FileUtil.cleanupStream(zis); - FileUtil.cleanupStream(bis); - FileUtil.cleanupStream(fis); - } - } - - private static class RecordRoot implements IXmlSerializable { - - public RecordRoot() { - me = this; - } - - public ObjectOutputStream oos; - public IOException lastException; - public final RecordRoot me; - public BattleRecordInfo recordInfo; - - public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException {} - - public XmlReader.Element readXml(XmlReader reader) { - return reader.expect("record", new XmlReader.Element() { - public IXmlSerializable read(final XmlReader reader) { - - final XmlReader.Element element = (new BattleRecordInfo()).readXml(reader); - - reader.expect("recordInfo", new XmlReader.ElementClose() { - public IXmlSerializable read(XmlReader reader) { - recordInfo = (BattleRecordInfo) element.read(reader); - return recordInfo; - } - - public void close() { - reader.getContext().put("robots", recordInfo.robotCount); - } - }); - - reader.expect("turns", new XmlReader.ListElement() { - public IXmlSerializable read(XmlReader reader) { - // prototype - return new TurnSnapshot(); - } - - public void add(IXmlSerializable child) { - try { - me.oos.writeObject(child); - } catch (IOException e) { - me.lastException = e; - } - } - - public void close() {} - }); - - return me; - } - }); - } - } - - public void saveRecord(String recordFilename, BattleRecordFormat format, SerializableOptions options) { - FileOutputStream fos = null; - BufferedOutputStream bos = null; - ZipOutputStream zos = null; - ObjectOutputStream oos = null; - OutputStreamWriter osw = null; - XmlWriter xwr = null; - - FileInputStream fis = null; - BufferedInputStream bis = null; - ObjectInputStream ois = null; - - final boolean isbin = format == BattleRecordFormat.BINARY || format == BattleRecordFormat.BINARY_ZIP; - final boolean isxml = format == BattleRecordFormat.XML || format == BattleRecordFormat.XML_ZIP; - Calendar calendar = Calendar.getInstance(); - - try { - fos = new FileOutputStream(recordFilename); - bos = new BufferedOutputStream(fos, 1024 * 1024); - - if (format == BattleRecordFormat.BINARY) { - oos = new ObjectOutputStream(bos); - } else if (format == BattleRecordFormat.BINARY_ZIP) { - zos = new ZipOutputStream(bos); - zos.putNextEntry(new ZipEntry(dateFormat.format(calendar.getTime()) + "-robocode.br")); - oos = new ObjectOutputStream(zos); - } else if (format == BattleRecordFormat.XML) { - final Charset utf8 = Charset.forName("UTF-8"); - - osw = new OutputStreamWriter(bos, utf8); - xwr = new XmlWriter(osw, true); - } else if (format == BattleRecordFormat.XML_ZIP) { - final Charset utf8 = Charset.forName("UTF-8"); - - zos = new ZipOutputStream(bos); - zos.putNextEntry(new ZipEntry(dateFormat.format(calendar.getTime()) + "-robocode.xml")); - - osw = new OutputStreamWriter(zos, utf8); - xwr = new XmlWriter(osw, false); - } - - if (isbin) { - oos.writeObject(recordInfo); - } else if (isxml) { - xwr.startDocument(); - xwr.startElement("record"); - xwr.writeAttribute("xmlns:xsi", "http://www.w3.org/2001/XMLSchema-instance"); - if (options.shortAttributes) { - xwr.writeAttribute("xsi:noNamespaceSchemaLocation", "battleRecordS.xsd"); - } else { - xwr.writeAttribute("xsi:noNamespaceSchemaLocation", "battleRecord.xsd"); - } - recordInfo.writeXml(xwr, options); - xwr.startElement("turns"); - } - - if (recordInfo.turnsInRounds != null) { - fis = new FileInputStream(tempFile); - bis = new BufferedInputStream(fis, 1024 * 1024); - ois = new ObjectInputStream(bis); - - for (int i = 0; i < recordInfo.turnsInRounds.length; i++) { - if (recordInfo.turnsInRounds[i] > 0) { - for (int j = 0; j <= recordInfo.turnsInRounds[i] - 1; j++) { - try { - TurnSnapshot turn = (TurnSnapshot) ois.readObject(); - - if (j != turn.getTurn()) { - throw new Error("Something rotten"); - } - - if (isbin) { - turn.stripDetails(options); - oos.writeObject(turn); - } else if (isxml) { - turn.writeXml(xwr, options); - } - } catch (ClassNotFoundException e) { - logError(e); - } - } - if (isbin) { - oos.flush(); - } else if (isxml) { - osw.flush(); - } - bos.flush(); - fos.flush(); - } - } - if (isxml) { - xwr.endElement(); // turns - xwr.endElement(); // record - osw.flush(); - } - } - - } catch (IOException e) { - logError(e); - recorder = new BattleRecorder(this, properties); - createTempFile(); - } finally { - FileUtil.cleanupStream(ois); - FileUtil.cleanupStream(bis); - FileUtil.cleanupStream(fis); - FileUtil.cleanupStream(oos); - FileUtil.cleanupStream(zos); - FileUtil.cleanupStream(bos); - FileUtil.cleanupStream(fos); - FileUtil.cleanupStream(osw); - } - } - - public boolean hasRecord() { - return recordInfo != null; - } - - void createRecordInfo(BattleRules rules, int numRobots) { - try { - createTempFile(); - - fileWriteStream = new FileOutputStream(tempFile); - bufferedWriteStream = new BufferedOutputStream(fileWriteStream, 1024 * 1024); - objectWriteStream = new ObjectOutputStream(bufferedWriteStream); - } catch (IOException e) { - logError(e); - } - - recordInfo = new BattleRecordInfo(); - recordInfo.robotCount = numRobots; - recordInfo.battleRules = rules; - recordInfo.turnsInRounds = new Integer[rules.getNumRounds()]; - for (int i = 0; i < rules.getNumRounds(); i++) { - recordInfo.turnsInRounds[i] = 0; - } - } - - void updateRecordInfoResults(List results) { - recordInfo.results = results; - } - - void writeTurn(ITurnSnapshot turn, int round, int time) { - try { - if (time != recordInfo.turnsInRounds[round]) { - throw new Error("Something rotten"); - } - if (time == 0) { - objectWriteStream.reset(); - } - recordInfo.turnsInRounds[round]++; - recordInfo.roundsCount = round + 1; - objectWriteStream.writeObject(turn); - } catch (IOException e) { - logError(e); - } - } -} diff --git a/workspace_robo/robocode.content/.classpath b/workspace_robo/robocode.content/.classpath deleted file mode 100644 index 5da7d76..0000000 --- a/workspace_robo/robocode.content/.classpath +++ /dev/null @@ -1,7 +0,0 @@ - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.content/.project b/workspace_robo/robocode.content/.project deleted file mode 100644 index c96d253..0000000 --- a/workspace_robo/robocode.content/.project +++ /dev/null @@ -1,16 +0,0 @@ - - - robocode.content - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.samples - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.content/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.content/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.content/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.content/pom.xml b/workspace_robo/robocode.content/pom.xml deleted file mode 100644 index 911d916..0000000 --- a/workspace_robo/robocode.content/pom.xml +++ /dev/null @@ -1,62 +0,0 @@ - - - 4.0.0 - robocode.content - Robocode Content - - net.sf.robocode - robocode - ${robocode.version} - - - - net.sf.robocode - robocode.samples - ${project.version} - - - net.sf.robocode - robocode.api - - - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - copy - prepare-package - - copy - - - - - org.eclipse.jdt.core.compiler - ecj - 4.4 - jar - false - ${project.build.directory}/classes/compilers - ecj.jar - - - false - false - true - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - diff --git a/workspace_robo/robocode.content/robocode.content.iml b/workspace_robo/robocode.content/robocode.content.iml deleted file mode 100644 index ecbc7a1..0000000 --- a/workspace_robo/robocode.content/robocode.content.iml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.content/src/main/resources/ReadMe.html b/workspace_robo/robocode.content/src/main/resources/ReadMe.html deleted file mode 100644 index 347ead6..0000000 --- a/workspace_robo/robocode.content/src/main/resources/ReadMe.html +++ /dev/null @@ -1,233 +0,0 @@ - - - - - - - - - - -

ReadMe for Robocode

-

Updated 06-Mar-2013 by Flemming N. Larsen

-

Robocode Home Page: http://robocode.sourceforge.net/

-

TABLE OF CONTENTS

-
    -
  1. What is Robocode?
  2. -
  3. History of Robocode
  4. -
  5. System Requirements
  6. -
  7. Getting Started
  8. -
  9. Robocode API
  10. -
  11. Robocode Repository
  12. -
  13. Community
  14. -
  15. Challenges
  16. -
  17. Competition
  18. -
  19. Command Line
  20. -
  21. Links
  22. -
  23. Reporting Defects
  24. -
  25. Feature Requests
  26. -
  27. Versions
  28. -
  29. News
  30. -
  31. How to contribute
  32. -
-

1. WHAT IS ROBOCODE?

-

Robocode is a programming game where the goal is to code a robot battle tank to compete against other robots in a battle arena. So the name Robocode is a short for "Robot code". The player is the programmer of the robot, who will have no direct influence on the game. Instead, the player must write the AI of the robot telling it how to behave and react on events occurring in the battle arena. Battles are running in real-time and on-screen.

-

The motto of Robocode is: Build the best, destroy the rest!

-

Besides being a programming game, Robocode is used for learning how to program, primarily in the Java language, but other languages like C# and Scala are becoming popular as well.

-

Schools and universities are using Robocode as part of teaching how to program, but also for studying artificial intelligence (AI). The concept of Robocode is easy to understand, and a fun way to learn how to program.

-

Robocode offers complete development environment, and comes with its own installer, built-in robot editor and Java compiler. Robocode only pre-requires that a JVM (Java Virtual Machine) to exist already on the system where Robocode is going to be installed. Hence, everything a robot developer needs to get started is provided with the main Robocode distribution file (robocode-xxx-setup.jar). Robocode also supports developing robots using external IDEs like e.g. Eclipse, IntelliJ IDEA, NetBeans, Visual Studio etc., which supports the developer much better than the robot editor in Robocode.

-

The fact that Robocode runs on the Java platform makes it possible to run it on any operating system with Java pre-installed, meaning that it will be able to run on Windows, Linux, Mac OS, but also UNIX and variants of UNIX. Note that Java 6 or newer must be installed on the system before Robocode is able to run. See the System Requirements for more information.

-

Be aware that many users of Robocode (aka Robocoders) find Robocode to be very fun, but also very addictive. :-)

-

Robocode comes free of charge and is being developed as a spare-time project where no money is involved. The developers of Robocode are developing on Robocode because they think it is fun, and because they improve themselves as developers this way.

-

Robocode is an Open Source project, which means that all sources are open to everybody. In addition, Robocode is provided under the terms of EPL (Eclipse Public License).

-

2. HISTORY OF ROBOCODE

-

The Robocode game was originally started by Mathew A. Nelson as a personal endeavor in late 2000 and became a professional one when he brought it to IBM, in the form of an AlphaWorks download, in July 2001.

-

IBM was interested in Robocode, as they saw an opportunity to promote Robocode as a fun way to get started with learning how to program in Java. IBM wrote lots of articles about Robocode, e.g. like Rock 'em, sock 'em Robocode! from AlphaWorks / developerWorks at IBM, a series of articles like Secrets from the Robocode masters, and "Robocode Rumble / RoboLeague".

-

The inspiration for creating Robocode came from Robot Battle, a programming game written by Brad Schick in 1992, which should still be alive. Robot Battle was, in turn, inspired by RobotWar, an Apple II+ game from the early 1980s.

-

The articles from IBM and the Robocode community behind the RoboWiki made Robocode very popular as programming game, and for many years Robocode has been used for education and research at schools and universities all over the world.

-

In the beginning of 2005, Mathew convinced IBM to release Robocode as Open Source on SourceForge. At this point, the development of Robocode had somewhat stopped. The community around Robocode began to develop their own versions of Robocode with bug fixes and new features, e.g. the OpenSourceRobocode/Contributions and later on the two projects, RobocodeNG and Robocode 2006, by Flemming N. Larsen.

-

Eventually, Flemming took over the Robocode project at SourceForge as administrator and developer in July 2006 to continue the original Robocode game. The RobocodeNG project was dropped, but Robocode 2006 was merged into the official Robocode version 1.1 containing lots of improvements. Since then, lots of new versions of Robocode have been released with more and more features and contributions from the community.

-

In May 2007, the RoboRumble client got built into Robocode. RoboRumble is widely used by the Robocode community for creating up-to-date robot ranking lists for the 1-to-1, Melee, Team, and Twin Dual competitions.

-

Since May 2010 a .NET plugin is provided for Robocode using a .NET / Java bridge, which makes it possible to develop robots for .NET beside developing robots in Java. This part was made by Pavel Savara, who is a major Robocode contributor.

-

3. SYSTEM REQUIREMENTS

-

In order to run Robocode, Java 6 Standard Edition (SE) or a newer version of Java must be installed on your system. Both the Java Runtime Environment (JRE) and the Java Developer Kit (JDK) can be used. Note that the JRE does not include the standard Java compiler (javac), but the JDK does. However, Robocode comes with a built-in compiler (ECJ). Hence, it is sufficient running Robocode on the JRE.

-

Also note that it is important that these environment variables have been set up prior to running Robocode:

-
    -
  • JAVA_HOME must be setup to point at the home directory for Java (JDK or JRE).
    Windows example: JAVA_HOME=C:\Program Files\Java\jdk1.6.0_41
    UNIX, Linux, Mac OS example: JAVA_HOME=/usr/local/jdk1.6.0_41

  • -
  • PATH must include the path to the bin of the Java home directory (JAVA_HOME) that includes java.exe for starting the Java virtual Machine (JVM).
    Windows example: PATH=%PATH%;%JAVA_HOME%
    UNIX, Linux, Mac OS example: PATH=${PATH}:${JAVA_HOME}/bin

  • -
-

You can read more details from here:

- -

If you want to program robots in .NET or control Robocode from a .NET application, you need to install the Robocode .NET API plug-in on top of Robocode. The plug-in is installed by double-clicking the robocode.dotnet-xxx-setup.jar the same way as Robocode itself is installed.

-

4. GETTING STARTED

-

Most documentation about Robocode is provided thru the RoboWiki, which contains the official documentation about Robocode, but which also hosts the community around Robocode. It is highly recommended to read the articles on the RoboWiki for getting started with Robocode. These articles are provided from here:

- -

You should read about the anatomy of a robot, the game physics, scoring etc.

-

To learn more about developing robots for .NET, these articles are a good starting point:

- -

5. ROBOCODE API

-

The Robocode API is provided as HTML pages for both the Java and .NET platform.

- -

The Robocode API actually consists of 3 different APIs.

-
    -
  • Robot API: Within the Java package robocode and .NET namespace Robocode.
    The Robot API is used for developing robots, and is the only part of the API that robots are allowed to access.

  • -
  • Robot Interfaces: Within the Java package robocode.robotinterfaces and .NET namespace Robocode.RobotInterfaces.
    The Robot Interfaces are used for developing new robot types with a different API that the standard Robot API.
    Note: The game rules and robot behaviors cannot be changed.

  • -
  • Control API: Within the Java package robocode.control and .NET namespace Robocode.Control.
    The Control API is used for letting another application start up battles with selected robots in Robocode and retrieve the results. It is also possible to get snapshots of robots and bullets (like position, heading, energy level etc.) at a specific time in a battle.

  • -
-

6. ROBOCODE REPOSITORY

-

If you want to try out new robots than the sample robots that come with Robocode, you should visit the Robocode Repository.

-

Robots are available under the Bots section of the repository.

-

The Robocode Repository is developed and maintained by David Lynn as a project independently of the Robocode project.

-

7. COMMUNITY

-

The community around Robocode is using the RoboWiki as communication channel. At the RoboWiki, people share new ideas, code snippets, algorithms, strategies, and lots of other stuff about Robocode. New official documentation from the developers of Robocode will be put at the RoboWiki as well.

-

On the RoboWiki, these strategies are provided:

- -

The code snippets are also provided on the RoboWiki:

- -

8. CHALLENGES

-

A good way to improve you self as a robot developer is to try out some real challenges. On the RoboWiki, two famous challenges exist for testing/studying a robots movement, targeting, and gun abilities:

- -

9. COMPETITION

-

If you want to challenge your robot(s) and yourself as robot developer, the RoboRumble@Home is the best way to do it. RoboRumble is the ultimate collaborative effort to have a live, up-to-date ranking of Robocode bots. It uses the power of available Robocoders' computers to distribute the effort of running battles and building the rankings.

-

RoboRumble is actually 3 different rumbles:

-
    -
  • RoboRumble (aka 1v1): One robot versus another robot - both picked at random. These two robots a alone on the battle field.
  • -
  • MeleeRumble: Ten robots picked at random all battle against each other..
  • -
  • TeamRumble: One team versus another team - both picked at random. Each team consists of five or less robots.
  • -
-

In order to get started with RoboRumble, you should read this page:

- -

Note that the RoboRumble@Home client is built into Robocode and can be started using the batch/shell/command files:

- - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
WindowsUNIX / LinuxMac OS
RoboRumbleroborumble.batroborumble.shroborumble.command
MeleeRumblemeleerumble.batmeleerumble.shmeleerumble.command
TeamRumbleteamrumble.batteamrumble.shteamrumble.command
-

Two other competitions exists which are:

-
    -
  • Twin Duel: Two teams battle on an 800x800 field. Each team consists of two robots (twins).
  • -
  • Hat League: Two teams not knowing each other are paired together at random (like drawing names from a hat). Each team consists of two robots. These two teams must work together and defeat two other teams that have also been picked at random.
  • -
-

10. COMMAND LINE

-

It is possible to specify options and predefined properties from the command-line when running Robocode. The usage of these can be listed by writing this from a command prompt or shell:

-
robocode -help
-

For example, it is possible to:

-
    -
  • disable the graphical user interface (GUI).
  • -
  • disable security that is specific to Robocode (but does not override the security that comes with the JVM).
  • -
  • enable/disable the debugging mode, useful when debugging robots.
  • -
  • play a battle based on an existing Robocode .battle file.
  • -
  • replay a recorded battle visually.
  • -
  • save the results of battles in a comma-separated file.
  • -
-

You can read more details here:

- - -

Links relevant to Robocode are provided on the home page of Robocode:

- -

Other links are provided from the RoboWiki - especially for challenges and competitions:

- -

The is also a Wikipedia page available about Robocode, which provides good links to movement and targeting strategies, competitions, and other sites about Robocode:

- -

12. REPORTING DEFECTS

-

If you discover a defect (bug) in Robocode you are encouraged to report the issue as soon as you discover it - the sooner the better.

-

A bug report should be reported on the Bugs page on the SourceForge site for Robocode. Each bug report will be prioritized among other bug reports depending on its impact on the game.

-

It will be a great help if you describe how to see or which steps to do in order to reproduce the defect. You are very welcome to provide a screen shot, source code or anything else that will show the bug. It is also a very good idea to write which system and version of Robocode and Java you are using.

-

If you are a registered user at SourceForge (register here) you will be able to add a "monitor" on your bug report. This way you will be able to receive notifications when someone add comments to your report, but will also be able to better track the current status of the bug, e.g. when the bug is fixed and with which version of Robocode the fix is available.

-

If you are a developer yourself, and have a good idea of how the bug could be fixed, you are more than welcome to do so. By fixing the bug, you will become a contributor of Robocode yourself. You can learn more about how to contribute here. Note that we accept bug fixes under the terms of EPL.

-

13. FEATURE REQUESTS

-

If you got an idea for a new feature or improvement for Robocode, you are very welcome to share your idea by summiting a feature request.

-

A feature request should be put on the Feature Requests on the SourceForge site for Robocode. Each feature request will be prioritized among other feature requests.

-

It will be a great help if you describe your idea in detail, and how you think it could be implemented into Robocode. For example, will it be possible to extend an existing feature with your idea?

-

If you are a registered user at SourceForge (register here) you will be able to add a "monitor" on your request. This way you will be able to receive notifications when someone add comments to your request entry, but will also be able to better track the current status of your entry, e.g. when the feature has been implemented and with which version of Robocode it will be available.

-

If you are a developer yourself, and have a good idea of how the feature could be implemented, you are more than welcome to do so if the feature is being accepted. By implementing the feature, you will become a contributor of Robocode yourself. You can learn more about how to contribute here. Note that we accept implementations under the terms of EPL.

-

14. VERSIONS

-

Robocode is continuously under development, and you should be aware that three different release types exist for Robocode:

-
    -
  • Alpha version is an unofficial "snapshot" version of Robocode that is under development and not feature complete yet. It is normally provided for the person that has put a bug report or feature request on the tracker for Robocode, which needs to be verified. Alpha versions are not meant to be redistributed at all.

  • -
  • Beta version is an official release that is considered feature complete, and which intended for everybody to try out and test regarding all new features and changes, but which is also considered "unstable", and might contain some unwanted side-effects due to the changes made to this version compared to the last final version of Robocode. Defects or undesired behaviors should be reported as soon as they are discovered so the issues can be fixed before the final release. Everybody is encouraged to take part in the testing Beta versions of Robocode.

  • -
  • Final version is (as it says) the final version of a specific and official release of Robocode, and where new features and bug fixes have been tested. Note, that the release will not state "final" on the distribution files for Robocode like it is the case for Alpha and Beta versions.

  • -
-

15. NEWS

-

News about Robocode is put on the blog spot for Robocode. Here it is possible subscribe to a RSS feed to receive news about Robocode.

- -

You can also follow Robocode on Twitter and Facebook here:

- -

The RoboWiki can be followed on Twitter as well:

- -

16. HOW TO CONTRIBUTE

-

If you want to contribute to Robocode with e.g. a new feature or bug fix, you should read the Developers Guide for building Robocode.

-

Note that we accept code changes under the terms of EPL.

-

There exist no or little documentation about the internals of Robocode, and the code base will need to be examined by a contributor in order to get an insight of how Robocode is implemented. Thus, it required a skilled Java developer to figure out how Robocode is put together.

-

Robocode is divided into several modules. You can read Pavel Savara's blog to get a good overview of Robocode here:

- -

Help for Robocode internals can be provided through the Robocode Developers Discussion Group where you can register yourself, and start up a new topic. This is the best way of getting information and asking about details for the internals in Robocode.

-

If a contribution is a somewhat small change to involves under 10 files, then the preferred way is to provide the contribution as a patch file that can be applied to the existing Robocode sources. Otherwise, you can be granted a Subversion branch for your work, where you can commit your changes. Later, this branch needs to be merged into the trunk be the administrators of Robocode and tested carefully. Additional work might be done by other Robocode developers to finalize the work.

- - diff --git a/workspace_robo/robocode.content/src/main/resources/ReadMe.txt b/workspace_robo/robocode.content/src/main/resources/ReadMe.txt deleted file mode 100644 index 1fe94cc..0000000 --- a/workspace_robo/robocode.content/src/main/resources/ReadMe.txt +++ /dev/null @@ -1,471 +0,0 @@ -## ReadMe for Robocode - -Updated 06-Mar-2013 by Flemming N. Larsen - -Robocode Home Page: -[http://robocode.sourceforge.net/](http://robocode.sourceforge.net/) - -### TABLE OF CONTENTS - -1. [What is Robocode?](#what-is-robocode) -2. [History of Robocode](#history-of-robocode) -3. [System Requirements](#system-requirements) -4. [Getting Started](#getting-started) -5. [Robocode API](#robocode-api) -6. [Robocode Repository](#robocode-repository) -7. [Community](#community) -8. [Challenges](#challenges) -9. [Competition](#competition) -10. [Command Line](#command-line) -11. [Links](#links) -12. [Reporting Defects](#reporting-defects) -13. [Feature Requests](#feature-requests) -14. [Versions](#versions) -15. [News](#news) -16. [How to contribute](#how-to-contribute) - -### 1. WHAT IS ROBOCODE? - -Robocode is a programming game where the goal is to code a robot battle -tank to compete against other robots in a battle arena. So the name -Robocode is a short for "Robot code". The player is the programmer of -the robot, who will have no direct influence on the game. Instead, the -player must write the AI of the robot telling it how to behave and -react on events occurring in the battle arena. Battles are running in -real-time and on-screen. - -**The motto of Robocode is: Build the best, destroy the rest!** - -Besides being a programming game, Robocode is used for learning how to -program, primarily in the Java language, but other languages like C# -and Scala are becoming popular as well. - -Schools and universities are using Robocode as part of teaching how to -program, but also for studying artificial intelligence (AI). The -concept of Robocode is easy to understand, and a fun way to learn how -to program. - -Robocode offers complete development environment, and comes with its -own installer, built-in robot editor and Java compiler. Robocode only -pre-requires that a JVM (Java Virtual Machine) to exist already on the -system where Robocode is going to be installed. Hence, everything a -robot developer needs to get started is provided with the main Robocode -distribution file (`robocode-xxx-setup.jar`). Robocode also supports -developing robots using external IDEs like e.g. -[Eclipse](http://www.eclipse.org/downloads/), -[IntelliJ IDEA](http://www.jetbrains.com/idea/), -[NetBeans](http://netbeans.org/), -[Visual Studio](http://msdn.microsoft.com/en-gb/vstudio/) etc., which -supports the developer much better than the robot editor in Robocode. - -The fact that Robocode runs on the Java platform makes it possible to -run it on any operating system with Java pre-installed, meaning that it -will be able to run on Windows, Linux, Mac OS, but also UNIX and -variants of UNIX. Note that Java 6 or newer must be installed on the -system before Robocode is able to run. See the [System -Requirements](#system-requirements) for more information. - -Be aware that many users of Robocode (aka Robocoders) find Robocode to -be very fun, but also very addictive. :-) - -Robocode comes free of charge and is being developed as a spare-time -project where no money is involved. The developers of Robocode are -developing on Robocode because they think it is fun, and because they -improve themselves as developers this way. - -Robocode is an Open Source project, which means that all sources are -open to everybody. In addition, Robocode is provided under the terms of -[EPL](http://www.eclipse.org/legal/epl-v10.html) (Eclipse Public -License). - -### 2. HISTORY OF ROBOCODE - -The Robocode game was originally started by **Mathew A. Nelson** as a -personal endeavor in late 2000 and became a professional one when he -brought it to IBM, in the form of an AlphaWorks download, in July 2001. - -IBM was interested in Robocode, as they saw an opportunity to promote -Robocode as a fun way to get started with learning how to program in -Java. IBM wrote lots of articles about Robocode, e.g. like -[Rock 'em, sock 'em Robocode!](http://www.ibm.com/developerworks/java/library/j-robocode/) -from AlphaWorks / developerWorks at IBM, a series of articles like -[Secrets from the Robocode masters](http://www.ibm.com/developerworks/java/library/j-robotips/), -and "Robocode Rumble / RoboLeague". - -The inspiration for creating Robocode came from -[Robot Battle](http://www.robotbattle.com/history.php), a programming -game written by Brad Schick in 1992, which should still be alive. Robot -Battle was, in turn, inspired by -[RobotWar](http://www.robotbattle.com/history.php), an Apple II+ game -from the early 1980s. - -The articles from IBM and the Robocode community behind the RoboWiki made -Robocode very popular as programming game, and for many years Robocode has been -used for education and research at schools and universities all over the world. - -In the beginning of 2005, Mathew convinced IBM to release Robocode as -**Open Source** on SourceForge. At this point, the development of Robocode had -somewhat stopped. The community around Robocode began to develop their own -versions of Robocode with bug fixes and new features, e.g. the -[OpenSourceRobocode/Contributions](http://old.robowiki.net/robowiki?OpenSourceRobocode/Contributions) -and later on the two projects, -[RobocodeNG and Robocode 2006](http://old.robowiki.net/robowiki?RobocodeNG/Archive), by **Flemming N. Larsen**. - -Eventually, Flemming took over the Robocode project at SourceForge as -administrator and developer in July 2006 to continue the original Robocode game. -The RobocodeNG project was dropped, but Robocode 2006 was merged into the -official Robocode version 1.1 containing lots of improvements. Since then, -lots of new versions of Robocode have been released with more and more features -and contributions from the community. - -In May 2007, the [RoboRumble](http://robowiki.net/wiki/RoboRumble) client got -built into Robocode. RoboRumble is widely used by the Robocode community for -creating up-to-date robot ranking lists for the 1-to-1, Melee, Team, and -Twin Dual competitions. - -Since May 2010 a **.NET plugin** is provided for Robocode using a .NET / Java -bridge, which makes it possible to develop robots for .NET beside developing -robots in Java. This part was made by **Pavel Savara**, who is a major Robocode -contributor. - -### 3. SYSTEM REQUIREMENTS - -In order to run Robocode, Java 6 Standard Edition (SE) or a newer -version of Java must be installed on your system. Both the Java Runtime -Environment (JRE) and the Java Developer Kit (JDK) can be used. Note -that the JRE does not include the standard Java compiler (javac), but -the JDK does. However, Robocode comes with a built-in compiler (ECJ). -Hence, it is sufficient running Robocode on the JRE. - -Also note that it is important that these environment variables have -been set up prior to running Robocode: - -- `JAVA_HOME` must be setup to point at the home directory for Java - (JDK or JRE). - Windows example: `JAVA_HOME=C:\Program Files\Java\jdk1.6.0_41` - UNIX, Linux, Mac OS example: `JAVA_HOME=/usr/local/jdk1.6.0_41` - -- `PATH` must include the path to the `bin` of the Java home - directory (`JAVA_HOME`) that includes `java.exe` for starting the - Java virtual Machine (JVM). - Windows example: `PATH=%PATH%;%JAVA_HOME%` - UNIX, Linux, Mac OS example: `PATH=${PATH}:${JAVA_HOME}/bin` - -You can read more details from here: - -- [System Requirements](http://robowiki.net/wiki/Robocode/System_Requirements) - -If you want to program robots in .NET or control Robocode from a .NET -application, you need to install the Robocode .NET API plug-in on top of -Robocode. The plug-in is installed by double-clicking the -`robocode.dotnet-xxx-setup.jar` the same way as Robocode itself is -installed. - -### 4. GETTING STARTED - -Most documentation about Robocode is provided thru the -[RoboWiki](http://robowiki.net), which contains the official -documentation about Robocode, but which also hosts the community around -Robocode. It is highly recommended to read the articles on the RoboWiki -for getting started with Robocode. These articles are provided from -here: - -- [Getting Started](http://robowiki.net/wiki/Robocode/Getting_Started) - -You should read about the anatomy of a robot, the game physics, scoring -etc. - -To learn more about developing robots for .NET, these articles are a -good starting point: - -- [Create a .NET robot with Visual Studio](http://robowiki.net/wiki/Robocode/.NET/Create_a_.NET_robot_with_Visual_Studio) -- [Debug a .NET robot with Visual Studio](http://robowiki.net/wiki/Robocode/.NET/Debug_a_.NET_robot_in_Visual_Studio) - -### 5. ROBOCODE API - -The Robocode API is provided as HTML pages for both the Java and .NET -platform. - -- [Java Robot API](http://robocode.sourceforge.net/docs/robocode/) -- [Java Control API](http://robocode.sourceforge.net/docs/robocode/index.html?robocode/control/package-summary.html) -- [.NET Robot API](http://robocode.sourceforge.net/docs/robocode.dotnet/Index.html) -- [.NET Control API](http://robocode.sourceforge.net/docs/robocode.dotnet.control/Index.html) - -The Robocode API actually consists of 3 different APIs. - -- **Robot API**: Within the Java package `robocode` and .NET namespace - `Robocode`. - The Robot API is used for developing robots, and is the only part of - the API that robots are allowed to access. - -- **Robot Interfaces**: Within the Java package - `robocode.robotinterfaces` and .NET namespace - `Robocode.RobotInterfaces`. - The Robot Interfaces are used for developing new robot types with a - different API that the standard Robot API. - **Note:** *The game rules and robot behaviors cannot be changed.* - -- **Control API**: Within the Java package `robocode.control` and .NET - namespace `Robocode.Control`. - The Control API is used for letting another application start up - battles with selected robots in Robocode and retrieve the results. - It is also possible to get snapshots of robots and bullets (like - position, heading, energy level etc.) at a specific time in a battle. - -### 6. ROBOCODE REPOSITORY - -If you want to try out new robots than the sample robots that come with -Robocode, you should visit the [Robocode -Repository](http://robocoderepository.com/). - -Robots are available under the -[Bots](http://robocoderepository.com/Categories.jsp) section of the -repository. - -The Robocode Repository is developed and maintained by David Lynn as a -project independently of the Robocode project. - -### 7. COMMUNITY - -The community around Robocode is using the RoboWiki as communication -channel. At the RoboWiki, people share new ideas, code snippets, -algorithms, strategies, and lots of other stuff about Robocode. New -official documentation from the developers of Robocode will be put at -the RoboWiki as well. - -On the RoboWiki, these strategies are provided: - -- [Radar](http://robowiki.net/wiki/Radar) -- [Movement](http://robowiki.net/wiki/Category:Movement) -- [Targeting](http://robowiki.net/wiki/Category:Targeting) - -The code snippets are also provided on the RoboWiki: - -- [Code Snippets](http://robowiki.net/wiki/Category:Code_Snippets) - -### 8. CHALLENGES - -A good way to improve you self as a robot developer is to try out some -real challenges. On the RoboWiki, two famous challenges exist for -testing/studying a robots movement, targeting, and gun abilities: - -- [Movement Challenge](http://robowiki.net/wiki/Movement_Challenge_(original)) -- [Targeting Challenge](http://robowiki.net/wiki/Targeting_Challenge_(original)) -- [RoboRumble Gun Challenge](hhttp://robowiki.net/wiki/RoboRumble_Gun_Challenge) - -### 9. COMPETITION - -If you want to challenge your robot(s) and yourself as robot developer, -the [RoboRumble@Home](http://robowiki.net/wiki/RoboRumble) is the best -way to do it. RoboRumble is the ultimate collaborative effort to have a -live, up-to-date ranking of Robocode bots. It uses the power of -available Robocoders' computers to distribute the effort of running -battles and building the rankings. - -RoboRumble is actually 3 different rumbles: - -- **RoboRumble** (aka 1v1): One robot versus another robot - both - picked at random. These two robots a alone on the battle field. -- **MeleeRumble**: Ten robots picked at random all battle against - each other.. -- **TeamRumble**: One team versus another team - both picked at - random. Each team consists of five or less robots. - -In order to get started with RoboRumble, you should read this page: - -- [Starting With RoboRumble](http://robowiki.net/wiki/RoboRumble/Starting_With_RoboRumble) - -Note that the RoboRumble@Home client is built into Robocode and can -be started using the batch/shell/command files: - -| | Windows | UNIX / Linux | Mac OS | -|-----------------+-------------------+------------------+-----------------------| -| **RoboRumble** | `roborumble.bat` | `roborumble.sh` | `roborumble.command` | -| **MeleeRumble** | `meleerumble.bat` | `meleerumble.sh` | `meleerumble.command` | -| **TeamRumble** | `teamrumble.bat` | `teamrumble.sh` | `teamrumble.command` | - -Two other competitions exists which are: - -- [Twin Duel](http://robowiki.net/wiki/Twin_Duel): Two teams - battle on an 800x800 field. Each team consists of two robots - (twins). -- [Hat League](http://robowiki.net/wiki/Hat_League): Two teams not - knowing each other are paired together at random (like drawing - names from a hat). Each team consists of two robots. These two - teams must work together and defeat two other teams that have also - been picked at random. - -### 10. COMMAND LINE - -It is possible to specify options and predefined properties from the -command-line when running Robocode. The usage of these can be listed by -writing this from a command prompt or shell: - - robocode -help - -For example, it is possible to: - -- disable the graphical user interface (GUI). -- disable security that is specific to Robocode (but does not - override the security that comes with the JVM). -- enable/disable the debugging mode, useful when debugging robots. -- play a battle based on an existing Robocode .battle file. -- replay a recorded battle visually. -- save the results of battles in a comma-separated file. - -You can read more details here: - -- [Console Usage](http://robowiki.net/w/index.php?title=Robocode/Console_Usage) - -### 11. LINKS - -Links relevant to Robocode are provided on the home page of Robocode: - -- [Home Page of Robocode](http://robocode.sourceforge.net/) - -Other links are provided from the RoboWiki - especially for challenges -and competitions: - -- [RoboWiki](http://robowiki.net/) - -The is also a Wikipedia page available about Robocode, which provides -good links to movement and targeting strategies, competitions, and other -sites about Robocode: - -- [Robocode on Wikipedia](http://en.wikipedia.org/wiki/Robocode) - -### 12. REPORTING DEFECTS - -If you discover a defect (bug) in Robocode you are encouraged to report -the issue as soon as you discover it - the sooner the better. - -A bug report should be reported on the [Bugs](http://http://sourceforge.net/p/robocode/bugs//p/robocode/bugs/) -page on the SourceForge site for Robocode. Each bug report will be -prioritized among other bug reports depending on its impact on the game. - -It will be a great help if you describe how to see or which steps to do -in order to reproduce the defect. You are very welcome to provide a -screen shot, source code or anything else that will show the bug. It is -also a very good idea to write which system and version of Robocode and -Java you are using. - -If you are a registered user at SourceForge (register -[here](http://sourceforge.net/account/registration/)) you will be able -to add a "monitor" on your bug report. This way you will be able to -receive notifications when someone add comments to your report, but will -also be able to better track the current status of the bug, e.g. when -the bug is fixed and with which version of Robocode the fix is -available. - -If you are a developer yourself, and have a good idea of how the bug -could be fixed, you are more than welcome to do so. By fixing the bug, -you will become a contributor of Robocode yourself. You can learn more -about how to contribute [here](#how-to-contribute). Note that we accept -bug fixes under the terms of -[EPL](http://www.eclipse.org/legal/epl-v10.html). - -### 13. FEATURE REQUESTS - -If you got an idea for a new feature or improvement for Robocode, you -are very welcome to share your idea by summiting a feature request. - -A feature request should be put on the -[Feature Requests](http://sourceforge.net/p/robocode/feature-requests/) -on the SourceForge site for Robocode. Each feature request will be -prioritized among other feature requests. - -It will be a great help if you describe your idea in detail, and how you -think it could be implemented into Robocode. For example, will it be -possible to extend an existing feature with your idea? - -If you are a registered user at SourceForge (register -[here](http://sourceforge.net/account/registration/)) you will be able -to add a "monitor" on your request. This way you will be able to receive -notifications when someone add comments to your request entry, but will -also be able to better track the current status of your entry, e.g. when -the feature has been implemented and with which version of Robocode it -will be available. - -If you are a developer yourself, and have a good idea of how the feature -could be implemented, you are more than welcome to do so if the feature -is being accepted. By implementing the feature, you will become a -contributor of Robocode yourself. You can learn more about how to -contribute [here](#how-to-contribute). Note that we accept -implementations under the terms of -[EPL](http://www.eclipse.org/legal/epl-v10.html). - -### 14. VERSIONS - -Robocode is continuously under development, and you should be aware that -three different release types exist for Robocode: - -- **Alpha** version is an unofficial "snapshot" version of Robocode - that is under development and not feature complete yet. It is - normally provided for the person that has put a bug report or - feature request on the tracker for Robocode, which needs to be - verified. Alpha versions are not meant to be redistributed at all. - -- **Beta** version is an official release that is considered feature - complete, and which intended for everybody to try out and test - regarding all new features and changes, but which is also - considered "unstable", and might contain some unwanted side-effects - due to the changes made to this version compared to the last final - version of Robocode. Defects or undesired behaviors should be - reported as soon as they are discovered so the issues can be fixed - before the final release. Everybody is encouraged to take part in - the testing Beta versions of Robocode. - -- **Final** version is (as it says) the final version of a specific - and official release of Robocode, and where new features and bug - fixes have been tested. Note, that the release will not state - "final" on the distribution files for Robocode like it is the case - for Alpha and Beta versions. - -### 15. NEWS - -News about Robocode is put on the blog spot for Robocode. Here it -is possible subscribe to a RSS feed to receive news about Robocode. - -- [Robocode News](http://robo-code.blogspot.com/) - -You can also follow Robocode on Twitter and Facebook here: - -- [Twitter for Robocode](http://twitter.com/robocode) -- [Robocode on Facebook](http://www.facebook.com/group.php?gid=129627130234) - -The RoboWiki can be followed on Twitter as well: - -- [Twitter for RoboRumble](http://twitter.com/robowiki) - -### 16. HOW TO CONTRIBUTE - -If you want to contribute to Robocode with e.g. a new feature or bug -fix, you should read the [Developers Guide for building -Robocode.](http://robowiki.net/wiki/Robocode/Developers_Guide_for_building_Robocode) - -Note that we accept code changes under the terms of -[EPL](http://www.eclipse.org/legal/epl-v10.html). - -There exist no or little documentation about the internals of Robocode, -and the code base will need to be examined by a contributor in order to -get an insight of how Robocode is implemented. Thus, it required a -skilled Java developer to figure out how Robocode is put together. - -Robocode is divided into several modules. You can read Pavel Savara's -blog to get a good overview of Robocode here: - -- [Robocode modules](http://zamboch.blogspot.com/2009/06/robocode-modules-as-in-version-17.html) - -Help for Robocode internals can be provided through the [Robocode -Developers Discussion Group](https://groups.google.com/forum/?fromgroups#!forum/robocode-developers) -where you can register yourself, and start up a new topic. This is the best -way of getting information and asking about details for the internals in -Robocode. - -If a contribution is a somewhat small change to involves under 10 files, -then the preferred way is to provide the contribution as a patch file -that can be applied to the existing Robocode sources. Otherwise, you can -be granted a Subversion branch for your work, where you can commit your -changes. Later, this branch needs to be merged into the trunk be the -administrators of Robocode and tested carefully. Additional work might -be done by other Robocode developers to finalize the work. \ No newline at end of file diff --git a/workspace_robo/robocode.content/src/main/resources/battles/intro.battle b/workspace_robo/robocode.content/src/main/resources/battles/intro.battle deleted file mode 100644 index 8bcded0..0000000 --- a/workspace_robo/robocode.content/src/main/resources/battles/intro.battle +++ /dev/null @@ -1,8 +0,0 @@ -#Battle Properties -robocode.battleField.width=800 -robocode.battleField.height=600 -robocode.battle.numRounds=1 -robocode.battle.gunCoolingRate=0.1 -robocode.battle.rules.inactivityTime=450 -robocode.battle.selectedRobots=sample.Tracker,sample.SittingDuck -robocode.battle.initialPositions=(50,50,0),(?,?,?) \ No newline at end of file diff --git a/workspace_robo/robocode.content/src/main/resources/battles/sample.battle b/workspace_robo/robocode.content/src/main/resources/battles/sample.battle deleted file mode 100644 index 2be49ab..0000000 --- a/workspace_robo/robocode.content/src/main/resources/battles/sample.battle +++ /dev/null @@ -1,8 +0,0 @@ -#Battle Properties -robocode.battleField.width=800 -robocode.battleField.height=600 -robocode.battle.numRounds=10 -robocode.battle.gunCoolingRate=0.1 -robocode.battle.rules.inactivityTime=450 -robocode.battle.hideEnemyNames=true -robocode.battle.selectedRobots=sample.Corners,sample.Fire,sample.MyFirstRobot,sample.SittingDuck,sample.Walls diff --git a/workspace_robo/robocode.content/src/main/resources/compilers/CompilerTest.java b/workspace_robo/robocode.content/src/main/resources/compilers/CompilerTest.java deleted file mode 100644 index 057737d..0000000 --- a/workspace_robo/robocode.content/src/main/resources/compilers/CompilerTest.java +++ /dev/null @@ -1,12 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -public class CompilerTest { - public static void main(String args[]) { - System.out.println("Compiler operational"); - } -} diff --git a/workspace_robo/robocode.content/src/main/resources/desktop/robocode.png b/workspace_robo/robocode.content/src/main/resources/desktop/robocode.png deleted file mode 100644 index 99b0d5b..0000000 Binary files a/workspace_robo/robocode.content/src/main/resources/desktop/robocode.png and /dev/null differ diff --git a/workspace_robo/robocode.content/src/main/resources/desktop/robocodeMeleeRumble.desktop b/workspace_robo/robocode.content/src/main/resources/desktop/robocodeMeleeRumble.desktop deleted file mode 100644 index 2b6a8cf..0000000 --- a/workspace_robo/robocode.content/src/main/resources/desktop/robocodeMeleeRumble.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Type=Application -Version=1.0 -Name=Robocode MeleeRumble -GenericName=Ranking system of Robocode bots -Comment=Run MeleeRumble battles for the LiteRumble -Icon=roborumble -Exec=robocode-MeleeRumble -Categories=Game;StrategyGame; \ No newline at end of file diff --git a/workspace_robo/robocode.content/src/main/resources/desktop/robocodeRoboRumble.desktop b/workspace_robo/robocode.content/src/main/resources/desktop/robocodeRoboRumble.desktop deleted file mode 100644 index f366fdf..0000000 --- a/workspace_robo/robocode.content/src/main/resources/desktop/robocodeRoboRumble.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Type=Application -Version=1.0 -Name=Robocode RoboRumble -GenericName=Ranking system of Robocode bots -Comment=Run RoboRumble battles for the LiteRumble -Icon=roborumble -Exec=robocode-RoboRumble -Categories=Game;StrategyGame; diff --git a/workspace_robo/robocode.content/src/main/resources/desktop/robocodeRobocode.desktop b/workspace_robo/robocode.content/src/main/resources/desktop/robocodeRobocode.desktop deleted file mode 100644 index 89c34f6..0000000 --- a/workspace_robo/robocode.content/src/main/resources/desktop/robocodeRobocode.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Type=Application -Version=1.0 -Name=Robocode -GenericName=Tank AI programming game for Java and .NET -Comment=Build the best - destroy the rest! -Icon=robocode -Exec=robocode-Robocode -Categories=Game;StrategyGame; diff --git a/workspace_robo/robocode.content/src/main/resources/desktop/robocodeTeamRumble.desktop b/workspace_robo/robocode.content/src/main/resources/desktop/robocodeTeamRumble.desktop deleted file mode 100644 index d0f1e25..0000000 --- a/workspace_robo/robocode.content/src/main/resources/desktop/robocodeTeamRumble.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Type=Application -Version=1.0 -Name=Robocode TeamRumble -GenericName=Ranking system of Robocode bots -Comment=Run TeamRumble battles for the LiteRumble -Icon=roborumble -Exec=robocode-TeamRumble -Categories=Game;StrategyGame; \ No newline at end of file diff --git a/workspace_robo/robocode.content/src/main/resources/desktop/robocodeTwinDuel.desktop b/workspace_robo/robocode.content/src/main/resources/desktop/robocodeTwinDuel.desktop deleted file mode 100644 index 564090b..0000000 --- a/workspace_robo/robocode.content/src/main/resources/desktop/robocodeTwinDuel.desktop +++ /dev/null @@ -1,9 +0,0 @@ -[Desktop Entry] -Type=Application -Version=1.0 -Name=Robocode TwinDuel -GenericName=Ranking system of Robocode bots -Comment=Run TwinDuel battles for the LiteRumble -Icon=roborumble -Exec=robocode-TwinDuel -Categories=Game;StrategyGame; \ No newline at end of file diff --git a/workspace_robo/robocode.content/src/main/resources/desktop/roborumble.png b/workspace_robo/robocode.content/src/main/resources/desktop/roborumble.png deleted file mode 100644 index f1560d1..0000000 Binary files a/workspace_robo/robocode.content/src/main/resources/desktop/roborumble.png and /dev/null differ diff --git a/workspace_robo/robocode.content/src/main/resources/license/epl-v10.html b/workspace_robo/robocode.content/src/main/resources/license/epl-v10.html deleted file mode 100644 index 16e1c6c..0000000 --- a/workspace_robo/robocode.content/src/main/resources/license/epl-v10.html +++ /dev/null @@ -1,188 +0,0 @@ - - -Eclipse Public License - Version 1.0 - - - - - -

Eclipse Public License - v 1.0

-

THE ACCOMPANYING PROGRAM IS PROVIDED UNDER THE TERMS OF THIS ECLIPSE PUBLIC -LICENSE ("AGREEMENT"). ANY USE, REPRODUCTION OR DISTRIBUTION OF THE PROGRAM -CONSTITUTES RECIPIENT'S ACCEPTANCE OF THIS AGREEMENT.

-

1. DEFINITIONS

-

"Contribution" means:

-

a) in the case of the initial Contributor, the initial code and -documentation distributed under this Agreement, and

-

b) in the case of each subsequent Contributor:

-

i) changes to the Program, and

-

ii) additions to the Program;

-

where such changes and/or additions to the Program originate from -and are distributed by that particular Contributor. A Contribution 'originates' -from a Contributor if it was added to the Program by such Contributor itself or -anyone acting on such Contributor's behalf. Contributions do not include -additions to the Program which: (i) are separate modules of software distributed -in conjunction with the Program under their own license agreement, and (ii) are -not derivative works of the Program.

-

"Contributor" means any person or entity that distributes the Program.

-

"Licensed Patents" mean patent claims licensable by a Contributor which are -necessarily infringed by the use or sale of its Contribution alone or when -combined with the Program.

-

"Program" means the Contributions distributed in accordance with this -Agreement.

-

"Recipient" means anyone who receives the Program under this Agreement, -including all Contributors.

-

2. GRANT OF RIGHTS

-

a) Subject to the terms of this Agreement, each Contributor hereby -grants Recipient a non-exclusive, worldwide, royalty-free copyright license to -reproduce, prepare derivative works of, publicly display, publicly perform, -distribute and sublicense the Contribution of such Contributor, if any, and such -derivative works, in source code and object code form.

-

b) Subject to the terms of this Agreement, each Contributor hereby -grants Recipient a non-exclusive, worldwide, royalty-free patent license under -Licensed Patents to make, use, sell, offer to sell, import and otherwise -transfer the Contribution of such Contributor, if any, in source code and object -code form. This patent license shall apply to the combination of the -Contribution and the Program if, at the time the Contribution is added by the -Contributor, such addition of the Contribution causes such combination to be -covered by the Licensed Patents. The patent license shall not apply to any other -combinations which include the Contribution. No hardware per se is licensed -hereunder.

-

c) Recipient understands that although each Contributor grants the -licenses to its Contributions set forth herein, no assurances are provided by -any Contributor that the Program does not infringe the patent or other -intellectual property rights of any other entity. Each Contributor disclaims any -liability to Recipient for claims brought by any other entity based on -infringement of intellectual property rights or otherwise. As a condition to -exercising the rights and licenses granted hereunder, each Recipient hereby -assumes sole responsibility to secure any other intellectual property rights -needed, if any. For example, if a third party patent license is required to -allow Recipient to distribute the Program, it is Recipient's responsibility to -acquire that license before distributing the Program.

-

d) Each Contributor represents that to its knowledge it has -sufficient copyright rights in its Contribution, if any, to grant the copyright -license set forth in this Agreement.

-

3. REQUIREMENTS

-

A Contributor may choose to distribute the Program in object code form under -its own license agreement, provided that:

-

a) it complies with the terms and conditions of this Agreement; -and

-

b) its license agreement:

-

i) effectively disclaims on behalf of all Contributors all -warranties and conditions, express and implied, including warranties or -conditions of title and non-infringement, and implied warranties or conditions -of merchantability and fitness for a particular purpose;

-

ii) effectively excludes on behalf of all Contributors all -liability for damages, including direct, indirect, special, incidental and -consequential damages, such as lost profits;

-

iii) states that any provisions which differ from this Agreement -are offered by that Contributor alone and not by any other party; and

-

iv) states that source code for the Program is available from such -Contributor, and informs licensees how to obtain it in a reasonable manner on or -through a medium customarily used for software exchange.

-

When the Program is made available in source code form:

-

a) it must be made available under this Agreement; and

-

b) a copy of this Agreement must be included with each copy of the -Program.

-

Contributors may not remove or alter any copyright notices contained within -the Program.

-

Each Contributor must identify itself as the originator of its Contribution, -if any, in a manner that reasonably allows subsequent Recipients to identify the -originator of the Contribution.

-

4. COMMERCIAL DISTRIBUTION

-

Commercial distributors of software may accept certain responsibilities with -respect to end users, business partners and the like. While this license is -intended to facilitate the commercial use of the Program, the Contributor who -includes the Program in a commercial product offering should do so in a manner -which does not create potential liability for other Contributors. Therefore, if -a Contributor includes the Program in a commercial product offering, such -Contributor ("Commercial Contributor") hereby agrees to defend and indemnify -every other Contributor ("Indemnified Contributor") against any losses, damages -and costs (collectively "Losses") arising from claims, lawsuits and other legal -actions brought by a third party against the Indemnified Contributor to the -extent caused by the acts or omissions of such Commercial Contributor in -connection with its distribution of the Program in a commercial product -offering. The obligations in this section do not apply to any claims or Losses -relating to any actual or alleged intellectual property infringement. In order -to qualify, an Indemnified Contributor must: a) promptly notify the Commercial -Contributor in writing of such claim, and b) allow the Commercial Contributor to -control, and cooperate with the Commercial Contributor in, the defense and any -related settlement negotiations. The Indemnified Contributor may participate in -any such claim at its own expense.

-

For example, a Contributor might include the Program in a commercial product -offering, Product X. That Contributor is then a Commercial Contributor. If that -Commercial Contributor then makes performance claims, or offers warranties -related to Product X, those performance claims and warranties are such -Commercial Contributor's responsibility alone. Under this section, the -Commercial Contributor would have to defend claims against the other -Contributors related to those performance claims and warranties, and if a court -requires any other Contributor to pay any damages as a result, the Commercial -Contributor must pay those damages.

-

5. NO WARRANTY

-

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, THE PROGRAM IS PROVIDED ON -AN "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, EITHER EXPRESS -OR IMPLIED INCLUDING, WITHOUT LIMITATION, ANY WARRANTIES OR CONDITIONS OF TITLE, -NON-INFRINGEMENT, MERCHANTABILITY OR FITNESS FOR A PARTICULAR PURPOSE. Each -Recipient is solely responsible for determining the appropriateness of using and -distributing the Program and assumes all risks associated with its exercise of -rights under this Agreement , including but not limited to the risks and costs -of program errors, compliance with applicable laws, damage to or loss of data, -programs or equipment, and unavailability or interruption of operations.

-

6. DISCLAIMER OF LIABILITY

-

EXCEPT AS EXPRESSLY SET FORTH IN THIS AGREEMENT, NEITHER RECIPIENT NOR ANY -CONTRIBUTORS SHALL HAVE ANY LIABILITY FOR ANY DIRECT, INDIRECT, INCIDENTAL, -SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING WITHOUT LIMITATION LOST -PROFITS), HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, -STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY -OUT OF THE USE OR DISTRIBUTION OF THE PROGRAM OR THE EXERCISE OF ANY RIGHTS -GRANTED HEREUNDER, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.

-

7. GENERAL

-

If any provision of this Agreement is invalid or unenforceable under -applicable law, it shall not affect the validity or enforceability of the -remainder of the terms of this Agreement, and without further action by the -parties hereto, such provision shall be reformed to the minimum extent necessary -to make such provision valid and enforceable.

-

If Recipient institutes patent litigation against any entity (including a -cross-claim or counterclaim in a lawsuit) alleging that the Program itself -(excluding combinations of the Program with other software or hardware) -infringes such Recipient's patent(s), then such Recipient's rights granted under -Section 2(b) shall terminate as of the date such litigation is filed.

-

All Recipient's rights under this Agreement shall terminate if it fails to -comply with any of the material terms or conditions of this Agreement and does -not cure such failure in a reasonable period of time after becoming aware of -such noncompliance. If all Recipient's rights under this Agreement terminate, -Recipient agrees to cease use and distribution of the Program as soon as -reasonably practicable. However, Recipient's obligations under this Agreement -and any licenses granted by Recipient relating to the Program shall continue and -survive.

-

Everyone is permitted to copy and distribute copies of this Agreement, but in -order to avoid inconsistency the Agreement is copyrighted and may only be -modified in the following manner. The Agreement Steward reserves the right to -publish new versions (including revisions) of this Agreement from time to time. -No one other than the Agreement Steward has the right to modify this Agreement. -The Eclipse Foundation is the initial Agreement Steward. The Eclipse Foundation -may assign the responsibility to serve as the Agreement Steward to a suitable -separate entity. Each new version of the Agreement will be given a -distinguishing version number. The Program (including Contributions) may always -be distributed subject to the version of the Agreement under which it was -received. In addition, after a new version of the Agreement is published, -Contributor may elect to distribute the Program (including its Contributions) -under the new version. Except as expressly stated in Sections 2(a) and 2(b) -above, Recipient receives no rights or licenses to the intellectual property of -any Contributor under this Agreement, whether expressly, by implication, -estoppel or otherwise. All rights in the Program not expressly granted under -this Agreement are reserved.

-

This Agreement is governed by the laws of the State of New York and the -intellectual property laws of the United States of America. No party to this -Agreement will bring a legal action under this Agreement more than one year -after the cause of action arose. Each party waives its rights to a jury trial in -any resulting litigation.

diff --git a/workspace_robo/robocode.content/src/main/resources/meleerumble.bat b/workspace_robo/robocode.content/src/main/resources/meleerumble.bat deleted file mode 100644 index 49fef2c..0000000 --- a/workspace_robo/robocode.content/src/main/resources/meleerumble.bat +++ /dev/null @@ -1,9 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -java -Xmx1024M -cp libs/robocode.jar;libs/roborumble.jar;libs/codesize-1.1.jar roborumble.RoboRumbleAtHome ./roborumble/meleerumble.txt \ No newline at end of file diff --git a/workspace_robo/robocode.content/src/main/resources/meleerumble.command b/workspace_robo/robocode.content/src/main/resources/meleerumble.command deleted file mode 100644 index f5ac342..0000000 --- a/workspace_robo/robocode.content/src/main/resources/meleerumble.command +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -################################################################################ -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -################################################################################ - -pwd=`pwd` -cd "${0%/*}" -java -Xdock:icon=roborumble.ico -Xdock:name=MeleeRumble -Xmx1024M -cp libs/robocode.jar:libs/roborumble.jar:libs/codesize-1.1.jar roborumble.RoboRumbleAtHome ./roborumble/meleerumble.txt -cd "${pwd}" diff --git a/workspace_robo/robocode.content/src/main/resources/meleerumble.sh b/workspace_robo/robocode.content/src/main/resources/meleerumble.sh deleted file mode 100644 index e6714a1..0000000 --- a/workspace_robo/robocode.content/src/main/resources/meleerumble.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - -pwd=`pwd` -cd "${0%/*}" -java -Xmx1024M -cp libs/robocode.jar:libs/roborumble.jar:libs/codesize-1.1.jar roborumble.RoboRumbleAtHome ./roborumble/meleerumble.txt -cd "${pwd}" diff --git a/workspace_robo/robocode.content/src/main/resources/robocode.bat b/workspace_robo/robocode.content/src/main/resources/robocode.bat deleted file mode 100644 index cdb3c2a..0000000 --- a/workspace_robo/robocode.content/src/main/resources/robocode.bat +++ /dev/null @@ -1,9 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -java -Xmx512M -cp libs/robocode.jar robocode.Robocode %* \ No newline at end of file diff --git a/workspace_robo/robocode.content/src/main/resources/robocode.command b/workspace_robo/robocode.content/src/main/resources/robocode.command deleted file mode 100644 index 3065355..0000000 --- a/workspace_robo/robocode.content/src/main/resources/robocode.command +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -################################################################################ -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -################################################################################ - -pwd=`pwd` -cd "${0%/*}" -java -Xdock:icon=robocode.ico -Xdock:name=Robocode -Xmx512M -cp libs/robocode.jar robocode.Robocode $* -cd "${pwd}" diff --git a/workspace_robo/robocode.content/src/main/resources/robocode.ico b/workspace_robo/robocode.content/src/main/resources/robocode.ico deleted file mode 100644 index 8c469e6..0000000 Binary files a/workspace_robo/robocode.content/src/main/resources/robocode.ico and /dev/null differ diff --git a/workspace_robo/robocode.content/src/main/resources/robocode.sh b/workspace_robo/robocode.content/src/main/resources/robocode.sh deleted file mode 100644 index 81ca7de..0000000 --- a/workspace_robo/robocode.content/src/main/resources/robocode.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - -pwd=`pwd` -cd "${0%/*}" -java -Xmx512M -cp libs/robocode.jar robocode.Robocode $* -cd "${pwd}" diff --git a/workspace_robo/robocode.content/src/main/resources/roborumble.bat b/workspace_robo/robocode.content/src/main/resources/roborumble.bat deleted file mode 100644 index e056ed9..0000000 --- a/workspace_robo/robocode.content/src/main/resources/roborumble.bat +++ /dev/null @@ -1,9 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -java -Xmx512M -cp libs/robocode.jar;libs/roborumble.jar;libs/codesize-1.1.jar; roborumble.RoboRumbleAtHome ./roborumble/roborumble.txt \ No newline at end of file diff --git a/workspace_robo/robocode.content/src/main/resources/roborumble.command b/workspace_robo/robocode.content/src/main/resources/roborumble.command deleted file mode 100644 index 27f9f4b..0000000 --- a/workspace_robo/robocode.content/src/main/resources/roborumble.command +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -################################################################################ -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -################################################################################ - -pwd=`pwd` -cd "${0%/*}" -java -Xdock:icon=roborumble.ico -Xdock:name=RoboRumble -Xmx512M -cp libs/robocode.jar:libs/roborumble.jar:libs/codesize-1.1.jar roborumble.RoboRumbleAtHome ./roborumble/roborumble.txt -cd "${pwd}" diff --git a/workspace_robo/robocode.content/src/main/resources/roborumble.ico b/workspace_robo/robocode.content/src/main/resources/roborumble.ico deleted file mode 100644 index 927ba6e..0000000 Binary files a/workspace_robo/robocode.content/src/main/resources/roborumble.ico and /dev/null differ diff --git a/workspace_robo/robocode.content/src/main/resources/roborumble.sh b/workspace_robo/robocode.content/src/main/resources/roborumble.sh deleted file mode 100644 index b0a4050..0000000 --- a/workspace_robo/robocode.content/src/main/resources/roborumble.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - -pwd=`pwd` -cd "${0%/*}" -java -Xmx512M -cp libs/robocode.jar:libs/roborumble.jar:libs/codesize-1.1.jar roborumble.RoboRumbleAtHome ./roborumble/roborumble.txt -cd "${pwd}" diff --git a/workspace_robo/robocode.content/src/main/resources/roborumble/meleerumble.txt b/workspace_robo/robocode.content/src/main/resources/roborumble/meleerumble.txt deleted file mode 100644 index 969673d..0000000 --- a/workspace_robo/robocode.content/src/main/resources/roborumble/meleerumble.txt +++ /dev/null @@ -1,244 +0,0 @@ -#=============================================================================== -# meleerumble.txt - Configuration file for MeleeRumble (melee battles) -#=============================================================================== - -#------------------------------------------------------------------------------- -# User property. It's highly recommendable that you change this to use your name -#------------------------------------------------------------------------------- - -# USER The user name used when uploading the results to the RoboRumble -# server. Hence, you should replace 'Put_Your_Name_Here' with your -# name, which could be the initials you use for your robot(s). - -USER=Put_Your_Name_Here - -#------------------------------------------------------------------------------- -# Exclude filter used for excluding participants. Use with care! -#------------------------------------------------------------------------------- - -# EXCLUDE A comma separated list of all the participants you want to exclude -# from the competition. Excluded participants will not be downloaded -# or take part in battles. This way you can exclude participants that -# cannot be downloaded due to web servers that are down or hanging, -# the repository is down, robots/teams that crashes for some reason or -# cause other trouble. -# -# You can use the filename wildcards * and ? in the filter. Example: -# -# EXCLUDE=xyz.*v1.?, *Nano* - -EXCLUDE= - -#------------------------------------------------------------------------------- -# Properties for controlling the rumble. Use YES or NOT -#------------------------------------------------------------------------------- - -# DOWNLOAD Download data like participants, missing robots, rating files etc. -# from Internet if these have not been downloaded for 2 hours. -# -# EXECUTE Execute battles. Battles files are first created and old battles -# files are deleted before the battles are executed. -# -# UPLOAD Upload results to the RoboRumble server specified by the RESULTSURL -# property. -# -# ITERATE If set to NOT, the rumble will only execute battles once. -# If set to YES, the rumble will restart with new battles every time -# the battles have been executed, and it will run infinitely until -# terminated. - -DOWNLOAD=YES -EXECUTE=YES -UPLOAD=YES -ITERATE=YES - -# MELEE Must be set if this rumble is meant for melee battles. -# -# TEAMS Must be set if this rumble is meant for team battles. -# This flag is necessary, as jar files for robot teams are different -# from jar files for ordinary robots. - -# MELEE=YES as this property file is meant for melee battles. -# TEAM=NOT, as this property file is not meant for team battles. - -# Do not modify these properties! - -MELEE=YES -TEAMS=NOT - -#------------------------------------------------------------------------------ -# Properties for the battle engine -#------------------------------------------------------------------------------ - -# FIELDL Battlefield width measured in pixels. -# FIELDH Battlefield height measured in pixels. -# -# NUMBATTLES Number of battles performed per rumble. -# ROUNDS Number of rounds per battle. -# -# MELEEBOTS Number of robots that participate in a melee battle. - -# These are standard values for the MeleeRumble. Do not modify these properties! - -FIELDL=1000 -FIELDH=1000 -NUMBATTLES=3 -ROUNDS=35 -MELEEBOTS=10 - -# INPUT Input battles file that is generated by the rumble automatically. -# The rumble uses this file for selecting which robots that must -# battle against each other. -# -# OUTPUT Battle results file, which is the output of running the rumble. - -INPUT=./roborumble/temp/battlesmelee.txt -OUTPUT=./roborumble/files/resultsmelee.txt - -#------------------------------------------------------------------------------- -# Properties for retrieving robots from Internet -#------------------------------------------------------------------------------- - -# BOTSREP The robot repository where downloaded robots are put. -# -# TEMP Directory containing all temporary files for RoboRumble. - -BOTSREP=./robots/ -TEMP=./roborumble/temp/ - -#------------------------------------------------------------------------------- -# Properties for updating participants from Internet -#------------------------------------------------------------------------------- - -# PARTICIPANTSURL -# URL to the web page containing all participants of the competition, -# which will be used for updating the participants file specified with -# the PARTICIPANTSFILE property. -# -# PARTICIPANTSFILE -# File containing all the participants for the competition. -# -# STARTAG Tag marking the start and end of the participants on the web page -# pointed to with the PARTICIPANTSURL property. -# -# UPDATEBOTSURL -# URL used for removing old participants, which is used for updating -# the participants file specified with the PARTICIPANTSFILE property. - -PARTICIPANTSURL=http://robowiki.net/wiki/RoboRumble/Participants/Melee&action=raw -PARTICIPANTSFILE=./roborumble/files/participmelee.txt - -STARTAG=pre - -UPDATEBOTSURL=http://literumble.appspot.com/RemoveOldParticipant - -#------------------------------------------------------------------------------- -# Properties to control the way battles are run -#------------------------------------------------------------------------------- - -# RUNONLY If left black or set to GENERAL, a new battle file is created where -# robots from the participants file are paired at random. The number -# of robot pairs will match number of battles defined the NUMBATTLES -# property. -# -# If set to MINI, a new battle file is created similar to the one -# for GENERAL, but it will only contains robots that are MiniBots, -# which has a code size < 1500 bytes (calculated by the codesize tool). -# -# If set to MICRO, a new battle file is created similar to the one -# for GENERAL, but it will only contains robots that are MicroBots, -# which has a code size < 750 bytes (calculated by the codesize tool). -# -# If set to NANO, a new battle file is created similar to the one for -# GENERAL, but it will only contains robots that are NanoBots, which -# has a code size < 250 bytes (calculated by the codesize tool). -# -# If set to SERVER (recommended), a new battle file is created which -# will first of all contain priority battles for robots that that has -# priority over other robots until they have fought a specific number -# of battles specified by the BATTLESPERBOT property. The number of -# battles fought by the individual robots are extracted from the -# rating files, which are downloaded from the server if the DOWNLOAD -# property is set to YES. When no more priority battles are left, -# robots from the participants file are paired at random similar to -# GENERAL. -# -# BATTLESPERBOT -# The number of battles a robot has to fight before it will no longer -# have priority over other robots in battles. Prioritizing a robot -# makes its rating more reliable faster as its number of fought -# battles increases faster than when it is not prioritized. -# -# PRIORITYBATTLESFILE -# The priority battles file that is generated automatically by the -# rumble when the RUNONLY property is set to SERVER. - -RUNONLY=SERVER - -BATTLESPERBOT=2000 - -PRIORITYBATTLESFILE=./roborumble/temp/prioritymelee.txt - -#------------------------------------------------------------------------------- -# Properties for uploading the results to the server -#------------------------------------------------------------------------------- - -# RESULTSURL -# URL used for uploading the results to the server. -# -# BATTLESNUMFILE -# File containing the number of battles fought by the robots, which is -# returned by the server when results are uploaded to the server. - -RESULTSURL=http://literumble.appspot.com/UploadedResults - -BATTLESNUMFILE=./roborumble/temp/meleebattlesnumber.txt - -#------------------------------------------------------------------------------- -# Properties for related competitions -#------------------------------------------------------------------------------- - -# Related competitions are competitions where participants are a subset of the -# participants in the general competition. -# -# The MiniBots (code size < 1500) are participants of the MiniRumble. -# The MicroBots (code size < 750) are participants of the MicroRumble. -# The NanoBots (code size < 250) are participants of the NanoRumble. - -# Do not modify these properties! - -MINIBOTS=minimeleerumble -MICROBOTS=micromeleerumble -NANOBOTS=nanomeleerumble - -# CODESIZEFILE: -# The code size file that is generated automatically by the rumble in -# order determine the code size of each individual robot. - -CODESIZEFILE=./roborumble/files/codesizemelee.txt - -#------------------------------------------------------------------------------- -# Properties for URLs and file names for the rating files to download -#------------------------------------------------------------------------------- - -# RATINGS.URL: -# URL to where ratings files are located on Internet. -# -# RATINGS.GENERAL: -# File name for the rating file of the general MeleeRumble. -# -# RATINGS.MINIBOTS: -# File name for the rating file of the Melee MiniRumble. -# -# RATINGS.MICROBOTS: -# File name for the rating file of the Melee MicroRumble. -# -# RATINGS.NANOBOTS: -# File name for the rating file of the Melee NanoRumble. - -RATINGS.URL=http://literumble.appspot.com/RatingsFile - -RATINGS.GENERAL=./roborumble/temp/ratings_m_roborumble.txt -RATINGS.MINIBOTS=./roborumble/temp/ratings_m_minirumble.txt -RATINGS.MICROBOTS=./roborumble/temp/ratings_m_microrumble.txt -RATINGS.NANOBOTS=./roborumble/temp/ratings_m_nanorumble.txt diff --git a/workspace_robo/robocode.content/src/main/resources/roborumble/roborumble.properties b/workspace_robo/robocode.content/src/main/resources/roborumble/roborumble.properties deleted file mode 100644 index 1df0dea..0000000 --- a/workspace_robo/robocode.content/src/main/resources/roborumble/roborumble.properties +++ /dev/null @@ -1,6 +0,0 @@ -# Connection timeout in milliseconds -connection.open.timeout=10000 -# Connection read timeout in milliseconds -connection.read.timeout=10000 -# Download session timeout -download.session.timeout=10000 diff --git a/workspace_robo/robocode.content/src/main/resources/roborumble/roborumble.txt b/workspace_robo/robocode.content/src/main/resources/roborumble/roborumble.txt deleted file mode 100644 index ae45516..0000000 --- a/workspace_robo/robocode.content/src/main/resources/roborumble/roborumble.txt +++ /dev/null @@ -1,241 +0,0 @@ -#=============================================================================== -# roborumble.txt - Configuration file for RoboRumble (1v1 battles) -#=============================================================================== - -#------------------------------------------------------------------------------- -# Username. It's highly recommendable that you change this to use your name -#------------------------------------------------------------------------------- - -# USER The username used when uploading the results to the RoboRumble -# server. Hence, you should replace 'Put_Your_Name_Here' with your -# name, which could be the initials you use for your robot(s). - -USER=Put_Your_Name_Here - -#------------------------------------------------------------------------------- -# Exclude filter used for excluding participants. Use with care! -#------------------------------------------------------------------------------- - -# EXCLUDE A comma separated list of all the participants you want to exclude -# from the competition. Excluded participants will not be downloaded -# or take part in battles. This way you can exclude participants that -# cannot be downloaded due to web servers that are down or hanging, -# the repository is down, robots/teams that crashes for some reason or -# cause other trouble. -# -# You can use the filename wildcards * and ? in the filter. Example: -# -# EXCLUDE=xyz.*v1.?, *Nano* - -EXCLUDE= - -#------------------------------------------------------------------------------- -# Properties for controlling the rumble. Use YES or NOT -#------------------------------------------------------------------------------- - -# DOWNLOAD Download data like participants, missing robots, rating files etc. -# from Internet if these have not been downloaded for 2 hours. -# -# EXECUTE Execute battles. Battles files are first created and old battles -# files are deleted before the battles are executed. -# -# UPLOAD Upload results to the RoboRumble server specified by the RESULTSURL -# property. -# -# ITERATE If set to NOT, the rumble will only execute battles once. -# If set to YES, the rumble will restart with new battles every time -# the battles have been executed, and it will run infinitely until -# terminated. - -DOWNLOAD=YES -EXECUTE=YES -UPLOAD=YES -ITERATE=YES - -# MELEE Must be set if this rumble is meant for melee battles. -# -# TEAMS Must be set if this rumble is meant for team battles. -# This flag is necessary, as jar files for robot teams are different -# from jar files for ordinary robots. - -# MELEE=NOT as this property file is not meant for melee battles. -# TEAM=NOT, as this property file is not meant for team battles. - -# Do not modify these properties! - -MELEE=NOT -TEAMS=NOT - -#------------------------------------------------------------------------------ -# Properties for the battle engine -#------------------------------------------------------------------------------ - -# FIELDL Battlefield width measured in pixels. -# FIELDH Battlefield height measured in pixels. -# -# NUMBATTLES Number of battles performed per rumble. -# ROUNDS Number of rounds per battle. - -# These are standard values for the RoboRumble. Do not modify these properties! - -FIELDL=800 -FIELDH=600 -NUMBATTLES=50 -ROUNDS=35 - -# INPUT Input battles file that is generated by the rumble automatically. -# The rumble uses this file for selecting which robots that must -# battle against each other. -# -# OUTPUT Battle results file, which is the output of running the rumble. - -INPUT=./roborumble/temp/battles1v1.txt -OUTPUT=./roborumble/files/results1v1.txt - -#------------------------------------------------------------------------------- -# Properties for retrieving robots from Internet -#------------------------------------------------------------------------------- - -# BOTSREP The robot repository where downloaded robots are put. -# -# TEMP Directory containing all temporary files for RoboRumble. - -BOTSREP=./robots/ -TEMP=./roborumble/temp/ - -#------------------------------------------------------------------------------- -# Properties for updating participants from Internet -#------------------------------------------------------------------------------- - -# PARTICIPANTSURL -# URL to the web page containing all participants of the competition, -# which will be used for updating the participants file specified with -# the PARTICIPANTSFILE property. -# -# PARTICIPANTSFILE -# File containing all the participants for the competition. -# -# STARTAG Tag marking the start and end of the participants on the web page -# pointed to with the PARTICIPANTSURL property. -# -# UPDATEBOTSURL -# URL used for removing old participants, which is used for updating -# the participants file specified with the PARTICIPANTSFILE property. - -PARTICIPANTSURL=http://robowiki.net/wiki/RoboRumble/Participants?action=raw -PARTICIPANTSFILE=./roborumble/files/particip1v1.txt - -STARTAG=pre - -UPDATEBOTSURL=http://literumble.appspot.com/RemoveOldParticipant - -#------------------------------------------------------------------------------- -# Properties to control the way battles are run -#------------------------------------------------------------------------------- - -# RUNONLY If left black or set to GENERAL, a new battle file is created where -# robots from the participants file are paired at random. The number -# of robot pairs will match number of battles defined the NUMBATTLES -# property. -# -# If set to MINI, a new battle file is created similar to the one -# for GENERAL, but it will only contains robots that are MiniBots, -# which has a code size < 1500 bytes (calculated by the codesize tool). -# -# If set to MICRO, a new battle file is created similar to the one -# for GENERAL, but it will only contains robots that are MicroBots, -# which has a code size < 750 bytes (calculated by the codesize tool). -# -# If set to NANO, a new battle file is created similar to the one for -# GENERAL, but it will only contains robots that are NanoBots, which -# has a code size < 250 bytes (calculated by the codesize tool). -# -# If set to SERVER (recommended), a new battle file is created which -# will first of all contain priority battles for robots that that has -# priority over other robots until they have fought a specific number -# of battles specified by the BATTLESPERBOT property. The number of -# battles fought by the individual robots are extracted from the -# rating files, which are downloaded from the server if the DOWNLOAD -# property is set to YES. When no more priority battles are left, -# robots from the participants file are paired at random similar to -# GENERAL. -# -# BATTLESPERBOT -# The number of battles a robot has to fight before it will no longer -# have priority over other robots in battles. Prioritizing a robot -# makes its rating more reliable faster as its number of fought -# battles increases faster than when it is not prioritized. -# -# PRIORITYBATTLESFILE -# The priority battles file that is generated automatically by the -# rumble when the RUNONLY property is set to SERVER. - -RUNONLY=SERVER - -BATTLESPERBOT=2000 - -PRIORITYBATTLESFILE=./roborumble/temp/priority1v1.txt - -#------------------------------------------------------------------------------- -# Properties for uploading the results to the server -#------------------------------------------------------------------------------- - -# RESULTSURL -# URL used for uploading the results to the server. -# -# BATTLESNUMFILE -# File containing the number of battles fought by the robots, which is -# returned by the server when results are uploaded to the server. - -RESULTSURL=http://literumble.appspot.com/UploadedResults - -BATTLESNUMFILE=./roborumble/temp/battlesnumber.txt - -#------------------------------------------------------------------------------- -# Properties for related competitions -#------------------------------------------------------------------------------- - -# Related competitions are competitions where participants are a subset of the -# participants in the general competition. -# -# The MiniBots (code size < 1500) are participants of the MiniRumble. -# The MicroBots (code size < 750) are participants of the MicroRumble. -# The NanoBots (code size < 250) are participants of the NanoRumble. - -# Do not modify these properties! - -MINIBOTS=minirumble -MICROBOTS=microrumble -NANOBOTS=nanorumble - -# CODESIZEFILE: -# The code size file that is generated automatically by the rumble in -# order determine the code size of each individual robot. - -CODESIZEFILE=./roborumble/files/codesize1v1.txt - -#------------------------------------------------------------------------------- -# Properties for URLs and file names for the rating files to download -#------------------------------------------------------------------------------- - -# RATINGS.URL: -# URL to where ratings files are located on Internet. -# -# RATINGS.GENERAL: -# File name for the rating file of the general RoboRumble. -# -# RATINGS.MINIBOTS: -# File name for the rating file of the MiniRumble. -# -# RATINGS.MICROBOTS: -# File name for the rating file of the MicroRumble. -# -# RATINGS.NANOBOTS: -# File name for the rating file of the NanoRumble. - -RATINGS.URL=http://literumble.appspot.com/RatingsFile - -RATINGS.GENERAL=./roborumble/temp/ratings_roborumble.txt -RATINGS.MINIBOTS=./roborumble/temp/ratings_minirumble.txt -RATINGS.MICROBOTS=./roborumble/temp/ratings_microrumble.txt -RATINGS.NANOBOTS=./roborumble/temp/ratings_nanorumble.txt diff --git a/workspace_robo/robocode.content/src/main/resources/roborumble/teamrumble.txt b/workspace_robo/robocode.content/src/main/resources/roborumble/teamrumble.txt deleted file mode 100644 index cf6262f..0000000 --- a/workspace_robo/robocode.content/src/main/resources/roborumble/teamrumble.txt +++ /dev/null @@ -1,203 +0,0 @@ -#=============================================================================== -# teamrumble.txt - Configuration file for TeamRumble (team battles) -#=============================================================================== - -#------------------------------------------------------------------------------- -# User property. It's highly recommendable that you change this to use your name -#------------------------------------------------------------------------------- - -# USER The user name used when uploading the results to the RoboRumble -# server. Hence, you should replace 'Put_Your_Name_Here' with your -# name, which could be the initials you use for your robot(s). - -USER=Put_Your_Name_Here - -#------------------------------------------------------------------------------- -# Exclude filter used for excluding participants. Use with care! -#------------------------------------------------------------------------------- - -# EXCLUDE A comma separated list of all the participants you want to exclude -# from the competition. Excluded participants will not be downloaded -# or take part in battles. This way you can exclude participants that -# cannot be downloaded due to web servers that are down or hanging, -# the repository is down, robots/teams that crashes for some reason or -# cause other trouble. -# -# You can use the filename wildcards * and ? in the filter. Example: -# -# EXCLUDE=xyz.*v1.?, *Nano* - -EXCLUDE= - -#------------------------------------------------------------------------------- -# Properties for controlling the rumble. Use YES or NOT -#------------------------------------------------------------------------------- - -# DOWNLOAD Download data like participants, missing robots, rating files etc. -# from Internet if these have not been downloaded for 2 hours. -# -# EXECUTE Execute battles. Battles files are first created and old battles -# files are deleted before the battles are executed. -# -# UPLOAD Upload results to the RoboRumble server specified by the RESULTSURL -# property. -# -# ITERATE If set to NOT, the rumble will only execute battles once. -# If set to YES, the rumble will restart with new battles every time -# the battles have been executed, and it will run infinitely until -# terminated. - -DOWNLOAD=YES -EXECUTE=YES -UPLOAD=YES -ITERATE=YES - -# MELEE Must be set if this rumble is meant for melee battles. -# -# TEAMS Must be set if this rumble is meant for team battles. -# This flag is necessary, as jar files for robot teams are different -# from jar files for ordinary robots. - -# MELEE=NOT as this property file is not meant for melee battles. -# TEAM=YES, as this property file is meant for team battles. - -# Do not modify these properties! - -MELEE=NOT -TEAMS=YES - -#------------------------------------------------------------------------------ -# Properties for the battle engine -#------------------------------------------------------------------------------ - -# FIELDL Battlefield width measured in pixels. -# FIELDH Battlefield height measured in pixels. -# -# NUMBATTLES Number of battles performed per rumble. -# ROUNDS Number of rounds per battle. - -# These are standard values for the TeamRumble. Do not modify these properties! - -FIELDL=1200 -FIELDH=1200 -NUMBATTLES=10 -ROUNDS=10 - -# INPUT Input battles file that is generated by the rumble automatically. -# The rumble uses this file for selecting which robots that must -# battle against each other. -# -# OUTPUT Battle results file, which is the output of running the rumble. - -INPUT=./roborumble/temp/battlesTeams.txt -OUTPUT=./roborumble/files/resultsTeams.txt - -#------------------------------------------------------------------------------- -# Properties for retrieving robots from Internet -#------------------------------------------------------------------------------- - -# BOTSREP The robot repository where downloaded robots are put. -# -# TEMP Directory containing all temporary files for RoboRumble. - -BOTSREP=./robots/ -TEMP=./roborumble/temp/ - -#------------------------------------------------------------------------------- -# Properties for updating participants from Internet -#------------------------------------------------------------------------------- - -# PARTICIPANTSURL -# URL to the web page containing all participants of the competition, -# which will be used for updating the participants file specified with -# the PARTICIPANTSFILE property. -# -# PARTICIPANTSFILE -# File containing all the participants for the competition. -# -# STARTAG Tag marking the start and end of the participants on the web page -# pointed to with the PARTICIPANTSURL property. -# -# UPDATEBOTSURL -# URL used for removing old participants, which is used for updating -# the participants file specified with the PARTICIPANTSFILE property. - -PARTICIPANTSURL=http://robowiki.net/wiki/RoboRumble/Participants/Teams&action=raw -PARTICIPANTSFILE=./roborumble/files/participTeams.txt - -STARTAG=pre - -UPDATEBOTSURL=http://literumble.appspot.com/RemoveOldParticipant - -#------------------------------------------------------------------------------- -# Properties to control the way battles are run -#------------------------------------------------------------------------------- - -# RUNONLY If left black or set to GENERAL, a new battle file is created where -# robots from the participants file are paired at random. The number -# of robot pairs will match number of battles defined the NUMBATTLES -# property. -# -# If set to SERVER (recommended), a new battle file is created which -# will first of all contain priority battles for robots that that has -# priority over other robots until they have fought a specific number -# of battles specified by the BATTLESPERBOT property. The number of -# battles fought by the individual robots are extracted from the -# rating files, which are downloaded from the server if the DOWNLOAD -# property is set to YES. When no more priority battles are left, -# robots from the participants file are paired at random similar to -# GENERAL. -# -# BATTLESPERBOT -# The number of battles a robot has to fight before it will no longer -# have priority over other robots in battles. Prioritizing a robot -# makes its rating more reliable faster as its number of fought -# battles increases faster than when it is not prioritized. -# -# PRIORITYBATTLESFILE -# The priority battles file that is generated automatically by the -# rumble when the RUNONLY property is set to SERVER. - -RUNONLY=SERVER - -BATTLESPERBOT=200 - -PRIORITYBATTLESFILE=./roborumble/temp/priorityTeams.txt - -#------------------------------------------------------------------------------- -# Properties for uploading the results to the server -#------------------------------------------------------------------------------- - -# RESULTSURL -# URL used for uploading the results to the server. -# -# BATTLESNUMFILE -# File containing the number of battles fought by the robots, which is -# returned by the server when results are uploaded to the server. - -RESULTSURL=http://literumble.appspot.com/UploadedResults - -BATTLESNUMFILE=./roborumble/temp/teambattlesnumber.txt - -#------------------------------------------------------------------------------- -# Properties for URLs and file names for the rating files to download -#------------------------------------------------------------------------------- - -# RATINGS.URL: -# URL to where ratings files are located on Internet. -# -# RATINGS.GENERAL: -# File name for the rating file of the general RoboRumble. -# -# RATINGS.MINIBOTS: -# File name for the rating file of the MiniRumble. -# -# RATINGS.MICROBOTS: -# File name for the rating file of the MicroRumble. -# -# RATINGS.NANOBOTS: -# File name for the rating file of the NanoRumble. - -RATINGS.URL=http://literumble.appspot.com/RatingsFile - -RATINGS.GENERAL=./roborumble/temp/ratings_teamrumble.txt diff --git a/workspace_robo/robocode.content/src/main/resources/roborumble/twinduel.txt b/workspace_robo/robocode.content/src/main/resources/roborumble/twinduel.txt deleted file mode 100644 index 8fc223b..0000000 --- a/workspace_robo/robocode.content/src/main/resources/roborumble/twinduel.txt +++ /dev/null @@ -1,203 +0,0 @@ -#=============================================================================== -# twinduel.txt - Configuration file for TwinDuel (rumble edition) -#=============================================================================== - -#------------------------------------------------------------------------------- -# User property. It's highly recommendable that you change this to use your name -#------------------------------------------------------------------------------- - -# USER The user name used when uploading the results to the RoboRumble -# server. Hence, you should replace 'Put_Your_Name_Here' with your -# name, which could be the initials you use for your robot(s). - -USER=Put_Your_Name_Here - -#------------------------------------------------------------------------------- -# Exclude filter used for excluding participants. Use with care! -#------------------------------------------------------------------------------- - -# EXCLUDE A comma separated list of all the participants you want to exclude -# from the competition. Excluded participants will not be downloaded -# or take part in battles. This way you can exclude participants that -# cannot be downloaded due to web servers that are down or hanging, -# the repository is down, robots/teams that crashes for some reason or -# cause other trouble. -# -# You can use the filename wildcards * and ? in the filter. Example: -# -# EXCLUDE=xyz.*v1.?, *Nano* - -EXCLUDE= - -#------------------------------------------------------------------------------- -# Properties for controlling the rumble. Use YES or NOT -#------------------------------------------------------------------------------- - -# DOWNLOAD Download data like participants, missing robots, rating files etc. -# from Internet if these have not been downloaded for 2 hours. -# -# EXECUTE Execute battles. Battles files are first created and old battles -# files are deleted before the battles are executed. -# -# UPLOAD Upload results to the RoboRumble server specified by the RESULTSURL -# property. -# -# ITERATE If set to NOT, the rumble will only execute battles once. -# If set to YES, the rumble will restart with new battles every time -# the battles have been executed, and it will run infinitely until -# terminated. - -DOWNLOAD=YES -EXECUTE=YES -UPLOAD=YES -ITERATE=YES - -# MELEE Must be set if this rumble is meant for melee battles. -# -# TEAMS Must be set if this rumble is meant for team battles. -# This flag is necessary, as jar files for robot teams are different -# from jar files for ordinary robots. - -# MELEE=NOT as this property file is not meant for melee battles. -# TEAM=YES, as this property file is meant for team battles. - -# Do not modify these properties! - -MELEE=NOT -TEAMS=YES - -#------------------------------------------------------------------------------ -# Properties for the battle engine -#------------------------------------------------------------------------------ - -# FIELDL Battlefield width measured in pixels. -# FIELDH Battlefield height measured in pixels. -# -# NUMBATTLES Number of battles performed per rumble. -# ROUNDS Number of rounds per battle. - -# These are standard values for the TeamRumble. Do not modify these properties! - -FIELDL=800 -FIELDH=800 -NUMBATTLES=10 -ROUNDS=75 - -# INPUT Input battles file that is generated by the rumble automatically. -# The rumble uses this file for selecting which robots that must -# battle against each other. -# -# OUTPUT Battle results file, which is the output of running the rumble. - -INPUT=./roborumble/temp/battlesTwinduel.txt -OUTPUT=./roborumble/files/resultsTwinduel.txt - -#------------------------------------------------------------------------------- -# Properties for retrieving robots from Internet -#------------------------------------------------------------------------------- - -# BOTSREP The robot repository where downloaded robots are put. -# -# TEMP Directory containing all temporary files for RoboRumble. - -BOTSREP=./robots/ -TEMP=./roborumble/temp/ - -#------------------------------------------------------------------------------- -# Properties for updating participants from Internet -#------------------------------------------------------------------------------- - -# PARTICIPANTSURL -# URL to the web page containing all participants of the competition, -# which will be used for updating the participants file specified with -# the PARTICIPANTSFILE property. -# -# PARTICIPANTSFILE -# File containing all the participants for the competition. -# -# STARTAG Tag marking the start and end of the participants on the web page -# pointed to with the PARTICIPANTSURL property. -# -# UPDATEBOTSURL -# URL used for removing old participants, which is used for updating -# the participants file specified with the PARTICIPANTSFILE property. - -PARTICIPANTSURL=http://robowiki.net/wiki/RoboRumble/Participants/TwinDuel -PARTICIPANTSFILE=./roborumble/files/participTwinduel.txt - -STARTAG=pre - -UPDATEBOTSURL=http://literumble.appspot.com/RemoveOldParticipant - -#------------------------------------------------------------------------------- -# Properties to control the way battles are run -#------------------------------------------------------------------------------- - -# RUNONLY If left black or set to GENERAL, a new battle file is created where -# robots from the participants file are paired at random. The number -# of robot pairs will match number of battles defined the NUMBATTLES -# property. -# -# If set to SERVER (recommended), a new battle file is created which -# will first of all contain priority battles for robots that that has -# priority over other robots until they have fought a specific number -# of battles specified by the BATTLESPERBOT property. The number of -# battles fought by the individual robots are extracted from the -# rating files, which are downloaded from the server if the DOWNLOAD -# property is set to YES. When no more priority battles are left, -# robots from the participants file are paired at random similar to -# GENERAL. -# -# BATTLESPERBOT -# The number of battles a robot has to fight before it will no longer -# have priority over other robots in battles. Prioritizing a robot -# makes its rating more reliable faster as its number of fought -# battles increases faster than when it is not prioritized. -# -# PRIORITYBATTLESFILE -# The priority battles file that is generated automatically by the -# rumble when the RUNONLY property is set to SERVER. - -RUNONLY=SERVER - -BATTLESPERBOT=200 - -PRIORITYBATTLESFILE=./roborumble/temp/priorityTwinduel.txt - -#------------------------------------------------------------------------------- -# Properties for uploading the results to the server -#------------------------------------------------------------------------------- - -# RESULTSURL -# URL used for uploading the results to the server. -# -# BATTLESNUMFILE -# File containing the number of battles fought by the robots, which is -# returned by the server when results are uploaded to the server. - -RESULTSURL=http://literumble.appspot.com/UploadedResults - -BATTLESNUMFILE=./roborumble/temp/twinduelbattlesnumber.txt - -#------------------------------------------------------------------------------- -# Properties for URLs and file names for the rating files to download -#------------------------------------------------------------------------------- - -# RATINGS.URL: -# URL to where ratings files are located on Internet. -# -# RATINGS.GENERAL: -# File name for the rating file of the general RoboRumble. -# -# RATINGS.MINIBOTS: -# File name for the rating file of the MiniRumble. -# -# RATINGS.MICROBOTS: -# File name for the rating file of the MicroRumble. -# -# RATINGS.NANOBOTS: -# File name for the rating file of the NanoRumble. - -RATINGS.URL=http://literumble.appspot.com/RatingsFile - -RATINGS.GENERAL=./roborumble/temp/ratings_twinduel.txt diff --git a/workspace_robo/robocode.content/src/main/resources/teamrumble.bat b/workspace_robo/robocode.content/src/main/resources/teamrumble.bat deleted file mode 100644 index 3d97f1f..0000000 --- a/workspace_robo/robocode.content/src/main/resources/teamrumble.bat +++ /dev/null @@ -1,9 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -java -Xmx512M -cp libs/robocode.jar;libs/roborumble.jar;libs/codesize-1.1.jar; roborumble.RoboRumbleAtHome ./roborumble/teamrumble.txt \ No newline at end of file diff --git a/workspace_robo/robocode.content/src/main/resources/teamrumble.command b/workspace_robo/robocode.content/src/main/resources/teamrumble.command deleted file mode 100644 index c103230..0000000 --- a/workspace_robo/robocode.content/src/main/resources/teamrumble.command +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -################################################################################ -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -################################################################################ - -pwd=`pwd` -cd "${0%/*}" -java -Xdock:icon=roborumble.ico -Xdock:name=TeamRumble -Xmx512M -cp libs/robocode.jar:libs/roborumble.jar:libs/codesize-1.1.jar roborumble.RoboRumbleAtHome ./roborumble/teamrumble.txt -cd "${pwd}" diff --git a/workspace_robo/robocode.content/src/main/resources/teamrumble.sh b/workspace_robo/robocode.content/src/main/resources/teamrumble.sh deleted file mode 100644 index 96b6e82..0000000 --- a/workspace_robo/robocode.content/src/main/resources/teamrumble.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - -pwd=`pwd` -cd "${0%/*}" -java -Xmx512M -cp libs/robocode.jar:libs/roborumble.jar:libs/codesize-1.1.jar roborumble.RoboRumbleAtHome ./roborumble/teamrumble.txt -cd "${pwd}" diff --git a/workspace_robo/robocode.content/src/main/resources/templates/newjavafile.tpt b/workspace_robo/robocode.content/src/main/resources/templates/newjavafile.tpt deleted file mode 100644 index b5bbc36..0000000 --- a/workspace_robo/robocode.content/src/main/resources/templates/newjavafile.tpt +++ /dev/null @@ -1,8 +0,0 @@ -package $PACKAGE; - -/** - * $CLASSNAME - a class by (your name here) - */ -public class $CLASSNAME -{ -} diff --git a/workspace_robo/robocode.content/src/main/resources/templates/newjuniorrobot.tpt b/workspace_robo/robocode.content/src/main/resources/templates/newjuniorrobot.tpt deleted file mode 100644 index c7f0ec8..0000000 --- a/workspace_robo/robocode.content/src/main/resources/templates/newjuniorrobot.tpt +++ /dev/null @@ -1,54 +0,0 @@ -package $PACKAGE; -import robocode.*; - -// API help : http://robocode.sourceforge.net/docs/robocode/robocode/JuniorRobot.html - -/** - * $CLASSNAME - a robot by (your name here) - */ -public class $CLASSNAME extends JuniorRobot -{ - /** - * run: $CLASSNAME's default behavior - */ - public void run() { - // Initialization of the robot should be put here - - // Some color codes: blue, yellow, black, white, red, pink, brown, grey, orange... - // Sets these colors (robot parts): body, gun, radar, bullet, scan_arc - setColors(orange, blue, white, yellow, black); - - // Robot main loop - while(true) { - // Replace the next 4 lines with any behavior you would like - ahead(100); - turnGunRight(360); - back(100); - turnGunRight(360); - } - } - - /** - * onScannedRobot: What to do when you see another robot - */ - public void onScannedRobot() { - // Replace the next line with any behavior you would like - fire(1); - } - - /** - * onHitByBullet: What to do when you're hit by a bullet - */ - public void onHitByBullet() { - // Replace the next line with any behavior you would like - back(10); - } - - /** - * onHitWall: What to do when you hit a wall - */ - public void onHitWall() { - // Replace the next line with any behavior you would like - back(20); - } -} diff --git a/workspace_robo/robocode.content/src/main/resources/templates/newrobot.tpt b/workspace_robo/robocode.content/src/main/resources/templates/newrobot.tpt deleted file mode 100644 index 070e471..0000000 --- a/workspace_robo/robocode.content/src/main/resources/templates/newrobot.tpt +++ /dev/null @@ -1,56 +0,0 @@ -package $PACKAGE; -import robocode.*; -//import java.awt.Color; - -// API help : http://robocode.sourceforge.net/docs/robocode/robocode/Robot.html - -/** - * $CLASSNAME - a robot by (your name here) - */ -public class $CLASSNAME extends Robot -{ - /** - * run: $CLASSNAME's default behavior - */ - public void run() { - // Initialization of the robot should be put here - - // After trying out your robot, try uncommenting the import at the top, - // and the next line: - - // setColors(Color.red,Color.blue,Color.green); // body,gun,radar - - // Robot main loop - while(true) { - // Replace the next 4 lines with any behavior you would like - ahead(100); - turnGunRight(360); - back(100); - turnGunRight(360); - } - } - - /** - * onScannedRobot: What to do when you see another robot - */ - public void onScannedRobot(ScannedRobotEvent e) { - // Replace the next line with any behavior you would like - fire(1); - } - - /** - * onHitByBullet: What to do when you're hit by a bullet - */ - public void onHitByBullet(HitByBulletEvent e) { - // Replace the next line with any behavior you would like - back(10); - } - - /** - * onHitWall: What to do when you hit a wall - */ - public void onHitWall(HitWallEvent e) { - // Replace the next line with any behavior you would like - back(20); - } -} diff --git a/workspace_robo/robocode.content/src/main/resources/theme/editor/Robocode Black Theme.properties b/workspace_robo/robocode.content/src/main/resources/theme/editor/Robocode Black Theme.properties deleted file mode 100644 index bd627b6..0000000 --- a/workspace_robo/robocode.content/src/main/resources/theme/editor/Robocode Black Theme.properties +++ /dev/null @@ -1,23 +0,0 @@ -#Robocode Editor Theme Properties -#Sun Sep 15 22:13:41 CEST 2013 -editor.theme=Robocode Black Theme -editor.font.name=Monospaced -editor.font.size=14 -editor.background.color=000000 -editor.lineNumber.background.color=22222 -editor.lineNumber.text.color=00CC00 -editor.highlighted.line.color=999999 -editor.selected.text.color=993300 -editor.selected.background.color=FFFFFF -editor.text.style.normal=Plain -editor.text.color.normal=00FFFF -editor.text.style.keyword=Bold -editor.text.color.keyword=0000FF -editor.text.style.literal=Plain -editor.text.color.literal=FFFF00 -editor.text.style.comment=Italic -editor.text.color.comment=00FF00 -editor.text.style.quoted=Plain -editor.text.color.quoted=FF0000 -editor.text.style.annotation=Plain -editor.text.color.annotation=FF00FF diff --git a/workspace_robo/robocode.content/src/main/resources/theme/editor/Robocode White Theme.properties b/workspace_robo/robocode.content/src/main/resources/theme/editor/Robocode White Theme.properties deleted file mode 100644 index 0eecd3e..0000000 --- a/workspace_robo/robocode.content/src/main/resources/theme/editor/Robocode White Theme.properties +++ /dev/null @@ -1,23 +0,0 @@ -#Robocode Editor Theme Properties -#Wed Jul 31 14:51:10 CEST 2013 -editor.theme=Robocode White Theme -editor.font.name=Monospaced -editor.font.size=14 -editor.background.color=FFFFFF -editor.lineNumber.background.color=EEEEEE -editor.lineNumber.text.color=000000 -editor.highlighted.line.color=FFFFCC -editor.selected.text.color=FFFFFF -editor.selected.background.color=3399FF -editor.text.style.normal=Plain -editor.text.color.normal=000000 -editor.text.style.keyword=Bold -editor.text.color.keyword=0000AF -editor.text.style.literal=Bold -editor.text.color.literal=0000AF -editor.text.style.comment=Plain -editor.text.color.comment=00AF00 -editor.text.style.quoted=Plain -editor.text.color.quoted=7F0000 -editor.text.style.annotation=Plain -editor.text.color.annotation=7F7F7F diff --git a/workspace_robo/robocode.content/src/main/resources/twinduel.bat b/workspace_robo/robocode.content/src/main/resources/twinduel.bat deleted file mode 100644 index c5573f2..0000000 --- a/workspace_robo/robocode.content/src/main/resources/twinduel.bat +++ /dev/null @@ -1,9 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -java -Xmx512M -cp libs/robocode.jar;libs/roborumble.jar;libs/codesize-1.1.jar; roborumble.RoboRumbleAtHome ./roborumble/twinduel.txt \ No newline at end of file diff --git a/workspace_robo/robocode.content/src/main/resources/twinduel.command b/workspace_robo/robocode.content/src/main/resources/twinduel.command deleted file mode 100644 index a61c9e8..0000000 --- a/workspace_robo/robocode.content/src/main/resources/twinduel.command +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -################################################################################ -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -################################################################################ - -pwd=`pwd` -cd "${0%/*}" -java -Xdock:icon=roborumble.ico -Xdock:name=TwinDuel -Xmx512M -cp libs/robocode.jar:libs/roborumble.jar:libs/codesize-1.1.jar roborumble.RoboRumbleAtHome ./roborumble/twinduel.txt -cd "${pwd}" diff --git a/workspace_robo/robocode.content/src/main/resources/twinduel.sh b/workspace_robo/robocode.content/src/main/resources/twinduel.sh deleted file mode 100644 index 1669b1b..0000000 --- a/workspace_robo/robocode.content/src/main/resources/twinduel.sh +++ /dev/null @@ -1,13 +0,0 @@ -#!/bin/sh -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - -pwd=`pwd` -cd "${0%/*}" -java -Xmx512M -cp libs/robocode.jar:libs/roborumble.jar:libs/codesize-1.1.jar roborumble.RoboRumbleAtHome ./roborumble/twinduel.txt -cd "${pwd}" diff --git a/workspace_robo/robocode.core/.classpath b/workspace_robo/robocode.core/.classpath deleted file mode 100644 index a5988a2..0000000 --- a/workspace_robo/robocode.core/.classpath +++ /dev/null @@ -1,12 +0,0 @@ - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.core/.project b/workspace_robo/robocode.core/.project deleted file mode 100644 index 45e2fe1..0000000 --- a/workspace_robo/robocode.core/.project +++ /dev/null @@ -1,16 +0,0 @@ - - - robocode.core - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.api - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.core/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.core/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 65f3846..0000000 --- a/workspace_robo/robocode.core/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:08 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.core/pom.xml b/workspace_robo/robocode.core/pom.xml deleted file mode 100644 index b544668..0000000 --- a/workspace_robo/robocode.core/pom.xml +++ /dev/null @@ -1,61 +0,0 @@ - - - 4.0.0 - robocode.core - Robocode Core - - net.sf.robocode - robocode - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - - org.picocontainer - picocontainer - 2.14.2 - - - - junit - junit - 4.11 - test - - - - - - maven-resources-plugin - - - copy-resources - validate - - copy-resources - - - ${basedir}/target/classes - - - .. - false - - - versions.md - - - - - - - - - - diff --git a/workspace_robo/robocode.core/robocode.core.iml b/workspace_robo/robocode.core/robocode.core.iml deleted file mode 100644 index 56af730..0000000 --- a/workspace_robo/robocode.core/robocode.core.iml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/BattleProperties.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/BattleProperties.java deleted file mode 100644 index c3a76d9..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/BattleProperties.java +++ /dev/null @@ -1,333 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -import robocode.AdvancedRobot; -import robocode.Robot; -import robocode.control.RobotSetup; -import robocode.control.RobotSpecification; - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.Serializable; -import java.util.Properties; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class BattleProperties implements Serializable { - - private static final long serialVersionUID = 1L; - - private final static String - BATTLEFIELD_WIDTH = "robocode.battleField.width", - BATTLEFIELD_HEIGHT = "robocode.battleField.height", - BATTLE_NUMROUNDS = "robocode.battle.numRounds", - BATTLE_GUNCOOLINGRATE = "robocode.battle.gunCoolingRate", - BATTLE_RULES_INACTIVITYTIME = "robocode.battle.rules.inactivityTime", - BATTLE_HIDE_ENEMY_NAMES = "robocode.battle.hideEnemyNames", - BATTLE_SELECTEDROBOTS = "robocode.battle.selectedRobots", - BATTLE_INITIAL_POSITIONS = "robocode.battle.initialPositions", - BATTLE_SENTRY_BORDER_SIZE = "robocode.battle.sentryBorderSize"; - - private int battlefieldWidth = 800; - private int battlefieldHeight = 600; - private int numRounds = 10; - private double gunCoolingRate = 0.1; - private long inactivityTime = 450; - private boolean hideEnemyNames = false; - private int sentryBorderSize = 100; - private String selectedRobots; - private String initialPositions; - - private final Properties props = new Properties(); - - /** - * Gets the battlefieldWidth. - * - * @return Returns a int - */ - public int getBattlefieldWidth() { - return battlefieldWidth; - } - - /** - * Sets the battlefieldWidth. - * - * @param battlefieldWidth The battlefieldWidth to set - */ - public void setBattlefieldWidth(int battlefieldWidth) { - this.battlefieldWidth = battlefieldWidth; - props.setProperty(BATTLEFIELD_WIDTH, "" + battlefieldWidth); - } - - /** - * Gets the battlefieldHeight. - * - * @return Returns a int - */ - public int getBattlefieldHeight() { - return battlefieldHeight; - } - - /** - * Sets the battlefieldHeight. - * - * @param battlefieldHeight The battlefieldHeight to set - */ - public void setBattlefieldHeight(int battlefieldHeight) { - this.battlefieldHeight = battlefieldHeight; - props.setProperty(BATTLEFIELD_HEIGHT, "" + battlefieldHeight); - } - - /** - * Gets the numRounds. - * - * @return Returns a int - */ - public int getNumRounds() { - return numRounds; - } - - /** - * Sets the numRounds. - * - * @param numRounds The numRounds to set - */ - public void setNumRounds(int numRounds) { - this.numRounds = numRounds; - props.setProperty(BATTLE_NUMROUNDS, "" + numRounds); - } - - /** - * Returns the rate at which the gun will cool down, i.e. the amount of heat the gun heat will drop per turn. - *

- * The gun cooling rate is default 0.1 per turn, but can be changed by the battle setup. - * So don't count on the cooling rate being 0.1! - * - * @return the gun cooling rate - * @see #setGunCoolingRate(double) - * @see Robot#getGunHeat() - * @see Robot#fire(double) - * @see Robot#fireBullet(double) - * @see robocode.BattleRules#getGunCoolingRate() - */ - public double getGunCoolingRate() { - return gunCoolingRate; - } - - /** - * Sets the rate at which the gun will cool down, i.e. the amount of heat the gun heat will drop per turn. - * - * @param gunCoolingRate the new gun cooling rate - * @see #getGunCoolingRate - * @see Robot#getGunHeat() - * @see Robot#fire(double) - * @see Robot#fireBullet(double) - * @see robocode.BattleRules#getGunCoolingRate() - */ - public void setGunCoolingRate(double gunCoolingRate) { - this.gunCoolingRate = gunCoolingRate; - props.setProperty(BATTLE_GUNCOOLINGRATE, "" + gunCoolingRate); - } - - /** - * Returns the allowed inactivity time, where the robot is not taking any action, before will begin to be zapped. - * The inactivity time is measured in turns, and is the allowed time that a robot is allowed to omit taking - * action before being punished by the game by zapping. - *

- * When a robot is zapped by the game, it will loose 0.1 energy points per turn. Eventually the robot will be - * killed by zapping until the robot takes action. When the robot takes action, the inactivity time counter is - * reset. - *

- * The allowed inactivity time is per default 450 turns, but can be changed by the battle setup. - * So don't count on the inactivity time being 450 turns! - * - * @return the allowed inactivity time. - * @see robocode.BattleRules#getInactivityTime() - * @see Robot#doNothing() - * @see AdvancedRobot#execute() - */ - public long getInactivityTime() { - return inactivityTime; - } - - /** - * Sets the allowed inactivity time, where the robot is not taking any action, before will begin to be zapped. - * - * @param inactivityTime the new allowed inactivity time. - * @see robocode.BattleRules#getInactivityTime() - * @see Robot#doNothing() - * @see AdvancedRobot#execute() - */ - public void setInactivityTime(long inactivityTime) { - this.inactivityTime = inactivityTime; - props.setProperty(BATTLE_RULES_INACTIVITYTIME, "" + inactivityTime); - } - - /** - * Sets the flag defining if enemy names are hidden for robots during a battle. - * - * @param hideEnemyNames true if the enemy names must be hidden for a robot; false otherwise. - * - * @since 1.7.3 - */ - public void setHideEnemyNames(boolean hideEnemyNames) { - this.hideEnemyNames = hideEnemyNames; - props.setProperty(BATTLE_HIDE_ENEMY_NAMES, "" + hideEnemyNames); - } - - /** - * Returns true if the enemy names are hidden for robots during a battle; false otherwise. - * - * @since 1.7.3 - */ - public boolean getHideEnemyNames() { - return hideEnemyNames; - } - - /** - * Gets the selectedRobots. - * - * @return Returns a String - */ - public String getSelectedRobots() { - return selectedRobots; - } - - /** - * Sets the selectedRobots. - * - * @param selectedRobots The selectedRobots to set - */ - public void setSelectedRobots(String selectedRobots) { - this.selectedRobots = selectedRobots; - props.setProperty(BATTLE_SELECTEDROBOTS, "" + selectedRobots); - } - - /** - * Sets the selectedRobots. - * - * @param robots The robots to set - */ - public void setSelectedRobots(RobotSpecification[] robots) { - StringBuffer robotString = new StringBuffer(); - RobotSpecification robot; - - for (int i = 0; i < robots.length; i++) { - robot = robots[i]; - if (robot == null) { - continue; - } - - robotString.append(robot.getClassName()); - - if (!(robot.getVersion() == null || robot.getVersion().length() == 0)) { - robotString.append(' ').append(robot.getVersion()); - } - - if (i < robots.length - 1) { - robotString.append(','); - } - } - setSelectedRobots(robotString.toString()); - } - - /** - * Gets the initial robot positions and headings. - * - * @return a comma-separated string containing the initial positions and headings as a comma separated string: - * x1,y1,heading1, x2,y2,heading2 - * - * @since 1.7.1.2 - */ - public String getInitialPositions() { - return initialPositions; - } - - /** - * Sets the initial robot positions and headings. - * - * @param positions is the initial positions and headings as a comma separated string: - * x1,y1,heading1, x2,y2,heading2 - * - * @since 1.7.1.2 - */ - public void setInitialPositions(String positions) { - this.initialPositions = positions; - } - - /** - * Sets the initial robot positions and headings. - * - * @param initialSetups is the initial positions and headings as a {@link RobotSetup} array. - * - * @since 1.9.2.0 - */ - public void setInitialPositions(RobotSetup[] initialSetups) { - if (initialSetups == null) { - return; - } - - StringBuilder sb = new StringBuilder(); - - for (RobotSetup setup : initialSetups) { - String x = (setup.getX() == null) ? "?" : "" + setup.getX(); - String y = (setup.getY() == null) ? "?" : "" + setup.getY(); - String heading = (setup.getHeading() == null) ? "?" : "" + setup.getHeading(); - - sb.append('('); - sb.append(x).append(','); - sb.append(y).append(','); - sb.append(heading); - sb.append("),"); - } - - this.initialPositions = sb.toString(); - } - - /** - * Returns the sentry border size for a {@link robocode.BorderSentry BorderSentry}. - * - * @return the border size in units/pixels. - */ - public int getSentryBorderSize() { - return sentryBorderSize; - } - - /** - * Returns the sentry border size for a {@link robocode.BorderSentry BorderSentry}. - * - * @param borderSize is the sentry border size in units/pixels. - */ - public void setSentryBorderSize(int borderSize) { - sentryBorderSize = borderSize; - props.setProperty(BATTLE_SENTRY_BORDER_SIZE, "" + sentryBorderSize); - } - - public void store(FileOutputStream out, String desc) throws IOException { - props.store(out, desc); - } - - public void load(FileInputStream in) throws IOException { - props.load(in); - battlefieldWidth = Integer.parseInt(props.getProperty(BATTLEFIELD_WIDTH, "800")); - battlefieldHeight = Integer.parseInt(props.getProperty(BATTLEFIELD_HEIGHT, "600")); - gunCoolingRate = Double.parseDouble(props.getProperty(BATTLE_GUNCOOLINGRATE, "0.1")); - inactivityTime = Long.parseLong(props.getProperty(BATTLE_RULES_INACTIVITYTIME, "450")); - hideEnemyNames = Boolean.parseBoolean(props.getProperty(BATTLE_HIDE_ENEMY_NAMES, "false")); - numRounds = Integer.parseInt(props.getProperty(BATTLE_NUMROUNDS, "10")); - selectedRobots = props.getProperty(BATTLE_SELECTEDROBOTS, ""); - initialPositions = props.getProperty(BATTLE_INITIAL_POSITIONS, ""); - sentryBorderSize = Integer.parseInt(props.getProperty(BATTLE_SENTRY_BORDER_SIZE, "100")); - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/BattleRankingTableModel.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/BattleRankingTableModel.java deleted file mode 100644 index bf32324..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/BattleRankingTableModel.java +++ /dev/null @@ -1,199 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -import robocode.control.snapshot.IScoreSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - -import javax.swing.table.AbstractTableModel; - - -/** - * This table model extracts the robot ranking from the current battle, - * in order to be displayed by the RankingDialog. - * - * @author Luis Crespo (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - * @author Endre Palatinus, Eniko Nagy, Attila Csizofszki and Laszlo Vigh (contributors) - */ -@SuppressWarnings("serial") -public class BattleRankingTableModel extends AbstractTableModel { - - private IScoreSnapshot[] scoreSnapshotList; - - // The sum of the scores gathered by the robots in the actual round - private double currentSum; - - // The sum of the scores gathered by the robots in the previous rounds - private double totalSum; - - /** - * Function for counting the sum of the scores gathered by the robots. - */ - private void countTotalScores() { - currentSum = 0; - totalSum = 0; - - for (IScoreSnapshot score : scoreSnapshotList) { - currentSum += score.getCurrentScore(); - totalSum += score.getTotalScore(); - } - } - - public void updateSource(ITurnSnapshot snapshot) { - if (snapshot != null) { - scoreSnapshotList = snapshot.getSortedTeamScores(); - countTotalScores(); - } else { - scoreSnapshotList = null; - } - } - - public int getColumnCount() { - return 12; - } - - public int getRowCount() { - return scoreSnapshotList == null ? 0 : scoreSnapshotList.length; - } - - @Override - public String getColumnName(int col) { - switch (col) { - case 0: - return "Rank"; - - case 1: - return "Robot Name"; - - case 2: - return " Total Score "; - - case 3: - return " Survival "; - - case 4: - return "Surv Bonus"; - - case 5: - return " Bullet Dmg "; - - case 6: - return " Bullet Bonus "; - - case 7: - return "Ram Dmg * 2"; - - case 8: - return "Ram Bonus"; - - case 9: - return " 1sts "; - - case 10: - return " 2nds "; - - case 11: - return " 3rds "; - - default: - return ""; - } - } - - public Object getValueAt(int row, int col) { - - final IScoreSnapshot statistics = scoreSnapshotList[row]; - - switch (col) { - case 0: - return getPlacementString(row + 1); - - case 1: - return statistics.getName(); - - case 2: { - final double current = statistics.getCurrentScore(); - final double total = statistics.getTotalScore(); - - return (int) (current + 0.5) + " / " + (int) (total + current + 0.5) + " (" - + (int) (current / currentSum * 100) + " / " + (int) ((total + current) / (totalSum + currentSum) * 100) - + "%)"; - } - - case 3: { - final double current = statistics.getCurrentSurvivalScore(); - final double total = statistics.getTotalSurvivalScore(); - - return (int) (current + 0.5) + " / " + (int) (total + current + 0.5); - } - - case 4: - return (int) (statistics.getTotalLastSurvivorBonus() + 0.5); - - case 5: { - final double current = statistics.getCurrentBulletDamageScore(); - final double total = statistics.getTotalBulletDamageScore(); - - return (int) (current + 0.5) + " / " + (int) (total + current + 0.5); - } - - case 6: { - final double current = statistics.getCurrentBulletKillBonus(); - final double total = statistics.getTotalBulletKillBonus(); - - return (int) (current + 0.5) + " / " + (int) (total + current + 0.5); - } - - case 7: { - final double current = statistics.getCurrentRammingDamageScore(); - final double total = statistics.getTotalRammingDamageScore(); - - return (int) (current + 0.5) + " / " + (int) (total + current + 0.5); - } - - case 8: { - final double current = statistics.getCurrentRammingKillBonus(); - final double total = statistics.getTotalRammingKillBonus(); - - return (int) (current + 0.5) + " / " + (int) (total + current + 0.5); - } - - case 9: - return "" + statistics.getTotalFirsts(); - - case 10: - return "" + statistics.getTotalSeconds(); - - case 11: - return "" + statistics.getTotalThirds(); - - default: - return ""; - } - } - - private static String getPlacementString(int i) { - String result = "" + i; - - if (i > 3 && i < 20) { - result += "th"; - } else if (i % 10 == 1) { - result += "st"; - } else if (i % 10 == 2) { - result += "nd"; - } else if (i % 10 == 3) { - result += "rd"; - } else { - result += "th"; - } - return result; - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/BattleResultsTableModel.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/BattleResultsTableModel.java deleted file mode 100644 index 1d3159f..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/BattleResultsTableModel.java +++ /dev/null @@ -1,253 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -import net.sf.robocode.io.Logger; -import robocode.BattleResults; - -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.text.DateFormat; -import java.text.NumberFormat; -import java.util.Date; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - * @author Nathaniel Troutman (contributor) - * @author Endre Palatinus, Eniko Nagy, Attila Csizofszki and Laszlo Vigh (contributors) - */ -@SuppressWarnings("serial") -public class BattleResultsTableModel extends javax.swing.table.AbstractTableModel { - private String title; - private final BattleResults[] results; - private final int numRounds; - - // The sum of the scores gathered by the robots. - private final double totalScore; - - public BattleResultsTableModel(BattleResults[] results, int numRounds) { - this.results = results; - this.numRounds = numRounds; - totalScore = countTotalScore(); - } - - /** - * Function for counting the sum of the scores gathered by the robots. - * - * @return The sum. - */ - private double countTotalScore() { - - double totalScore = 0; - - for (BattleResults result : results) { - totalScore += result.getScore(); - } - - return totalScore; - } - - public int getColumnCount() { - return 12; - } - - @Override - public String getColumnName(int col) { - switch (col) { - case 0: - return "Rank"; - - case 1: - return "Robot Name"; - - case 2: - return " Total Score "; - - case 3: - return "Survival"; - - case 4: - return "Surv Bonus"; - - case 5: - return "Bullet Dmg"; - - case 6: - return "Bullet Bonus"; - - case 7: - return "Ram Dmg * 2"; - - case 8: - return "Ram Bonus"; - - case 9: - return " 1sts "; - - case 10: - return " 2nds "; - - case 11: - return " 3rds "; - - default: - return ""; - } - } - - public int getRowCount() { - return results.length; - } - - public String getTitle() { - if (title == null) { - int round = numRounds; - - title = "Results for " + round + " round"; - if (round > 1) { - title += 's'; - } - } - return title; - } - - public Object getValueAt(int row, int col) { - - BattleResults statistics = results[row]; - - switch (col) { - case 0: { - int place = row + 1; - - while (place < getRowCount() && statistics.getScore() == results[place].getScore()) { - place++; - } - return getPlacementString(place); - } - - case 1: - return statistics.getTeamLeaderName(); - - case 2: - String percent = ""; - - if (totalScore != 0) { - percent = " (" + NumberFormat.getPercentInstance().format(statistics.getScore() / totalScore) + ")"; - } - return "" + (int) (statistics.getScore() + 0.5) + percent; - - case 3: - return "" + (int) (statistics.getSurvival() + 0.5); - - case 4: - return "" + (int) (statistics.getLastSurvivorBonus() + 0.5); - - case 5: - return "" + (int) (statistics.getBulletDamage() + 0.5); - - case 6: - return "" + (int) (statistics.getBulletDamageBonus() + 0.5); - - case 7: - return "" + (int) (statistics.getRamDamage() + 0.5); - - case 8: - return "" + (int) (statistics.getRamDamageBonus() + 0.5); - - case 9: - return "" + statistics.getFirsts(); - - case 10: - return "" + statistics.getSeconds(); - - case 11: - return "" + statistics.getThirds(); - - default: - return ""; - } - } - - // Used for printing to the console only - public void print(PrintStream out) { - out.println(getTitle()); - - for (int col = 1; col < getColumnCount(); col++) { - out.print(getColumnName(col) + "\t"); - } - - out.println(); - - for (int row = 0; row < getRowCount(); row++) { - out.print(getValueAt(row, 0) + ": "); - for (int col = 1; col < getColumnCount(); col++) { - out.print(getValueAt(row, col) + "\t"); - } - out.println(); - } - } - - public void saveToFile(String filename, boolean append) { - try { - PrintStream out = new PrintStream(new FileOutputStream(filename, append)); - - out.println(DateFormat.getDateTimeInstance().format(new Date())); - - out.println(getTitle()); - - for (int col = 0; col < getColumnCount(); col++) { - if (col > 0) { - out.print(','); - } - out.print(getColumnName(col)); - } - - out.println(); - - for (int row = 0; row < getRowCount(); row++) { - for (int col = 0; col < getColumnCount(); col++) { - if (col > 0) { - out.print(','); - } - out.print(getValueAt(row, col)); - } - out.println(); - } - - out.println("$"); - - out.close(); - - } catch (IOException e) { - Logger.logError(e); - } - } - - private static String getPlacementString(int i) { - String result = "" + i; - - if (i > 3 && i < 20) { - result += "th"; - } else if (i % 10 == 1) { - result += "st"; - } else if (i % 10 == 2) { - result += "nd"; - } else if (i % 10 == 3) { - result += "rd"; - } else { - result += "th"; - } - return result; - } - -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/IBattleManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/IBattleManager.java deleted file mode 100644 index 76049be..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/IBattleManager.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle; - - -import robocode.Event; - - -/** - * Used for controlling a robot from the e.g. the UI or RobocodeEngine. - * - * @author Flemming N. Larsen - * - * @since 1.6.1 - */ -public interface IBattleManager extends IBattleManagerBase { - - /** - * Kills the robot. - * - * @param robotIndex the index of the robot to kill. - */ - void killRobot(int robotIndex); - - /** - * Enable or disable the robot paintings. - * - * @param robotIndex the index of the robot that must have its paintings enabled or disabled. - * @param enable {@code true} if paint must be enabled; {@code false} otherwise. - */ - void setPaintEnabled(int robotIndex, boolean enable); - - /** - * Enable or disable the robot paintings using the RobocodeSG coordinate system - * with the y-axis reversed compared to the coordinate system used in Robocode. - * - * @param robotIndex the index of the robot that must use RobocodeSG paintings. - * @param enable {@code true} if RobocodeSG paint coordinate system must be - * enabled when painting the robot; {@code false} otherwise. - */ - void setSGPaintEnabled(int robotIndex, boolean enable); - - /** - * Sends an interactive event for the robot. - * - * @param event the interactive event that has occurred to the robot. - */ - void sendInteractiveEvent(Event event); - - void startNewBattle(BattleProperties battleProperties, boolean waitTillOver, boolean enableCLIRecording); - - void nextTurn(); - - void prevTurn(); - - void pauseBattle(); - - void resumeBattle(); - - void togglePauseResumeBattle(); - - void resumeIfPausedBattle(); // TODO refactor, remove - - void pauseIfResumedBattle(); // TODO refactor, remove - - void restart(); - - void replay(); - - boolean isManagedTPS(); - - void setManagedTPS(boolean value); - - String getBattlePath(); - - String getBattleFilename(); - - void setBattleFilename(String newBattleFilename); - - BattleProperties loadBattleProperties(); - - void saveBattleProperties(); - - BattleProperties getBattleProperties(); - - void setDefaultBattleProperties(); - - void cleanup(); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/events/BattleEventDispatcher.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/events/BattleEventDispatcher.java deleted file mode 100644 index c6a146f..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/battle/events/BattleEventDispatcher.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.battle.events; - - -import static net.sf.robocode.io.Logger.logError; - -import net.sf.robocode.io.Logger; -import robocode.control.events.*; - -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - - -/** - * @author Flemming N. Larsen (original) - * @author Pavel Savara (original) - * - * @since 1.6.1 - */ -public class BattleEventDispatcher implements IBattleListener { - // This list is guaranteed to be thread-safe, which is necessary as it will be accessed - // by both the battle thread and battle manager thread. If this list is not thread-safe - // then ConcurentModificationExceptions will occur from time to time. - private final List listeners = new CopyOnWriteArrayList(); - - public BattleEventDispatcher() {} - - public void addListener(IBattleListener listener) { - assert (listener != null); - - listeners.add(listener); - } - - public void removeListener(IBattleListener listener) { - assert (listener != null); - listeners.remove(listener); - } - - public void onBattleStarted(BattleStartedEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onBattleStarted(event); - } catch (Throwable ex) { - logError("onBattleStarted " + listener.getClass(), ex); - } - } - } - - public void onBattleCompleted(BattleCompletedEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onBattleCompleted(event); - } catch (Throwable ex) { - logError("onBattleCompleted " + listener.getClass(), ex); - } - } - } - - public void onBattleFinished(BattleFinishedEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onBattleFinished(event); - } catch (Throwable ex) { - logError("onBattleFinished " + listener.getClass(), ex); - } - } - } - - public void onBattlePaused(BattlePausedEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onBattlePaused(event); - } catch (Throwable ex) { - logError("onBattlePaused " + listener.getClass(), ex); - } - } - } - - public void onBattleResumed(BattleResumedEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onBattleResumed(event); - } catch (Throwable ex) { - logError("onBattleResumed " + listener.getClass(), ex); - } - } - } - - public void onRoundStarted(RoundStartedEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onRoundStarted(event); - } catch (Throwable ex) { - logError("onRoundStarted " + listener.getClass(), ex); - } - } - } - - public void onRoundEnded(RoundEndedEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onRoundEnded(event); - } catch (Throwable ex) { - logError("onRoundEnded " + listener.getClass(), ex); - } - } - } - - public void onTurnStarted(TurnStartedEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onTurnStarted(event); - } catch (Throwable ex) { - logError("onTurnStarted " + listener.getClass(), ex); - } - } - } - - public void onTurnEnded(TurnEndedEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onTurnEnded(event); - } catch (Throwable ex) { - logError("onTurnEnded " + listener.getClass(), ex); - } - } - } - - public void onBattleMessage(BattleMessageEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onBattleMessage(event); - } catch (Throwable ex) { - logError("onBattleMessage " + listener.getClass(), ex); - } - } - } - - public void onBattleError(BattleErrorEvent event) { - for (IBattleListener listener : listeners) { - try { - listener.onBattleError(event); - } catch (Throwable ex) { - Logger.realErr.println(listener.getClass() + " " + ex.getMessage()); - } - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/cachecleaner/CacheCleaner.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/cachecleaner/CacheCleaner.java deleted file mode 100644 index e14ecdd..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/cachecleaner/CacheCleaner.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.cachecleaner; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.IRepositoryManager; - -import java.io.File; -import java.io.IOException; - - -/** - * Cache cleaner used for cleaning the /robot directory of Robocode, especially - * for RoboRumble - * - * @author AaronR - * @author Flemming N. Larsen (minor optimizations) - */ -public final class CacheCleaner { - private CacheCleaner() {} - - public static void main(String[] args) { - clean(); - } - - public static void clean() { - File roborumbleTempFile = new File("roborumble/temp"); - - deleteFile(roborumbleTempFile.getPath()); - deleteFile(FileUtil.getRobotsDataDir().getPath()); - deleteFile(FileUtil.getRobotDatabaseFile().getPath()); - - FileUtil.createDir(roborumbleTempFile); - - final IRepositoryManager repositoryManager = Container.getComponent(IRepositoryManager.class); - - repositoryManager.reload(true); - - Logger.logMessage("Cleaning done."); - } - - private static void deleteFile(String filename) { - Logger.logMessage("Deleting " + filename + "..."); - try { - recursivelyDelete(new File(filename)); - } catch (IOException ex) { - Logger.logError(ex.getMessage()); - } - } - - private static void recursivelyDelete(File file) throws IOException { - if (file.exists()) { - if (file.isDirectory()) { - final File[] files = file.listFiles(); - - for (File f : files) { - recursivelyDelete(f); - } - } - if (!file.delete()) { - throw new IOException("Failed deleting file: " + file.getPath()); - } - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/BaseModule.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/BaseModule.java deleted file mode 100644 index f3586b0..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/BaseModule.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.core; - - -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public class BaseModule implements IModule { - public void afterLoaded(List allModules) {} -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/Container.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/Container.java deleted file mode 100644 index 3b2cba2..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/Container.java +++ /dev/null @@ -1,257 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.core; - - -import net.sf.robocode.io.Logger; - -import org.picocontainer.Characteristics; -import org.picocontainer.MutablePicoContainer; -import org.picocontainer.behaviors.Caching; -import org.picocontainer.behaviors.OptInCaching; -import org.picocontainer.classname.DefaultClassLoadingPicoContainer; - -import java.awt.Toolkit; -import java.io.File; -import java.io.FilenameFilter; -import java.io.IOException; -import java.net.URL; -import java.net.MalformedURLException; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - - -/** - * Root of loaders. - * - * we have three types of classLoaders. - * 1) System class loader. Is loaded by default and is parent of loaders below. It contains this container class. All content of robot.api module. All general java stuff. - * 2) EngineClassLoader. Is used as isolation of all other robocode modules from system classloader. Anything loaded by engine is loaded there. We use single instance of this loader. - * 3) RobotClassLoader. Is used by robots. It will load every class on robot's private classPath. It blocks malicious attempts of references to robocode engine classes. We use multiple instances of this loader. - * - communication between classes from different classloaders must be done using interfaces or data types from system classLoader - * - this class must not reference any class of EngineClassLoader scope - * - * Dependency injection - * We use PicoContainer as IoC vehicle. We configure it by loading Module class in every .jar or classpath we can find on system classPath - * 1) Container.cache is containing singletons - * 2) Container.factory will create always new instance of component - * - * @author Pavel Savara (original) - */ -public final class Container extends ContainerBase { - - private static final String classPath = System.getProperties().getProperty("robocode.class.path", null); - - public static final MutablePicoContainer cache; - public static final MutablePicoContainer factory; - public static final ClassLoader systemLoader; - public static final ClassLoader engineLoader; // NO_UCD (use private - used by the .NET plug-in) - private static Set known = new HashSet(); - private static final List modules = new ArrayList(); - - static { - instance = new Container(); - systemLoader = Container.class.getClassLoader(); - engineLoader = new EngineClassLoader(systemLoader); - final Thread currentThread = Thread.currentThread(); - - currentThread.setContextClassLoader(engineLoader); - currentThread.setName("Application Thread"); - - // make sure we have AWT before we init security - Toolkit.getDefaultToolkit(); - - cache = new DefaultClassLoadingPicoContainer(engineLoader, new Caching(), null); - factory = new DefaultClassLoadingPicoContainer(engineLoader, new OptInCaching(), cache); - loadModule("net.sf.robocode.api", systemLoader); - final String[] cp = classPath.split(File.pathSeparator); - - // load core first - for (String path : cp) { - if (path.toLowerCase().contains("robocode.core")) { - loadFromPath(path); - } - } - for (String path : cp) { - loadFromPath(path); - } - - if (known.size() < 2) { - Logger.logError("Main modules not loaded, something went wrong. We have only " + known.size() + " modules"); - Logger.logError("Class path: " + classPath); - throw new Error("Main modules not loaded"); - } - - for (IModule module : modules) { - module.afterLoaded(modules); - } - } - - static void init() {} - - private static void loadFromPath(String path) { - try { - File pathf = new File(path).getCanonicalFile(); - - path = pathf.toString(); - final String test = path.toLowerCase(); - - if (pathf.isDirectory()) { - String name = getModuleName(path); - - if (name != null) { - loadModule(name, engineLoader); - } - } else if (test.contains(File.separator + "robocode.") && test.endsWith(".jar")) { - final int i = test.lastIndexOf("robocode.jar"); - - if (i > 0) { - // load other .jar files in location - final File dir = new File(path.substring(0, i)); - - Logger.logMessage("Loading plugins from " + dir.toString()); - loadJars(dir); - } else { - String name = getModuleName(path); - - if (name != null) { - loadModule(name, engineLoader); - } - } - } - } catch (IOException e) { - Logger.logError(e); - } - } - - private static void loadJars(File pathf) { - final File[] files = pathf.listFiles(new FilenameFilter() { - public boolean accept(File dir, String name) { - return name.toLowerCase().startsWith("robocode") && name.toLowerCase().endsWith(".jar"); - } - }); - - for (File file : files) { - loadModule(getModuleName(file.toString()), engineLoader); - } - } - - private static boolean loadModule(String module, ClassLoader loader) { - try { - if (known.contains(module)) { - // Logger.logMessage("already loaded " + module); - return false; - } - Class modClass = loader.loadClass(module + ".Module"); - - final Object moduleInstance = modClass.newInstance(); - - if (moduleInstance instanceof IModule) { - modules.add((IModule) moduleInstance); - } - Logger.logMessage("Loaded " + module); - known.add(module); - return true; - } catch (ClassNotFoundException ignore) {// it is not our module ? - // Logger.logMessage("Can't load " + module); - } catch (IllegalAccessException e) { - Logger.logError(e); - } catch (InstantiationException e) { - Logger.logError(e); - } - return false; - } - - private static String getModuleName(String path) { - final String test = path.toLowerCase(); - - if (test.endsWith("robocode.jar") || test.contains("robocode.api")) { - return null; - } - int i = test.lastIndexOf("robocode."); - - if (i > 0) { - String name = path.substring(i); - - i = name.indexOf(File.separator); - if (i > 0) { - return "net.sf." + name.substring(0, i); - } - i = name.indexOf("-"); - if (i > 0) { - return "net.sf." + name.substring(0, i); - } - return "net.sf." + name; - } - return null; - } - - static URL[] findJars(String allowed) { - List urls = new ArrayList(); - final String classPath = System.getProperty("robocode.class.path", null); - - for (String path : classPath.split(File.pathSeparator)) { - String test = path.toLowerCase(); - - if (test.contains(allowed)) { - if (!test.contains("robocode.jar") && !test.contains("robocode.api") - ) { - urls.add(path); - } - } - } - return convertUrls(urls); - } - - private static URL[] convertUrls(List surls) { - final URL[] urls = new URL[surls.size()]; - - for (int i = 0; i < surls.size(); i++) { - String url = surls.get(i); - File f = new File(url); - - try { - urls[i] = f.getCanonicalFile().toURI().toURL(); - } catch (MalformedURLException e) { - Logger.logError(e); - } catch (IOException e) { - Logger.logError(e); - } - } - return urls; - } - - protected T getBaseComponent(final Class tClass) { - return cache.getComponent(tClass); - } - - public static T getComponent(java.lang.Class tClass) { - return cache.getComponent(tClass); - } - - public static T getComponent(java.lang.Class tClass, String className) { - final List list = cache.getComponents(tClass); - - for (T component : list) { - if (component.getClass().getName().endsWith(className)) { - return component; - } - } - return null; - } - - public static List getComponents(java.lang.Class tClass) { - return cache.getComponents(tClass); - } - - public static T createComponent(java.lang.Class tClass) { - return factory.as(Characteristics.NO_CACHE).getComponent(tClass); - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/EngineClassLoader.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/EngineClassLoader.java deleted file mode 100644 index b796707..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/EngineClassLoader.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.core; - - -import java.net.URL; -import java.net.URLClassLoader; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.HashSet; -import java.util.Set; -import java.io.File; - -import net.sf.robocode.io.RobocodeProperties; - - -/** - * @author Pavel Savara (original) - */ -public class EngineClassLoader extends URLClassLoader { - - private static Set exclusions = new HashSet(); - static { - // this will be loaded on system classloader - exclusions.add(EngineClassLoader.class.getName()); - exclusions.add(Container.class.getName()); - exclusions.add(RobocodeMainBase.class.getName()); - - // .NET proxies and their interfaces must be loaded in system class loader in order to call native methods - exclusions.add("net.sf.robocode.host.IHost"); - exclusions.add("net.sf.robocode.host.IHostManager"); - exclusions.add("net.sf.robocode.host.proxies.IHostingRobotProxy"); - exclusions.add("net.sf.robocode.peer.IRobotPeer"); - exclusions.add("net.sf.robocode.repository.IRobotItem"); - exclusions.add("net.sf.robocode.repository.RobotType"); - exclusions.add("net.sf.robocode.host.RobotStatics"); - exclusions.add("net.sf.robocode.peer.BadBehavior"); - exclusions.add("net.sf.robocode.dotnet.host.DotNetHost"); - exclusions.add("net.sf.robocode.dotnet.repository.root.DllRootHelper"); - exclusions.add("net.sf.robocode.dotnet.nhost.ModuleN"); - exclusions.add("net.sf.robocode.host.proxies.__IHostingRobotProxy"); - } - - public EngineClassLoader(ClassLoader parent) { - super(Container.findJars(File.separator + "robocode."), parent); - } - - public synchronized void addURL(URL url) { - super.addURL(url); - } - - public synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { - - if (RobocodeProperties.isSecurityOff() || name.startsWith("java.lang")) { - return super.loadClass(name, resolve); - } - if (isEngineClass(name)) { - return loadEngineClass(name, resolve); - } - return super.loadClass(name, resolve); - } - - private Class loadEngineClass(String name, boolean resolve) throws ClassNotFoundException { - Class result = findLoadedClass(name); - - if (result == null) { - result = findClass(name); - } - if (resolve) { - resolveClass(result); - } - return result; - } - - private boolean isEngineClass(String name) { - if (name.startsWith("net.sf.robocode") || name.startsWith("robocode.control")) { - if (exclusions.contains(name)) { - return false; - } - // try to find it in engine's classpath - // this is URL, don't change to File.pathSeparator - final String path = name.replace('.', '/').concat(".class"); - - return AccessController.doPrivileged(new PrivilegedAction() { - public Boolean run() { - return findResource(path) != null; - } - }); - } - return false; - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/Module.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/Module.java deleted file mode 100644 index ae76ab2..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/Module.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.core; - - -import net.sf.robocode.host.RobotStatics; -import net.sf.robocode.peer.*; -import net.sf.robocode.serialization.RbSerializer; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.settings.SettingsManager; -import net.sf.robocode.version.IVersionManager; -import net.sf.robocode.version.VersionManager; - -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public class Module extends BaseModule { - static { - Container.cache.addComponent(RobocodeMain.class); - Container.cache.addComponent(IVersionManager.class, VersionManager.class); - Container.cache.addComponent(ISettingsManager.class, SettingsManager.class); - } - - @Override - public void afterLoaded(List allModules) { - RbSerializer.register(ExecCommands.class, RbSerializer.ExecCommands_TYPE); - RbSerializer.register(BulletCommand.class, RbSerializer.BulletCommand_TYPE); - RbSerializer.register(TeamMessage.class, RbSerializer.TeamMessage_TYPE); - RbSerializer.register(DebugProperty.class, RbSerializer.DebugProperty_TYPE); - RbSerializer.register(ExecResults.class, RbSerializer.ExecResults_TYPE); - RbSerializer.register(BulletStatus.class, RbSerializer.BulletStatus_TYPE); - RbSerializer.register(RobotStatics.class, RbSerializer.RobotStatics_TYPE); - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/RobocodeMain.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/RobocodeMain.java deleted file mode 100644 index 24c831b..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/RobocodeMain.java +++ /dev/null @@ -1,414 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.core; - - -import net.sf.robocode.battle.BattleResultsTableModel; -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.host.ICpuManager; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.RobocodeProperties; -import net.sf.robocode.recording.BattleRecordFormat; -import net.sf.robocode.recording.IRecordManager; -import net.sf.robocode.repository.IRepositoryManager; -import net.sf.robocode.serialization.SerializableOptions; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.sound.ISoundManager; -import net.sf.robocode.ui.IWindowManager; -import net.sf.robocode.util.StringUtil; -import net.sf.robocode.version.IVersionManager; -import robocode.control.events.*; - -import java.awt.Toolkit; -import java.io.ByteArrayOutputStream; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; - - -/** - * Robocode - A programming game involving battling AI tanks.
- * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * - * @see robocode.sourceforge.net - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Pavel Savara (contributor) - */ -public final class RobocodeMain extends RobocodeMainBase { - - private final Setup setup; - private final BattleObserver battleObserver = new BattleObserver(); - final private ISettingsManager properties; - final private IHostManager hostManager; - final private IWindowManager windowManager; - final private ISoundManager soundManager; - final private IBattleManager battleManager; - final private IRecordManager recordManager; - final private IVersionManager versionManager; - - private static class Setup { - boolean minimize; - boolean exitOnComplete; - String battleFilename; - String recordFilename; - String recordXmlFilename; - String replayFilename; - String resultsFilename; - int tps; - } - - public RobocodeMain(ISettingsManager properties, - IHostManager hostManager, - IWindowManager windowManager, - ISoundManager soundManager, - IBattleManager battleManager, - IRecordManager recordManager, - IVersionManager versionManager - ) { - setup = new Setup(); - this.properties = properties; - this.hostManager = hostManager; - this.windowManager = windowManager; - this.soundManager = soundManager; - this.battleManager = battleManager; - this.recordManager = recordManager; - this.versionManager = versionManager; - } - - public RobocodeMain(ISettingsManager properties, - IHostManager hostManager, - IWindowManager windowManager, - IBattleManager battleManager, - IRecordManager recordManager, - IVersionManager versionManager - ) { - this(properties, hostManager, windowManager, null, battleManager, recordManager, versionManager); - } - - public RobocodeMain(ISettingsManager properties, - IHostManager hostManager, - IBattleManager battleManager, - IRecordManager recordManager, - IVersionManager versionManager - ) { - this(properties, hostManager, null, battleManager, recordManager, versionManager); - } - - public void run() { - Thread.setDefaultUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() { - @Override - public void uncaughtException(Thread thread, Throwable t) { - t.printStackTrace(); - } - }); - - try { - hostManager.initSecurity(); - - // Set the Look and Feel (LAF) - if (windowManager != null && windowManager.isGUIEnabled()) { - windowManager.init(); - } - properties.setOptionsBattleDesiredTPS(setup.tps); - - battleManager.addListener(battleObserver); - - if (windowManager != null && windowManager.isGUIEnabled()) { - if (!setup.minimize && setup.battleFilename == null && soundManager != null) { - soundManager.playThemeMusic(); - windowManager.showSplashScreen(); - } - windowManager.showRobocodeFrame(true, setup.minimize); - - // Play the intro battle if a battle file is not specified and this is the first time Robocode is being run - - if (setup.battleFilename == null && versionManager.isLastRunVersionChanged()) { - properties.saveProperties(); - windowManager.runIntroBattle(); - } - } - - final boolean enableCLIRecording = (setup.recordFilename != null || setup.recordXmlFilename != null); - - // Note: At this point the GUI should be opened (if enabled) before starting the battle from a battle file - if (setup.battleFilename != null) { - if (setup.replayFilename != null) { - System.err.println("You cannot run both a battle and replay a battle record in the same time."); - System.exit(8); - } - - setup.exitOnComplete = true; - - battleManager.setBattleFilename(setup.battleFilename); - if (new File(battleManager.getBattleFilename()).exists()) { - battleManager.startNewBattle(battleManager.loadBattleProperties(), false, enableCLIRecording); - } else { - System.err.println("The specified battle file '" + setup.battleFilename + "' was not found"); - System.exit(8); - } - } else if (setup.replayFilename != null) { - setup.exitOnComplete = true; - if (setup.replayFilename.toLowerCase().endsWith("xml.zip")) { - recordManager.loadRecord(setup.replayFilename, BattleRecordFormat.XML_ZIP); - } else { - recordManager.loadRecord(setup.replayFilename, BattleRecordFormat.BINARY_ZIP); - } - - if (new File(setup.replayFilename).exists()) { - battleManager.replay(); - } else { - System.err.println("The specified battle record file '" + setup.replayFilename + "' was not found"); - System.exit(8); - } - } - } catch (Throwable e) { - Logger.logError(e); - } - } - - public void loadSetup(String[] args) { - - final String nosecMessage = "Robocode is running without a security manager.\n" - + "Robots have full access to your system.\n" + "You should only run robots which you trust!"; - final String exMessage = "Robocode is running in experimental mode.\n" - + "Robots have access to their IRobotPeer interfaces.\n" + "You should only run robots which you trust!"; - - if (RobocodeProperties.isSecurityOff()) { - Logger.logWarning(nosecMessage); - } - if (System.getProperty("EXPERIMENTAL", "false").equals("true")) { - Logger.logWarning(exMessage); - } - - setup.tps = properties.getOptionsBattleDesiredTPS(); - - // Disable canonical file path cache under Windows as it causes trouble when returning - // paths with differently-capitalized file names. - if (System.getProperty("os.name").toLowerCase().startsWith("windows ")) { - System.setProperty("sun.io.useCanonCaches", "false"); - } - - // Initialize the system property so the AWT does not use headless mode meaning that the - // GUI (Awt and Swing) is enabled per default when running starting Robocode. - // It might be set to true later, if the -nodisplay option is set (in the setEnableGUI method). - // Read more about headless mode here: - // http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/ - System.setProperty("java.awt.headless", "false"); - - for (int i = 0; i < args.length; i++) { - String currentArg = args[i]; - if (currentArg.equalsIgnoreCase("-cwd") && (i < args.length + 1)) { - changeDirectory(args[i + 1]); - i++; - } else if (currentArg.equalsIgnoreCase("-battle") && (i < args.length + 1)) { - setup.battleFilename = args[i + 1]; - i++; - } else if (currentArg.equalsIgnoreCase("-record") && (i < args.length + 1)) { - setup.recordFilename = args[i + 1]; - i++; - } else if (currentArg.equalsIgnoreCase("-recordXML") && (i < args.length + 1)) { - setup.recordXmlFilename = args[i + 1]; - i++; - } else if (currentArg.equalsIgnoreCase("-replay") && (i < args.length + 1)) { - setup.replayFilename = args[i + 1]; - i++; - } else if (currentArg.equalsIgnoreCase("-results") && (i < args.length + 1)) { - setup.resultsFilename = args[i + 1]; - i++; - } else if (currentArg.equalsIgnoreCase("-tps") && (i < args.length + 1)) { - setup.tps = Integer.parseInt(args[i + 1]); - if (setup.tps < 1) { - Logger.logError("tps must be > 0"); - System.exit(8); - } - i++; - } else if (currentArg.equalsIgnoreCase("-minimize")) { - setup.minimize = true; - } else if (currentArg.equalsIgnoreCase("-nodisplay")) { - if (windowManager != null) { - windowManager.setEnableGUI(false); - } - if (soundManager != null) { - soundManager.setEnableSound(false); - } - setup.tps = 10000; // set TPS to maximum - } else if (currentArg.equalsIgnoreCase("-nosound")) { - if (soundManager != null) { - soundManager.setEnableSound(false); - } - } else if (currentArg.equals("-?") || currentArg.equalsIgnoreCase("-help")) { - printUsage(); - System.exit(0); - } else { - Logger.logError("Not understood: " + currentArg); - printUsage(); - System.exit(8); - } - } - File robotsDir = FileUtil.getRobotsDir(); - - if (robotsDir == null) { - System.err.println("No valid robot directory is specified"); - System.exit(8); - } else if (!(robotsDir.exists() && robotsDir.isDirectory())) { - System.err.println('\'' + robotsDir.getAbsolutePath() + "' is not a valid robot directory"); - System.exit(8); - } - - // The Default Toolkit must be set as soon as we know if we are going to use headless mode or not. - // That is if the toolkit must be headless or not (GUI on/off). If we are running in headless mode - // from this point, a HeadlessException will be thrown if we access a AWT/Swing component. - // Read more about headless mode here: - // http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/ - Toolkit.getDefaultToolkit(); - } - - private void changeDirectory(String robocodeDir) { - try { - FileUtil.setCwd(new File(robocodeDir)); - } catch (IOException e) { - System.err.println(robocodeDir + " is not a valid directory to start Robocode in."); - System.exit(8); - } - } - - private void printUsage() { - System.out.print( - "Usage: robocode [-?] [-help] [-cwd path] [-battle filename [-results filename]\n" - + " [-record filename] [-recordXML filename] [-replay filename]\n" - + " [-tps tps] [-minimize] [-nodisplay] [-nosound]\n\n" + "where options include:\n" - + " -? or -help Prints out the command line usage of Robocode\n" - + " -cwd Change the current working directory\n" - + " -battle Run the battle specified in a battle file\n" - + " -results Save results to the specified text file\n" - + " -record Record the battle into the specified file as binary\n" - + " -recordXML Record the battle into the specified file as XML\n" - + " -replay Replay the specified battle record\n" - + " -tps Set the TPS > 0 (Turns Per Second)\n" - + " -minimize Run minimized when Robocode starts\n" - + " -nodisplay Run with the display / GUI disabled\n" - + " -nosound Run with sound disabled\n\n" + "Java Properties include:\n" - + " -DWORKINGDIRECTORY= Set the working directory\n" - + " -DROBOTPATH= Set the robots directory (default is 'robots')\n" - + " -DBATTLEPATH= Set the battles directory (default is 'battles')\n" - + " -DNOSECURITY=true|false Enable/disable Robocode's security manager\n" - + " -Ddebug=true|false Enable/disable debugging used for preventing\n" - + " robot timeouts and skipped turns, and allows an\n" - + " an unlimited painting buffer when debugging robots\n" - + " -DlogMessages=true|false Log messages and warnings will be disabled\n" - + " -DlogErrors=true|false Log errors will be disabled\n" - + " -DEXPERIMENTAL=true|false Enable/disable access to peer in robot interfaces\n" - + " -DPARALLEL=true|false Enable/disable parallel processing of robots turns\n" - + " -DRANDOMSEED= Set seed for deterministic behavior of random\n" - + " numbers\n"); - } - - private void printResultsData(BattleCompletedEvent event) { - // Do not print out if no result file has been specified and the GUI is enabled - if ((setup.resultsFilename == null && (!setup.exitOnComplete || windowManager.isGUIEnabled()))) { - return; - } - - PrintStream out = null; - FileOutputStream fos = null; - - try { - if (setup.resultsFilename == null) { - out = Logger.realOut; - } else { - File f = new File(setup.resultsFilename); - - try { - fos = new FileOutputStream(f); - out = new PrintStream(fos); - } catch (IOException e) { - Logger.logError(e); - } - } - if (out != null) { - BattleResultsTableModel resultsTable = new BattleResultsTableModel(event.getSortedResults(), - event.getBattleRules().getNumRounds()); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - resultsTable.print(new PrintStream(baos)); - out.append(StringUtil.toBasicLatin(baos.toString())); - } - } finally { - FileUtil.cleanupStream(out); - FileUtil.cleanupStream(fos); - } - } - - private class BattleObserver extends BattleAdaptor { - boolean isReplay; - - @Override - public void onBattleStarted(BattleStartedEvent event) { - isReplay = event.isReplay(); - } - - @Override - public void onBattleCompleted(BattleCompletedEvent event) { - if (!isReplay) { - printResultsData(event); - } - if (setup.recordFilename != null) { - recordManager.saveRecord(setup.recordFilename, BattleRecordFormat.BINARY_ZIP, - new SerializableOptions(false)); - } - if (setup.recordXmlFilename != null) { - recordManager.saveRecord(setup.recordXmlFilename, BattleRecordFormat.XML, new SerializableOptions(false)); - } - } - - @Override - public void onBattleMessage(BattleMessageEvent event) { - if (System.getProperty("logMessages", "true").equalsIgnoreCase("true")) { - Logger.realOut.println(event.getMessage()); - } - } - - @Override - public void onBattleError(BattleErrorEvent event) { - if (System.getProperty("logErrors", "true").equalsIgnoreCase("true")) { - Logger.realErr.println(event.getError()); - } - } - } - - public void cleanup() { - final IWindowManager windowManager = Container.getComponent(IWindowManager.class); - - if (windowManager != null) { - windowManager.cleanup(); - } - Container.getComponent(IBattleManager.class).cleanup(); - Container.getComponent(IHostManager.class).cleanup(); - } - - public void initForRobocodeEngine(IBattleListener listener) { - final IWindowManager windowManager = Container.getComponent(IWindowManager.class); - - if (windowManager != null) { - windowManager.setSlave(true); - windowManager.setEnableGUI(false); - } - Container.getComponent(IHostManager.class).initSecurity(); - if (listener != null) { - Container.getComponent(IBattleManager.class).addListener(listener); - } - Container.getComponent(ICpuManager.class).getCpuConstant(); - Container.getComponent(IRepositoryManager.class).reload(versionManager.isLastRunVersionChanged()); - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/RobocodeMainBase.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/RobocodeMainBase.java deleted file mode 100644 index 79e6db4..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/core/RobocodeMainBase.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.core; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import robocode.control.events.IBattleListener; - -import java.io.File; -import java.io.IOException; -import java.lang.Thread.UncaughtExceptionHandler; - - -/** - * There are entrypoints called with reflection from HiddenAccess in robocode.api module, - * they cross classloaders boundaries. - * - * @author Pavel Savara (original) - */ -public abstract class RobocodeMainBase implements Runnable { - public abstract void loadSetup(String[] args); - - public abstract void initForRobocodeEngine(IBattleListener listener); - - public abstract void cleanup(); - - // ----------- - // entrypoints called with reflection from HiddenAccess in robocode.api module - // ----------- - - public static void robocodeMain(Object args) { - // here we cross transition to EngineClassLoader classes using interface which is defined in system classLoader - RobocodeMainBase main = Container.getComponent(RobocodeMainBase.class); - - main.loadSetup((String[]) args); - - // Make sure ALL uncaught exceptions are logged - Thread.setDefaultUncaughtExceptionHandler(new UncaughtExceptionHandler() { - public void uncaughtException(Thread t, Throwable e) { - Logger.logError("UncaughtException on thread " + t.getClass(), e); - } - }); - - ThreadGroup group = new ThreadGroup("Robocode thread group"); - - new Thread(group, main, "Robocode main thread").start(); - } - - public static void initContainer() { - // here we cross transition to EngineClassLoader classes using interface which is defined in system classLoader - Container.init(); - } - - public static void cleanupForRobocodeEngine() { - // here we cross transition to EngineClassLoader classes using interface which is defined in system classLoader - RobocodeMainBase main = Container.getComponent(RobocodeMainBase.class); - - main.cleanup(); - } - - public static void initContainerForRobocodeEngine(File robocodeHome, IBattleListener listener) { - try { - if (robocodeHome == null) { - robocodeHome = FileUtil.getCwd(); - } - FileUtil.setCwd(robocodeHome); - - File robotsDir = FileUtil.getRobotsDir(); - - if (robotsDir == null) { - throw new RuntimeException("No valid robot directory is specified"); - } else if (!(robotsDir.exists() && robotsDir.isDirectory())) { - throw new RuntimeException('\'' + robotsDir.getAbsolutePath() + "' is not a valid robot directory"); - } - - } catch (IOException e) { - System.err.println(e); - return; - } - - // here we cross transition to EngineClassLoader classes using interface which is defined in system classLoader - RobocodeMainBase main = Container.getComponent(RobocodeMainBase.class); - - main.initForRobocodeEngine(listener); - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/ICpuManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/ICpuManager.java deleted file mode 100644 index 03bc90d..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/ICpuManager.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -/** - * @author Pavel Savara (original) - */ -public interface ICpuManager { - long getCpuConstant(); - - void calculateCpuConstant(); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/IHostManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/IHostManager.java deleted file mode 100644 index 8a80d46..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/IHostManager.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -import net.sf.robocode.peer.IRobotPeer; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.repository.RobotType; -import robocode.control.RobotSpecification; - -import java.io.PrintStream; - - -/** - * @author Pavel Savara (original) - */ -public interface IHostManager { - - void initSecurity(); - - long getRobotFilesystemQuota(); - - void resetThreadManager(); - - void addSafeThread(Thread safeThread); - - void removeSafeThread(Thread safeThread); - - PrintStream getRobotOutputStream(); - - Object createRobotProxy(RobotSpecification robotSpecification, RobotStatics statics, IRobotPeer peer); - - void cleanup(); - - String[] getReferencedClasses(IRobotItem robotItem); - - RobotType getRobotType(IRobotItem robotItem, boolean resolve, boolean message); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/IRobotClassLoader.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/IRobotClassLoader.java deleted file mode 100644 index 245b165..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/IRobotClassLoader.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -import robocode.robotinterfaces.IBasicRobot; - - -/** - * @author Pavel Savara (original) - */ -public interface IRobotClassLoader { - Class loadRobotMainClass(boolean resolve) throws ClassNotFoundException; - IBasicRobot createRobotInstance() throws ClassNotFoundException, InstantiationException, IllegalAccessException; - String[] getReferencedClasses(); - void setRobotProxy(Object robotProxy); - void cleanup(); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/RobotStatics.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/RobotStatics.java deleted file mode 100644 index 3f1367a..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/host/RobotStatics.java +++ /dev/null @@ -1,319 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.security.HiddenAccess; -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.BattleRules; -import robocode.control.RobotSpecification; - -import java.io.Serializable; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public final class RobotStatics implements IRobotStatics, Serializable { - private static final long serialVersionUID = 1L; - - private final String robocodeVersion; - - private final boolean isJuniorRobot; - private final boolean isAdvancedRobot; - private final boolean isTeamRobot; - private final boolean isDroid; - private final boolean isSentryRobot; - - private final boolean isInteractiveRobot; - private final boolean isPaintRobot; - - private final boolean isTeamLeader; - - private final String name; - private final String shortName; - private final String veryShortName; - - private final String fullClassName; - private final String shortClassName; - - private final BattleRules battleRules; - - private final String[] teammates; - private final String teamName; - - private final int robotIndex; - private final int teamIndex; - - public RobotStatics(RobotSpecification robotSpecification, int duplicate, boolean isLeader, BattleRules rules, String teamName, List teamMembers, int robotIndex, int teamIndex) { - IRobotItem robotItem = ((IRobotItem) HiddenAccess.getFileSpecification(robotSpecification)); - - this.robotIndex = robotIndex; - this.teamIndex = teamIndex; - - shortClassName = robotItem.getShortClassName(); - fullClassName = robotItem.getFullClassName(); - if (duplicate >= 0) { - String countString = " (" + (duplicate + 1) + ')'; - - name = robotItem.getUniqueFullClassNameWithVersion() + countString; - shortName = robotItem.getUniqueShortClassNameWithVersion() + countString; - veryShortName = robotItem.getUniqueVeryShortClassNameWithVersion() + countString; - } else { - name = robotItem.getUniqueFullClassNameWithVersion(); - shortName = robotItem.getUniqueShortClassNameWithVersion(); - veryShortName = robotItem.getUniqueVeryShortClassNameWithVersion(); - } - this.robocodeVersion = robotItem.getRobocodeVersion(); - this.isJuniorRobot = robotItem.isJuniorRobot(); - this.isAdvancedRobot = robotItem.isAdvancedRobot(); - this.isTeamRobot = robotItem.isTeamRobot(); - this.isDroid = robotItem.isDroid(); - this.isSentryRobot = robotItem.isSentryRobot(); - this.isInteractiveRobot = robotItem.isInteractiveRobot(); - this.isPaintRobot = robotItem.isPaintRobot(); - this.isTeamLeader = isLeader; - this.battleRules = rules; - - if (teamMembers != null) { - List list = new ArrayList(); - - for (String mate : teamMembers) { - if (!name.equals(mate)) { - list.add(mate); - } - } - teammates = list.toArray(new String[] {}); - this.teamName = teamName; - } else { - teammates = null; - this.teamName = name; - } - } - - private RobotStatics(String robocodeVersion, boolean isJuniorRobot, boolean isInteractiveRobot, boolean isPaintRobot, boolean isAdvancedRobot, - boolean isTeamRobot, boolean isTeamLeader, boolean isDroid, boolean isSentryRobot, String name, String shortName, - String veryShortName, String fullClassName, String shortClassName, BattleRules battleRules, - String[] teammates, String teamName, int robotIndex, int teamIndex) { - - this.robocodeVersion = robocodeVersion; - this.isJuniorRobot = isJuniorRobot; - this.isAdvancedRobot = isAdvancedRobot; - this.isTeamRobot = isTeamRobot; - this.isDroid = isDroid; - this.isSentryRobot = isSentryRobot; - this.isInteractiveRobot = isInteractiveRobot; - this.isPaintRobot = isPaintRobot; - this.isTeamLeader = isTeamLeader; - this.name = name; - this.shortName = shortName; - this.veryShortName = veryShortName; - this.fullClassName = fullClassName; - this.shortClassName = shortClassName; - this.battleRules = battleRules; - this.teammates = teammates; - this.teamName = teamName; - this.robotIndex = robotIndex; - this.teamIndex = teamIndex; - } - - public String getRobocodeVersion() { - return robocodeVersion; - } - - public String getAnnonymousName() { - return "#" + robotIndex; - } - - public boolean isJuniorRobot() { - return isJuniorRobot; - } - - public boolean isAdvancedRobot() { - return isAdvancedRobot; - } - - public boolean isTeamRobot() { - return isTeamRobot; - } - - public boolean isDroid() { - return isDroid; - } - - public boolean isSentryRobot() { - return isSentryRobot; - } - - public boolean isInteractiveRobot() { - return isInteractiveRobot; - } - - public boolean isPaintRobot() { - return isPaintRobot; - } - - public boolean isTeamLeader() { - return isTeamLeader; - } - - public String getName() { - return name; - } - - public String getShortName() { - return shortName; - } - - public String getVeryShortName() { - return veryShortName; - } - - public String getFullClassName() { - return fullClassName; - } - - public String getShortClassName() { - return shortClassName; - } - - public BattleRules getBattleRules() { - return battleRules; - } - - public String[] getTeammates() { - return teammates == null ? null : teammates.clone(); - } - - public String getTeamName() { - return teamName; - } - - public int getRobotIndex() { - return robotIndex; - } - - public int getTeamIndex() { - return teamIndex; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - RobotStatics obj = (RobotStatics) object; - int size = RbSerializer.SIZEOF_TYPEINFO + serializer.sizeOf(obj.robocodeVersion) - + RbSerializer.SIZEOF_BOOL * 9 + serializer.sizeOf(obj.name) + serializer.sizeOf(obj.shortName) - + serializer.sizeOf(obj.veryShortName) + serializer.sizeOf(obj.fullClassName) - + serializer.sizeOf(obj.shortClassName) + RbSerializer.SIZEOF_INT * 6 + RbSerializer.SIZEOF_DOUBLE - + RbSerializer.SIZEOF_LONG; - - if (obj.teammates != null) { - for (String mate : obj.teammates) { - size += serializer.sizeOf(mate); - } - } - size += RbSerializer.SIZEOF_INT; - size += serializer.sizeOf(obj.teamName); - - return size; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - RobotStatics obj = (RobotStatics) object; - - serializer.serialize(buffer, obj.robocodeVersion); - serializer.serialize(buffer, obj.isJuniorRobot); - serializer.serialize(buffer, obj.isInteractiveRobot); - serializer.serialize(buffer, obj.isPaintRobot); - serializer.serialize(buffer, obj.isAdvancedRobot); - serializer.serialize(buffer, obj.isTeamRobot); - serializer.serialize(buffer, obj.isTeamLeader); - serializer.serialize(buffer, obj.isDroid); - serializer.serialize(buffer, obj.isSentryRobot); - serializer.serialize(buffer, obj.name); - serializer.serialize(buffer, obj.shortName); - serializer.serialize(buffer, obj.veryShortName); - serializer.serialize(buffer, obj.fullClassName); - serializer.serialize(buffer, obj.shortClassName); - serializer.serialize(buffer, obj.battleRules.getBattlefieldWidth()); - serializer.serialize(buffer, obj.battleRules.getBattlefieldHeight()); - serializer.serialize(buffer, obj.battleRules.getNumRounds()); - serializer.serialize(buffer, obj.battleRules.getGunCoolingRate()); - serializer.serialize(buffer, obj.battleRules.getInactivityTime()); - serializer.serialize(buffer, obj.battleRules.getHideEnemyNames()); - serializer.serialize(buffer, obj.battleRules.getSentryBorderSize()); - if (obj.teammates != null) { - for (String mate : obj.teammates) { - serializer.serialize(buffer, mate); - } - } - buffer.putInt(-1); - serializer.serialize(buffer, obj.teamName); - serializer.serialize(buffer, obj.robotIndex); - serializer.serialize(buffer, obj.teamIndex); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - - String robocodeVersion = serializer.deserializeString(buffer); - boolean isJuniorRobot = serializer.deserializeBoolean(buffer); - boolean isInteractiveRobot = serializer.deserializeBoolean(buffer); - boolean isPaintRobot = serializer.deserializeBoolean(buffer); - boolean isAdvancedRobot = serializer.deserializeBoolean(buffer); - boolean isTeamRobot = serializer.deserializeBoolean(buffer); - boolean isTeamLeader = serializer.deserializeBoolean(buffer); - boolean isDroid = serializer.deserializeBoolean(buffer); - boolean isSentryRobot = serializer.deserializeBoolean(buffer); - String name = serializer.deserializeString(buffer); - String shortName = serializer.deserializeString(buffer); - String veryShortName = serializer.deserializeString(buffer); - String fullClassName = serializer.deserializeString(buffer); - String shortClassName = serializer.deserializeString(buffer); - - BattleRules battleRules = HiddenAccess.createRules(serializer.deserializeInt(buffer), // battleFieldWidth - serializer.deserializeInt(buffer), // battleFieldHeight - serializer.deserializeInt(buffer), // numOfRounds - serializer.deserializeDouble(buffer), // gunCoolingRate - serializer.deserializeLong(buffer), // inactivityTime - serializer.deserializeBoolean(buffer), // hideEnemyNames - serializer.deserializeInt(buffer)); // sentryBorderSize - - List teammates = new ArrayList(); - Object item = serializer.deserializeString(buffer); - - if (item == null) { - teammates = null; - } - while (item != null) { - if (item instanceof String) { - teammates.add((String) item); - } - item = serializer.deserializeString(buffer); - } - - String teamName = serializer.deserializeString(buffer); - int index = serializer.deserializeInt(buffer); - int contestantIndex = serializer.deserializeInt(buffer); - - return new RobotStatics(robocodeVersion, isJuniorRobot, isInteractiveRobot, isPaintRobot, isAdvancedRobot, - isTeamRobot, isTeamLeader, isDroid, isSentryRobot, name, shortName, veryShortName, fullClassName, - shortClassName, battleRules, teammates.toArray(new String[teammates.size()]), teamName, index, - contestantIndex); - } - } - -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/io/JarJar.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/io/JarJar.java deleted file mode 100644 index 720dc88..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/io/JarJar.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.io; - - -/** - * @author Pavel Savara (original) - */ -public class JarJar { - public final static char SEPARATOR_CHAR = '^'; - public final static String SEPARATOR = SEPARATOR_CHAR + "/"; -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/io/URLJarCollector.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/io/URLJarCollector.java deleted file mode 100644 index 89727db..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/io/URLJarCollector.java +++ /dev/null @@ -1,176 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.io; - - -import java.net.URLConnection; -import java.net.URL; -import java.net.URLDecoder; -import java.lang.reflect.Field; -import java.util.*; -import java.util.jar.JarFile; -import java.io.File; -import java.io.IOException; - - -/** - * This ugly class is helping with closing of robot .jar files when used with URL, URLConnection and useCaches=true - * It is designed to close JarFiles opened and cached in SUN's JarFileFactory. - * If we are not on SUN's JVM, we fallback to useCaches=false, to not lock the files. - * Collection is now called after reposiotry refresh and after battle ended. - * Collection is disabled/posponed during running battle. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class URLJarCollector { - - private static HashMap fileCache; - private static HashMap urlCache; - private static Field jarFileURL; - private static final boolean sunJVM; - private static boolean enabled; - private static Set urlsToClean = new HashSet(); - - static { - boolean localSunJVM = false; - - try { - final Class jarFactory = ClassLoader.getSystemClassLoader().loadClass( - "sun.net.www.protocol.jar.JarFileFactory"); - final Field fileCacheF = jarFactory.getDeclaredField("fileCache"); - - fileCacheF.setAccessible(true); - fileCache = (HashMap) fileCacheF.get(null); - - final Field urlCacheF = jarFactory.getDeclaredField("urlCache"); - - urlCacheF.setAccessible(true); - urlCache = (HashMap) urlCacheF.get(null); - - final Class jarURLConnection = ClassLoader.getSystemClassLoader().loadClass( - "sun.net.www.protocol.jar.JarURLConnection"); - - jarFileURL = jarURLConnection.getDeclaredField("jarFileURL"); - jarFileURL.setAccessible(true); - - localSunJVM = true; - } catch (ClassNotFoundException ignore) { - Logger.logError(ignore); - } catch (NoSuchFieldException ignore) { - Logger.logError(ignore); - } catch (IllegalAccessException ignore) { - Logger.logError(ignore); - } - sunJVM = localSunJVM; - } - - public static synchronized URLConnection openConnection(URL url) throws IOException { - // Logger.logMessage("Open connection to URL: " + url); - final URLConnection urlConnection = url.openConnection(); - - if (sunJVM) { - registerConnection(urlConnection); - urlConnection.setUseCaches(true); - } else { - urlConnection.setUseCaches(false); - } - return urlConnection; - } - - public static synchronized void enableGc(boolean enabled) { - URLJarCollector.enabled = enabled; - } - - public static synchronized void gc() { - if (sunJVM) { - // Close all JarURLConnections if garbage collection is enabled - if (enabled) { - synchronized (urlsToClean) { - for (URL url : urlsToClean) { - closeJarURLConnection(url); - } - urlsToClean.clear(); - } - } - - // Bug fix [2867326] - Lockup on start if too many bots in robots dir (cont'd). - - // Remove all cache entries to temporary jar cache files created - // for connections using the jarjar protocol that get stuck up. - for (Iterator it = fileCache.keySet().iterator(); it.hasNext();) { - Object urlJarFile = it.next(); - - final JarFile jarFile = (JarFile) fileCache.get(urlJarFile); - - String filename = jarFile.getName(); - - filename = filename.substring(filename.lastIndexOf(File.separatorChar) + 1).toLowerCase(); - - if (filename.startsWith("jar_cache")) { - it.remove(); - synchronized (urlCache) { - urlCache.remove(jarFile); - } - } - } - } - } - - private static void registerConnection(URLConnection conn) { - if (conn != null) { - final String cl = conn.getClass().getName(); - - if (cl.equals("sun.net.www.protocol.jar.JarURLConnection")) { - try { - final URL url = (URL) jarFileURL.get(conn); - - if (!urlsToClean.contains(url)) { - synchronized (urlsToClean) { - urlsToClean.add(url); - } - } - } catch (IllegalAccessException ignore) {} - } - } - } - - // Added due to bug fix [2867326] - Lockup on start if too many bots in robots dir (cont'd). - public synchronized static void closeJarURLConnection(URL url) { - if (url != null) { - for (Iterator it = fileCache.keySet().iterator(); it.hasNext();) { - Object urlJarFile = it.next(); - - final JarFile jarFile = (JarFile) fileCache.get(urlJarFile); - - String urlPath = url.getPath(); - - try { - urlPath = URLDecoder.decode(urlPath, "UTF-8"); - } catch (java.io.UnsupportedEncodingException ignore) {} - - File urlFile = new File(urlPath); - - String jarFileName = jarFile.getName(); - String urlFileName = urlFile.getPath(); - - if (urlFileName.equals(jarFileName)) { - it.remove(); - synchronized (urlCache) { - urlCache.remove(jarFile); - } - try { - jarFile.close(); - } catch (IOException e) { - Logger.logError(e); - } - } - } - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/BadBehavior.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/BadBehavior.java deleted file mode 100644 index 502bcb8..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/BadBehavior.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.peer; - - -/** - * @author Flemming N. Larsen (original) - */ -public enum BadBehavior { - CANNOT_START, - SKIPPED_TOO_MANY_TURNS, - UNSTOPPABLE, - SECURITY_VIOLATION -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/BulletCommand.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/BulletCommand.java deleted file mode 100644 index 2a0cd54..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/BulletCommand.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.peer; - - -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; - -import java.io.Serializable; -import java.nio.ByteBuffer; - - -/** - * @author Pavel Savara (original) - */ -public class BulletCommand implements Serializable { - private static final long serialVersionUID = 1L; - - public BulletCommand(double power, boolean fireAssistValid, double fireAssistAngle, int bulletId) { - this.fireAssistValid = fireAssistValid; - this.fireAssistAngle = fireAssistAngle; - this.bulletId = bulletId; - this.power = power; - } - - private final double power; - private final boolean fireAssistValid; - private final double fireAssistAngle; - private final int bulletId; - - public boolean isFireAssistValid() { - return fireAssistValid; - } - - public int getBulletId() { - return bulletId; - } - - public double getPower() { - return power; - } - - public double getFireAssistAngle() { - return fireAssistAngle; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_DOUBLE + RbSerializer.SIZEOF_BOOL - + RbSerializer.SIZEOF_DOUBLE + RbSerializer.SIZEOF_INT; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - BulletCommand obj = (BulletCommand) object; - - serializer.serialize(buffer, obj.power); - serializer.serialize(buffer, obj.fireAssistValid); - serializer.serialize(buffer, obj.fireAssistAngle); - serializer.serialize(buffer, obj.bulletId); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - double power = buffer.getDouble(); - boolean fireAssistValid = serializer.deserializeBoolean(buffer); - double fireAssistAngle = buffer.getDouble(); - int bulletId = buffer.getInt(); - - return new BulletCommand(power, fireAssistValid, fireAssistAngle, bulletId); - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/BulletStatus.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/BulletStatus.java deleted file mode 100644 index 7fef56f..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/BulletStatus.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.peer; - - -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; - -import java.io.Serializable; -import java.nio.ByteBuffer; - - -/** - * @author Pavel Savara (original) - */ -public class BulletStatus implements Serializable { - private static final long serialVersionUID = 1L; - - public BulletStatus(int bulletId, double x, double y, String victimName, boolean isActive) { - this.bulletId = bulletId; - this.x = x; - this.y = y; - this.isActive = isActive; - this.victimName = victimName; - } - - public final int bulletId; - public final String victimName; - public final boolean isActive; - public final double x; - public final double y; - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - BulletStatus obj = (BulletStatus) object; - - return RbSerializer.SIZEOF_TYPEINFO + RbSerializer.SIZEOF_INT + serializer.sizeOf(obj.victimName) - + RbSerializer.SIZEOF_BOOL + 2 * RbSerializer.SIZEOF_DOUBLE; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - BulletStatus obj = (BulletStatus) object; - - serializer.serialize(buffer, obj.bulletId); - serializer.serialize(buffer, obj.victimName); - serializer.serialize(buffer, obj.isActive); - serializer.serialize(buffer, obj.x); - serializer.serialize(buffer, obj.y); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - int bulletId = buffer.getInt(); - String victimName = serializer.deserializeString(buffer); - boolean isActive = serializer.deserializeBoolean(buffer); - double x = buffer.getDouble(); - double y = buffer.getDouble(); - - return new BulletStatus(bulletId, x, y, victimName, isActive); - } - } - -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/DebugProperty.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/DebugProperty.java deleted file mode 100644 index 62ff930..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/DebugProperty.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.peer; - - -import net.sf.robocode.serialization.*; -import robocode.control.snapshot.IDebugProperty; - -import java.io.IOException; -import java.io.Serializable; -import java.nio.ByteBuffer; - - -/** - * @author Pavel Savara (original) - */ -public class DebugProperty implements Serializable, IXmlSerializable, IDebugProperty { - private static final long serialVersionUID = 1L; - - public DebugProperty() {} - - public DebugProperty(String key, String value) { - this.setKey(key); - this.setValue(value); - } - - private String key; - private String value; - - public void writeXml(XmlWriter writer, SerializableOptions options) throws IOException { - writer.startElement("debug"); { - writer.writeAttribute("key", getKey()); - writer.writeAttribute("value", getValue()); - } - writer.endElement(); - } - - public XmlReader.Element readXml(XmlReader reader) { - return reader.expect("debug", new XmlReader.Element() { - public IXmlSerializable read(XmlReader reader) { - final DebugProperty snapshot = new DebugProperty(); - - reader.expect("key", new XmlReader.Attribute() { - public void read(String value) { - snapshot.setKey(value); - } - }); - - reader.expect("value", new XmlReader.Attribute() { - public void read(String value) { - snapshot.setValue(value); - } - }); - - return snapshot; - } - }); - } - - public String getKey() { - return key; - } - - public void setKey(String key) { - this.key = key; - } - - public String getValue() { - return value; - } - - public void setValue(String value) { - this.value = value; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - DebugProperty obj = (DebugProperty) object; - - return RbSerializer.SIZEOF_TYPEINFO + serializer.sizeOf(obj.key) + serializer.sizeOf(obj.value); - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - DebugProperty obj = (DebugProperty) object; - - serializer.serialize(buffer, obj.key); - serializer.serialize(buffer, obj.value); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - String key = serializer.deserializeString(buffer); - String value = serializer.deserializeString(buffer); - - return new DebugProperty(key, value); - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/ExecCommands.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/ExecCommands.java deleted file mode 100644 index bc089d7..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/ExecCommands.java +++ /dev/null @@ -1,428 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.peer; - - -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.Rules; - -import java.io.Serializable; -import static java.lang.Math.abs; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public final class ExecCommands implements Serializable { - private static final long serialVersionUID = 1L; - public static final int defaultBodyColor = 0xFF29298C; - public static final int defaultGunColor = 0xFF29298C; - public static final int defaultRadarColor = 0xFF29298C; - public static final int defaultScanColor = 0xFF0000FF; - public static final int defaultBulletColor = 0xFFFFFFFF; - - private double bodyTurnRemaining; - private double radarTurnRemaining; - private double gunTurnRemaining; - private double distanceRemaining; - - private boolean isAdjustGunForBodyTurn; - private boolean isAdjustRadarForGunTurn; - private boolean isAdjustRadarForBodyTurn; - private boolean isAdjustRadarForBodyTurnSet; - - private int bodyColor = defaultBodyColor; - private int gunColor = defaultGunColor; - private int radarColor = defaultRadarColor; - private int scanColor = defaultScanColor; - private int bulletColor = defaultBulletColor; - private double maxTurnRate; - private double maxVelocity; - - private boolean moved; - private boolean scan; - private boolean isIORobot; - private boolean isTryingToPaint; - private String outputText; - private List bullets = new ArrayList(); - private List teamMessages = new ArrayList(); - private List debugProperties = new ArrayList(); - private Object graphicsCalls; - - public ExecCommands() { - setMaxVelocity(Double.MAX_VALUE); - setMaxTurnRate(Double.MAX_VALUE); - } - - public ExecCommands(ExecCommands origin, boolean fromRobot) { - bodyTurnRemaining = origin.bodyTurnRemaining; - radarTurnRemaining = origin.radarTurnRemaining; - gunTurnRemaining = origin.gunTurnRemaining; - distanceRemaining = origin.distanceRemaining; - isAdjustGunForBodyTurn = origin.isAdjustGunForBodyTurn; - isAdjustRadarForGunTurn = origin.isAdjustRadarForGunTurn; - isAdjustRadarForBodyTurn = origin.isAdjustRadarForBodyTurn; - isAdjustRadarForBodyTurnSet = origin.isAdjustRadarForBodyTurnSet; - maxTurnRate = origin.maxTurnRate; - maxVelocity = origin.maxVelocity; - copyColors(origin); - if (fromRobot) { - debugProperties = origin.debugProperties; - bullets = origin.bullets; - scan = origin.scan; - moved = origin.moved; - graphicsCalls = origin.graphicsCalls; - outputText = origin.outputText; - teamMessages = origin.teamMessages; - isTryingToPaint = origin.isTryingToPaint; - } - } - - public void copyColors(ExecCommands origin) { - if (origin != null) { - bodyColor = origin.bodyColor; - gunColor = origin.gunColor; - radarColor = origin.radarColor; - bulletColor = origin.bulletColor; - scanColor = origin.scanColor; - } - } - - public int getBodyColor() { - return bodyColor; - } - - public int getRadarColor() { - return radarColor; - } - - public int getGunColor() { - return gunColor; - } - - public int getBulletColor() { - return bulletColor; - } - - public int getScanColor() { - return scanColor; - } - - public void setBodyColor(int color) { - bodyColor = color; - } - - public void setRadarColor(int color) { - radarColor = color; - } - - public void setGunColor(int color) { - gunColor = color; - } - - public void setBulletColor(int color) { - bulletColor = color; - } - - public void setScanColor(int color) { - scanColor = color; - } - - public double getBodyTurnRemaining() { - return bodyTurnRemaining; - } - - public void setBodyTurnRemaining(double bodyTurnRemaining) { - this.bodyTurnRemaining = bodyTurnRemaining; - } - - public double getRadarTurnRemaining() { - return radarTurnRemaining; - } - - public void setRadarTurnRemaining(double radarTurnRemaining) { - this.radarTurnRemaining = radarTurnRemaining; - } - - public double getGunTurnRemaining() { - return gunTurnRemaining; - } - - public void setGunTurnRemaining(double gunTurnRemaining) { - this.gunTurnRemaining = gunTurnRemaining; - } - - public double getDistanceRemaining() { - return distanceRemaining; - } - - public void setDistanceRemaining(double distanceRemaining) { - this.distanceRemaining = distanceRemaining; - } - - public boolean isAdjustGunForBodyTurn() { - return isAdjustGunForBodyTurn; - } - - public void setAdjustGunForBodyTurn(boolean adjustGunForBodyTurn) { - isAdjustGunForBodyTurn = adjustGunForBodyTurn; - } - - public boolean isAdjustRadarForGunTurn() { - return isAdjustRadarForGunTurn; - } - - public void setAdjustRadarForGunTurn(boolean adjustRadarForGunTurn) { - isAdjustRadarForGunTurn = adjustRadarForGunTurn; - } - - public boolean isAdjustRadarForBodyTurn() { - return isAdjustRadarForBodyTurn; - } - - public void setAdjustRadarForBodyTurn(boolean adjustRadarForBodyTurn) { - isAdjustRadarForBodyTurn = adjustRadarForBodyTurn; - } - - public boolean isAdjustRadarForBodyTurnSet() { - return isAdjustRadarForBodyTurnSet; - } - - public void setAdjustRadarForBodyTurnSet(boolean adjustRadarForBodyTurnSet) { - isAdjustRadarForBodyTurnSet = adjustRadarForBodyTurnSet; - } - - public double getMaxTurnRate() { - return maxTurnRate; - } - - public void setMaxTurnRate(double maxTurnRate) { - this.maxTurnRate = Math.min(abs(maxTurnRate), Rules.MAX_TURN_RATE_RADIANS); - } - - public double getMaxVelocity() { - return maxVelocity; - } - - public void setMaxVelocity(double maxVelocity) { - this.maxVelocity = Math.min(abs(maxVelocity), Rules.MAX_VELOCITY); - } - - public boolean isMoved() { - return moved; - } - - public void setMoved(boolean moved) { - this.moved = moved; - } - - public boolean isScan() { - return scan; - } - - public void setScan(boolean scan) { - this.scan = scan; - } - - public List getBullets() { - return bullets; - } - - public Object getGraphicsCalls() { - return graphicsCalls; - } - - public List getDebugProperties() { - return debugProperties; - } - - public void setGraphicsCalls(Object graphicsCalls) { - this.graphicsCalls = graphicsCalls; - } - - public String getOutputText() { - final String out = outputText; - - outputText = ""; - if (out == null) { - return ""; - } - return out; - } - - public void setOutputText(String out) { - outputText = out; - } - - public List getTeamMessages() { - return teamMessages; - } - - public boolean isIORobot() { - return isIORobot; - } - - public void setIORobot() { - isIORobot = true; - } - - public void setDebugProperty(String key, String value) { - debugProperties.add(new DebugProperty(key, value)); - } - - public boolean isTryingToPaint() { - return isTryingToPaint; - } - - public void setTryingToPaint(boolean tryingToPaint) { - isTryingToPaint = tryingToPaint; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - ExecCommands obj = (ExecCommands) object; - int size = RbSerializer.SIZEOF_TYPEINFO + 4 * RbSerializer.SIZEOF_DOUBLE; - - size += 4 * RbSerializer.SIZEOF_BOOL; - size += 5 * RbSerializer.SIZEOF_INT; - size += 2 * RbSerializer.SIZEOF_DOUBLE; - size += 4 * RbSerializer.SIZEOF_BOOL; - size += serializer.sizeOf(obj.outputText); - - size += serializer.sizeOf((byte[]) obj.graphicsCalls); - - // bullets - size += obj.bullets.size() * serializer.sizeOf(RbSerializer.BulletCommand_TYPE, null); - size += 1; - - // messages - for (TeamMessage m : obj.teamMessages) { - size += serializer.sizeOf(RbSerializer.TeamMessage_TYPE, m); - } - size += 1; - - // properties - for (DebugProperty d : obj.debugProperties) { - size += serializer.sizeOf(RbSerializer.DebugProperty_TYPE, d); - } - size += 1; - - return size; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - ExecCommands obj = (ExecCommands) object; - - serializer.serialize(buffer, obj.bodyTurnRemaining); - serializer.serialize(buffer, obj.radarTurnRemaining); - serializer.serialize(buffer, obj.gunTurnRemaining); - serializer.serialize(buffer, obj.distanceRemaining); - - serializer.serialize(buffer, obj.isAdjustGunForBodyTurn); - serializer.serialize(buffer, obj.isAdjustRadarForGunTurn); - serializer.serialize(buffer, obj.isAdjustRadarForBodyTurn); - serializer.serialize(buffer, obj.isAdjustRadarForBodyTurnSet); - - serializer.serialize(buffer, obj.bodyColor); - serializer.serialize(buffer, obj.gunColor); - serializer.serialize(buffer, obj.radarColor); - serializer.serialize(buffer, obj.scanColor); - serializer.serialize(buffer, obj.bulletColor); - - serializer.serialize(buffer, obj.maxTurnRate); - serializer.serialize(buffer, obj.maxVelocity); - - serializer.serialize(buffer, obj.moved); - serializer.serialize(buffer, obj.scan); - serializer.serialize(buffer, obj.isIORobot); - serializer.serialize(buffer, obj.isTryingToPaint); - - serializer.serialize(buffer, obj.outputText); - - serializer.serialize(buffer, (byte[]) obj.graphicsCalls); - - for (BulletCommand bullet : obj.bullets) { - serializer.serialize(buffer, RbSerializer.BulletCommand_TYPE, bullet); - } - buffer.put(RbSerializer.TERMINATOR_TYPE); - for (TeamMessage message : obj.teamMessages) { - serializer.serialize(buffer, RbSerializer.TeamMessage_TYPE, message); - } - buffer.put(RbSerializer.TERMINATOR_TYPE); - for (DebugProperty prop : obj.debugProperties) { - serializer.serialize(buffer, RbSerializer.DebugProperty_TYPE, prop); - } - buffer.put(RbSerializer.TERMINATOR_TYPE); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - ExecCommands res = new ExecCommands(); - - res.bodyTurnRemaining = buffer.getDouble(); - res.radarTurnRemaining = buffer.getDouble(); - res.gunTurnRemaining = buffer.getDouble(); - res.distanceRemaining = buffer.getDouble(); - - res.isAdjustGunForBodyTurn = serializer.deserializeBoolean(buffer); - res.isAdjustRadarForGunTurn = serializer.deserializeBoolean(buffer); - res.isAdjustRadarForBodyTurn = serializer.deserializeBoolean(buffer); - res.isAdjustRadarForBodyTurnSet = serializer.deserializeBoolean(buffer); - - res.bodyColor = buffer.getInt(); - res.gunColor = buffer.getInt(); - res.radarColor = buffer.getInt(); - res.scanColor = buffer.getInt(); - res.bulletColor = buffer.getInt(); - - res.maxTurnRate = buffer.getDouble(); - res.maxVelocity = buffer.getDouble(); - - res.moved = serializer.deserializeBoolean(buffer); - res.scan = serializer.deserializeBoolean(buffer); - res.isIORobot = serializer.deserializeBoolean(buffer); - res.isTryingToPaint = serializer.deserializeBoolean(buffer); - - res.outputText = serializer.deserializeString(buffer); - - res.graphicsCalls = serializer.deserializeBytes(buffer); - - Object item = serializer.deserializeAny(buffer); - - while (item != null) { - if (item instanceof BulletCommand) { - res.bullets.add((BulletCommand) item); - } - item = serializer.deserializeAny(buffer); - } - item = serializer.deserializeAny(buffer); - while (item != null) { - if (item instanceof TeamMessage) { - res.teamMessages.add((TeamMessage) item); - } - item = serializer.deserializeAny(buffer); - } - item = serializer.deserializeAny(buffer); - while (item != null) { - if (item instanceof DebugProperty) { - res.debugProperties.add((DebugProperty) item); - } - item = serializer.deserializeAny(buffer); - } - return res; - } - } -} - diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/ExecResults.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/ExecResults.java deleted file mode 100644 index c24330c..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/ExecResults.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.peer; - - -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; -import robocode.Event; -import robocode.RobotStatus; - -import java.io.Serializable; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public final class ExecResults implements Serializable { - private static final long serialVersionUID = 1L; - - private ExecCommands commands; - private RobotStatus status; - private List events; - private List teamMessages; - private List bulletUpdates; - private boolean halt; - private boolean shouldWait; - private boolean paintEnabled; - - public ExecResults(ExecCommands commands, RobotStatus status, List events, List teamMessages, List bulletUpdates, boolean halt, boolean shouldWait, boolean paintEnabled) { - this.commands = commands; - this.status = status; - this.events = events; - this.teamMessages = teamMessages; - this.bulletUpdates = bulletUpdates; - this.halt = halt; - this.shouldWait = shouldWait; - this.paintEnabled = paintEnabled; - } - - private ExecResults() {} - - public ExecCommands getCommands() { - return commands; - } - - public RobotStatus getStatus() { - return status; - } - - public List getEvents() { - return events; - } - - public List getTeamMessages() { - return teamMessages; - } - - public List getBulletUpdates() { - return bulletUpdates; - } - - public boolean isHalt() { - return halt; - } - - public boolean isShouldWait() { - return shouldWait; - } - - public boolean isPaintEnabled() { - return paintEnabled; - } - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - ExecResults obj = (ExecResults) object; - int size = RbSerializer.SIZEOF_TYPEINFO + 3 * RbSerializer.SIZEOF_BOOL; - - size += serializer.sizeOf(RbSerializer.ExecCommands_TYPE, obj.commands); - size += serializer.sizeOf(RbSerializer.RobotStatus_TYPE, obj.status); - - // events - for (Event event : obj.events) { - size += serializer.sizeOf(event); - } - size += 1; - - // messages - for (TeamMessage m : obj.teamMessages) { - size += serializer.sizeOf(RbSerializer.TeamMessage_TYPE, m); - } - size += 1; - - // bullets - for (BulletStatus b : obj.bulletUpdates) { - size += serializer.sizeOf(RbSerializer.BulletStatus_TYPE, b); - } - size += 1; - - return size; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - ExecResults obj = (ExecResults) object; - - serializer.serialize(buffer, obj.halt); - serializer.serialize(buffer, obj.shouldWait); - serializer.serialize(buffer, obj.paintEnabled); - - serializer.serialize(buffer, RbSerializer.ExecCommands_TYPE, obj.commands); - serializer.serialize(buffer, RbSerializer.RobotStatus_TYPE, obj.status); - - for (Event event : obj.events) { - serializer.serialize(buffer, event); - } - buffer.put(RbSerializer.TERMINATOR_TYPE); - for (TeamMessage message : obj.teamMessages) { - serializer.serialize(buffer, RbSerializer.TeamMessage_TYPE, message); - } - buffer.put(RbSerializer.TERMINATOR_TYPE); - for (BulletStatus bulletStatus : obj.bulletUpdates) { - serializer.serialize(buffer, RbSerializer.BulletStatus_TYPE, bulletStatus); - } - buffer.put(RbSerializer.TERMINATOR_TYPE); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - ExecResults res = new ExecResults(); - - res.halt = serializer.deserializeBoolean(buffer); - res.shouldWait = serializer.deserializeBoolean(buffer); - res.paintEnabled = serializer.deserializeBoolean(buffer); - - res.commands = (ExecCommands) serializer.deserializeAny(buffer); - res.status = (RobotStatus) serializer.deserializeAny(buffer); - - res.events = new ArrayList(); - res.teamMessages = new ArrayList(); - res.bulletUpdates = new ArrayList(); - Object item = serializer.deserializeAny(buffer); - - while (item != null) { - if (item instanceof Event) { - res.events.add((Event) item); - } - item = serializer.deserializeAny(buffer); - } - item = serializer.deserializeAny(buffer); - while (item != null) { - if (item instanceof TeamMessage) { - res.teamMessages.add((TeamMessage) item); - } - item = serializer.deserializeAny(buffer); - } - item = serializer.deserializeAny(buffer); - while (item != null) { - if (item instanceof BulletStatus) { - res.bulletUpdates.add((BulletStatus) item); - } - item = serializer.deserializeAny(buffer); - } - return res; - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/IRobotPeer.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/IRobotPeer.java deleted file mode 100644 index faf5f63..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/IRobotPeer.java +++ /dev/null @@ -1,39 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.peer; - - -import java.io.IOException; -import java.nio.ByteBuffer; - - -/** - * @author Pavel Savara (original) - */ -public interface IRobotPeer { - - void drainEnergy(); - - void punishBadBehavior(BadBehavior badBehavior); - - void setRunning(boolean value); - - boolean isRunning(); - - ExecResults waitForBattleEndImpl(ExecCommands newCommands); - - ExecResults executeImpl(ExecCommands newCommands); - - void setupBuffer(ByteBuffer bidirectionalBuffer); // NO_UCD (unused code - used by the .NET plug-in) - - void executeImplSerial() throws IOException; // NO_UCD (unused code - used by the .NET plug-in) - - void waitForBattleEndImplSerial() throws IOException; // NO_UCD (unused code - used by the .NET plug-in) - - void setupThread(); // NO_UCD (unused code - used by the .NET plug-in) -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/TeamMessage.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/TeamMessage.java deleted file mode 100644 index 5db0dc1..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/peer/TeamMessage.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.peer; - - -import net.sf.robocode.serialization.ISerializableHelper; -import net.sf.robocode.serialization.RbSerializer; - -import java.io.Serializable; -import java.nio.ByteBuffer; - - -/** - * @author Pavel Savara (original) - */ -public class TeamMessage implements Serializable { - private static final long serialVersionUID = 1L; - - public TeamMessage(String sender, String recipient, byte[] message) { - this.sender = sender; - this.recipient = recipient; - this.message = message; - - } - - public final String sender; - public final String recipient; - public final byte[] message; - - static ISerializableHelper createHiddenSerializer() { - return new SerializableHelper(); - } - - private static class SerializableHelper implements ISerializableHelper { - public int sizeOf(RbSerializer serializer, Object object) { - TeamMessage obj = (TeamMessage) object; - final int s = serializer.sizeOf(obj.sender); - final int r = serializer.sizeOf(obj.recipient); - final int m = serializer.sizeOf(obj.message); - - return RbSerializer.SIZEOF_TYPEINFO + s + r + m; - } - - public void serialize(RbSerializer serializer, ByteBuffer buffer, Object object) { - TeamMessage obj = (TeamMessage) object; - - serializer.serialize(buffer, obj.sender); - serializer.serialize(buffer, obj.recipient); - serializer.serialize(buffer, obj.message); - } - - public Object deserialize(RbSerializer serializer, ByteBuffer buffer) { - String sender = serializer.deserializeString(buffer); - String recipient = serializer.deserializeString(buffer); - byte[] message = serializer.deserializeBytes(buffer); - - return new TeamMessage(sender, recipient, message); - } - } - -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/recording/BattleRecordFormat.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/recording/BattleRecordFormat.java deleted file mode 100644 index c4b825d..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/recording/BattleRecordFormat.java +++ /dev/null @@ -1,19 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.recording; - - -/** - * @author Flemming N. Larsen (original) - */ -public enum BattleRecordFormat { - BINARY, - BINARY_ZIP, - XML, - XML_ZIP -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/recording/IRecordManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/recording/IRecordManager.java deleted file mode 100644 index 4a50d66..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/recording/IRecordManager.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.recording; - - -import net.sf.robocode.battle.events.BattleEventDispatcher; -import net.sf.robocode.serialization.SerializableOptions; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (original) - */ -public interface IRecordManager { - - void attachRecorder(BattleEventDispatcher battleEventDispatcher); - void detachRecorder(); - - void saveRecord(String fileName, BattleRecordFormat format, SerializableOptions options); - - void loadRecord(String fileName, BattleRecordFormat format); - - boolean hasRecord(); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/CodeSizeCalculator.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/CodeSizeCalculator.java deleted file mode 100644 index b1bbdb4..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/CodeSizeCalculator.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; - - -/** - * Tool used for calculating the code size of a directory or jar file. - * - * @author Flemming N. Larsen (original) - */ -public final class CodeSizeCalculator { - - public static Integer getDirectoryCodeSize(File dir) { - return getCodeSize("processDirectory", dir); - } - - public static Integer getJarFileCodeSize(File jarFile) { - return getCodeSize("processZipFile", jarFile); - } - - private static Integer getCodeSize(String invokeMethod, File jarFile) { - Integer codesize; - try { - // Call the code size utility using reflection - Class classType = Class.forName("codesize.Codesize"); - - Method method = classType.getMethod(invokeMethod, new Class[] { File.class }); - Object item = method.invoke(null/* static method */, jarFile); - - // Calls Codesize.Item.getCodeSize() - method = item.getClass().getMethod("getCodeSize", (Class[]) null); - codesize = (Integer) method.invoke(item, (Object[]) null); - - } catch (IllegalAccessException e) { - codesize = null; - } catch (InvocationTargetException e) { - codesize = null; - } catch (NoSuchMethodException e) { - codesize = null; - } catch (ClassNotFoundException e) { - codesize = null; - } - return codesize; - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/IRepositoryManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/IRepositoryManager.java deleted file mode 100644 index fb6bc87..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/IRepositoryManager.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import robocode.control.RobotSpecification; - -import java.io.File; -import java.io.IOException; -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public interface IRepositoryManager extends IRepositoryManagerBase { - - /** - * Returns the directory containing the robots. - * - * @return a file that is the directory containing the robots. - */ - File getRobotsDirectory(); - - /** - * Returns all development directories that are additional directories to the 'robots' directory. - * - * @return a list of files containing development directories. - */ - List getDevelDirectories(); - - void refresh(String friendlyUrl); - - boolean refresh(boolean force); - void reload(boolean forced); - - List getRepositoryItems(boolean onlyWithSource, boolean onlyWithPackage, - boolean onlyRobots, boolean onlyDevelopment, boolean onlyNotDevelopment, boolean ignoreTeamRobots, boolean onlyInJar); - - RobotSpecification[] loadSelectedRobots(RobotSpecification[] selectedRobots); - - List getSelectedSpecifications(String selectedRobots); - - boolean verifyRobotName(String robotName, String shortClassName); - - int extractJar(IRobotSpecItem item); - - void createTeam(File target, TeamProperties teamProperties) throws IOException; - - String createPackage(File jarFile, List selectedRobots, RobotProperties robotProperties); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/IRobotItem.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/IRobotItem.java deleted file mode 100644 index 7497808..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/IRobotItem.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import java.net.URL; - - -/** - * @author Pavel Savara (original) - */ -public interface IRobotItem extends IRobotSpecItem { - String getPlatform(); - - boolean isJuniorRobot(); - boolean isStandardRobot(); - boolean isAdvancedRobot(); - boolean isTeamRobot(); - boolean isDroid(); - boolean isSentryRobot(); - - boolean isInteractiveRobot(); - boolean isPaintRobot(); - - URL getClassPathURL(); - URL[] getSourcePathURLs(); - - String getWritableDirectory(); - String getReadableDirectory(); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/IRobotSpecItem.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/IRobotSpecItem.java deleted file mode 100644 index 60c77f2..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/IRobotSpecItem.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import robocode.control.RobotSpecification; - -import java.io.IOException; -import java.io.OutputStream; -import java.net.URL; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public interface IRobotSpecItem extends Comparable { - boolean isValid(); - - boolean isTeam(); - - boolean isInJAR(); - - void setValid(boolean value); - - String getVersion(); - - String getDescription(); - - String getAuthorName(); - - URL getWebpage(); - - boolean getIncludeSource(); - - boolean getIncludeData(); - - boolean isSourceIncluded(); - - String getRootPath(); - - URL getItemURL(); - - boolean isDevelopmentVersion(); - - String getRobocodeVersion(); - - String getFullPackage(); - - String getRelativePath(); - - String getRootPackage(); - - String getFullClassNameWithVersion(); - - String getUniqueFullClassName(); - - String getUniqueFullClassNameWithVersion(); - - String getUniqueShortClassNameWithVersion(); - - String getUniqueVeryShortClassNameWithVersion(); - - String getFullClassName(); - - String getShortClassName(); - - RobotSpecification createRobotSpecification(); - - void storeProperties(OutputStream os, RobotProperties robotProperties) throws IOException; -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/RobotProperties.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/RobotProperties.java deleted file mode 100644 index 3bd9e0e..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/RobotProperties.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import java.net.URL; - - -/** - * Container for the robot properties used in robot packages. - * - * @author Flemming N. Larsen (original) - */ -public class RobotProperties { - - private boolean includeSource; - private boolean includeData; - private String version; - private String author; - private String description; - private URL webPage; - private Integer codeSize; - - public boolean isIncludeSource() { - return includeSource; - } - - public void setIncludeSource(boolean includeSource) { - this.includeSource = includeSource; - } - - public boolean isIncludeData() { - return includeData; - } - - public void setIncludeData(boolean includeData) { - this.includeData = includeData; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public URL getWebPage() { - return webPage; - } - - public void setWebPage(URL webPage) { - this.webPage = webPage; - } - - public Integer getCodeSize() { - return codeSize; - } - - public void setCodeSize(Integer codeSize) { - this.codeSize = codeSize; - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/RobotType.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/RobotType.java deleted file mode 100644 index ce64a75..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/RobotType.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import java.io.Serializable; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public final class RobotType implements Serializable { - private static final long serialVersionUID = 1L; - - private static final transient int - NONE_FLAG = 0, - JUNIOR_FLAG = 1, - STANDARD_FLAG = 2, - ADVANCED_FLAG = 4, - TEAM_FLAG = 8, - DROID_FLAG = 16, - INTERACTIVE_FLAG = 32, - PAINTING_FLAG = 64, - SENTRY_FLAG = 128; - - public static final transient RobotType INVALID = new RobotType(NONE_FLAG); - - private int typeFlags; - - public RobotType(int typeFlags) { // NO_UCD (use private - used by .NET plug-in) - this.typeFlags = typeFlags; - } - - public RobotType( - boolean isJuniorRobot, - boolean isStandardRobot, - boolean isInteractiveRobot, - boolean isPaintRobot, - boolean isAdvancedRobot, - boolean isTeamRobot, - boolean isDroid, - boolean isSentryRobot) { - - typeFlags = NONE_FLAG; - - if (isJuniorRobot) { - typeFlags |= JUNIOR_FLAG; - } - if (isStandardRobot) { - typeFlags |= STANDARD_FLAG; - } - if (isInteractiveRobot) { - typeFlags |= INTERACTIVE_FLAG; - } - if (isPaintRobot) { - typeFlags |= PAINTING_FLAG; - } - if (isAdvancedRobot) { - typeFlags |= ADVANCED_FLAG; - } - if (isTeamRobot) { - typeFlags |= TEAM_FLAG; - } - if (isDroid) { - typeFlags |= DROID_FLAG; - } - if (isSentryRobot) { - typeFlags |= SENTRY_FLAG; - } - } - - public int getTypeFlags() { - return typeFlags; - } - - public boolean isValid() { - return isJuniorRobot() || isStandardRobot() || isAdvancedRobot(); - } - - public boolean isJuniorRobot() { - return (typeFlags & JUNIOR_FLAG) != 0; - } - - public boolean isStandardRobot() { - return (typeFlags & STANDARD_FLAG) != 0; - } - - public boolean isInteractiveRobot() { - return (typeFlags & INTERACTIVE_FLAG) != 0; - } - - public boolean isPaintRobot() { - return (typeFlags & PAINTING_FLAG) != 0; - } - - public boolean isAdvancedRobot() { - return (typeFlags & ADVANCED_FLAG) != 0; - } - - public boolean isTeamRobot() { - return (typeFlags & TEAM_FLAG) != 0; - } - - public boolean isDroid() { - return (typeFlags & DROID_FLAG) != 0; - } - - public boolean isSentryRobot() { - return (typeFlags & SENTRY_FLAG) != 0; - } - - @Override - public int hashCode() { - final int prime = 31; - int result = 1; - result = prime * result + typeFlags; - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || getClass() != obj.getClass()) { - return false; - } - RobotType other = (RobotType) obj; - return (typeFlags == other.typeFlags); - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/TeamProperties.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/TeamProperties.java deleted file mode 100644 index dcd74f9..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/repository/TeamProperties.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import java.net.URL; - - -/** - * Container for Team properties used in Team packages. - * - * @author Flemming N. Larsen (original) - */ -public class TeamProperties { - - private String members; - private String version; - private String author; - private String description; - private URL webPage; - - public String getMembers() { - return members; - } - - public void setMembers(String members) { - this.members = members; - } - - public String getVersion() { - return version; - } - - public void setVersion(String version) { - this.version = version; - } - - public String getAuthor() { - return author; - } - - public void setAuthor(String author) { - this.author = author; - } - - public String getDescription() { - return description; - } - - public void setDescription(String description) { - this.description = description; - } - - public URL getWebPage() { - return webPage; - } - - public void setWebPage(URL webPage) { - this.webPage = webPage; - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/robotpaint/Graphics2DSerialized.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/robotpaint/Graphics2DSerialized.java deleted file mode 100644 index 8246511..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/robotpaint/Graphics2DSerialized.java +++ /dev/null @@ -1,2340 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.robotpaint; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.RobocodeProperties; -import net.sf.robocode.serialization.RbSerializer; - -import java.awt.*; -import java.awt.font.FontRenderContext; -import java.awt.font.GlyphVector; -import java.awt.geom.*; -import java.awt.image.BufferedImage; -import java.awt.image.BufferedImageOp; -import java.awt.image.ImageObserver; -import java.awt.image.RenderedImage; -import java.awt.image.renderable.RenderableImage; -import java.nio.BufferOverflowException; -import java.nio.ByteBuffer; -import java.nio.ByteOrder; -import java.text.AttributedCharacterIterator; -import java.text.CharacterIterator; -import java.util.Map; - -import javax.swing.UIManager; - - -/** - * @author Flemming N. Larsen (original) - * @author Pavel Savara (original) - */ -public class Graphics2DSerialized extends Graphics2D implements IGraphicsProxy { - - private static final int INITIAL_BUFFER_SIZE = 2 * 1024; - private static final int MAX_BUFFER_SIZE = 64 * 1024; - - private final Method[] methods = Method.class.getEnumConstants(); - - private enum Method { - TRANSLATE_INT, // translate(int, int) - SET_COLOR, // setColor(Color) - SET_PAINT_MODE, // setPaintMode() - SET_XOR_MODE, // setXORMode(Color) - SET_FONT, // setFont(Font) - CLIP_RECT, // clipRect(int, int, int, int) - SET_CLIP, // setClip(int, int, int, int) - SET_CLIP_SHAPE, // setClip(Shape) - COPY_AREA, // copyArea(int, int, int, int, int, int) - DRAW_LINE, // drawLine(int, int, int, int) - FILL_RECT, // fillRect(int, int, int, int) - DRAW_RECT, // drawRect(int, int, int, int) - CLEAR_RECT, // clearRect(int, int, int, int) - DRAW_ROUND_RECT, // drawRoundRect(int, int, int, int, int, int) - FILL_ROUND_RECT, // fillRoundRect(int, int, int, int, int, int) - DRAW_3D_RECT, // draw3DRect(int, int, int, int, boolean) - FILL_3D_RECT, // draw3DRect(int, int, int, int, boolean) - DRAW_OVAL, // drawOval(int, int, int, int) - FILL_OVAL, // fillOval(int, int, int, int) - DRAW_ARC, // drawArc(int, int, int, int, int, int) - FILL_ARC, // fillArc(int, int, int, int, int, int) - DRAW_POLYLINE, // drawPolyline(int[], int[], int) - DRAW_POLYGON, // drawPolygon(int[], int[], int) - FILL_POLYGON, // fillPolygon(int[], int[], int) - DRAW_STRING_INT, // drawString(String, int, int) - DRAW_STRING_ACI_INT, // drawString(AttributedCharacterIterator, int, int) - DRAW_CHARS, // drawChars(char[], int, int, int, int) - DRAW_BYTES, // drawBytes(byte[], int, int, int, int) - DRAW_IMAGE_1, // drawImage(Image, int, int, ImageObserver) - DRAW_IMAGE_2, // drawImage(Image, int, int, int, int, ImageObserver) - DRAW_IMAGE_3, // drawImage(Image, int, int, Color, ImageObserver) - DRAW_IMAGE_4, // drawImage(Image, int, int, int, int, Color, ImageObserver) - DRAW_IMAGE_5, // drawImage(Image, int, int, int, int, int, int, int, int, ImageObserver) - DRAW_IMAGE_6, // drawImage(Image, int, int, int, int, int, int, int, int, Color, ImageObserver) - DRAW_SHAPE, // draw(Shape) - DRAW_IMAGE_7, // drawImage(Image, AffineTransform, ImageObserver) - DRAW_IMAGE_8, // drawImage(BufferedImage, BufferedImageOp, int, int) - DRAW_RENDERED_IMAGE, // drawRenderedImage(RenderedImage, AffineTransform) - DRAW_RENDERABLE_IMAGE, // drawRenderableImage(RenderableImage, AffineTransform) - DRAW_STRING_FLOAT, // drawString(String, float, float) - DRAW_STRING_ACI_FLOAT, // drawString(AttributedCharacterIterator, float, float) - DRAW_GLYPH_VECTOR, // drawGlyphVector(GlyphVector gv, float x, float y) - FILL_SHAPE, // fill(Shape) - SET_COMPOSITE, // setComposite(Composite) - SET_PAINT, // setPaint(Paint) - SET_STROKE, // setStroke(Stroke) - SET_RENDERING_HINT, // setRenderingHint(Key, Object) - SET_RENDERING_HINTS, // setRenderingHints(Map) - ADD_RENDERING_HINTS, // addRenderingHints(Map) - TRANSLATE_DOUBLE, // translate(double, double) - ROTATE, // rotate(double) - ROTATE_XY, // rotate(double, double, double) - SCALE, // scale(double, double) - SHEAR, // shear(double, double) - TRANSFORM, // transform(AffineTransform) - SET_TRANSFORM, // setTransform(AffineTransform Tx) - SET_BACKGROUND, // setBackground(Color) - CLIP, // clip(Shape) - } - - // Needed for getTransform() - private transient AffineTransform transform = new AffineTransform(); - - // Needed for getComposite() - private transient Composite composite = AlphaComposite.getInstance(AlphaComposite.SRC_OVER); - - // Needed for getPaint() - private transient Paint paint = Color.BLACK; - - // Needed for getStroke() - private transient Stroke stroke = new BasicStroke(); - - // Needed for getRenderingHint() and getRenderingHints() - private transient RenderingHints renderingHints; - - // Needed for getBackground() - private transient Color background = UIManager.getColor("Button.background"); - - // Needed for getClip() - private transient Shape clip; // is null initially - - // Needed for getColor() - private transient Color color = Color.BLACK; - - // Needed for getFont() - private transient Font font = new Font("Dialog", Font.PLAIN, 11); // used for robot labels - - // Flag indicating if this proxy has been initialized - private transient boolean isInitialized; - - // Flag indicating if painting is enabled - private transient boolean isPaintingEnabled; - - // Byte buffer that works as a stack of method calls to this proxy - private ByteBuffer calls; - - // Serializer for this proxy - private final RbSerializer serializer = new RbSerializer(); - - // FOR-DEBUG private Method lastRead; - // FOR-DEBUG private int lastPos; - - - // The one and only constructor - public Graphics2DSerialized() { - // Create a default RenderingHints object - renderingHints = new RenderingHints(null); - renderingHints.put(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_DEFAULT); - renderingHints.put(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_OFF); - renderingHints.put(RenderingHints.KEY_FRACTIONALMETRICS, RenderingHints.VALUE_FRACTIONALMETRICS_OFF); - renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT); - renderingHints.put(RenderingHints.KEY_STROKE_CONTROL, RenderingHints.VALUE_STROKE_DEFAULT); - } - - // -------------------------------------------------------------------------- - // Overriding all methods from the extended Graphics class - // -------------------------------------------------------------------------- - - // Methods that should not be overridden or implemented: - // - finalize() - // - toString() - - @Override - public Graphics create() { - Graphics2DSerialized gfxProxyCopy = new Graphics2DSerialized(); - - gfxProxyCopy.calls = ByteBuffer.allocate(INITIAL_BUFFER_SIZE); - gfxProxyCopy.transform = transform; - gfxProxyCopy.composite = copyOf(composite); - gfxProxyCopy.paint = paint; - gfxProxyCopy.stroke = copyOf(stroke); - gfxProxyCopy.renderingHints = renderingHints; - gfxProxyCopy.background = copyOf(background); - gfxProxyCopy.clip = copyOf(clip); - gfxProxyCopy.color = copyOf(color); - gfxProxyCopy.font = font; - gfxProxyCopy.isInitialized = isInitialized; - - calls.put(calls); - - return gfxProxyCopy; - } - - @Override - public Graphics create(int x, int y, int width, int height) { - Graphics g = create(); - - g.translate(x, y); - g.setClip(0, 0, width, height); - - return g; - } - - @Override - public void translate(int x, int y) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.TRANSLATE_INT); - put(x); - put(y); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - translate(x, y); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getTransform() - this.transform.translate(x, y); - } - - @Override - public Color getColor() { - return color; - } - - @Override - public void setColor(Color c) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_COLOR); - put(c); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setColor(c); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getColor() - this.color = c; - } - - @Override - public void setPaintMode() { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_PAINT_MODE); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setPaintMode(); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void setXORMode(Color c1) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_XOR_MODE); - put(c1); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setXORMode(c1); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public Font getFont() { - return font; - } - - @Override - public void setFont(Font font) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_FONT); - put(font); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setFont(font); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getFont() - this.font = font; - } - - @Override - public FontMetrics getFontMetrics(Font f) { - return new FontMetricsByFont(f, getFontRenderContext()); - } - - @Override - public Rectangle getClipBounds() { - return clip.getBounds(); - } - - @Override - public void clipRect(int x, int y, int width, int height) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.CLIP_RECT); - put(x); - put(y); - put(width); - put(height); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - clipRect(x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getClip() - - Area clipArea = new Area(clip); - Area clipRectArea = new Area(new Rectangle(x, y, width, height)); - - clipArea.intersect(clipRectArea); - - this.clip = clipArea; - } - - @Override - public void setClip(int x, int y, int width, int height) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_CLIP); - put(x); - put(y); - put(width); - put(height); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setClip(x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getClip() - this.clip = new Rectangle(x, y, width, height); - } - - @Override - public Shape getClip() { - return clip; - } - - @Override - public void setClip(Shape clip) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_CLIP_SHAPE); - put(clip); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setClip(clip); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getClip() - this.clip = clip; - } - - @Override - public void copyArea(int x, int y, int width, int height, int dx, int dy) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.COPY_AREA); - put(x); - put(y); - put(width); - put(height); - put(dx); - put(dy); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - copyArea(x, y, width, height, dx, dy); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawLine(int x1, int y1, int x2, int y2) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_LINE); - put(x1); - put(y1); - put(x2); - put(y2); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawLine(x1, y1, x2, y2); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void fillRect(int x, int y, int width, int height) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.FILL_RECT); - put(x); - put(y); - put(width); - put(height); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - fillRect(x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawRect(int x, int y, int width, int height) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_RECT); - put(x); - put(y); - put(width); - put(height); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawRect(x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void clearRect(int x, int y, int width, int height) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.CLEAR_RECT); - put(x); - put(y); - put(width); - put(height); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - clearRect(x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_ROUND_RECT); - put(x); - put(y); - put(width); - put(height); - put(arcWidth); - put(arcHeight); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawRoundRect(x, y, width, height, arcWidth, arcHeight); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.FILL_ROUND_RECT); - put(x); - put(y); - put(width); - put(height); - put(arcWidth); - put(arcHeight); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - fillRoundRect(x, y, width, height, arcWidth, arcHeight); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void draw3DRect(int x, int y, int width, int height, boolean raised) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_3D_RECT); - put(x); - put(y); - put(width); - put(height); - put(raised); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - draw3DRect(x, y, width, height, raised); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void fill3DRect(int x, int y, int width, int height, boolean raised) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.FILL_3D_RECT); - put(x); - put(y); - put(width); - put(height); - put(raised); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - fill3DRect(x, y, width, height, raised); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawOval(int x, int y, int width, int height) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_OVAL); - put(x); - put(y); - put(width); - put(height); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawOval(x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void fillOval(int x, int y, int width, int height) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.FILL_OVAL); - put(x); - put(y); - put(width); - put(height); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - fillOval(x, y, width, height); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_ARC); - put(x); - put(y); - put(width); - put(height); - put(startAngle); - put(arcAngle); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawArc(x, y, width, height, startAngle, arcAngle); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.FILL_ARC); - put(x); - put(y); - put(width); - put(height); - put(startAngle); - put(arcAngle); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - fillArc(x, y, width, height, startAngle, arcAngle); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawPolyline(int[] xPoints, int[] yPoints, int npoints) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_POLYLINE); - put(xPoints); - put(yPoints); - put(npoints); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawPolyline(xPoints, yPoints, npoints); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawPolygon(int[] xPoints, int[] yPoints, int npoints) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_POLYGON); - put(xPoints); - put(yPoints); - put(npoints); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawPolygon(xPoints, yPoints, npoints); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawPolygon(Polygon p) { - if (isPaintingEnabled) { - drawPolygon(p.xpoints, p.ypoints, p.npoints); // Reuse sister method - } - } - - @Override - public void fillPolygon(int[] xPoints, int[] yPoints, int npoints) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.FILL_POLYGON); - put(xPoints); - put(yPoints); - put(npoints); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - fillPolygon(xPoints, yPoints, npoints); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void fillPolygon(Polygon p) { - if (isPaintingEnabled) { - fillPolygon(p.xpoints, p.ypoints, p.npoints); // Reuse sister method - } - } - - @Override - public void drawString(String str, int x, int y) { - if (str == null) { - throw new NullPointerException("str is null"); // According to the specification! - } - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_STRING_INT); - put(str); - put(x); - put(y); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawString(str, x, y); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawString(AttributedCharacterIterator iterator, int x, int y) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_STRING_ACI_INT); - put(iterator); - put(x); - put(y); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawString(iterator, x, y); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawChars(char[] data, int offset, int length, int x, int y) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_CHARS); - put(data); - put(offset); - put(length); - put(x); - put(y); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawChars(data, offset, length, x, y); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawBytes(byte[] data, int offset, int length, int x, int y) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_BYTES); - put(data); - put(offset); - put(length); - put(x); - put(y); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawBytes(data, offset, length, x, y); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public boolean drawImage(Image img, int x, int y, ImageObserver observer) { - if (isPaintingEnabled) { - notSupported(); - } - return false; // as if the image pixels are still changing (as the call is queued) - } - - @Override - public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) { - if (isPaintingEnabled) { - notSupported(); - } - return false; // as if the image pixels are still changing (as the call is queued) - } - - @Override - public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) { - if (isPaintingEnabled) { - notSupported(); - } - return false; // as if the image pixels are still changing (as the call is queued) - } - - @Override - public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) { - if (isPaintingEnabled) { - notSupported(); - } - return false; // as if the image pixels are still changing (as the call is queued) - } - - @Override - public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, - ImageObserver observer) { - - if (isPaintingEnabled) { - notSupported(); - } - return false; // as if the image pixels are still changing (as the call is queued) - } - - @Override - public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, - Color bgcolor, ImageObserver observer) { - - if (isPaintingEnabled) { - notSupported(); - } - return false; // as if the image pixels are still changing (as the call is queued) - } - - @Override - public void dispose() {// Ignored here - } - - @Override - @Deprecated - public Rectangle getClipRect() { - return getClipBounds(); // Must use getClipBounds() instead of this deprecated method - } - - @Override - public boolean hitClip(int x, int y, int width, int height) { - return (clip != null) && clip.intersects(x, y, width, height); - } - - @Override - public Rectangle getClipBounds(Rectangle r) { - Rectangle bounds = clip.getBounds(); - - r.setBounds(bounds); - return bounds; - } - - // -------------------------------------------------------------------------- - // Overriding all methods from the extended Graphics2D class - // -------------------------------------------------------------------------- - - @Override - public void draw(Shape s) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_SHAPE); - put(s); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - draw(s); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) { - if (isPaintingEnabled) { - notSupported(); - } - return false; // as if the image is still being rendered (as the call is queued) - } - - @Override - public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) { - if (isPaintingEnabled) { - notSupported(); - } - } - - @Override - public void drawRenderedImage(RenderedImage img, AffineTransform xform) {} - - @Override - public void drawRenderableImage(RenderableImage img, AffineTransform xform) { - if (isPaintingEnabled) { - notSupported(); - } - } - - @Override - public void drawString(String str, float x, float y) { - if (str == null) { - throw new NullPointerException("str is null"); // According to the specification! - } - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_STRING_FLOAT); - put(str); - put(x); - put(y); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawString(str, x, y); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawString(AttributedCharacterIterator iterator, float x, float y) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.DRAW_STRING_ACI_FLOAT); - put(iterator); - put(x); - put(y); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - drawString(iterator, x, y); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public void drawGlyphVector(GlyphVector gv, float x, float y) { - if (isPaintingEnabled) { - notSupported(); - } - } - - @Override - public void fill(Shape s) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.FILL_SHAPE); - put(s); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - fill(s); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - } - - @Override - public boolean hit(Rectangle rect, Shape s, boolean onStroke) { - if (onStroke && getStroke() != null) { - s = getStroke().createStrokedShape(s); - } - - if (getTransform() != null) { - s = getTransform().createTransformedShape(s); - } - - Area area = new Area(s); - - if (getClip() != null) { - area.intersect(new Area(getClip())); - } - - return area.intersects(rect); - } - - @Override - public GraphicsConfiguration getDeviceConfiguration() { - return GraphicsEnvironment.getLocalGraphicsEnvironment().getDefaultScreenDevice().getDefaultConfiguration(); - } - - @Override - public void setComposite(Composite comp) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_COMPOSITE); - put(comp); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setComposite(comp); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getComposite() - this.composite = comp; - } - - @Override - public void setPaint(Paint paint) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_PAINT); - put(paint); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setPaint(paint); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getPaint() - this.paint = paint; - } - - @Override - public void setStroke(Stroke s) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_STROKE); - put(s); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setStroke(s); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getStroke() - this.stroke = s; - } - - @Override - public void setRenderingHint(RenderingHints.Key hintKey, Object hintValue) { - // for getRenderingHint() and getRenderingHints() - this.renderingHints.put(hintKey, hintValue); - - if (isPaintingEnabled) { - notSupportedWarn(); - } - } - - @Override - public Object getRenderingHint(RenderingHints.Key hintKey) { - return renderingHints.get(hintKey); - } - - @Override - public void setRenderingHints(Map hints) { - // for getRenderingHint() and getRenderingHints() - this.renderingHints.clear(); // Needs to clear first - this.renderingHints.putAll(hints); // Only overrides existing keys - - if (isPaintingEnabled) { - notSupportedWarn(); - } - } - - @Override - public void addRenderingHints(Map hints) { - // for getRenderingHint() and getRenderingHints() - this.renderingHints.putAll(hints); - - if (isPaintingEnabled) { - notSupportedWarn(); - } - } - - @Override - public RenderingHints getRenderingHints() { - return renderingHints; - } - - @Override - public void translate(double tx, double ty) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.TRANSLATE_DOUBLE); - put(tx); - put(ty); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - translate(tx, ty); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getTransform() - transform.translate(tx, ty); - } - - @Override - public void rotate(double theta) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.ROTATE); - put(theta); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - rotate(theta); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getTransform() - transform.rotate(theta); - } - - @Override - public void rotate(double theta, double x, double y) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.ROTATE_XY); - put(theta); - put(x); - put(y); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - rotate(theta, x, y); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getTransform() - transform.rotate(theta, x, y); - } - - @Override - public void scale(double sx, double sy) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SCALE); - put(sx); - put(sy); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - scale(sx, sy); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getTransform() - transform.scale(sx, sy); - } - - @Override - public void shear(double shx, double shy) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SHEAR); - put(shx); - put(shy); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - shear(shx, shy); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getTransform() - transform.shear(shx, shy); - } - - @Override - public void transform(AffineTransform Tx) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.TRANSFORM); - put(Tx); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - transform(Tx); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getTransform() - transform.concatenate(Tx); - } - - @Override - public void setTransform(AffineTransform Tx) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_TRANSFORM); - put(Tx); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setTransform(Tx); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getTransform() - this.transform = Tx; - } - - @Override - public AffineTransform getTransform() { - return (AffineTransform) transform.clone(); - } - - @Override - public Paint getPaint() { - return paint; - } - - @Override - public Composite getComposite() { - return composite; - } - - @Override - public void setBackground(Color color) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.SET_BACKGROUND); - put(color); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - setBackground(color); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getBackground() - background = color; - } - - @Override - public Color getBackground() { - return background; - } - - @Override - public Stroke getStroke() { - return stroke; - } - - @Override - public void clip(Shape s) { - if (isPaintingEnabled) { - calls.mark(); // Mark for rollback - try { - put(Method.CLIP); - put(s); - } catch (BufferOverflowException e) { - if (recoverFromBufferOverflow()) { - clip(s); // Retry this method after reallocation - return; // Make sure we leave - } - } - } - - // for getClip() - if (s == null) { - this.clip = null; - } else { - Area shapeArea = new Area(s); - Area clipArea = new Area(clip); - - shapeArea.transform(transform); // transform by the current transform - clipArea.intersect(shapeArea); // intersect current clip by the transformed shape - - this.clip = clipArea; - } - } - - @Override - public FontRenderContext getFontRenderContext() { - RenderingHints hints = getRenderingHints(); - - if (hints == null) { - return new FontRenderContext(null, false, false); - } else { - boolean isAntiAliased = RenderingHints.VALUE_FRACTIONALMETRICS_ON.equals( - hints.get(RenderingHints.KEY_TEXT_ANTIALIASING)); - boolean usesFractionalMetrics = RenderingHints.VALUE_FRACTIONALMETRICS_ON.equals( - hints.get(RenderingHints.KEY_FRACTIONALMETRICS)); - - return new FontRenderContext(null, isAntiAliased, usesFractionalMetrics); - } - } - - // -------------------------------------------------------------------------- - // Processing of queued method calls to a Graphics2D object - // -------------------------------------------------------------------------- - - public void setPaintingEnabled(boolean enabled) { - if (enabled && !isPaintingEnabled) { - calls = ByteBuffer.allocate(INITIAL_BUFFER_SIZE); - calls.put(calls.order() == ByteOrder.BIG_ENDIAN ? (byte) 1 : (byte) 0); - } - isPaintingEnabled = enabled; - } - - public void processTo(Graphics2D g) { - if (!isInitialized) { - calls = ByteBuffer.allocate(INITIAL_BUFFER_SIZE); - - // Make sure the transform is not null - transform = g.getTransform(); - transform = transform == null ? new AffineTransform() : new AffineTransform(transform); - - color = copyOf(g.getColor()); - - font = g.getFont(); - - clip = copyOf(g.getClip()); - - composite = copyOf(g.getComposite()); - - paint = g.getPaint(); - - stroke = copyOf(g.getStroke()); - - renderingHints = (RenderingHints) g.getRenderingHints().clone(); - - background = copyOf(g.getBackground()); - - isInitialized = true; - } - - calls.flip(); - - while (calls.remaining() > 0) { - processQueuedCall(g); - } - } - - public void processTo(Graphics2D g, Object graphicsCalls) { - calls.clear(); - - calls.mark(); // Mark for rollback - try { - calls.put((byte[]) graphicsCalls); - } catch (BufferOverflowException e) { - calls.reset(); // Rollback buffer - if (reallocBuffer()) { - processTo(g, graphicsCalls); - return; // must exit here - } - calls.clear(); - } - - calls.flip(); - calls.order(calls.get() == 1 ? ByteOrder.BIG_ENDIAN : ByteOrder.LITTLE_ENDIAN); - - while (calls.remaining() > 0) { - try { - processQueuedCall(g); - } catch (Exception e) { - e.printStackTrace(); - // FOR-DEBUG } catch (Error e) { - // FOR-DEBUG calls.position(lastPos - 4); - } - } - } - - public byte[] readoutQueuedCalls() { - if (calls == null || calls.position() == 0) { - return null; - } - byte[] res = new byte[calls.position()]; - - calls.flip(); - calls.get(res); - - calls.clear(); - calls.put(calls.order() == ByteOrder.BIG_ENDIAN ? (byte) 1 : (byte) 0); - - return res; - } - - private void processQueuedCall(Graphics2D g) { - Method m = readMethod(); - - switch (m) { - case TRANSLATE_INT: - processTranslate_int(g); - break; - - case SET_COLOR: - processSetColor(g); - break; - - case SET_PAINT_MODE: - processSetPaintMode(g); - break; - - case SET_XOR_MODE: - processSetXORMode(g); - break; - - case SET_FONT: - processSetFont(g); - break; - - case CLIP_RECT: - processClipRect(g); - break; - - case SET_CLIP: - processSetClip(g); - break; - - case SET_CLIP_SHAPE: - processSetClip_Shape(g); - break; - - case COPY_AREA: - processCopyArea(g); - break; - - case DRAW_LINE: - processDrawLine(g); - break; - - case FILL_RECT: - processFillRect(g); - break; - - case DRAW_RECT: - processDrawRect(g); - break; - - case CLEAR_RECT: - processClearRect(g); - break; - - case DRAW_ROUND_RECT: - processDrawRoundRect(g); - break; - - case FILL_ROUND_RECT: - processFillRoundRect(g); - break; - - case DRAW_3D_RECT: - processDraw3DRect(g); - break; - - case FILL_3D_RECT: - processFill3DRect(g); - break; - - case DRAW_OVAL: - processDrawOval(g); - break; - - case FILL_OVAL: - processFillOval(g); - break; - - case DRAW_ARC: - processDrawArc(g); - break; - - case FILL_ARC: - processFillArc(g); - break; - - case DRAW_POLYLINE: - processDrawPolyline(g); - break; - - case DRAW_POLYGON: - processDrawPolygon(g); - break; - - case FILL_POLYGON: - processFillPolygon(g); - break; - - case DRAW_STRING_INT: - processDrawString_int(g); - break; - - case DRAW_STRING_ACI_INT: - processDrawString_ACIterator_int(g); - break; - - case DRAW_CHARS: - processDrawChars(g); - break; - - case DRAW_BYTES: - processDrawBytes(g); - break; - - case DRAW_SHAPE: - processDrawShape(g); - break; - - case DRAW_STRING_FLOAT: - processDrawString_float(g); - break; - - case DRAW_STRING_ACI_FLOAT: - processDrawString_ACIterator_float(g); - break; - - case FILL_SHAPE: - processFillShape(g); - break; - - case SET_COMPOSITE: - processSetComposite(g); - break; - - case SET_PAINT: - processSetPaint(g); - break; - - case SET_STROKE: - processSetStroke(g); - break; - - case TRANSLATE_DOUBLE: - processTranslate_double(g); - break; - - case ROTATE: - processRotate(g); - break; - - case ROTATE_XY: - processRotate_xy(g); - break; - - case SCALE: - processScale(g); - break; - - case SHEAR: - processShear(g); - break; - - case TRANSFORM: - processTransform(g); - break; - - case SET_TRANSFORM: - processSetTransform(g); - break; - - case SET_BACKGROUND: - processSetBackground(g); - break; - - case CLIP: - processClip(g); - break; - - case DRAW_GLYPH_VECTOR: - case DRAW_IMAGE_1: - case DRAW_IMAGE_2: - case DRAW_IMAGE_3: - case DRAW_IMAGE_4: - case DRAW_IMAGE_5: - case DRAW_IMAGE_6: - case DRAW_IMAGE_7: - case DRAW_IMAGE_8: - case DRAW_RENDERED_IMAGE: - case DRAW_RENDERABLE_IMAGE: - case SET_RENDERING_HINT: - case SET_RENDERING_HINTS: - case ADD_RENDERING_HINTS: - default: - notSupported(); - break; - } - } - - private void processTranslate_int(Graphics2D g) { - // translate(int, int) - g.translate(calls.getInt(), calls.getInt()); - } - - private void processSetColor(Graphics2D g) { - // setColor(Color) - g.setColor(readColor()); - } - - private void processSetPaintMode(Graphics2D g) { - // setPaintMode() - g.setPaintMode(); - } - - private void processSetXORMode(Graphics2D g) { - // setXORMode(Color) - g.setXORMode(readColor()); - } - - private void processSetFont(Graphics2D g) { - Font font = calls.get() == 0 - ? null - : new Font(serializer.deserializeString(calls), calls.getInt(), calls.getInt()); - - // setFont(Font) - g.setFont(font); - } - - private void processClipRect(Graphics2D g) { - // clipRect(int, int, int, int) - g.clipRect(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processSetClip(Graphics2D g) { - // setClip(int, int, int, int) - g.setClip(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processSetClip_Shape(Graphics2D g) { - // setClip(Shape) - g.setClip(readShape()); - } - - private void processCopyArea(Graphics2D g) { - // copyArea(int, int, int, int, int, int) - g.copyArea(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processDrawLine(Graphics2D g) { - // drawLine(int, int, int, int) - g.drawLine(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processFillRect(Graphics2D g) { - // fillRect(int, int, int, int) - g.fillRect(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processDrawRect(Graphics2D g) { - // drawRect(int, int, int, int) - g.drawRect(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processClearRect(Graphics2D g) { - // clearRect(int, int, int, int) - g.clearRect(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processDrawRoundRect(Graphics2D g) { - // drawRoundRect(int, int, int, int, int, int) - g.drawRoundRect(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processFillRoundRect(Graphics2D g) { - // fillRoundRect(int, int, int, int, int, int) - g.fillRoundRect(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processDraw3DRect(Graphics2D g) { - // draw3DRect(int, int, int, int, boolean) - g.draw3DRect(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), - serializer.deserializeBoolean(calls)); - } - - private void processFill3DRect(Graphics2D g) { - // fill3DRect(int, int, int, int, boolean) - g.fill3DRect(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), - serializer.deserializeBoolean(calls)); - } - - private void processDrawOval(Graphics2D g) { - // drawOval(int, int, int, int) - g.drawOval(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processFillOval(Graphics2D g) { - // fillOval(int, int, int, int) - g.fillOval(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processDrawArc(Graphics2D g) { - // drawArc(int, int, int, int, int, int) - g.drawArc(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processFillArc(Graphics2D g) { - // fillArc(int, int, int, int, int, int) - g.fillArc(calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processDrawPolyline(Graphics2D g) { - // drawPolyline(int[], int[], int) - g.drawPolyline(serializer.deserializeIntegers(calls), serializer.deserializeIntegers(calls), calls.getInt()); - } - - private void processDrawPolygon(Graphics2D g) { - // drawPolygon(int[], int[], int) - g.drawPolygon(serializer.deserializeIntegers(calls), serializer.deserializeIntegers(calls), calls.getInt()); - } - - private void processFillPolygon(Graphics2D g) { - // fillPolygon(int[], int[], int) - g.fillPolygon(serializer.deserializeIntegers(calls), serializer.deserializeIntegers(calls), calls.getInt()); - } - - private void processDrawString_int(Graphics2D g) { - // drawString(String, int, int) - g.drawString(serializer.deserializeString(calls), calls.getInt(), calls.getInt()); - } - - private void processDrawString_ACIterator_int(Graphics2D g) { - // drawString(String, int, int) - g.drawString(serializer.deserializeString(calls), calls.getInt(), calls.getInt()); - } - - private void processDrawChars(Graphics2D g) { - // drawBytes(char[], int, int, int, int) - g.drawChars(serializer.deserializeChars(calls), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processDrawBytes(Graphics2D g) { - // drawBytes(byte[], int, int, int, int) - g.drawBytes(serializer.deserializeBytes(calls), calls.getInt(), calls.getInt(), calls.getInt(), calls.getInt()); - } - - private void processDrawShape(Graphics2D g) { - // draw(Shape) - g.draw(readShape()); - } - - private void processDrawString_float(Graphics2D g) { - // drawString(String, float, float) - g.drawString(serializer.deserializeString(calls), calls.getFloat(), calls.getFloat()); - } - - private void processDrawString_ACIterator_float(Graphics2D g) { - // drawString(String, float, float) - g.drawString(serializer.deserializeString(calls), calls.getFloat(), calls.getFloat()); - } - - private void processFillShape(Graphics2D g) { - // fill(Shape) - g.fill(readShape()); - } - - private void processSetComposite(Graphics2D g) { - // setComposite(Composite) - g.setComposite(readComposite()); - } - - private void processSetPaint(Graphics2D g) { - // setPaint(Paint) - g.setPaint(readPaint()); - } - - private void processSetStroke(Graphics2D g) { - // setStroke(Stroke) - g.setStroke(readStroke()); - } - - private void processTranslate_double(Graphics2D g) { - // translate(double, double) - g.translate(calls.getDouble(), calls.getDouble()); - } - - private void processRotate(Graphics2D g) { - // rotate(double) - g.rotate(calls.getDouble()); - } - - private void processRotate_xy(Graphics2D g) { - // rotate(double) - g.rotate(calls.getDouble(), calls.getDouble(), calls.getDouble()); - } - - private void processScale(Graphics2D g) { - // scale(double, double) - g.scale(calls.getDouble(), calls.getDouble()); - } - - private void processShear(Graphics2D g) { - // shear(double, double) - g.shear(calls.getDouble(), calls.getDouble()); - } - - private void processTransform(Graphics2D g) { - // transform(AffineTransform) - g.transform(readAffineTransform()); - } - - private void processSetTransform(Graphics2D g) { - // setTransform(AffineTransform) - g.setTransform(readAffineTransform()); - } - - private void processSetBackground(Graphics2D g) { - // setBackground(Color) - g.setBackground(readColor()); - } - - private void processClip(Graphics2D g) { - // clip(Shape) - g.clip(readShape()); - } - - private Shape readShape() { - switch (calls.get()) { - case 0: - return null; - - case 1: - return new Arc2D.Double(calls.getDouble(), // x - calls.getDouble(), // y - calls.getDouble(), // width - calls.getDouble(), // height - calls.getDouble(), // angle start - calls.getDouble(), // angle extended - calls.getInt()); // arc type - - case 2: - return new Line2D.Double(calls.getDouble(), // x1 - calls.getDouble(), // y1 - calls.getDouble(), // x2 - calls.getDouble()); // y2 - - case 3: - return new Rectangle2D.Double(calls.getDouble(), // x - calls.getDouble(), // y - calls.getDouble(), // width - calls.getDouble()); // height - - case 4: - return new Ellipse2D.Double(calls.getDouble(), // x - calls.getDouble(), // y - calls.getDouble(), // width - calls.getDouble()); // height - - case 5: - GeneralPath path = new GeneralPath(); - - path.append(new DeserializePathIterator(), false); - return path; - } - notSupported(); - return null; - } - - /** - * Reallocates the calls buffer by replacing it with a new one with doubled capacity - * and copying the old one. - * - * @return {@code true} if the buffer was reallocated; - * {@code false} if the max. capacity has been reached meaning that the reallocation - * was not performed. - */ - private boolean reallocBuffer() { - int bufferSize; - - if (calls == null) { - // No buffer -> Use initial buffer size - bufferSize = INITIAL_BUFFER_SIZE; - } else { - // Otherwise, double up capacity - bufferSize = 2 * calls.capacity(); - } - - // Check if the max. buffer size has been reached - if (RobocodeProperties.isDebuggingOff() && bufferSize > MAX_BUFFER_SIZE) { - return false; // not reallocated! - } - - // Allocate new buffer - ByteBuffer newBuffer = ByteBuffer.allocate(bufferSize); - - if (calls != null) { - // Copy all bytes contained in the current buffer to the new buffer - - byte[] copiedBytes = new byte[calls.position()]; - - calls.clear(); - calls.get(copiedBytes); - - newBuffer.put(copiedBytes); - } - - // Switch to the new buffer - calls = newBuffer; - - return true; // buffer was reallocated - } - - private int unrecoveredBufferOverflowCount; - - private boolean recoverFromBufferOverflow() { - calls.reset(); // Rollback buffer - - boolean recovered = reallocBuffer(); - - if (!recovered) { - if (unrecoveredBufferOverflowCount++ == 1) { // Prevent spamming - System.out.println( - "SYSTEM: This robot is painting too much between actions.\n" + "SYSTEM: Max. buffer capacity (" - + MAX_BUFFER_SIZE + " bytes per turn) has been reached.\n" - + "SYSTEM: Last painting operations are being dropped.\n"); - } - } - return recovered; - } - - private class DeserializePathIterator implements PathIterator { - final int count; - int pos; - final int windingRule; - int[] type; - double[][] coords; - - public DeserializePathIterator() { - count = calls.getInt(); - pos = 0; - windingRule = calls.getInt(); - if (count > 0) { - type = new int[count]; - coords = new double[count][]; - for (int i = 0; i < count; i++) { - type[i] = calls.getInt(); - coords[i] = serializer.deserializeDoubles(calls); - } - } - } - - public int getWindingRule() { - return windingRule; - } - - public boolean isDone() { - return pos == count; - } - - public void next() { - pos++; - } - - public int currentSegment(float[] coords) { - for (int i = 0; i < coords.length; i++) { - coords[i] = (float) this.coords[pos][i]; - } - return type[pos]; - } - - public int currentSegment(double[] coords) { - System.arraycopy(this.coords[pos], 0, coords, 0, coords.length); - return type[pos]; - } - } - - private void put(Shape shape) { - if (shape == null) { - put((byte) 0); - } else if (shape instanceof Arc2D) { - put((byte) 1); - Arc2D arc = (Arc2D) shape; - - put(arc.getX()); - put(arc.getY()); - put(arc.getWidth()); - put(arc.getHeight()); - put(arc.getAngleStart()); - put(arc.getAngleExtent()); - put(arc.getArcType()); - } else if (shape instanceof Line2D) { - put((byte) 2); - Line2D line = (Line2D) shape; - - put(line.getX1()); - put(line.getY1()); - put(line.getX2()); - put(line.getY2()); - } else if (shape instanceof Rectangle2D) { - put((byte) 3); - Rectangle2D rect = (Rectangle2D) shape; - - put(rect.getX()); - put(rect.getY()); - put(rect.getWidth()); - put(rect.getHeight()); - } else if (shape instanceof Ellipse2D) { - put((byte) 4); - Ellipse2D elipse = (Ellipse2D) shape; - - put(elipse.getX()); - put(elipse.getY()); - put(elipse.getWidth()); - put(elipse.getHeight()); - } else { - put((byte) 5); - - double coords[] = new double[6]; - int count = 0; - - // count them first - PathIterator pi = shape.getPathIterator(null); - - while (!pi.isDone()) { - count++; - pi.next(); - } - put(count); - - // write them - pi = shape.getPathIterator(null); - put(pi.getWindingRule()); - while (!pi.isDone()) { - int type = pi.currentSegment(coords); - - put(type); - put(coords); - pi.next(); - } - } - } - - private Composite readComposite() { - switch (calls.get()) { - case 0: - return null; - - case 1: - return AlphaComposite.getInstance(calls.getInt()); - } - notSupported(); - return null; - } - - private void put(Composite comp) { - if (comp == null) { - put((byte) 0); - } else if (comp instanceof AlphaComposite) { - AlphaComposite composite = (AlphaComposite) comp; - - put((byte) 1); - put(composite.getRule()); - } else { - notSupported(); - } - } - - private Paint readPaint() { - switch (calls.get()) { - case 0: - return null; - - case 1: - return new Color(calls.getInt(), true); - } - notSupported(); - return null; - } - - private void put(Paint paint) { - if (paint == null) { - put((byte) 0); - } else if (paint instanceof Color) { - Color color = (Color) paint; - - put((byte) 1); - put(color.getRGB()); - } else { - notSupported(); - } - } - - private Stroke readStroke() { - switch (calls.get()) { - case 0: - return null; - - case 1: - return new BasicStroke(calls.getFloat(), calls.getInt(), calls.getInt(), calls.getFloat(), - serializer.deserializeFloats(calls), calls.getFloat()); - } - notSupported(); - return null; - } - - private void put(Stroke stroke) { - if (stroke == null) { - put((byte) 0); - } else if (stroke instanceof BasicStroke) { - BasicStroke bs = (BasicStroke) stroke; - - put((byte) 1); - put(bs.getLineWidth()); - put(bs.getEndCap()); - put(bs.getLineJoin()); - put(bs.getMiterLimit()); - put(bs.getDashArray()); - put(bs.getDashPhase()); - } else { - notSupported(); - } - } - - private AffineTransform readAffineTransform() { - switch (calls.get()) { - case 0: - return null; - - case 1: - return new AffineTransform(serializer.deserializeDoubles(calls)); - } - notSupported(); - return null; - } - - private void put(AffineTransform tx) { - if (tx == null) { - put((byte) 0); - } else { - double[] m = new double[6]; - - tx.getMatrix(m); - - put((byte) 1); - put(m); - put(tx.getType()); - } - } - - private Method readMethod() { - // FOR-DEBUG if (calls.getInt() != 0xBADF00D) { - // FOR-DEBUG calls.position(lastPos); - // FOR-DEBUG // throw new Error(); - // FOR-DEBUG } - // FOR-DEBUG lastPos = calls.position(); - Method m = methods[calls.get()]; - - // FOR-DEBUG if (calls.getInt() != 0xBADF00D) { - // FOR-DEBUG throw new Error(); - // FOR-DEBUG } - // FOR-DEBUG lastRead = m; - return m; - } - - private void put(Method m) { - // FOR-DEBUG calls.putInt(0xBADF00D); - calls.put((byte) m.ordinal()); - // FOR-DEBUG calls.putInt(0xBADF00D); - } - - private void put(AttributedCharacterIterator iterator) { - if (iterator == null) { - put((String) null); - } else { - StringBuilder sb = new StringBuilder(); - - for (char c = iterator.first(); c != CharacterIterator.DONE; c = iterator.next()) { - sb.append(c); - } - put(sb.toString()); - } - } - - private void put(String value) { - serializer.serialize(calls, value); - } - - private void put(boolean value) { - serializer.serialize(calls, value); - } - - private void put(byte value) { - calls.put(value); - } - - private void put(int value) { - calls.putInt(value); - } - - private void put(int[] values) { - serializer.serialize(calls, values); - } - - private void put(byte[] values) { - serializer.serialize(calls, values); - } - - private void put(char[] values) { - serializer.serialize(calls, values); - } - - private void put(double[] values) { - serializer.serialize(calls, values); - } - - private void put(float[] values) { - serializer.serialize(calls, values); - } - - private void put(double value) { - calls.putDouble(value); - } - - private void put(float value) { - calls.putFloat(value); - } - - private Color readColor() { - return calls.get() == 0 ? null : new Color(calls.getInt(), true); - } - - private void put(Color value) { - if (value == null) { - calls.put((byte) 0); - } else { - calls.put((byte) 1); - calls.putInt(value.getRGB()); - } - } - - private void put(Font font) { - if (font == null) { - calls.put((byte) 0); - } else { - calls.put((byte) 1); - serializer.serialize(calls, font.getFontName()); - calls.putInt(font.getStyle()); - calls.putInt(font.getSize()); - } - } - - // -------------------------------------------------------------------------- - // Copy - // -------------------------------------------------------------------------- - - private static Color copyOf(Color c) { - return (c != null) ? new Color(c.getRGB(), true) : null; - } - - private Shape copyOf(Shape s) { - return (s != null) ? new GeneralPath(s) : null; - } - - private Stroke copyOf(Stroke s) { - if (s == null) { - return null; - } - if (s instanceof BasicStroke) { - BasicStroke bs = (BasicStroke) s; - - return new BasicStroke(bs.getLineWidth(), bs.getEndCap(), bs.getLineJoin(), bs.getMiterLimit(), - bs.getDashArray(), bs.getDashPhase()); - } - throw new UnsupportedOperationException("The Stroke type '" + s.getClass().getName() + "' is not supported"); - } - - private Composite copyOf(Composite c) { - if (c == null) { - return null; - } - if (c instanceof AlphaComposite) { - AlphaComposite ac = (AlphaComposite) c; - - return AlphaComposite.getInstance(ac.getRule(), ac.getAlpha()); - } - throw new UnsupportedOperationException("The Composite type '" + c.getClass().getName() + "' is not supported"); - } - - private void notSupported() { - throw new UnsupportedOperationException("We are sorry. Operation is not supported in Robocode."); - } - - private void notSupportedWarn() { - Logger.printlnToRobotsConsole("SYSTEM: We are sorry. Operation is not supported in Robocode."); - } - - // -------------------------------------------------------------------------- - // Worker classes - // -------------------------------------------------------------------------- - - - /** - * Extended FontMetrics class which only purpose is to let us access its - * protected contructor taking a Font as input parameter. - * - * @author Flemming N. Larsen - */ - private class FontMetricsByFont extends FontMetrics { - static final long serialVersionUID = 1L; - - final FontRenderContext fontRenderContext; - - FontMetricsByFont(Font font, FontRenderContext frc) { - super(font); - fontRenderContext = frc; - } - - /** - * Bugfix [2791007] - FontMetrics StackOverflowError. - * More info here: http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=4257064 - */ - @Override - public int charsWidth(char[] data, int off, int len) { - if (font == null) { - return 0; - } - Rectangle2D bounds = font.getStringBounds(data, off, off + len, fontRenderContext); - - return (bounds != null) ? (int) (bounds.getWidth() + 0.5) : 0; - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/robotpaint/IGraphicsProxy.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/robotpaint/IGraphicsProxy.java deleted file mode 100644 index 89a1031..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/robotpaint/IGraphicsProxy.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.robotpaint; - - -import java.awt.*; - - -/** - * @author Pavel Savara (original) - */ -public interface IGraphicsProxy { - void setPaintingEnabled(boolean enabled); - void processTo(Graphics2D g, Object graphicsCalls); - - void processTo(Graphics2D g); - - Object readoutQueuedCalls(); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/IXmlSerializable.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/IXmlSerializable.java deleted file mode 100644 index 78330dd..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/IXmlSerializable.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.serialization; - - -import java.io.IOException; - - -/** - * @author Pavel Savara (original) - */ -public interface IXmlSerializable { - void writeXml(XmlWriter writer, SerializableOptions options) throws IOException; - - XmlReader.Element readXml(XmlReader reader); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/SerializableOptions.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/SerializableOptions.java deleted file mode 100644 index 9e3f9f8..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/SerializableOptions.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.serialization; - - -/** - * @author Pavel Savara (original) - */ -public class SerializableOptions { - public boolean skipExploded; - public boolean skipNames; - public boolean skipVersion; - public boolean skipDebug; - public boolean skipTotal; - public boolean trimPrecision; - public boolean shortAttributes; - - public SerializableOptions(SerializableOptions src) { - skipExploded = src.skipExploded; - skipNames = src.skipNames; - skipVersion = src.skipVersion; - skipDebug = src.skipDebug; - skipTotal = src.skipTotal; - trimPrecision = src.trimPrecision; - shortAttributes = src.shortAttributes; - } - - public SerializableOptions(boolean skipAllDetails) { - if (skipAllDetails) { - skipExploded = true; - skipNames = true; - skipVersion = true; - skipDebug = true; - skipTotal = true; - trimPrecision = true; - shortAttributes = true; - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/XmlReader.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/XmlReader.java deleted file mode 100644 index 6d0e453..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/XmlReader.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.serialization; - - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParser; -import javax.xml.parsers.SAXParserFactory; -import java.io.IOException; -import java.io.InputStream; -import java.util.HashMap; -import java.util.Map; -import java.util.Stack; - - -/** - * @author Pavel Savara (original) - */ -public class XmlReader { - - private SAXParser parser; - - private final InputStream input; - private final Stack elements = new Stack(); - private final Stack items = new Stack(); - private final Stack> elementNames = new Stack>(); - private final Stack> attributeNames = new Stack>(); - private IXmlSerializable result; - private Map context = new HashMap(); - - private XmlReader(InputStream input) throws SAXException, ParserConfigurationException { - this.input = input; - SAXParserFactory factory = SAXParserFactory.newInstance(); - - parser = factory.newSAXParser(); - } - - private Object deserialize(IXmlSerializable prototype) throws IOException, SAXException { - elementNames.push(new HashMap()); - attributeNames.push(new HashMap()); - items.push(null); - elements.push(new ListElement() { - public IXmlSerializable read(XmlReader reader) { - return null; - } - - public void add(IXmlSerializable child) { - result = child; - } - - public void close() {} - }); - prototype.readXml(this); - parser.parse(input, new Handler(this)); - items.pop(); - elements.pop(); - elementNames.pop(); - attributeNames.pop(); - - return result; - } - - private class Handler extends DefaultHandler { - final XmlReader parent; - - public Handler(XmlReader parent) { - this.parent = parent; - } - - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - final Map names = XmlReader.this.elementNames.peek(); - final Element element = names == null ? null : names.get(qName); - - if (element != null) { - elements.push(element); - XmlReader.this.elementNames.push(new HashMap()); - attributeNames.push(new HashMap()); - final IXmlSerializable item = element.read(parent); - - item.readXml(parent); - for (int i = 0; i < attributes.getLength(); i++) { - Attribute attribute = attributeNames.peek().get(attributes.getQName(i)); - - if (attribute != null) { - attribute.read(attributes.getValue(i)); - } - } - items.push(item); - } else { - items.push(null); - elements.push(null); - XmlReader.this.elementNames.push(null); - attributeNames.push(null); - } - } - - public void endElement(String uri, String localName, String qName) throws SAXException { - elements.pop(); - final IXmlSerializable item = items.peek(); - final Element parentElement = elements.peek(); - - if (parentElement instanceof ListElement) { - ListElement le = (ListElement) parentElement; - - le.add(item); - } - items.pop(); - elementNames.pop(); - attributeNames.pop(); - final Map names = XmlReader.this.elementNames.peek(); - final Element element = names == null ? null : names.get(qName); - - if (element != null) { - if (element instanceof ElementClose) { - ElementClose ec = (ElementClose) element; - - ec.close(); - } - } - } - - } - - public Map getContext() { - return context; - } - - public Element expect(String name, Element element) { - elementNames.peek().put(name, element); - return element; - } - - public Element expect(String name, String altName, Element element) { - elementNames.peek().put(name, element); - elementNames.peek().put(altName, element); - return element; - } - - public Attribute expect(String name, Attribute attribute) { - attributeNames.peek().put(name, attribute); - return attribute; - } - - public Attribute expect(String name, String altName, Attribute attribute) { - attributeNames.peek().put(name, attribute); - attributeNames.peek().put(altName, attribute); - return attribute; - } - - public interface Element { - IXmlSerializable read(XmlReader reader); - } - - - public interface ElementClose extends Element { - void close(); - } - - - public interface ListElement extends ElementClose { - void add(IXmlSerializable child); - } - - - public interface Attribute { - void read(String value); - } - - public static Object deserialize(InputStream input, IXmlSerializable prototype) throws IOException { - try { - XmlReader xr = new XmlReader(input); - - return xr.deserialize(prototype); - } catch (SAXException e) { - throw new IOException(); - } catch (ParserConfigurationException e) { - throw new IOException(); - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/XmlWriter.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/XmlWriter.java deleted file mode 100644 index bbddec2..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/serialization/XmlWriter.java +++ /dev/null @@ -1,142 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.serialization; - - -import java.io.IOException; -import java.io.Writer; -import java.text.CharacterIterator; -import java.text.DecimalFormat; -import java.text.DecimalFormatSymbols; -import java.text.StringCharacterIterator; -import java.util.Locale; -import java.util.Stack; - - -/** - * @author Pavel Savara (original) - */ -public class XmlWriter { - private static final DecimalFormat decimalFormat = new DecimalFormat("#.####", new DecimalFormatSymbols(Locale.US)); - private final Writer writer; - private final Stack elements = new Stack(); - private boolean headClosed = true; - private boolean innerElement = false; - private boolean indent = true; - - public XmlWriter(Writer writer, boolean indent) { - this.writer = writer; - this.indent = indent; - } - - public void startDocument() throws IOException { - writer.write("\n"); - } - - public void startElement(String name) throws IOException { - closeHead(); - indent(elements.size()); - elements.push(name); - writer.write('<'); - writer.write(encode(name)); - headClosed = false; - innerElement = false; - } - - public void writeAttribute(String name, String value) throws IOException { - if (value != null) { - writer.write(' '); - writer.write(encode(name)); - writer.write("=\""); - writer.write(encode(value)); - writer.write('"'); - } - } - - public void writeAttribute(String name, boolean value) throws IOException { - writeAttribute(name, Boolean.toString(value)); - } - - public void writeAttribute(String name, long value) throws IOException { - writeAttribute(name, Long.toString(value)); - } - - public void writeAttribute(String name, double value, boolean trim) throws IOException { - if (trim) { - writeAttribute(name, decimalFormat.format(value)); - } else { - writeAttribute(name, Double.toString(value)); - } - } - - public void endElement() throws IOException { - String name = elements.pop(); - - if (innerElement || headClosed) { - closeHead(); - indent(elements.size()); - writer.write(""); - } else { - writer.write("/>"); - headClosed = true; - } - newline(); - innerElement = true; - } - - private void newline() throws IOException { - if (indent) { - writer.write("\n"); - } - } - - private void closeHead() throws IOException { - if (!headClosed) { - writer.write('>'); - newline(); - headClosed = true; - } - } - - private void indent(int level) throws IOException { - if (indent) { - for (int i = 0; i < level; i++) { - writer.write("\t"); - } - } - } - - private static String encode(String text) { - final StringBuilder result = new StringBuilder(); - final StringCharacterIterator iterator = new StringCharacterIterator(text); - char character = iterator.current(); - - while (character != CharacterIterator.DONE) { - if (character == '<') { - result.append("<"); - } else if (character == '>') { - result.append(">"); - } else if (character == '&') { - result.append("&"); - } else if (character == '\"') { - result.append("""); - } else if (character == '\n') { - result.append(" "); - } else { - // the char is not a special one - // add it to the result as is - result.append(character); - } - character = iterator.next(); - } - return result.toString(); - } - -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/settings/ISettingsListener.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/settings/ISettingsListener.java deleted file mode 100644 index f779268..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/settings/ISettingsListener.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.settings; - - -/** - * @author Pavel Savara (original) - */ -public interface ISettingsListener { - void settingChanged(String property); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/settings/ISettingsManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/settings/ISettingsManager.java deleted file mode 100644 index db43abb..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/settings/ISettingsManager.java +++ /dev/null @@ -1,317 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.settings; - - -import java.awt.*; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Collection; -import java.util.Date; - - -/** - * @author Pavel Savara (original) - */ -public interface ISettingsManager { - void saveProperties(); - - boolean getOptionsViewRobotNames(); - - void setOptionsViewRobotNames(boolean optionsViewRobotNames); - - boolean getOptionsViewScanArcs(); - - void setOptionsViewScanArcs(boolean optionsViewScanArcs); - - boolean getOptionsViewRobotEnergy(); - - void setOptionsViewRobotEnergy(boolean optionsViewRobotEnergy); - - boolean getOptionsViewGround(); - - void setOptionsViewGround(boolean optionsViewGround); - - boolean getOptionsViewTPS(); - - void setOptionsViewTPS(boolean optionsViewTPS); - - boolean getOptionsViewFPS(); - - void setOptionsViewFPS(boolean optionsViewFPS); - - boolean getOptionsViewExplosions(); - - void setOptionsViewExplosions(boolean optionsViewExplosions); - - boolean getOptionsViewExplosionDebris(); - - void setOptionsViewExplosionDebris(boolean optionsViewExplosionDebris); - - boolean getOptionsViewSentryBorder(); - - void setOptionsViewSentryBorder(boolean optionsViewSentryBorder); - - boolean getOptionsViewPreventSpeedupWhenMinimized(); - - void setOptionsViewPreventSpeedupWhenMinimized(boolean preventSpeedupWhenMinimized); - - int getOptionsRenderingAntialiasing(); - - void setOptionsRenderingAntialiasing(int optionsRenderingAntialiasing); - - int getOptionsRenderingTextAntialiasing(); - - void setOptionsRenderingTextAntialiasing(int optionsRenderingTextAntialiasing); - - int getOptionsRenderingMethod(); - - void setOptionsRenderingMethod(int optionsRenderingMethod); - - RenderingHints getRenderingHints(); - - int getOptionsRenderingNoBuffers(); - - void setOptionsRenderingNoBuffers(int optionsRenderingNoBuffers); - - boolean getOptionsRenderingBufferImages(); - - void setOptionsRenderingBufferImages(boolean optionsRenderingBufferImages); - - boolean getOptionsRenderingForceBulletColor(); - - void setOptionsRenderingForceBulletColor(boolean optionsRenderingForceBulletColor); - - int getOptionsBattleDesiredTPS(); - - void setOptionsBattleDesiredTPS(int optionsBattleDesiredTPS); - - boolean getOptionsSoundEnableSound(); - - void setOptionsSoundEnableSound(boolean optionsSoundEnableSound); - - boolean getOptionsSoundEnableGunshot(); - - void setOptionsSoundEnableGunshot(boolean optionsSoundEnableGunshot); - - boolean getOptionsSoundEnableBulletHit(); - - void setOptionsSoundEnableBulletHit(boolean optionsSoundEnableBulletHit); - - boolean getOptionsSoundEnableRobotDeath(); - - void setOptionsSoundEnableRobotDeath(boolean optionsSoundEnableRobotDeath); - - boolean getOptionsSoundEnableWallCollision(); - - void setOptionsSoundEnableWallCollision(boolean optionsSoundEnableWallCollision); - - boolean getOptionsSoundEnableRobotCollision(); - - void setOptionsSoundEnableRobotCollision(boolean optionsSoundEnableRobotCollision); - - boolean getOptionsSoundEnableMixerVolume(); - - void setOptionsSoundMixer(String optionsSoundMixer); - - String getOptionsSoundMixer(); - - void setOptionsSoundEnableMixerVolume(boolean optionsSoundEnableMixerVolume); - - boolean getOptionsSoundEnableMixerPan(); - - void setOptionsSoundEnableMixerPan(boolean optionsSoundEnableMixerPan); - - boolean getOptionsTeamShowTeamRobots(); - - void setOptionsTeamShowTeamRobots(boolean optionsTeamShowTeamRobots); - - String getFileThemeMusic(); - - String getFileBackgroundMusic(); - - String getFileEndOfBattleMusic(); - - String getFileGunshotSfx(); - - String getBulletHitsRobotSfx(); - - String getBulletHitsBulletSfx(); - - String getRobotDeathSfx(); - - String getRobotCollisionSfx(); - - String getWallCollisionSfx(); - - Date getVersionChecked(); - - void setVersionChecked(Date versionChecked); - - long getRobotFilesystemQuota(); - - void setRobotFilesystemQuota(long robotFilesystemQuota); - - long getConsoleQuota(); - - void setConsoleQuota(long consoleQuota); - - long getCpuConstant(); - - void setCpuConstant(long cpuConstant); - - Collection getOptionsDevelopmentPaths(); - - void setOptionsDevelopmentPaths(Collection paths); - - Collection getOptionsExcludedDevelopmentPaths(); - - void setOptionsExcludedDevelopmentPaths(Collection excludedPaths); - - Collection getOptionsEnabledDevelopmentPaths(); - - boolean getOptionsCommonShowResults(); - - boolean getOptionsCommonDontHideRankings(); - - void setOptionsCommonDontHideRankings(boolean dontHide); - - void setOptionsCommonAppendWhenSavingResults(boolean enable); - - boolean getOptionsCommonAppendWhenSavingResults(); - - void setOptionsCommonShowResults(boolean enable); - - boolean getOptionsCommonEnableReplayRecording(); - - boolean getOptionsCommonEnableAutoRecording(); - - boolean getOptionsCommonAutoRecordingXML(); - - void setOptionsCommonEnableReplayRecording(boolean enable); - - void setOptionsCommonEnableAutoRecording(boolean enable); - - void setOptionsCommonEnableAutoRecordingXML(boolean enable); - - void setOptionsCommonNotifyAboutNewBetaVersions(boolean enable); - - boolean getOptionsCommonNotifyAboutNewBetaVersions(); - - int getBattleDefaultBattlefieldWidth(); - - void setBattleDefaultBattlefieldWidth(int battlefieldWidth); - - int getBattleDefaultBattlefieldHeight(); - - void setBattleDefaultBattlefieldHeight(int battlefieldHeight); - - double getBattleDefaultGunCoolingRate(); - - void setBattleDefaultGunCoolingRate(double gunCoolingRate); - - long getBattleDefaultInactivityTime(); - - void setBattleDefaultInactivityTime(long inactivityTime); - - int getBattleDefaultSentryBorderSize(); - - void setBattleDefaultSentryBorderSize(int sentryBorderSize); - - boolean getBattleDefaultHideEnemyNames(); - - void setBattleDefaultHideEnemyNames(boolean hideEnemyNames); - - int getBattleDefaultNumberOfRounds(); - - void setBattleDefaultNumberOfRounds(int numberOfRounds); - - void store(FileOutputStream out, String desc) throws IOException; - - void load(FileInputStream in) throws IOException; - - String getLastRunVersion(); - - void setLastRunVersion(String lastRunVersion); - - void addPropertyListener(ISettingsListener listener); - - void removePropertyListener(ISettingsListener propertyListener); - - public final static String - OPTIONS_VIEW_ROBOTNAMES = "robocode.options.view.robotNames", - OPTIONS_VIEW_SCANARCS = "robocode.options.view.scanArcs", - OPTIONS_VIEW_ROBOTENERGY = "robocode.options.view.robotEnergy", - OPTIONS_VIEW_GROUND = "robocode.options.view.ground", - OPTIONS_VIEW_TPS = "robocode.options.view.TPS", - OPTIONS_VIEW_FPS = "robocode.options.view.FPS", - OPTIONS_VIEW_EXPLOSIONS = "robocode.options.view.explosions", - OPTIONS_VIEW_EXPLOSION_DEBRIS = "robocode.options.view.explosionDebris", - OPTIONS_VIEW_SENTRY_BORDER = "robocode.options.view.sentryBorder", - - OPTIONS_BATTLE_DESIREDTPS = "robocode.options.battle.desiredTPS", - - OPTIONS_VIEW_PREVENT_SPEEDUP_WHEN_MINIMIZED = "robocode.options.view.preventSpeedupWhenMinimized", - - OPTIONS_RENDERING_ANTIALIASING = "robocode.options.rendering.antialiasing", - OPTIONS_RENDERING_TEXT_ANTIALIASING = "robocode.options.rendering.text.antialiasing", - OPTIONS_RENDERING_METHOD = "robocode.options.rendering.method", - OPTIONS_RENDERING_NO_BUFFERS = "robocode.options.rendering.noBuffers", - OPTIONS_RENDERING_BUFFER_IMAGES = "robocode.options.rendering.bufferImages", - OPTIONS_RENDERING_FORCE_BULLET_COLOR = "robocode.options.rendering.forceBulletColor", - - OPTIONS_SOUND_ENABLESOUND = "robocode.options.sound.enableSound", - OPTIONS_SOUND_ENABLEGUNSHOT = "robocode.options.sound.enableGunshot", - OPTIONS_SOUND_ENABLEBULLETHIT = "robocode.options.sound.enableBulletHit", - OPTIONS_SOUND_ENABLEROBOTDEATH = "robocode.options.sound.enableRobotDeath", - OPTIONS_SOUND_ENABLEWALLCOLLISION = "robocode.options.sound.enableWallCollision", - OPTIONS_SOUND_ENABLEROBOTCOLLISION = "robocode.options.sound.enableRobotCollision", - - OPTIONS_SOUND_MIXER = "robocode.options.sound.mixer", - OPTIONS_SOUND_ENABLEMIXERVOLUME = "robocode.options.sound.enableMixerVolume", - OPTIONS_SOUND_ENABLEMIXERPAN = "robocode.options.sound.enableMixerPan", - - OPTIONS_COMMON_NOTIFY_ABOUT_NEW_BETA_VERSIONS = "robocode.options.common.notifyAboutNewBetaVersions", - OPTIONS_COMMON_SHOW_RESULTS = "robocode.options.common.showResults", - OPTIONS_COMMON_DONT_HIDE_RANKINGS = "robocode.options.common.dontHideRankings", - OPTIONS_COMMON_APPEND_WHEN_SAVING_RESULTS = "robocode.options.common.appendWhenSavingResults", - OPTIONS_COMMON_ENABLE_REPLAY_RECORDING = "robocode.options.common.enableReplayRecording", - OPTIONS_COMMON_ENABLE_AUTO_RECORDING = "robocode.options.common.enableAutoRecording", - OPTIONS_COMMON_AUTO_RECORDING_XML = "robocode.options.common.autoRecordingXML", - - OPTIONS_TEAM_SHOWTEAMROBOTS = "robocode.options.team.showTeamRobots", - - OPTIONS_DEVELOPMENT_PATH = "robocode.options.development.path", - OPTIONS_DEVELOPMENT_PATH_EXCLUDED = "robocode.options.development.path.excluded", - - FILE_THEME_MUSIC = "robocode.file.music.theme", - FILE_BACKGROUND_MUSIC = "robocode.file.music.background", - FILE_END_OF_BATTLE_MUSIC = "robocode.file.music.endOfBattle", - - FILE_GUNSHOT_SFX = "robocode.file.sfx.gunshot", - FILE_ROBOT_COLLISION_SFX = "robocode.file.sfx.robotCollision", - FILE_WALL_COLLISION_SFX = "robocode.file.sfx.wallCollision", - FILE_ROBOT_DEATH_SFX = "robocode.file.sfx.robotDeath", - FILE_BULLET_HITS_ROBOT_SFX = "robocode.file.sfx.bulletHitsRobot", - FILE_BULLET_HITS_BULLET_SFX = "robocode.file.sfx.bulletHitsBullet", - - VERSIONCHECKED = "robocode.versionchecked", - ROBOT_FILESYSTEM_QUOTA = "robocode.robot.filesystem.quota", - CONSOLE_QUOTA = "robocode.console.quota", - CPU_CONSTANT = "robocode.cpu.constant", - LAST_RUN_VERSION = "robocode.version.lastrun", - - BATTLE_DEFAULT_BATTLEFIELD_WIDTH = "robocode.battle.default.battlefieldWidth", - BATTLE_DEFAULT_BATTLEFIELD_HEIGHT = "robocode.battle.default.battlefieldHeight", - BATTLE_DEFAULT_NUMBER_OF_ROUNDS = "robocode.battle.default.numberOfBattles", - BATTLE_DEFAULT_GUN_COOLING_RATE = "robocode.battle.default.gunCoolingRate", - BATTLE_DEFAULT_INACTIVITY_TIME = "robocode.battle.default.inactivityTime", - BATTLE_DEFAULT_SENTRY_BORDER_SIZE = "robocode.battle.default.sentryBorderSize", - BATTLE_DEFAULT_HIDE_ENEMY_NAMES = "robocode.battle.default.hideEnemyNames"; -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/settings/SettingsManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/settings/SettingsManager.java deleted file mode 100644 index 39c4a9c..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/settings/SettingsManager.java +++ /dev/null @@ -1,896 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.settings; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import static net.sf.robocode.io.Logger.logError; - -import java.awt.*; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.*; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Nathaniel Troutman (contributor) - */ -// TODO ZAMO, refactor, split by modules -public class SettingsManager implements ISettingsManager { - // Default SFX files - private final static String - DEFAULT_FILE_GUNSHOT_SFX = "/net/sf/robocode/sound/sounds/zap.wav", - DEFAULT_FILE_ROBOT_COLLISION_SFX = "/net/sf/robocode/sound/sounds/13831_adcbicycle_22.wav", - DEFAULT_FILE_WALL_COLLISION_SFX = DEFAULT_FILE_ROBOT_COLLISION_SFX, - DEFAULT_FILE_ROBOT_DEATH_SFX = "/net/sf/robocode/sound/sounds/explode.wav", - DEFAULT_FILE_BULLET_HITS_ROBOT_SFX = "/net/sf/robocode/sound/sounds/shellhit.wav", - DEFAULT_FILE_BULLET_HITS_BULLET_SFX = DEFAULT_FILE_BULLET_HITS_ROBOT_SFX; - - // View Options (Arena) - private boolean - optionsViewRobotEnergy = true, - optionsViewRobotNames = true, - optionsViewScanArcs = false, - optionsViewExplosions = true, - optionsViewGround = true, - optionsViewExplosionDebris = true, - optionsViewSentryBorder = false; - - // View Options (Turns Per Second) - private boolean - optionsViewTPS = true, - optionsViewFPS = true; - - // Prevent speedup when view is minimized - private boolean - optionsViewPreventSpeedupWhenMinimized = false; - - // Rendering Options - private int - optionsRenderingAntialiasing = 0, // 0 = default, 1 = on, 2 = off - optionsRenderingTextAntialiasing = 0, // 0 = default, 1 = on, 2 = off - optionsRenderingMethod = 0, // 0 = default, 1 = speed, 2 = quality - optionsRenderingNoBuffers = 2, // 1 = single buffering, 2 = double buffering, 3 = triple buffering - optionsBattleDesiredTPS = 30; - - private boolean - optionsRenderingBufferImages = true, - optionsRenderingForceBulletColor = false; - - // Sound Options (Sound Effects) - private boolean - optionsSoundEnableSound = false, - optionsSoundEnableGunshot = true, - optionsSoundEnableBulletHit = true, - optionsSoundEnableRobotDeath = true, - optionsSoundEnableWallCollision = true, - optionsSoundEnableRobotCollision = true; - - // Sound Options (Mixer) - private String optionsSoundMixer = "DirectAudioDevice"; - private boolean - optionsSoundEnableMixerVolume = true, - optionsSoundEnableMixerPan = true; - - // Development Options - private Collection - optionsDevelopmentPaths = new HashSet(), - optionsExcludedDevelopmentPaths = new HashSet(); - - // Common Options - private boolean - optionsCommonNotifyAboutNewBetaVersions = false, - optionsCommonShowResults = true, - optionsCommonAppendWhenSavingResults = true, - optionsCommonDontHideRankings = true, - optionsCommonEnableAutoRecording = false, - optionsCommonAutoRecordingXML = false, - optionsCommonEnableReplayRecording = false; - - // Team Options - private boolean optionsTeamShowTeamRobots = false; - - // Music files - private String - fileThemeMusic = "", - fileBackgroundMusic = "", - fileEndOfBattleMusic = ""; - - // SFX files - private String - fileGunshotSfx = DEFAULT_FILE_GUNSHOT_SFX, - fileRobotCollisionSfx = DEFAULT_FILE_ROBOT_COLLISION_SFX, - fileWallCollisionSfx = DEFAULT_FILE_WALL_COLLISION_SFX, - fileRobotDeathSfx = DEFAULT_FILE_ROBOT_DEATH_SFX, - fileBulletHitsRobotSfx = DEFAULT_FILE_BULLET_HITS_ROBOT_SFX, - fileBulletHitsBulletSfx = DEFAULT_FILE_BULLET_HITS_BULLET_SFX; - - // Robocode internals - private String lastRunVersion = ""; - private Date versionChecked; - private long robotFilesystemQuota = 200000; - private long consoleQuota = 8192; - private long cpuConstant = -1; - - // Battle default settings - private int battleDefaultBattlefieldWidth = 800; - private int battleDefaultBattlefieldHeight = 600; - private double battleDefaultGunCoolingRate = 0.1; - private long battleDefaultInactivityTime = 450; - private int battleDefaultSentryBorderSize = 100; - private boolean battleDefaultHideEnemyNames = false; - private int battleDefaultNumberOfRounds = 10; - - private final Properties props = new SortedProperties(); - - private final SimpleDateFormat dateFormat = new SimpleDateFormat("MM/dd/yyyy H:mm:ss"); - - private final RenderingHints renderingHints = new RenderingHints(new HashMap()); - - private final List listeners = new ArrayList(); - - public SettingsManager() { - FileInputStream in = null; - try { - in = new FileInputStream(FileUtil.getRobocodeConfigFile()); - this.load(in); - } catch (FileNotFoundException e) { - logError("No " + FileUtil.getRobocodeConfigFile().getName() + ". Using defaults."); - } catch (IOException e) { - logError("Error while reading " + FileUtil.getRobocodeConfigFile().getName() + ": " + e); - } finally { - if (in != null) { - // noinspection EmptyCatchBlock - try { - in.close(); - } catch (IOException e) {} - } - } - } - - public void saveProperties() { - FileOutputStream out = null; - try { - out = new FileOutputStream(FileUtil.getRobocodeConfigFile()); - this.store(out, "Robocode Properties"); - } catch (IOException e) { - Logger.logError(e); - } finally { - if (out != null) { - // noinspection EmptyCatchBlock - try { - out.close(); - } catch (IOException e) {} - } - } - } - - public boolean getOptionsViewRobotNames() { - return optionsViewRobotNames; - } - - public void setOptionsViewRobotNames(boolean optionsViewRobotNames) { - this.optionsViewRobotNames = optionsViewRobotNames; - props.setProperty(OPTIONS_VIEW_ROBOTNAMES, "" + optionsViewRobotNames); - } - - public boolean getOptionsViewScanArcs() { - return optionsViewScanArcs; - } - - public void setOptionsViewScanArcs(boolean optionsViewScanArcs) { - this.optionsViewScanArcs = optionsViewScanArcs; - props.setProperty(OPTIONS_VIEW_SCANARCS, "" + optionsViewScanArcs); - } - - public boolean getOptionsViewRobotEnergy() { - return optionsViewRobotEnergy; - } - - public void setOptionsViewRobotEnergy(boolean optionsViewRobotEnergy) { - this.optionsViewRobotEnergy = optionsViewRobotEnergy; - props.setProperty(OPTIONS_VIEW_ROBOTENERGY, "" + optionsViewRobotEnergy); - } - - public boolean getOptionsViewGround() { - return optionsViewGround; - } - - public void setOptionsViewGround(boolean optionsViewGround) { - this.optionsViewGround = optionsViewGround; - props.setProperty(OPTIONS_VIEW_GROUND, "" + optionsViewGround); - } - - public boolean getOptionsViewTPS() { - return optionsViewTPS; - } - - public void setOptionsViewTPS(boolean optionsViewTPS) { - this.optionsViewTPS = optionsViewTPS; - props.setProperty(OPTIONS_VIEW_TPS, "" + optionsViewTPS); - } - - public boolean getOptionsViewFPS() { - return optionsViewFPS; - } - - public void setOptionsViewFPS(boolean optionsViewFPS) { - this.optionsViewFPS = optionsViewFPS; - props.setProperty(OPTIONS_VIEW_FPS, "" + optionsViewFPS); - } - - public boolean getOptionsViewExplosions() { - return optionsViewExplosions; - } - - public void setOptionsViewExplosions(boolean optionsViewExplosions) { - this.optionsViewExplosions = optionsViewExplosions; - props.setProperty(OPTIONS_VIEW_EXPLOSIONS, "" + optionsViewExplosions); - } - - public boolean getOptionsViewExplosionDebris() { - return optionsViewExplosionDebris; - } - - public void setOptionsViewExplosionDebris(boolean optionsViewExplosionDebris) { - this.optionsViewExplosionDebris = optionsViewExplosionDebris; - props.setProperty(OPTIONS_VIEW_EXPLOSION_DEBRIS, "" + optionsViewExplosionDebris); - } - - public boolean getOptionsViewPreventSpeedupWhenMinimized() { - return optionsViewPreventSpeedupWhenMinimized; - } - - public void setOptionsViewPreventSpeedupWhenMinimized(boolean preventSpeedupWhenMinimized) { - this.optionsViewPreventSpeedupWhenMinimized = preventSpeedupWhenMinimized; - props.setProperty(OPTIONS_VIEW_PREVENT_SPEEDUP_WHEN_MINIMIZED, "" + preventSpeedupWhenMinimized); - } - - public boolean getOptionsViewSentryBorder() { - return optionsViewSentryBorder; - } - - public void setOptionsViewSentryBorder(boolean optionsViewSentryBorder) { - this.optionsViewSentryBorder = optionsViewSentryBorder; - props.setProperty(OPTIONS_VIEW_SENTRY_BORDER, "" + optionsViewSentryBorder); - } - - public int getOptionsRenderingAntialiasing() { - return optionsRenderingAntialiasing; - } - - public void setOptionsRenderingAntialiasing(int optionsRenderingAntialiasing) { - this.optionsRenderingAntialiasing = optionsRenderingAntialiasing; - props.setProperty(OPTIONS_RENDERING_ANTIALIASING, "" + optionsRenderingAntialiasing); - - Object value; - - switch (optionsRenderingAntialiasing) { - case 1: - value = RenderingHints.VALUE_ANTIALIAS_ON; - break; - - case 2: - value = RenderingHints.VALUE_ANTIALIAS_OFF; - break; - - case 0: - default: - value = RenderingHints.VALUE_ANTIALIAS_DEFAULT; - } - renderingHints.put(RenderingHints.KEY_ANTIALIASING, value); - } - - public int getOptionsRenderingTextAntialiasing() { - return optionsRenderingTextAntialiasing; - } - - public void setOptionsRenderingTextAntialiasing(int optionsRenderingTextAntialiasing) { - this.optionsRenderingTextAntialiasing = optionsRenderingTextAntialiasing; - props.setProperty(OPTIONS_RENDERING_TEXT_ANTIALIASING, "" + optionsRenderingTextAntialiasing); - - Object value; - - switch (optionsRenderingTextAntialiasing) { - case 1: - value = RenderingHints.VALUE_TEXT_ANTIALIAS_ON; - break; - - case 2: - value = RenderingHints.VALUE_TEXT_ANTIALIAS_OFF; - break; - - case 0: - default: - value = RenderingHints.VALUE_TEXT_ANTIALIAS_DEFAULT; - } - renderingHints.put(RenderingHints.KEY_TEXT_ANTIALIASING, value); - } - - public int getOptionsRenderingMethod() { - return optionsRenderingMethod; - } - - public void setOptionsRenderingMethod(int optionsRenderingMethod) { - this.optionsRenderingMethod = optionsRenderingMethod; - props.setProperty(OPTIONS_RENDERING_METHOD, "" + optionsRenderingMethod); - - Object value; - - switch (optionsRenderingMethod) { - case 1: - value = RenderingHints.VALUE_RENDER_QUALITY; - break; - - case 2: - value = RenderingHints.VALUE_RENDER_SPEED; - break; - - case 0: - default: - value = RenderingHints.VALUE_RENDER_DEFAULT; - } - renderingHints.put(RenderingHints.KEY_RENDERING, value); - } - - public RenderingHints getRenderingHints() { - return renderingHints; - } - - public int getOptionsRenderingNoBuffers() { - return optionsRenderingNoBuffers; - } - - public void setOptionsRenderingNoBuffers(int optionsRenderingNoBuffers) { - this.optionsRenderingNoBuffers = optionsRenderingNoBuffers; - props.setProperty(OPTIONS_RENDERING_NO_BUFFERS, "" + optionsRenderingNoBuffers); - } - - public boolean getOptionsRenderingBufferImages() { - return optionsRenderingBufferImages; - } - - public void setOptionsRenderingBufferImages(boolean optionsRenderingBufferImages) { - this.optionsRenderingBufferImages = optionsRenderingBufferImages; - props.setProperty(OPTIONS_RENDERING_BUFFER_IMAGES, "" + optionsRenderingBufferImages); - } - - public boolean getOptionsRenderingForceBulletColor() { - return optionsRenderingForceBulletColor; - } - - public void setOptionsRenderingForceBulletColor(boolean optionsRenderingForceBulletColor) { - this.optionsRenderingForceBulletColor = optionsRenderingForceBulletColor; - props.setProperty(OPTIONS_RENDERING_FORCE_BULLET_COLOR, "" + optionsRenderingForceBulletColor); - } - - public int getOptionsBattleDesiredTPS() { - return optionsBattleDesiredTPS; - } - - public void setOptionsBattleDesiredTPS(int optionsBattleDesiredTPS) { - this.optionsBattleDesiredTPS = optionsBattleDesiredTPS; - props.setProperty(OPTIONS_BATTLE_DESIREDTPS, "" + optionsBattleDesiredTPS); - } - - public boolean getOptionsSoundEnableSound() { - return optionsSoundEnableSound; - } - - public void setOptionsSoundEnableSound(boolean optionsSoundEnableSound) { - this.optionsSoundEnableSound = optionsSoundEnableSound; - props.setProperty(OPTIONS_SOUND_ENABLESOUND, "" + optionsSoundEnableSound); - } - - public boolean getOptionsSoundEnableGunshot() { - return optionsSoundEnableGunshot; - } - - public void setOptionsSoundEnableGunshot(boolean optionsSoundEnableGunshot) { - this.optionsSoundEnableGunshot = optionsSoundEnableGunshot; - props.setProperty(OPTIONS_SOUND_ENABLEGUNSHOT, "" + optionsSoundEnableGunshot); - } - - public boolean getOptionsSoundEnableBulletHit() { - return optionsSoundEnableBulletHit; - } - - public void setOptionsSoundEnableBulletHit(boolean optionsSoundEnableBulletHit) { - this.optionsSoundEnableBulletHit = optionsSoundEnableBulletHit; - props.setProperty(OPTIONS_SOUND_ENABLEBULLETHIT, "" + optionsSoundEnableBulletHit); - } - - public boolean getOptionsSoundEnableRobotDeath() { - return optionsSoundEnableRobotDeath; - } - - public void setOptionsSoundEnableRobotDeath(boolean optionsSoundEnableRobotDeath) { - this.optionsSoundEnableRobotDeath = optionsSoundEnableRobotDeath; - props.setProperty(OPTIONS_SOUND_ENABLEROBOTDEATH, "" + optionsSoundEnableRobotDeath); - } - - public boolean getOptionsSoundEnableWallCollision() { - return optionsSoundEnableWallCollision; - } - - public void setOptionsSoundEnableWallCollision(boolean optionsSoundEnableWallCollision) { - this.optionsSoundEnableWallCollision = optionsSoundEnableWallCollision; - props.setProperty(OPTIONS_SOUND_ENABLEWALLCOLLISION, "" + optionsSoundEnableWallCollision); - } - - public boolean getOptionsSoundEnableRobotCollision() { - return optionsSoundEnableRobotCollision; - } - - public void setOptionsSoundEnableRobotCollision(boolean optionsSoundEnableRobotCollision) { - this.optionsSoundEnableRobotCollision = optionsSoundEnableRobotCollision; - props.setProperty(OPTIONS_SOUND_ENABLEROBOTCOLLISION, "" + optionsSoundEnableRobotCollision); - } - - public boolean getOptionsSoundEnableMixerVolume() { - return optionsSoundEnableMixerVolume; - } - - public void setOptionsSoundMixer(String optionsSoundMixer) { - this.optionsSoundMixer = optionsSoundMixer; - props.setProperty(OPTIONS_SOUND_MIXER, optionsSoundMixer); - } - - public String getOptionsSoundMixer() { - return optionsSoundMixer; - } - - public void setOptionsSoundEnableMixerVolume(boolean optionsSoundEnableMixerVolume) { - this.optionsSoundEnableMixerVolume = optionsSoundEnableMixerVolume; - props.setProperty(OPTIONS_SOUND_ENABLEMIXERVOLUME, "" + optionsSoundEnableMixerVolume); - } - - public boolean getOptionsSoundEnableMixerPan() { - return optionsSoundEnableMixerPan; - } - - public void setOptionsSoundEnableMixerPan(boolean optionsSoundEnableMixerPan) { - this.optionsSoundEnableMixerPan = optionsSoundEnableMixerPan; - props.setProperty(OPTIONS_SOUND_ENABLEMIXERPAN, "" + optionsSoundEnableMixerPan); - } - - public boolean getOptionsTeamShowTeamRobots() { - return optionsTeamShowTeamRobots; - } - - public void setOptionsTeamShowTeamRobots(boolean optionsTeamShowTeamRobots) { - this.optionsTeamShowTeamRobots = optionsTeamShowTeamRobots; - props.setProperty(OPTIONS_TEAM_SHOWTEAMROBOTS, "" + optionsTeamShowTeamRobots); - } - - public String getFileThemeMusic() { - return fileThemeMusic; - } - - public String getFileBackgroundMusic() { - return fileBackgroundMusic; - } - - public String getFileEndOfBattleMusic() { - return fileEndOfBattleMusic; - } - - public String getFileGunshotSfx() { - return fileGunshotSfx; - } - - public String getBulletHitsRobotSfx() { - return fileBulletHitsRobotSfx; - } - - public String getBulletHitsBulletSfx() { - return fileBulletHitsBulletSfx; - } - - public String getRobotDeathSfx() { - return fileRobotDeathSfx; - } - - public String getRobotCollisionSfx() { - return fileRobotCollisionSfx; - } - - public String getWallCollisionSfx() { - return fileWallCollisionSfx; - } - - public Date getVersionChecked() { - return (versionChecked != null) ? (Date) versionChecked.clone() : null; - } - - public void setVersionChecked(Date versionChecked) { - this.versionChecked = (versionChecked != null) ? (Date) versionChecked.clone() : null; - props.setProperty(VERSIONCHECKED, dateFormat.format(new Date())); - } - - public long getRobotFilesystemQuota() { - return robotFilesystemQuota; - } - - public void setRobotFilesystemQuota(long robotFilesystemQuota) { - this.robotFilesystemQuota = robotFilesystemQuota; - props.setProperty(ROBOT_FILESYSTEM_QUOTA, "" + robotFilesystemQuota); - } - - public long getConsoleQuota() { - return consoleQuota; - } - - public void setConsoleQuota(long consoleQuota) { - this.consoleQuota = consoleQuota; - props.setProperty(CONSOLE_QUOTA, "" + consoleQuota); - } - - public long getCpuConstant() { - return cpuConstant; - } - - public void setCpuConstant(long cpuConstant) { - this.cpuConstant = cpuConstant; - props.setProperty(CPU_CONSTANT, "" + cpuConstant); - } - - public Collection getOptionsDevelopmentPaths() { - return new HashSet(optionsDevelopmentPaths); - } - - public void setOptionsDevelopmentPaths(Collection paths) { - this.optionsDevelopmentPaths = new HashSet(paths); - - props.setProperty(OPTIONS_DEVELOPMENT_PATH, toCommaSeparatedString(paths)); - } - - public Collection getOptionsExcludedDevelopmentPaths() { - return new HashSet(optionsExcludedDevelopmentPaths); - } - - public void setOptionsExcludedDevelopmentPaths(Collection paths) { - this.optionsExcludedDevelopmentPaths = new HashSet(paths); - - props.setProperty(OPTIONS_DEVELOPMENT_PATH_EXCLUDED, toCommaSeparatedString(paths)); - } - - public Collection getOptionsEnabledDevelopmentPaths() { - Collection paths = getOptionsDevelopmentPaths(); - - paths.removeAll(getOptionsExcludedDevelopmentPaths()); - return paths; - } - - public boolean getOptionsCommonShowResults() { - return optionsCommonShowResults; - } - - public void setOptionsCommonAppendWhenSavingResults(boolean enable) { - this.optionsCommonAppendWhenSavingResults = enable; - props.setProperty(OPTIONS_COMMON_APPEND_WHEN_SAVING_RESULTS, "" + enable); - } - - public boolean getOptionsCommonAppendWhenSavingResults() { - return optionsCommonAppendWhenSavingResults; - } - - public void setOptionsCommonShowResults(boolean enable) { - this.optionsCommonShowResults = enable; - props.setProperty(OPTIONS_COMMON_SHOW_RESULTS, "" + enable); - } - - public boolean getOptionsCommonDontHideRankings() { - return optionsCommonDontHideRankings; - } - - public void setOptionsCommonDontHideRankings(boolean enable) { - this.optionsCommonDontHideRankings = enable; - props.setProperty(OPTIONS_COMMON_DONT_HIDE_RANKINGS, "" + enable); - } - - public boolean getOptionsCommonEnableReplayRecording() { - return optionsCommonEnableReplayRecording; - } - - public void setOptionsCommonEnableReplayRecording(boolean enable) { - this.optionsCommonEnableReplayRecording = enable; - props.setProperty(OPTIONS_COMMON_ENABLE_REPLAY_RECORDING, "" + enable); - } - - public boolean getOptionsCommonEnableAutoRecording() { - return optionsCommonEnableAutoRecording; - } - - public boolean getOptionsCommonAutoRecordingXML() { - return optionsCommonAutoRecordingXML; - } - - public void setOptionsCommonEnableAutoRecording(boolean enable) { - this.optionsCommonEnableAutoRecording = enable; - props.setProperty(OPTIONS_COMMON_ENABLE_AUTO_RECORDING, "" + enable); - } - - public void setOptionsCommonEnableAutoRecordingXML(boolean enable) { - this.optionsCommonAutoRecordingXML = enable; - props.setProperty(OPTIONS_COMMON_AUTO_RECORDING_XML, "" + enable); - } - - public void setOptionsCommonNotifyAboutNewBetaVersions(boolean enable) { - this.optionsCommonNotifyAboutNewBetaVersions = enable; - props.setProperty(OPTIONS_COMMON_NOTIFY_ABOUT_NEW_BETA_VERSIONS, "" + enable); - } - - public boolean getOptionsCommonNotifyAboutNewBetaVersions() { - return optionsCommonNotifyAboutNewBetaVersions; - } - - public int getBattleDefaultBattlefieldWidth() { - return battleDefaultBattlefieldWidth; - } - - public void setBattleDefaultBattlefieldWidth(int battlefieldWidth) { - this.battleDefaultBattlefieldWidth = Math.max(400, battlefieldWidth); - props.setProperty(BATTLE_DEFAULT_BATTLEFIELD_WIDTH, "" + this.battleDefaultBattlefieldWidth); - } - - public int getBattleDefaultBattlefieldHeight() { - return battleDefaultBattlefieldHeight; - } - - public void setBattleDefaultBattlefieldHeight(int battlefieldHeight) { - this.battleDefaultBattlefieldHeight = Math.max(400, battlefieldHeight); - props.setProperty(BATTLE_DEFAULT_BATTLEFIELD_HEIGHT, "" + this.battleDefaultBattlefieldHeight); - } - - public double getBattleDefaultGunCoolingRate() { - return battleDefaultGunCoolingRate; - } - - public void setBattleDefaultGunCoolingRate(double gunCoolingRate) { - this.battleDefaultGunCoolingRate = Math.max(0.1, gunCoolingRate); - props.setProperty(BATTLE_DEFAULT_GUN_COOLING_RATE, "" + this.battleDefaultGunCoolingRate); - } - - public long getBattleDefaultInactivityTime() { - return battleDefaultInactivityTime; - } - - public void setBattleDefaultInactivityTime(long inactivityTime) { - this.battleDefaultInactivityTime = Math.max(0, inactivityTime); - props.setProperty(BATTLE_DEFAULT_INACTIVITY_TIME, "" + this.battleDefaultInactivityTime); - } - - public int getBattleDefaultSentryBorderSize() { - return battleDefaultSentryBorderSize; - } - - public void setBattleDefaultSentryBorderSize(int sentryBorderSize) { - this.battleDefaultSentryBorderSize = sentryBorderSize; - props.setProperty(BATTLE_DEFAULT_SENTRY_BORDER_SIZE, "" + this.battleDefaultSentryBorderSize); - } - - public boolean getBattleDefaultHideEnemyNames() { - return battleDefaultHideEnemyNames; - } - - public void setBattleDefaultHideEnemyNames(boolean hideEnemyNames) { - this.battleDefaultHideEnemyNames = hideEnemyNames; - props.setProperty(BATTLE_DEFAULT_HIDE_ENEMY_NAMES, "" + this.battleDefaultHideEnemyNames); - } - - public int getBattleDefaultNumberOfRounds() { - return battleDefaultNumberOfRounds; - } - - public void setBattleDefaultNumberOfRounds(int numberOfRounds) { - this.battleDefaultNumberOfRounds = Math.max(1, numberOfRounds); - props.setProperty(BATTLE_DEFAULT_NUMBER_OF_ROUNDS, "" + this.battleDefaultNumberOfRounds); - } - - public void store(FileOutputStream out, String desc) throws IOException { - props.store(out, desc); - } - - public void load(FileInputStream in) throws IOException { - props.load(in); - - optionsViewRobotNames = Boolean.valueOf(props.getProperty(OPTIONS_VIEW_ROBOTNAMES, "true")); - optionsViewScanArcs = Boolean.valueOf(props.getProperty(OPTIONS_VIEW_SCANARCS, "false")); - optionsViewRobotEnergy = Boolean.valueOf(props.getProperty(OPTIONS_VIEW_ROBOTENERGY, "true")); - optionsViewGround = Boolean.valueOf(props.getProperty(OPTIONS_VIEW_GROUND, "true")); - optionsViewTPS = Boolean.valueOf(props.getProperty(OPTIONS_VIEW_TPS, "true")); - optionsViewFPS = Boolean.valueOf(props.getProperty(OPTIONS_VIEW_FPS, "true")); - optionsViewExplosions = Boolean.valueOf(props.getProperty(OPTIONS_VIEW_EXPLOSIONS, "true")); - optionsViewExplosionDebris = Boolean.valueOf(props.getProperty(OPTIONS_VIEW_EXPLOSION_DEBRIS, "true")); - optionsViewSentryBorder = Boolean.valueOf(props.getProperty(OPTIONS_VIEW_SENTRY_BORDER, "false")); - optionsViewPreventSpeedupWhenMinimized = Boolean.valueOf( - props.getProperty(OPTIONS_VIEW_PREVENT_SPEEDUP_WHEN_MINIMIZED, "false")); - - optionsBattleDesiredTPS = Integer.parseInt(props.getProperty(OPTIONS_BATTLE_DESIREDTPS, "30")); - - // set methods are used here in order to set the rendering hints, which must be rebuild - setOptionsRenderingAntialiasing(Integer.parseInt(props.getProperty(OPTIONS_RENDERING_ANTIALIASING, "0"))); - setOptionsRenderingTextAntialiasing( - Integer.parseInt(props.getProperty(OPTIONS_RENDERING_TEXT_ANTIALIASING, "0"))); - setOptionsRenderingMethod(Integer.parseInt(props.getProperty(OPTIONS_RENDERING_METHOD, "0"))); - optionsRenderingNoBuffers = Integer.parseInt(props.getProperty(OPTIONS_RENDERING_NO_BUFFERS, "2")); - optionsRenderingBufferImages = Boolean.valueOf(props.getProperty(OPTIONS_RENDERING_BUFFER_IMAGES, "true")); - optionsRenderingForceBulletColor = Boolean.valueOf( - props.getProperty(OPTIONS_RENDERING_FORCE_BULLET_COLOR, "false")); - - optionsSoundEnableSound = Boolean.valueOf(props.getProperty(OPTIONS_SOUND_ENABLESOUND, "false")); - optionsSoundEnableGunshot = Boolean.valueOf(props.getProperty(OPTIONS_SOUND_ENABLEGUNSHOT, "true")); - optionsSoundEnableBulletHit = Boolean.valueOf(props.getProperty(OPTIONS_SOUND_ENABLEBULLETHIT, "true")); - optionsSoundEnableRobotDeath = Boolean.valueOf(props.getProperty(OPTIONS_SOUND_ENABLEROBOTDEATH, "true")); - optionsSoundEnableRobotCollision = Boolean.valueOf(props.getProperty(OPTIONS_SOUND_ENABLEROBOTCOLLISION, "true")); - optionsSoundEnableWallCollision = Boolean.valueOf(props.getProperty(OPTIONS_SOUND_ENABLEWALLCOLLISION, "true")); - - optionsSoundMixer = props.getProperty(OPTIONS_SOUND_MIXER, "DirectAudioDevice"); - optionsSoundEnableMixerVolume = Boolean.valueOf(props.getProperty(OPTIONS_SOUND_ENABLEMIXERVOLUME, "true")); - optionsSoundEnableMixerPan = Boolean.valueOf(props.getProperty(OPTIONS_SOUND_ENABLEMIXERPAN, "true")); - - optionsDevelopmentPaths = fromCommaSeparatedString(props.getProperty(OPTIONS_DEVELOPMENT_PATH, "")); - optionsExcludedDevelopmentPaths = fromCommaSeparatedString( - props.getProperty(OPTIONS_DEVELOPMENT_PATH_EXCLUDED, "")); - - optionsCommonNotifyAboutNewBetaVersions = Boolean.valueOf( - props.getProperty(OPTIONS_COMMON_NOTIFY_ABOUT_NEW_BETA_VERSIONS, "false")); - optionsCommonShowResults = Boolean.valueOf(props.getProperty(OPTIONS_COMMON_SHOW_RESULTS, "true")); - optionsCommonAppendWhenSavingResults = Boolean.valueOf( - props.getProperty(OPTIONS_COMMON_APPEND_WHEN_SAVING_RESULTS, "true")); - optionsCommonDontHideRankings = Boolean.valueOf(props.getProperty(OPTIONS_COMMON_DONT_HIDE_RANKINGS, "true")); - optionsCommonEnableReplayRecording = Boolean.valueOf( - props.getProperty(OPTIONS_COMMON_ENABLE_REPLAY_RECORDING, "false")); - optionsCommonEnableAutoRecording = Boolean.valueOf( - props.getProperty(OPTIONS_COMMON_ENABLE_AUTO_RECORDING, "false")); - optionsCommonAutoRecordingXML = Boolean.valueOf(props.getProperty(OPTIONS_COMMON_AUTO_RECORDING_XML, "false")); - - optionsTeamShowTeamRobots = Boolean.valueOf(props.getProperty(OPTIONS_TEAM_SHOWTEAMROBOTS, "false")); - - fileThemeMusic = props.getProperty(FILE_THEME_MUSIC); - fileBackgroundMusic = props.getProperty(FILE_BACKGROUND_MUSIC); - fileEndOfBattleMusic = props.getProperty(FILE_END_OF_BATTLE_MUSIC); - - fileGunshotSfx = props.getProperty(FILE_GUNSHOT_SFX, DEFAULT_FILE_GUNSHOT_SFX); - fileRobotCollisionSfx = props.getProperty(FILE_ROBOT_COLLISION_SFX, DEFAULT_FILE_ROBOT_COLLISION_SFX); - fileWallCollisionSfx = props.getProperty(FILE_WALL_COLLISION_SFX, DEFAULT_FILE_WALL_COLLISION_SFX); - fileRobotDeathSfx = props.getProperty(FILE_ROBOT_DEATH_SFX, DEFAULT_FILE_ROBOT_DEATH_SFX); - fileBulletHitsRobotSfx = props.getProperty(FILE_BULLET_HITS_ROBOT_SFX, DEFAULT_FILE_BULLET_HITS_ROBOT_SFX); - fileBulletHitsBulletSfx = props.getProperty(FILE_BULLET_HITS_BULLET_SFX, DEFAULT_FILE_BULLET_HITS_BULLET_SFX); - - lastRunVersion = props.getProperty(LAST_RUN_VERSION, ""); - - props.remove("robocode.cpu.constant.1000"); - - try { - versionChecked = dateFormat.parse(props.getProperty(VERSIONCHECKED)); - } catch (Exception e) { - Logger.logMessage("Initializing version check date."); - setVersionChecked(new Date()); - } - - battleDefaultBattlefieldWidth = Integer.parseInt(props.getProperty(BATTLE_DEFAULT_BATTLEFIELD_WIDTH, "800")); - battleDefaultBattlefieldHeight = Integer.parseInt(props.getProperty(BATTLE_DEFAULT_BATTLEFIELD_HEIGHT, "600")); - battleDefaultGunCoolingRate = Double.parseDouble(props.getProperty(BATTLE_DEFAULT_GUN_COOLING_RATE, "0.1")); - battleDefaultInactivityTime = Long.parseLong(props.getProperty(BATTLE_DEFAULT_INACTIVITY_TIME, "450")); - battleDefaultHideEnemyNames = Boolean.parseBoolean(props.getProperty(BATTLE_DEFAULT_HIDE_ENEMY_NAMES, "false")); - battleDefaultNumberOfRounds = Integer.parseInt(props.getProperty(BATTLE_DEFAULT_NUMBER_OF_ROUNDS, "10")); - - robotFilesystemQuota = Long.parseLong(props.getProperty(ROBOT_FILESYSTEM_QUOTA, "" + 200000)); - consoleQuota = Long.parseLong(props.getProperty(CONSOLE_QUOTA, "8192")); - cpuConstant = Long.parseLong(props.getProperty(CPU_CONSTANT, "-1")); - } - - public String getLastRunVersion() { - return lastRunVersion; - } - - public void setLastRunVersion(String lastRunVersion) { - this.lastRunVersion = lastRunVersion; - props.setProperty(LAST_RUN_VERSION, "" + lastRunVersion); - } - - public void addPropertyListener(ISettingsListener listener) { - listeners.add(listener); - } - - public void removePropertyListener(ISettingsListener propertyListener) { - listeners.remove(propertyListener); - } - - private void notifyPropertyChanged(String name) { - for (ISettingsListener listener : listeners) { - try { - listener.settingChanged(name); - } catch (Exception e) { - Logger.logError(e); - } - } - } - - /** - * Returns a comma-separated string from a collection of strings. - */ - private static String toCommaSeparatedString(Collection strings) { - if (strings == null || strings.size() == 0) { - return ""; - } - StringBuilder sb = new StringBuilder(); - - for (String s : strings) { - sb.append(s).append(','); - } - String line = sb.toString(); - - return line.substring(0, line.length() - 1); - } - - /** - * Returns a collection of strings from a comma-separated string. - */ - private static Collection fromCommaSeparatedString(String line) { - if (line == null || line.trim().length() == 0) { - return new HashSet(); - } - Set set = new HashSet(); - String splitExpr = File.pathSeparatorChar == ':' ? "[,:]+" : "[,;]+"; - String[] strings = line.split(splitExpr); - - for (String s : strings) { - set.add(s); - } - return set; - } - - /** - * Sorted properties used for sorting the keys for the properties file. - * - * @author Flemming N. Larsen - */ - private class SortedProperties extends Properties { - private static final long serialVersionUID = 1L; - - @SuppressWarnings({ "unchecked", "rawtypes" }) - @Override - public Enumeration keys() { - Enumeration keysEnum = super.keys(); - - Vector keyList = new Vector(); - - while (keysEnum.hasMoreElements()) { - keyList.add((String) keysEnum.nextElement()); - } - - Collections.sort(keyList); - - // noinspection RedundantCast - return (Enumeration) keyList.elements(); - } - - @Override - public synchronized Object setProperty(String key, String value) { - final String old = super.getProperty(key, null); - boolean notify = (old == null && value != null) || (old != null && !old.equals(value)); - final Object res = super.setProperty(key, value); - - if (notify) { - notifyPropertyChanged(key); - } - return res; - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/sound/ISoundManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/sound/ISoundManager.java deleted file mode 100644 index 691a57f..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/sound/ISoundManager.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.sound; - - -/** - * @author Pavel Savara (original) - */ -public interface ISoundManager { - void setEnableSound(boolean enable); - - void playThemeMusic(); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/ui/IWindowManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/ui/IWindowManager.java deleted file mode 100644 index 80be36a..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/ui/IWindowManager.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui; - - -import net.sf.robocode.gui.IWindowManagerBase; -import robocode.control.events.IBattleListener; -import robocode.control.snapshot.ITurnSnapshot; - -import javax.swing.*; - - -/** - * @author Pavel Savara (original) - */ -public interface IWindowManager extends IWindowManagerBase { - void init(); - - void setEnableGUI(boolean enable); - - boolean isGUIEnabled(); - - boolean isSlave(); - - boolean isShowResultsEnabled(); - - boolean isIconified(); - - void setSlave(boolean slave); - - void showRobocodeFrame(boolean visible, boolean iconified); - - void showSplashScreen(); - - void cleanup(); - - JFrame getRobocodeFrame(); - - void setBusyPointer(boolean enabled); - - void setStatus(String s); - - ITurnSnapshot getLastSnapshot(); - - void addBattleListener(IBattleListener listener); - - void removeBattleListener(IBattleListener listener); - - void runIntroBattle(); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/util/AlphanumericComparator.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/util/AlphanumericComparator.java deleted file mode 100644 index 0bace67..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/util/AlphanumericComparator.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.util; - - -import java.util.Comparator; - -import static java.lang.Character.isDigit; - - -/** - * This is a comparator used for comparing two alphanumeric strings. - * Normally strings are sorted one character at a time, meaning that e.g. "1.22" comes before "1.3". - * However, with alphanumeric sorting, "1.3" comes before "1.22", as 3 is lesser than 22. - * This comparator also others letter in this order "A", "a", "B", "b" instead of the normal character - * order "A", "B", "a", "b". - * - * Example of usage: - *
- *    String[] strings = new String[] { "1.22", "1.3", "A", "B", "a", "b" };
- *
- *    Arrays.sort(strings, new AlphanumericComparator());
- *	
- *    for (String s : strings) {
- *        System.out.println(s);
- *    }
- * 
- * - * @author Flemming N. Larsen - */ -public class AlphanumericComparator implements Comparator, java.io.Serializable { - - private static final long serialVersionUID = 1L; - - /** - * Compares two alphanumeric strings. - * - * @param str1 the first string to be compared. - * @param str2 the second string to be compared. - * @return a negative integer, zero, or a positive integer as the first string is less than, equal to, or greater - * than the second. - */ - public int compare(final String str1, final String str2) { - - // Checks against null strings - if (str1 == null) { - return (str2 == null) ? 0 : 1; - } - if (str2 == null) { - return -1; - } - if (str1.equals(str2)) { - return 0; - } - - // Main loop where we keep read tokens from both input strings until the tokens differ - - String tok1; - int result = 0; - - for (int index = 0;; index += tok1.length()) { - tok1 = readToken(str1, index); - - result = compareTokens(tok1, readToken(str2, index)); - if (result != 0) { - return result; - } - } - } - - /** - * Reads a token from the specified input string from a start index. - * - * @param input the input string. - * @param startIndex the start index of the token to read. - * @return the read token or null if there is no token could be read. - */ - private static String readToken(final String input, final int startIndex) { - - // Return null if the input string is null or the startIndex is out of bounds - if (input == null || startIndex >= input.length()) { - return null; - } - - int index = startIndex + 1; - - // Check if the next token is numeric or not - if (isDigit(input.charAt(startIndex))) { - // Handle numeric token, which contains only digits in one continuous sequence - for (; index < input.length() && isDigit(input.charAt(index)); index++) { - ; - } - } else { - // Handle all other tokens that does not contain any digits - for (; index < input.length() && !isDigit(input.charAt(index)); index++) { - ; - } - } - - // Return our token - return input.substring(startIndex, index); - } - - /** - * Compares two tokens. - * - * @param tok1 the first token to be compared. - * @param tok2 the second token to be compared. - * @return a negative integer, zero, or a positive integer as the first token is less than, equal to, or greater - * than the second. - */ - private static int compareTokens(final String tok1, final String tok2) { - - // Checks against null strings - if (tok1 == null) { - return (tok2 == null) ? 0 : 1; - } - if (tok2 == null) { - return -1; - } - - // A numeric token has precedence over other tokens - - if (isDigit(tok1.charAt(0))) { - if (isDigit(tok2.charAt(0))) { - // Two numeric tokens are compared as two long values - return (int) (Long.parseLong(tok1) - Long.parseLong(tok2)); - } - return -1; - } else if (isDigit(tok2.charAt(0))) { - return 1; - } - - // Compare two non-numeric tokens in alphabetic order. - // That is, we want "A", "a", "B", "b" instead of "A", "B", "a", "b" - - int result = tok1.toUpperCase().compareTo(tok2.toUpperCase()); - - if (result != 0) { - return result; - } - return tok1.compareTo(tok2); - } - - /* Example application where output must be: - "1.2" - "1.3" - "1.22A" - "1.22" - "1c" - "1h" - "1p" - "2.1.1" - "2.1a" - "2.10.2" - "2.10a.1" - "2.10" - " " - "ALPHA" - "ALpha" - "Alpha1" - "Alpha2" - "Alpha" - "alPHA" - "alpha1" - "alpha2" - "alpha" - "alpha" - "BETA" - "BEta" - "BeTa" - "bEtA" - "beTA" - "beta" - "" - - */ - public static void main(String... args) { - // Our unsorted strings that must be sorted - final String[] strings = { - null, "", " ", "alpha2", "alpha1", "bEtA", "BeTa", "alpha", "Alpha2", "Alpha1", "Alpha", "1.2", "1.22", - "1.22A", "1.3", "2.10a.1", "2.1.1", "2.10", "2.1a", "2.10.2", "1c", "1h", "1p", "alpha", "beta", "alPHA", - "beTA", "ALpha", "BEta", "ALPHA", "BETA" - }; - - java.util.Arrays.sort(strings, new AlphanumericComparator()); - - for (String s : strings) { - System.out.println(s == null ? "" : '"' + s + '"'); - } - } -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/version/IVersionManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/version/IVersionManager.java deleted file mode 100644 index 3c9dd32..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/version/IVersionManager.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.version; - - -import net.sf.robocode.manager.IVersionManagerBase; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public interface IVersionManager extends IVersionManagerBase { - String checkForNewVersion(); -} diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/version/Version.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/version/Version.java deleted file mode 100644 index 88ac8a5..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/version/Version.java +++ /dev/null @@ -1,178 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.version; - - -/** - * @author Flemming N. Larsen (original) - */ -public class Version implements Comparable { - - private final String version; - - // The allowed format is ... where all of these are ints - private final int major; - private final int minor; - private final int revision; - private final int build; - - // , e.g. in "Beta 3" the maturity is 2, and maturity version is 3 - private final int maturity; // Alpha is 1, Beta is 2, Final is 3 - private final int maturity_version; // The number following e.g. "Alpha" or "Beta" - - public Version(String version) { - - // Validate version format - if (!version.matches("\\s*[0-9]+\\.[0-9]+(\\.[0-9]+)?(\\.[0-9]+)?(\\s?(([aA]lpha)|([bB]eta))(\\s?[0-9]+)?)?\\s*")) { - throw new IllegalArgumentException("The format of the version string is not a valid"); - } - version = version.trim(); - this.version = version; - - // Split the version number into its integer numbers - final String[] numbers = version.split("\\."); - - // Parse the major version - int major = 0; - - if (numbers.length >= 1) { - try { - major = Integer.parseInt(numbers[0]); - } catch (NumberFormatException ignore) {} - } - this.major = major; - - // Parse the minor version - int minor = 0; - - if (numbers.length >= 2) { - try { - String[] split = numbers[1].split("\\s++|([aA]lpha)|([bB]eta)"); - - minor = Integer.parseInt(split[0]); - } catch (NumberFormatException ignore) {} - } - this.minor = minor; - - // Parse the revision - int revision = 0; - - if (numbers.length >= 3) { - try { - String[] split = numbers[2].split("\\s++|([aA]lpha)|([bB]eta)"); - - revision = Integer.parseInt(split[0]); - } catch (NumberFormatException ignore) {} - } - this.revision = revision; - - // Parse the build number - int build = 0; - - if (numbers.length >= 4) { - try { - String[] split = numbers[3].split("\\s++|([aA]lpha)|([bB]eta)"); - - build = Integer.parseInt(split[0]); - } catch (NumberFormatException ignore) {} - } - this.build = build; - - // Parse the maturity version, e.g. "Beta 1" - int maturity; - int maturity_version = 1; - - if (isAlpha()) { - maturity = 1; - final String[] split = version.split("[aA]lpha"); - - if (split.length >= 2) { - maturity_version = Integer.parseInt(split[1].trim()); - } - } else if (isBeta()) { - maturity = 2; - final String[] split = version.split("[bB]eta"); - - if (split.length >= 2) { - maturity_version = Integer.parseInt(split[1].trim()); - } - } else { - maturity = 3; - } - this.maturity = maturity; - this.maturity_version = maturity_version; - } - - public boolean isAlpha() { - return (version.matches(".*[aA]lpha.*")); - } - - public boolean isBeta() { - return (version.matches(".*[bB]eta.*")); - } - - public boolean isFinal() { - return !(isAlpha() || isBeta()); - } - - public int getMajor() { - return major; - } - - public int getMinor() { - return minor; - } - - public int getRevision() { - return revision; - } - - public int getBuild() { - return build; - } - - @Override - public String toString() { - return version; - } - - public int compareTo(Object o) { - if (o == null) { - throw new IllegalArgumentException("The input object cannot be null"); - } - if (o instanceof String) { - return compareTo(new Version((String) o)); - } - if (o instanceof Version) { - Version v = (Version) o; - - long delta = getVersionLong() - v.getVersionLong(); - - return (delta == 0) ? 0 : (delta < 0) ? -1 : 1; - } - throw new IllegalArgumentException("The input object must be a String or Version object"); - } - - private long getVersionLong() { - return ((long) major << 40) + ((long) minor << 32) + (revision << 24) + (build << 16) + (maturity << 8) - + maturity_version; - } - - public static int compare(String oneVersion, String anotherVersion) { - return new Version(oneVersion).compareTo(new Version(anotherVersion)); - } - - public static boolean isBeta(String version) { - return new Version(version).isBeta(); - } - - public static boolean isFinal(String version) { - return new Version(version).isFinal(); - } -} - diff --git a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/version/VersionManager.java b/workspace_robo/robocode.core/src/main/java/net/sf/robocode/version/VersionManager.java deleted file mode 100644 index 774b557..0000000 --- a/workspace_robo/robocode.core/src/main/java/net/sf/robocode/version/VersionManager.java +++ /dev/null @@ -1,224 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.version; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.RobocodeProperties; -import static net.sf.robocode.io.Logger.logError; -import static net.sf.robocode.io.Logger.logMessage; -import static net.sf.robocode.io.Logger.logWarning; -import net.sf.robocode.settings.ISettingsManager; - -import java.io.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; - - -/** - * @author Mathew A. Nelson (original) - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public final class VersionManager implements IVersionManager { - - private static final String VERSIONS_TXT = "versions.md"; - private static final String UNKNOWN_VERSION = "unknown"; - - private static Version version; - - private final boolean versionChanged; - - public VersionManager(ISettingsManager settingsManager) { // NO_UCD (unused code) - if (settingsManager != null) { - versionChanged = !settingsManager.getLastRunVersion().equals(getVersion()); - if (versionChanged) { - settingsManager.setLastRunVersion(getVersion()); - } - } else { - versionChanged = false; - } - } - - public String checkForNewVersion() { - String newVersLine = null; - InputStream inputStream = null; - InputStreamReader inputStreamReader = null; - BufferedReader reader = null; - - try { - URL url = new URL("http://robocode.sourceforge.net/version/version.html"); - - URLConnection urlConnection = url.openConnection(); - - urlConnection.setConnectTimeout(5000); - - if (urlConnection instanceof HttpURLConnection) { - logMessage("Update checking with http."); - HttpURLConnection h = (HttpURLConnection) urlConnection; - - if (h.usingProxy()) { - logMessage("http using proxy."); - } - } - inputStream = urlConnection.getInputStream(); - inputStreamReader = new InputStreamReader(inputStream); - reader = new BufferedReader(inputStreamReader); - - newVersLine = reader.readLine(); - - } catch (MalformedURLException e) { - logError("Unable to check for new version", e); - newVersLine = null; - } catch (IOException e) { - logError("Unable to check for new version", e); - newVersLine = null; - } finally { - FileUtil.cleanupStream(inputStream); - FileUtil.cleanupStream(inputStreamReader); - FileUtil.cleanupStream(reader); - } - return newVersLine; - } - - public String getVersion() { - return getVersionInstance().toString(); - } - - private static Version getVersionInstance() { - if (version == null) { - version = new Version(getVersionFromJar()); - } - return version; - } - - public boolean isLastRunVersionChanged() { - return versionChanged; - } - - public String getVersionN() { - Version v = getVersionInstance(); - - return v.getMajor() + "." + v.getMinor() + "." + v.getRevision() + "." + v.getBuild(); - } - - public int getVersionAsInt() { - Version v = getVersionInstance(); - - return (v.getMajor() << 24) + (v.getMinor() << 16) + (v.getRevision() << 8) + v.getBuild(); - } - - private static String getVersionFromJar() { - String versionString = null; - - BufferedReader in = null; - - try { - URL versionsUrl = VersionManager.class.getResource("/" + VERSIONS_TXT); - - if (versionsUrl == null) { - logError("The URL for the " + VERSIONS_TXT + " was not found"); - versionString = UNKNOWN_VERSION; - } else { - final URLConnection connection = versionsUrl.openConnection(); - - connection.setUseCaches(false); - final InputStream is = connection.getInputStream(); - - in = new BufferedReader(new InputStreamReader(is)); - - versionString = in.readLine(); - while (versionString != null && !versionString.startsWith("## Version ")) { - versionString = in.readLine(); - } - } - } catch (FileNotFoundException e) { - logError("No " + VERSIONS_TXT + " file in robocode.jar"); - versionString = UNKNOWN_VERSION; - } catch (IOException e) { - logError("Error while reading " + VERSIONS_TXT + " from robocode.jar: " + e); - versionString = UNKNOWN_VERSION; - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException ignored) {} - } - } - - String version = UNKNOWN_VERSION; - - if (versionString != null && !versionString.equals(UNKNOWN_VERSION)) { - try { - version = versionFileLineToVersion(versionString); - } catch (Exception ignore) {} - } - if (version.equals(UNKNOWN_VERSION)) { - logWarning("Getting version from file"); - return getVersionFromFile(); - } - return version; - } - - private static String getVersionFromFile() { - String versionString = null; - - FileReader fileReader = null; - BufferedReader in = null; - - try { - File dir = FileUtil.getCwd(); - - if (RobocodeProperties.isTestingOn()) { - dir = dir.getParentFile().getParentFile().getParentFile(); - } - fileReader = new FileReader(new File(dir, VERSIONS_TXT)); - in = new BufferedReader(fileReader); - - versionString = in.readLine(); - } catch (FileNotFoundException e) { - logError("No " + VERSIONS_TXT + " file."); - versionString = UNKNOWN_VERSION; - } catch (IOException e) { - logError("IO Exception reading " + VERSIONS_TXT, e); - versionString = UNKNOWN_VERSION; - } finally { - if (fileReader != null) { - try { - fileReader.close(); - } catch (IOException ignored) {} - } - if (in != null) { - try { - in.close(); - } catch (IOException ignored) {} - } - } - - String version = UNKNOWN_VERSION; - - if (versionString != null && !versionString.equals(UNKNOWN_VERSION)) { - try { - version = versionFileLineToVersion(versionString); - } catch (Exception ignore) {} - } - return version; - } - - private static String versionFileLineToVersion(String versionFileLine) { - String version = versionFileLine.substring("## Version ".length()); - - int index = version.indexOf('('); - if (index >= 0) { - version = version.substring(0, index); - } - return version.trim(); - } -} diff --git a/workspace_robo/robocode.core/src/main/resources/battleRecord.xsd b/workspace_robo/robocode.core/src/main/resources/battleRecord.xsd deleted file mode 100644 index b29815e..0000000 --- a/workspace_robo/robocode.core/src/main/resources/battleRecord.xsd +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.core/src/main/resources/battleRecordS.xsd b/workspace_robo/robocode.core/src/main/resources/battleRecordS.xsd deleted file mode 100644 index abd5f78..0000000 --- a/workspace_robo/robocode.core/src/main/resources/battleRecordS.xsd +++ /dev/null @@ -1,193 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.core/src/test/java/net/sf/robocode/serialization/ObjectCloner.java b/workspace_robo/robocode.core/src/test/java/net/sf/robocode/serialization/ObjectCloner.java deleted file mode 100644 index 1f4207a..0000000 --- a/workspace_robo/robocode.core/src/test/java/net/sf/robocode/serialization/ObjectCloner.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.serialization; - - -import java.awt.*; -import java.io.*; - - -/** - * This utility class is used for cloning objects. - * - * @author Flemming N. Larsen (original) - */ -public class ObjectCloner { - - /** - * Returns a deep copy of the specified object, or {@code null} if the - * object cannot be serialized. - * - * @param orig the object to deep copy. - * @return a new object that is a deep copy of the specified input object; or - * {@code null} if the object was not copied for some reason. - */ - public static Object deepCopy(Object orig) { - if (!(orig instanceof Serializable)) { - return null; - } - - // Write the object out to a byte array - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - ObjectOutputStream out = null; - - try { - out = new ObjectOutputStream(baos); - out.writeObject(orig); - out.flush(); - } catch (IOException e) { - return null; - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException ignored) {} - } - } - - // Now, create a new object by reading it in from the byte array where the - // original object was written to. - - Object obj = null; - ObjectInputStream in = null; - - try { - in = new ObjectInputStream(new ByteArrayInputStream(baos.toByteArray())); - - obj = in.readObject(); - } catch (IOException e) { - return null; - } catch (ClassNotFoundException e) { - return null; - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException ignored) {} - } - } - - return obj; - } - - /** - * Returns a deep copy of the specified {@code Color}, or {@code null} if - * the reference to the {@code Color} is {@code null}. - * - * @param c the {@code Color} to deep copy. - * @return a new {@code Color} that is a deep copy if the specified input - * {@code Color}; or {@code null} if the reference to the - * {@code Color} is {@code null}. - */ - public static Color deepCopy(Color c) { - return (c != null) ? new Color(c.getRGB(), true) : null; - } -} diff --git a/workspace_robo/robocode.core/src/test/java/net/sf/robocode/serialization/RbSerializerTest.java b/workspace_robo/robocode.core/src/test/java/net/sf/robocode/serialization/RbSerializerTest.java deleted file mode 100644 index af1b629..0000000 --- a/workspace_robo/robocode.core/src/test/java/net/sf/robocode/serialization/RbSerializerTest.java +++ /dev/null @@ -1,261 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.serialization; - - -import net.sf.robocode.peer.BulletCommand; -import net.sf.robocode.peer.DebugProperty; -import net.sf.robocode.peer.ExecCommands; -import net.sf.robocode.peer.TeamMessage; -import net.sf.robocode.robotpaint.Graphics2DSerialized; -import net.sf.robocode.security.HiddenAccess; - -import org.junit.AfterClass; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import robocode.util.Utils; - -import javax.swing.*; - -import java.awt.*; -import java.awt.geom.*; -import java.io.ByteArrayInputStream; -import java.io.ByteArrayOutputStream; -import java.io.IOException; - - -/** - * @author Pavel Savara (original) - */ -public class RbSerializerTest { - - Exception exception = null; - - @BeforeClass - public static void init() { - // we need to switch off engine classloader for this test - System.setProperty("NOSECURITY", "true"); - System.setProperty("WORKINGDIRECTORY", "target//test-classes"); - System.setProperty("TESTING", "true"); - HiddenAccess.initContainer(); - } - - @AfterClass - public static void cleanup() { - System.setProperty("NOSECURITY", "false"); - } - - @Test - public void empty() throws IOException { - HiddenAccess.initContainer(); - ExecCommands ec = new ExecCommands(); - - ec.setBodyTurnRemaining(150.123); - ec.setTryingToPaint(true); - - ByteArrayOutputStream out = new ByteArrayOutputStream(1024); - RbSerializer rbs = new RbSerializer(); - - rbs.serialize(out, RbSerializer.ExecCommands_TYPE, ec); - ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); - ExecCommands ec2 = (ExecCommands) rbs.deserialize(in); - - assertNear(ec2.getBodyTurnRemaining(), ec.getBodyTurnRemaining()); - Assert.assertEquals(ec2.isTryingToPaint(), true); - } - - @Test - public void withBullets() throws IOException { - ExecCommands ec = new ExecCommands(); - - ec.setBodyTurnRemaining(150.123); - ec.getBullets().add(new BulletCommand(1.0, true, 0.9354, 11)); - ec.getBullets().add(new BulletCommand(1.0, false, 0.9454, 12)); - ec.getBullets().add(new BulletCommand(1.0, true, 0.9554, -128)); - - ByteArrayOutputStream out = new ByteArrayOutputStream(1024); - RbSerializer rbs = new RbSerializer(); - - rbs.serialize(out, RbSerializer.ExecCommands_TYPE, ec); - ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); - ExecCommands ec2 = (ExecCommands) rbs.deserialize(in); - - assertNear(ec2.getBodyTurnRemaining(), ec.getBodyTurnRemaining()); - assertNear(ec2.getBullets().get(0).getPower(), 1.0); - Assert.assertEquals(ec2.getBullets().get(1).isFireAssistValid(), false); - Assert.assertEquals(ec2.getBullets().get(2).isFireAssistValid(), true); - Assert.assertEquals(ec2.getBullets().get(2).getBulletId(), -128); - } - - @Test - public void withMessages() throws IOException { - ExecCommands ec = new ExecCommands(); - - ec.setBodyTurnRemaining(150.123); - ec.getBullets().add(new BulletCommand(1.0, true, 0.9354, 11)); - final byte[] data = new byte[20]; - - data[10] = 10; - ec.getTeamMessages().add(new TeamMessage("Foo", "Bar", data)); - ec.getTeamMessages().add(new TeamMessage("Foo", "Bar", null)); - - ByteArrayOutputStream out = new ByteArrayOutputStream(1024); - RbSerializer rbs = new RbSerializer(); - - rbs.serialize(out, RbSerializer.ExecCommands_TYPE, ec); - ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); - ExecCommands ec2 = (ExecCommands) rbs.deserialize(in); - - Assert.assertEquals(ec2.getTeamMessages().get(0).message[0], 0); - Assert.assertEquals(ec2.getTeamMessages().get(0).message[10], 10); - Assert.assertEquals(ec2.getTeamMessages().get(0).sender, "Foo"); - Assert.assertEquals(ec2.getTeamMessages().get(0).recipient, "Bar"); - Assert.assertEquals(ec2.getTeamMessages().get(1).message, null); - } - - @Test - public void withProperties() throws IOException { - ExecCommands ec = new ExecCommands(); - - ec.setBodyTurnRemaining(150.123); - ec.getBullets().add(new BulletCommand(1.0, true, 0.9354, 11)); - ec.getTeamMessages().add(new TeamMessage("Foo", "Bar", null)); - ec.getDebugProperties().add( - new DebugProperty("UTF8 Native characters", "Pøíliš žlu?ouèký kùò úpìl ïábelské ódy")); - - ByteArrayOutputStream out = new ByteArrayOutputStream(1024); - RbSerializer rbs = new RbSerializer(); - - rbs.serialize(out, RbSerializer.ExecCommands_TYPE, ec); - ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); - ExecCommands ec2 = (ExecCommands) rbs.deserialize(in); - - Assert.assertEquals(ec2.getDebugProperties().get(0).getKey(), "UTF8 Native characters"); - Assert.assertEquals(ec2.getDebugProperties().get(0).getValue(), "Pøíliš žlu?ouèký kùò úpìl ïábelské ódy"); - } - - // @Test - // 14 seconds for 1000 000, - // 15x faster - public void speed() throws IOException { - ExecCommands ec = new ExecCommands(); - - ec.setBodyTurnRemaining(150.123); - ec.getBullets().add(new BulletCommand(1.0, true, 0.9354, 11)); - ec.getBullets().add(new BulletCommand(1.0, true, 0.9354, 11)); - ec.getBullets().add(new BulletCommand(1.0, true, 0.9354, 11)); - ec.getTeamMessages().add(new TeamMessage("Foo", "Bar", null)); - ec.getDebugProperties().add(new DebugProperty("ooooh", "aaaah")); - - ByteArrayOutputStream out = new ByteArrayOutputStream(1024); - - for (int i = 0; i < 1000000; i++) { - out.reset(); - ec.setGunColor(i); - RbSerializer rbs = new RbSerializer(); - - rbs.serialize(out, RbSerializer.ExecCommands_TYPE, ec); - ByteArrayInputStream in = new ByteArrayInputStream(out.toByteArray()); - ExecCommands ec2 = (ExecCommands) rbs.deserialize(in); - - Assert.assertEquals(ec2.getGunColor(), i); - } - } - - // @Test - // 21 seconds for 100 000 - public void speed2() { - ExecCommands ec = new ExecCommands(); - - ec.setBodyTurnRemaining(150.123); - ec.getBullets().add(new BulletCommand(1.0, true, 0.9354, 11)); - ec.getBullets().add(new BulletCommand(1.0, true, 0.9354, 11)); - ec.getBullets().add(new BulletCommand(1.0, true, 0.9354, 11)); - ec.getTeamMessages().add(new TeamMessage("Foo", "Bar", null)); - ec.getDebugProperties().add(new DebugProperty("ooooh", "aaaah")); - - ByteArrayOutputStream out = new ByteArrayOutputStream(1024); - - for (int i = 0; i < 100000; i++) { - out.reset(); - ec.setGunColor(i); - ExecCommands ec2 = (ExecCommands) ObjectCloner.deepCopy(ec); - - Assert.assertEquals(ec2.getGunColor(), i); - } - } - - @SuppressWarnings("serial") - @Test - public void graphics() throws InterruptedException { - final Graphics2DSerialized sg = new Graphics2DSerialized(); - - sg.setPaintingEnabled(true); - sg.setBackground(Color.GREEN); - sg.setColor(Color.RED); - Arc2D a = new Arc2D.Double(Arc2D.PIE); - - a.setAngleExtent(10); - a.setAngleStart(-30); - a.setFrame(0, 0, 80, 80); - sg.draw(a); - - sg.setColor(Color.BLUE); - sg.draw(new Line2D.Double(99, 98, 78, 3)); - - sg.setColor(Color.YELLOW); - sg.draw(new Rectangle2D.Double(20, 20, 30, 50)); - - sg.setColor(Color.BLACK); - sg.drawLine(99, 3, 78, 3); - sg.drawRect(90, 20, 30, 50); - - sg.setColor(Color.CYAN); - - sg.setStroke(new BasicStroke(1, 2, BasicStroke.JOIN_ROUND, 4, null, 0)); - sg.fill(new Rectangle2D.Double(20, 70, 30, 50)); - sg.fill(new Ellipse2D.Double(70, 70, 30, 50)); - - sg.setColor(Color.MAGENTA); - sg.fill(new RoundRectangle2D.Double(110, 70, 30, 50, 13.5, 16.1)); - - exception = null; - - Canvas d = new Canvas() { - @Override - public void paint(Graphics g) { - synchronized (this) { - try { - sg.processTo((Graphics2D) g); - } catch (Exception e) { - exception = e; - } - } - } - }; - - d.setSize(200, 200); - - JFrame f = new JFrame() {}; - - f.add(d); - f.pack(); - f.setVisible(true); - f.setFocusable(true); - Thread.sleep(100); - f.setVisible(false); - - Assert.assertNull("Exception occured: " + exception, exception); - } - - public static void assertNear(double v1, double v2) { - org.junit.Assert.assertEquals(v1, v2, Utils.NEAR_DELTA); - } -} diff --git a/workspace_robo/robocode.core/src/test/java/net/sf/robocode/version/VersionTest.java b/workspace_robo/robocode.core/src/test/java/net/sf/robocode/version/VersionTest.java deleted file mode 100644 index 2feb52c..0000000 --- a/workspace_robo/robocode.core/src/test/java/net/sf/robocode/version/VersionTest.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.version; - - -import org.junit.Assert; -import org.junit.Test; - - -/** - * @author Pavel Savara (original) - */ -public class VersionTest { - - @Test - public void same() { - Assert.assertTrue(Version.compare("1.1.3", "1.1.3") == 0); - } - - @Test - public void equalVersion() { - Assert.assertTrue(Version.compare("1.1", "1.1.0.0") == 0); - } - - @Test - public void equalAlphas() { - Assert.assertTrue(Version.compare(" 1.2 Alpha", "1.2.0.0alpha1 ") == 0); - } - - @Test - public void equalBetas() { - Assert.assertTrue(Version.compare("4.2.1Beta2 ", " 4.2.1.0 beta 2") == 0); - } - - @Test - public void greater() { - Assert.assertTrue(Version.compare("1.1.4", "1.1.3") > 0); - } - - @Test - public void greaterShort() { - Assert.assertTrue(Version.compare("1.4", "1.1.3") > 0); - } - - @Test - public void greaterShort2() { - Assert.assertTrue(Version.compare("1.4", "1.1") > 0); - } - - @Test - public void greaterShortBeta() { - Assert.assertTrue(Version.compare("1.4 Beta", "1.1.3") > 0); - } - - @Test - public void greaterShortBeta3() { - Assert.assertTrue(Version.compare("1.4 Beta", "1.1") > 0); - } - - @Test - public void greaterShortBeta2() { - Assert.assertTrue(Version.compare("1.4", "1.1.3") > 0); - } - - @Test - public void greaterLong() { - Assert.assertTrue(Version.compare("1.4.1", "1.1") > 0); - } - - @Test - public void smaller() { - Assert.assertTrue(Version.compare("1.1.2", "1.1.3") < 0); - } - - @Test - public void greaterToo() { - Assert.assertTrue(Version.compare("4.1.2", "1.1.3") > 0); - } - - @Test - public void greaterThanBeta() { - Assert.assertTrue(Version.compare("1.1.3", "1.1.3 Beta") > 0); - } - - @Test - public void smallerThanBeta() { - Assert.assertTrue(Version.compare("1.1.2", "1.1.3 Beta") < 0); - } - - @Test - public void smallerThanAlpha() { - Assert.assertTrue(Version.compare("1.1.3 Alpha", "1.1.3 Beta") < 0); - } - - @Test - public void compareBetas() { - // we can't name versions Beta 2 - Assert.assertTrue(Version.compare("1.1.3 Beta", "1.1.3 Beta 2") < 0); - } - - @Test - public void compareBetas2() { - // we can't name versions Beta 2 - Assert.assertTrue(Version.compare("1.1.3 Beta 2 ", "1.1.3 Beta 3") < 0); - } - - @Test - public void compareBetas3() { - // we can't name versions Beta 2 - Assert.assertTrue(Version.compare("1.1.3 Beta2 ", "1.1.3 Beta 3") < 0); - } - - @Test - public void compareBetas4() { - // we can't name versions Beta 2 - Assert.assertTrue(Version.compare("1.1.3Beta2", "1.1.3 Beta 3") < 0); - } - - @Test - public void compareBetasShort() { - // we can't name versions Beta 2 - Assert.assertTrue(Version.compare("1.7 Beta", "1.1") > 0); - } - - @Test - public void compareBetasShort2() { - // we can't name versions Beta 2 - Assert.assertTrue(Version.compare("1.7 Beta", "1.8") < 0); - } -} diff --git a/workspace_robo/robocode.distribution/.classpath b/workspace_robo/robocode.distribution/.classpath deleted file mode 100644 index adc405e..0000000 --- a/workspace_robo/robocode.distribution/.classpath +++ /dev/null @@ -1,19 +0,0 @@ - - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.distribution/.project b/workspace_robo/robocode.distribution/.project deleted file mode 100644 index 602d015..0000000 --- a/workspace_robo/robocode.distribution/.project +++ /dev/null @@ -1,27 +0,0 @@ - - - robocode.distribution - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.api - robocode.roborumble - robocode.battle - robocode.core - robocode.host - robocode.repository - robocode.ui.editor - robocode.ui - robocode.sound - robocode.installer - robocode.content - robocode.samples - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.distribution/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.distribution/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 66e68a8..0000000 --- a/workspace_robo/robocode.distribution/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:10 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.distribution/pom.xml b/workspace_robo/robocode.distribution/pom.xml deleted file mode 100644 index d13ecae..0000000 --- a/workspace_robo/robocode.distribution/pom.xml +++ /dev/null @@ -1,73 +0,0 @@ - - - 4.0.0 - robocode.distribution - Robocode Distribution - - net.sf.robocode - robocode - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - jar - - - net.sf.robocode - robocode.roborumble - ${project.version} - jar - - - net.sf.robocode - robocode.ui.editor - ${project.version} - jar - - - net.sf.robocode - robocode.installer - ${project.version} - jar - - - net.sf.robocode - robocode.content - ${project.version} - jar - - - - - - maven-assembly-plugin - - ${project.parent.artifactId}-${project.version} - true - - setup.asm.xml - src.asm.xml - - - - net.sf.robocode.installer.AutoExtract - - - - - - make-assembly - package - - single - - - - - - - diff --git a/workspace_robo/robocode.distribution/robocode.distribution.iml b/workspace_robo/robocode.distribution/robocode.distribution.iml deleted file mode 100644 index daa00fa..0000000 --- a/workspace_robo/robocode.distribution/robocode.distribution.iml +++ /dev/null @@ -1,91 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.distribution/setup.asm.xml b/workspace_robo/robocode.distribution/setup.asm.xml deleted file mode 100644 index c8a5b52..0000000 --- a/workspace_robo/robocode.distribution/setup.asm.xml +++ /dev/null @@ -1,96 +0,0 @@ - - - setup - - dir - jar - - false - - - - - net.sf.robocode:robocode.api - - libs - false - robocode.${artifact.extension} - - - - - net.sf.robocode:robocode.roborumble - - libs - false - roborumble.${artifact.extension} - - - - - - net.sf.robocode:robocode.distribution - - net.sf.robocode:robocode.installer - net.sf.robocode:robocode.content - net.sf.robocode:robocode.samples - - net.sf.robocode:robocode.api - - net.sf.robocode:robocode.roborumble - - libs - false - - - - - net.sf.robocode:robocode.content - net.sf.robocode:robocode.installer - - true - - - **/META-INF/** - - - - - - - - net.sf.robocode:robocode.samples - - true - - robots - - - - - ../robocode.api/target/site/apidocs - javadoc - lf - - - - - ../versions.md - lf - - - diff --git a/workspace_robo/robocode.distribution/src.asm.xml b/workspace_robo/robocode.distribution/src.asm.xml deleted file mode 100644 index 86b0cec..0000000 --- a/workspace_robo/robocode.distribution/src.asm.xml +++ /dev/null @@ -1,53 +0,0 @@ - - - src - - dir - zip - - - - .. - lf - - plugins/battleview3d/** - plugins/js/** - plugins/scala/** - **/_ReSharper*/** - **/_ReSharper.*/** - **/Debug/** - **/Release/** - **/obj/** - **/target/** - **/lib/** - **/*.suo - **/*.user - **/*.log - **/*.iws - **/*.iml - **/*.ipr - **/*.jar - **/*.dll - **/*.exe - **/*.bak - **/Thumbs.db - **/~* - **/.* - **/.* - **/_svn/** - **/.svn/** - **/.metadata/** - **/*.jkey - **/*.snk - - - - diff --git a/workspace_robo/robocode.dummy.zip b/workspace_robo/robocode.dummy.zip deleted file mode 100644 index 354edba..0000000 Binary files a/workspace_robo/robocode.dummy.zip and /dev/null differ diff --git a/workspace_robo/robocode.host/.classpath b/workspace_robo/robocode.host/.classpath deleted file mode 100644 index a1d093f..0000000 --- a/workspace_robo/robocode.host/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.host/.project b/workspace_robo/robocode.host/.project deleted file mode 100644 index e6a7e2e..0000000 --- a/workspace_robo/robocode.host/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - robocode.host - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.api - robocode.core - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.host/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.host/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index 65f3846..0000000 --- a/workspace_robo/robocode.host/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:08 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.host/pom.xml b/workspace_robo/robocode.host/pom.xml deleted file mode 100644 index f0e6ed6..0000000 --- a/workspace_robo/robocode.host/pom.xml +++ /dev/null @@ -1,31 +0,0 @@ - - - 4.0.0 - robocode.host - Robocode Host - - net.sf.robocode - robocode - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - net.sf.robocode - robocode.core - ${project.version} - - - - junit - junit - 4.11 - test - - - diff --git a/workspace_robo/robocode.host/robocode.host.iml b/workspace_robo/robocode.host/robocode.host.iml deleted file mode 100644 index ddbee93..0000000 --- a/workspace_robo/robocode.host/robocode.host.iml +++ /dev/null @@ -1,93 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/CpuManager.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/CpuManager.java deleted file mode 100644 index 93a9a28..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/CpuManager.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.io.Logger; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.ui.IWindowManager; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert Maupin (contributor) - * @author Pavel Savara (contributor) - */ -public class CpuManager implements ICpuManager { // NO_UCD (use default) - private final static int APPROXIMATE_CYCLES_ALLOWED = 6250; - private final static int TEST_PERIOD_MILLIS = 5000; - - private long cpuConstant = -1; - private final ISettingsManager properties; - - public CpuManager(ISettingsManager properties) { // NO_UCD (unused code) - this.properties = properties; - } - - public long getCpuConstant() { - if (cpuConstant == -1) { - cpuConstant = properties.getCpuConstant(); - if (cpuConstant == -1) { - calculateCpuConstant(); - } - } - return cpuConstant; - } - - public void calculateCpuConstant() { - setStatus("Estimating CPU speed, please wait..."); - - setCpuConstant(); - Logger.logMessage( - "Each robot will be allowed a maximum of " + cpuConstant + " nanoseconds per turn on this system."); - - properties.setCpuConstant(cpuConstant); - properties.saveProperties(); - - setStatus(""); - } - - private void setCpuConstant() { - long count = 0; - double d = 0; - - long start = System.currentTimeMillis(); - - while (System.currentTimeMillis() - start < TEST_PERIOD_MILLIS) { - d += Math.hypot(Math.sqrt(Math.abs(Math.log(Math.atan(Math.random())))), - Math.cbrt(Math.abs(Math.random() * 10))) - / Math.exp(Math.random()); - count++; - } - - // to cheat optimizer, almost never happen - if (d == 0.0) { - Logger.logMessage("bingo!"); - } - - cpuConstant = Math.max(1, (long) (1000000.0 * APPROXIMATE_CYCLES_ALLOWED * TEST_PERIOD_MILLIS / count)); - } - - private void setStatus(String message) { - IWindowManager windowManager = Container.getComponent(IWindowManager.class); - - if (windowManager != null) { - windowManager.setStatus(message); - } - } - -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/HostManager.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/HostManager.java deleted file mode 100644 index 8dd1320..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/HostManager.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -import net.sf.robocode.host.proxies.*; -import net.sf.robocode.host.security.*; -import net.sf.robocode.host.jarjar.JarJarURLConnection; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.RobocodeProperties; -import net.sf.robocode.peer.IRobotPeer; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.repository.RobotType; -import net.sf.robocode.security.HiddenAccess; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.core.Container; -import robocode.control.RobotSpecification; - -import java.io.InputStream; -import java.io.PrintStream; - - -/** - * @author Pavel Savara (original) - */ -public class HostManager implements IHostManager { - private final ISettingsManager properties; - private IThreadManager threadManager; - - public HostManager(ISettingsManager properties, IThreadManager threadManager) { // NO_UCD (unused code) - this.properties = properties; - this.threadManager = threadManager; - } - - static { - initStreams(); - } - - private static void initStreams() { - PrintStream sysout = new SecurePrintStream(Logger.realOut, true); - PrintStream syserr = new SecurePrintStream(Logger.realErr, true); - InputStream sysin = new SecureInputStream(System.in); - - System.setOut(sysout); - if (RobocodeProperties.isDebuggingOff()) { - System.setErr(syserr); - } - System.setIn(sysin); - } - - public long getRobotFilesystemQuota() { - return properties.getRobotFilesystemQuota(); - } - - public IThreadManager getThreadManager() { - return threadManager; - } - - public void resetThreadManager() { - threadManager.reset(); - } - - public void addSafeThread(Thread safeThread) { - threadManager.addSafeThread(safeThread); - } - - public void removeSafeThread(Thread safeThread) { - threadManager.removeSafeThread(safeThread); - } - - public PrintStream getRobotOutputStream() { - return threadManager.getRobotOutputStream(); - } - - public void cleanup() {// TODO - } - - public String[] getReferencedClasses(IRobotItem robotItem) { - return getHost(robotItem).getReferencedClasses(robotItem); - } - - public RobotType getRobotType(IRobotItem robotItem, boolean resolve, boolean message) { - return getHost(robotItem).getRobotType(robotItem, resolve, message); - } - - public IHostingRobotProxy createRobotProxy(RobotSpecification robotSpecification, RobotStatics statics, IRobotPeer peer) { - IRobotItem specification = (IRobotItem) HiddenAccess.getFileSpecification(robotSpecification); - return getHost(specification).createRobotProxy(this, robotSpecification, statics, peer); - } - - private IHost getHost(IRobotItem robotItem) { - return (IHost) Container.cache.getComponent("robocode.host." + robotItem.getPlatform().toLowerCase()); - } - - public void initSecurity() { - JarJarURLConnection.register(); - new RobocodeSecurityPolicy(threadManager); - new RobocodeSecurityManager(threadManager); - } - -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/IHost.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/IHost.java deleted file mode 100644 index f5d6a33..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/IHost.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.repository.RobotType; -import net.sf.robocode.host.proxies.IHostingRobotProxy; -import net.sf.robocode.peer.IRobotPeer; -import robocode.control.RobotSpecification; - - -/** - * @author Pavel Savara (original) - */ -public interface IHost { // NO_UCD (use default) - IHostingRobotProxy createRobotProxy(IHostManager hostManager, RobotSpecification robotSpecification, IRobotStatics statics, IRobotPeer peer); - String[] getReferencedClasses(IRobotItem robotItem); - RobotType getRobotType(IRobotItem robotItem, boolean resolve, boolean message); -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/IHostedThread.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/IHostedThread.java deleted file mode 100644 index 98addcc..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/IHostedThread.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -import net.sf.robocode.host.io.RobotFileSystemManager; -import net.sf.robocode.host.io.RobotOutputStream; - - -/** - * @author Pavel Savara (original) - */ -public interface IHostedThread extends Runnable { - void println(String s); - - void drainEnergy(); - - void punishSecurityViolation(String message); - - RobotStatics getStatics(); - - RobotFileSystemManager getRobotFileSystemManager(); - - RobotOutputStream getOut(); - - ClassLoader getRobotClassloader(); -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/IThreadManager.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/IThreadManager.java deleted file mode 100644 index e0e3aac..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/IThreadManager.java +++ /dev/null @@ -1,43 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -import net.sf.robocode.security.IThreadManagerBase; - -import java.io.PrintStream; - - -/** - * @author Pavel Savara (original) - */ -public interface IThreadManager extends IThreadManagerBase { - void addThreadGroup(ThreadGroup g, IHostedThread robotProxy); - - IHostedThread getLoadingRobotProxy(Thread t); - - IHostedThread getLoadedOrLoadingRobotProxy(Thread t); - - IHostedThread getRobotProxy(Thread t); - - void reset(); - - void setLoadingRobot(IHostedThread newLoadingRobotProxy); - - void addSafeThread(Thread safeThread); - - void addSafeThreadGroup(ThreadGroup safeThreadGroup); - - void removeSafeThread(Thread safeThread); - - boolean isSafeThread(Thread c); - - PrintStream getRobotOutputStream(); - - boolean checkRobotFileStream(); -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/JavaHost.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/JavaHost.java deleted file mode 100644 index 3540256..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/JavaHost.java +++ /dev/null @@ -1,192 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -import net.sf.robocode.host.security.RobotClassLoader; -import net.sf.robocode.host.proxies.*; -import net.sf.robocode.peer.IRobotStatics; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.repository.RobotType; -import static net.sf.robocode.io.Logger.logError; -import net.sf.robocode.io.Logger; -import net.sf.robocode.peer.IRobotPeer; -import net.sf.robocode.security.HiddenAccess; -import robocode.Droid; -import robocode.Robot; -import robocode.BorderSentry; -import robocode.control.RobotSpecification; -import robocode.robotinterfaces.*; - -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.MouseWheelEvent; -import java.awt.*; -import java.security.AccessControlException; -import java.lang.reflect.Method; - - -/** - * @author Pavel Savara (original) - */ -public class JavaHost implements IHost { - public IRobotClassLoader createLoader(IRobotItem robotItem) { - return new RobotClassLoader(robotItem.getClassPathURL(), robotItem.getFullClassName()); - } - - public IHostingRobotProxy createRobotProxy(IHostManager hostManager, RobotSpecification robotSpecification, IRobotStatics statics, IRobotPeer peer) { - IHostingRobotProxy robotProxy; - final IRobotItem specification = (IRobotItem) HiddenAccess.getFileSpecification(robotSpecification); - - if (specification.isTeamRobot()) { - robotProxy = new TeamRobotProxy(specification, hostManager, peer, (RobotStatics) statics); - } else if (specification.isAdvancedRobot()) { - robotProxy = new AdvancedRobotProxy(specification, hostManager, peer, (RobotStatics) statics); - } else if (specification.isStandardRobot()) { - robotProxy = new StandardRobotProxy(specification, hostManager, peer, (RobotStatics) statics); - } else if (specification.isJuniorRobot()) { - robotProxy = new JuniorRobotProxy(specification, hostManager, peer, (RobotStatics) statics); - } else { - throw new AccessControlException("Unknown robot type"); - } - return robotProxy; - } - - public String[] getReferencedClasses(IRobotItem robotItem) { - IRobotClassLoader loader = null; - - try { - loader = createLoader(robotItem); - loader.loadRobotMainClass(true); - return loader.getReferencedClasses(); - - } catch (ClassNotFoundException e) { - Logger.logError(e); - return new String[0]; - } finally { - if (loader != null) { - loader.cleanup(); - } - } - } - - public RobotType getRobotType(IRobotItem robotItem, boolean resolve, boolean message) { - IRobotClassLoader loader = null; - - try { - loader = createLoader(robotItem); - Class robotClass = loader.loadRobotMainClass(resolve); - - if (robotClass == null || java.lang.reflect.Modifier.isAbstract(robotClass.getModifiers())) { - // this class is not robot - return RobotType.INVALID; - } - return checkInterfaces(robotClass, robotItem); - - } catch (Throwable t) { - if (message) { - logError("Got an error with " + robotItem.getFullClassName() + ": " + t); // just message here - if (t.getMessage() != null && t.getMessage().contains("Bad version number in .class file")) { - logError( - "Maybe robot was compiled with a newer Java version the Java version used for running Robocode?"); - } - } - return RobotType.INVALID; - } finally { - if (loader != null) { - loader.cleanup(); - } - } - } - - private RobotType checkInterfaces(Class robotClass, IRobotItem robotItem) { - boolean isJuniorRobot = false; - boolean isStandardRobot = false; - boolean isInteractiveRobot = false; - boolean isPaintRobot = false; - boolean isAdvancedRobot = false; - boolean isTeamRobot = false; - boolean isDroid = false; - boolean isSentryRobot = false; - - if (IAdvancedRobot.class.isAssignableFrom(robotClass)) { // Note: must be checked first - isAdvancedRobot = true; - } - if (Robot.class.isAssignableFrom(robotClass) && !isAdvancedRobot) { - isStandardRobot = true; - } - if (IJuniorRobot.class.isAssignableFrom(robotClass)) { // Note: Must be checked before checking for standard robot - isJuniorRobot = true; - if (isAdvancedRobot) { - throw new AccessControlException( - robotItem.getFullClassName() + ": Junior robot should not implement IAdvancedRobot interface."); - } - } - if (IBasicRobot.class.isAssignableFrom(robotClass)) { - if (!(isAdvancedRobot || isJuniorRobot)) { - isStandardRobot = true; - } - } - if (ITeamRobot.class.isAssignableFrom(robotClass)) { - isTeamRobot = true; - } - if (Droid.class.isAssignableFrom(robotClass)) { - isDroid = true; - } - if (BorderSentry.class.isAssignableFrom(robotClass)) { - isSentryRobot = true; - } - - if (IInteractiveRobot.class.isAssignableFrom(robotClass)) { - // in this case we make sure that robot don't waste time - if (checkMethodOverride(robotClass, Robot.class, "getInteractiveEventListener") - || checkMethodOverride(robotClass, Robot.class, "onKeyPressed", KeyEvent.class) - || checkMethodOverride(robotClass, Robot.class, "onKeyReleased", KeyEvent.class) - || checkMethodOverride(robotClass, Robot.class, "onKeyTyped", KeyEvent.class) - || checkMethodOverride(robotClass, Robot.class, "onMouseClicked", MouseEvent.class) - || checkMethodOverride(robotClass, Robot.class, "onMouseEntered", MouseEvent.class) - || checkMethodOverride(robotClass, Robot.class, "onMouseExited", MouseEvent.class) - || checkMethodOverride(robotClass, Robot.class, "onMousePressed", MouseEvent.class) - || checkMethodOverride(robotClass, Robot.class, "onMouseReleased", MouseEvent.class) - || checkMethodOverride(robotClass, Robot.class, "onMouseMoved", MouseEvent.class) - || checkMethodOverride(robotClass, Robot.class, "onMouseDragged", MouseEvent.class) - || checkMethodOverride(robotClass, Robot.class, "onMouseWheelMoved", MouseWheelEvent.class) - ) { - isInteractiveRobot = true; - } - } - - if (IPaintRobot.class.isAssignableFrom(robotClass)) { - if (checkMethodOverride(robotClass, Robot.class, "getPaintEventListener") - || checkMethodOverride(robotClass, Robot.class, "onPaint", Graphics2D.class) - ) { - isPaintRobot = true; - } - } - - return new RobotType(isJuniorRobot, isStandardRobot, isInteractiveRobot, isPaintRobot, isAdvancedRobot, - isTeamRobot, isDroid, isSentryRobot); - } - - private boolean checkMethodOverride(Class robotClass, Class knownBase, String name, Class... parameterTypes) { - if (knownBase.isAssignableFrom(robotClass)) { - final Method getInteractiveEventListener; - - try { - getInteractiveEventListener = robotClass.getMethod(name, parameterTypes); - } catch (NoSuchMethodException e) { - return false; - } - if (getInteractiveEventListener.getDeclaringClass().equals(knownBase)) { - return false; - } - } - return true; - } - -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/Module.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/Module.java deleted file mode 100644 index d551df1..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/Module.java +++ /dev/null @@ -1,26 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host; - - -import net.sf.robocode.core.BaseModule; -import net.sf.robocode.core.Container; -import net.sf.robocode.host.security.ThreadManager; - - -/** - * @author Pavel Savara (original) - */ -public class Module extends BaseModule { - static { - Container.cache.addComponent(IHostManager.class, HostManager.class); - Container.cache.addComponent(ICpuManager.class, CpuManager.class); - Container.cache.addComponent(IThreadManager.class, ThreadManager.class); - Container.cache.addComponent("robocode.host.java", JavaHost.class); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java deleted file mode 100644 index 0024a6b..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/events/EventManager.java +++ /dev/null @@ -1,572 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.events; - - -import net.sf.robocode.host.proxies.BasicRobotProxy; -import net.sf.robocode.security.HiddenAccess; -import robocode.*; -import robocode.exception.EventInterruptedException; -import robocode.robotinterfaces.IBasicRobot; - -import java.util.*; -import java.util.concurrent.CopyOnWriteArrayList; - - -// XXX Remember to update the .NET version whenever a change is made to this class! - -/** - * This class is used for managing the event queue for a robot. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Matthew Reeder (contributor) - * @author Robert D. Maupin (contributor) - * @author Nathaniel Troutman (contributor) - * @author Pavel Savara (contributor) - */ -public final class EventManager implements IEventManager { - - private final static int MAX_PRIORITY = 100; - public final static int MAX_EVENT_STACK = 2; - public final static int MAX_QUEUE_SIZE = 256; - - private final List customEvents = new CopyOnWriteArrayList(); - private final EventQueue eventQueue; - - private final boolean[] interruptible = new boolean[MAX_PRIORITY + 1]; - private Event currentTopEvent; - private int currentTopEventPriority; - private ScannedRobotEvent dummyScannedRobotEvent; - private Map eventNames; - - private IBasicRobot robot; - private BasicRobotProxy robotProxy; - - /** - * Constructs a new EventManager. - * - * @param robotProxy the robot proxy that this event manager applies to. - */ - public EventManager(BasicRobotProxy robotProxy) { - this.robotProxy = robotProxy; - eventQueue = new EventQueue(); - - registerEventNames(); - reset(); - } - - /** - * Adds an event to the event queue. - * @param event is the event to add to the event queue. - */ - public void add(Event event) { - if (!HiddenAccess.isCriticalEvent(event)) { - final int priority = getEventPriority(event.getClass().getName()); - HiddenAccess.setEventPriority(event, priority); - } - addImpl(event); - } - - /** - * Internal method for adding an event to the event queue. - * @param event is the event to add to the event queue. - */ - private void addImpl(Event event) { - if (eventQueue != null) { - if (eventQueue.size() > MAX_QUEUE_SIZE) { - robotProxy.println( - "Not adding to " + robotProxy.getStatics().getName() + "'s queue, exceeded " + MAX_QUEUE_SIZE - + " events in queue."); - } else { - HiddenAccess.setEventTime(event, getTime()); - eventQueue.add(event); - } - } - } - - /** - * Adds an custom event to the event queue based on a condition. - * @param condition is the condition that must be met in order to trigger the custom event. - */ - public void addCustomEvent(Condition condition) { - customEvents.add(condition); - } - - /** - * Removes all events from the event queue. - * @param includingSystemEvents {@code true} if system events must be removed as well; - * {@code false} if system events should stay on the event queue. - */ - public void clearAllEvents(boolean includingSystemEvents) { - eventQueue.clear(includingSystemEvents); - // customEvents.clear(); // Custom event should not be cleared here - } - - /** - * Cleans up the event queue. - *

- * This method should be called when the event queue is no longer needed, - * i.e. before it must be garbage collected. - */ - public void cleanup() { - // Remove all events - reset(); - - // Remove all references to robots - robot = null; - robotProxy = null; - } - - /** - * Returns a list containing all events currently in the robot's queue. - */ - public List getAllEvents() { - List events = new ArrayList(); - synchronized (eventQueue) { - for (Event e : eventQueue) { - events.add(e); - } - } - return events; - } - - /** - * Returns a list containing all BulletHitBulletEvents currently in the robot's queue. - */ - public List getBulletHitBulletEvents() { - List events = new ArrayList(); - synchronized (eventQueue) { - for (Event e : eventQueue) { - if (e instanceof BulletHitBulletEvent) { - events.add((BulletHitBulletEvent) e); - } - } - } - return events; - } - - /** - * Returns a list containing all BulletHitEvents currently in the robot's queue. - */ - public List getBulletHitEvents() { - List events = new ArrayList(); - synchronized (eventQueue) { - for (Event e : eventQueue) { - if (e instanceof BulletHitEvent) { - events.add((BulletHitEvent) e); - } - } - } - return events; - } - - /** - * Returns a list containing all BulletMissedEvents currently in the robot's queue. - */ - public List getBulletMissedEvents() { - List events = new ArrayList(); - synchronized (eventQueue) { - for (Event e : eventQueue) { - if (e instanceof BulletMissedEvent) { - events.add((BulletMissedEvent) e); - } - } - } - return events; - } - - /** - * Returns a list containing all HitByBulletEvents currently in the robot's queue. - */ - public List getHitByBulletEvents() { - List events = new ArrayList(); - synchronized (eventQueue) { - for (Event e : eventQueue) { - if (e instanceof HitByBulletEvent) { - events.add((HitByBulletEvent) e); - } - } - } - return events; - } - - /** - * Returns a list containing all HitRobotEvents currently in the robot's queue. - */ - public List getHitRobotEvents() { - List events = new ArrayList(); - - synchronized (eventQueue) { - for (Event e : eventQueue) { - if (e instanceof HitRobotEvent) { - events.add((HitRobotEvent) e); - } - } - } - return events; - } - - /** - * Returns a list containing all HitWallEvents currently in the robot's queue. - */ - public List getHitWallEvents() { - List events = new ArrayList(); - synchronized (eventQueue) { - for (Event e : eventQueue) { - if (e instanceof HitWallEvent) { - events.add((HitWallEvent) e); - } - } - } - return events; - } - - /** - * Returns a list containing all RobotDeathEvents currently in the robot's queue. - */ - public List getRobotDeathEvents() { - List events = new ArrayList(); - synchronized (eventQueue) { - for (Event e : eventQueue) { - if (e instanceof RobotDeathEvent) { - events.add((RobotDeathEvent) e); - } - } - } - return events; - } - - /** - * Returns a list containing all ScannedRobotEvents currently in the robot's queue. - */ - public List getScannedRobotEvents() { - List events = new ArrayList(); - synchronized (eventQueue) { - for (Event e : eventQueue) { - if (e instanceof ScannedRobotEvent) { - events.add((ScannedRobotEvent) e); - } - } - } - return events; - } - - /** - * Returns a list containing all MessageEvents currently in the robot's queue. - */ - public List getMessageEvents() { - List events = new ArrayList(); - synchronized (eventQueue) { - for (Event e : eventQueue) { - if (e instanceof MessageEvent) { - events.add((MessageEvent) e); - } - } - } - return events; - } - - /** - * Returns a list containing all StatusEvents currently in the robot's queue. - */ - public List getStatusEvents() { - List events = new ArrayList(); - synchronized (eventQueue) { - for (Event e : eventQueue) { - if (e instanceof StatusEvent) { - events.add((StatusEvent) e); - } - } - } - return events; - } - - /** - * Returns the priority of the current top event. - */ - public int getCurrentTopEventPriority() { - return currentTopEventPriority; - } - - /** - * Returns the current top event. - */ - public Event getCurrentTopEvent() { - return currentTopEvent; - } - - /** - * Checks if events with a specific event priority are interruptible. - * @param priority is the event priority that must be checked. - * @see #setInterruptible(int, boolean) - */ - public boolean isInterruptible(int priority) { - return interruptible[priority]; - } - - /** - * Sets the robot that will receive events dispatched from the event queue. - * @param robot is the robot that will receive event dispatched from the event queue. - */ - public void setRobot(IBasicRobot robot) { - this.robot = robot; - } - - /** - * Returns the priority of a ScannedRobotEvent. - */ - public int getScannedRobotEventPriority() { - return dummyScannedRobotEvent.getPriority(); - } - - /** - * Returns the current time/turn of the battle round. - */ - public long getTime() { - return robotProxy.getTimeImpl(); - } - - /** - * This is the heart of the event manager, which processes the events for a robot. - */ - public void processEvents() { - // Remove old events - eventQueue.clear(getTime() - MAX_EVENT_STACK); - - // Process custom events - for (Condition customEvent : customEvents) { - boolean conditionSatisfied = callUserCode(customEvent); - if (conditionSatisfied) { - addImpl(new CustomEvent(customEvent)); - } - } - - // Sort the events based on the time and priority of the events - eventQueue.sort(); - - // Process event queue here - Event currentEvent; - while ((currentEvent = (eventQueue.size() > 0) ? eventQueue.get(0) : null) != null - && currentEvent.getPriority() >= currentTopEventPriority) { - - if (currentEvent.getPriority() == currentTopEventPriority) { - if (currentTopEventPriority > Integer.MIN_VALUE && isInterruptible(currentTopEventPriority)) { - setInterruptible(currentTopEventPriority, false); // we're going to restart it, so reset. - - // We are already in an event handler, took action, and a new event was generated. - // So we want to break out of the old handler to process it here. - throw new EventInterruptedException(currentEvent.getPriority()); - } - break; - } - - int oldTopEventPriority = currentTopEventPriority; - - currentTopEventPriority = currentEvent.getPriority(); - currentTopEvent = currentEvent; - - eventQueue.remove(currentEvent); - try { - dispatch(currentEvent); - - setInterruptible(currentTopEventPriority, false); - - } catch (EventInterruptedException e) { - currentTopEvent = null; - } catch (RuntimeException e) { - currentTopEvent = null; - throw e; - } catch (Error e) { - currentTopEvent = null; - throw e; - } finally { - currentTopEventPriority = oldTopEventPriority; - } - } - } - - /** - * Checks if the user's condition for a custom event is satisfied. - * @param condition is the condition to check. - * @return {@code true} if the condition is satisfied; {@code false} otherwise. - */ - private boolean callUserCode(Condition condition) { - boolean conditionSatisfied; - robotProxy.setTestingCondition(true); - try { - conditionSatisfied = condition.test(); - } finally { - robotProxy.setTestingCondition(false); - } - return conditionSatisfied; - } - - /** - * Dispatches an event for a robot. - *

- * Too old events will not be dispatched and a critical event is always dispatched. - * - * @param event the event to dispatch to the robot. - */ - private void dispatch(Event event) { - if (robot != null && event != null) { - try { - // skip too old events - if ((event.getTime() > getTime() - MAX_EVENT_STACK) || HiddenAccess.isCriticalEvent(event)) { - HiddenAccess.dispatch(event, robot, robotProxy.getStatics(), robotProxy.getGraphicsImpl()); - } - } catch (Exception ex) { - robotProxy.println("SYSTEM: " + ex.getClass().getName() + " occurred on " + event.getClass().getName()); - ex.printStackTrace(robotProxy.getOut()); - } - } - } - - /** - * Removes the custom event with the specified condition from the event queue. - * @param condition is the condition of the custom event to remove. - */ - public void removeCustomEvent(Condition condition) { - customEvents.remove(condition); - } - - /** - * Removes all custom events from the event queue. - */ - public void resetCustomEvents() { - customEvents.clear(); - } - - /** - * Resets this event manager by removing all events from the event queue. - */ - public synchronized void reset() { - currentTopEventPriority = Integer.MIN_VALUE; - clearAllEvents(true); - customEvents.clear(); - } - - /** - * Changes the interruptible flag for events with a specific priority. - * When an event is interrupted, events with the same priority are allowed to restart the event handler. - * - * @param priority is the priority of the event to set the interruptible flag for. - * @param isInterruptable {@code true} if events with the specified priority must be interruptible - * allowing events with the same priority to restart the event handler. - * {@code false} if events with the specified priority must not be interruptible - * disallowing events with the same priority to restart the event handler. - */ - public void setInterruptible(int priority, boolean isInterruptable) { - if (priority >= 0 && priority < MAX_PRIORITY) { - interruptible[priority] = isInterruptable; - } - } - - /** - * Returns the priority of events belonging to a specific class. - * @param eventClass is a string with the full class name of the event type to get the priority from. - * @return the event priority of the specified event class. - * @see robocode.Event#getPriority() - */ - public int getEventPriority(String eventClass) { - if (eventClass == null) { - return -1; - } - final Event event = eventNames.get(eventClass); - if (event == null) { - return -1; - } - return event.getPriority(); - } - - /** - * Sets the event priority of events belonging to a specific class. - * @param eventClass is a string with the full class name of the event type to set the priority for. - * @param priority is the new priority - */ - public void setEventPriority(String eventClass, int priority) { - if (eventClass == null) { - return; - } - final Event event = eventNames.get(eventClass); - if (event == null) { - robotProxy.println("SYSTEM: Unknown event class: " + eventClass); - return; - } - if (HiddenAccess.isCriticalEvent(event)) { - robotProxy.println("SYSTEM: You may not change the priority of a system event."); - } - HiddenAccess.setEventPriority(event, priority); - } - - /** - * Registers the full and simple class names of all events used by {@link #getEventPriority(String)} and - * {@link #setEventPriority(String, int)} and sets the default priority of each event class. - */ - private void registerEventNames() { - eventNames = new HashMap(); - dummyScannedRobotEvent = new ScannedRobotEvent(null, 0, 0, 0, 0, 0, false); - registerEventNames(new BattleEndedEvent(false, null)); - registerEventNames(new BulletHitBulletEvent(null, null)); - registerEventNames(new BulletHitEvent(null, 0, null)); - registerEventNames(new BulletMissedEvent(null)); - registerEventNames(new DeathEvent()); - registerEventNames(new HitByBulletEvent(0, null)); - registerEventNames(new HitRobotEvent(null, 0, 0, false)); - registerEventNames(new HitWallEvent(0)); - registerEventNames(new KeyPressedEvent(null)); - registerEventNames(new KeyReleasedEvent(null)); - registerEventNames(new KeyTypedEvent(null)); - registerEventNames(new MessageEvent(null, null)); - registerEventNames(new MouseClickedEvent(null)); - registerEventNames(new MouseDraggedEvent(null)); - registerEventNames(new MouseEnteredEvent(null)); - registerEventNames(new MouseExitedEvent(null)); - registerEventNames(new MouseMovedEvent(null)); - registerEventNames(new MousePressedEvent(null)); - registerEventNames(new MouseReleasedEvent(null)); - registerEventNames(new MouseWheelMovedEvent(null)); - registerEventNames(new PaintEvent()); - registerEventNames(new RobotDeathEvent(null)); - registerEventNames(new RoundEndedEvent(0, 0, 0)); - registerEventNames(dummyScannedRobotEvent); - registerEventNames(new SkippedTurnEvent(0)); - registerEventNames(new StatusEvent(null)); - registerEventNames(new WinEvent()); - - // same as any line above but for custom event - final DummyCustomEvent customEvent = new DummyCustomEvent(); - eventNames.put("robocode.CustomEvent", customEvent); // full name with package name - eventNames.put("CustomEvent", customEvent); // only the class name - } - - /** - * Registers the full and simple class name of the specified event and sets the default - * priority of the event class. - * @param event an event belonging to the event class to register the class name for etc. - */ - private void registerEventNames(Event event) { - if (!HiddenAccess.isCriticalEvent(event)) { - HiddenAccess.setDefaultPriority(event); - } - final Class type = event.getClass(); - eventNames.put(type.getName(), event); // full name with package name - eventNames.put(type.getSimpleName(), event); // only the class name - } - - /** - * A dummy CustomEvent used only for registering the class name. - */ - @SuppressWarnings("serial") - private static final class DummyCustomEvent extends CustomEvent { - public DummyCustomEvent() { - super(null); - } - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/events/EventQueue.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/events/EventQueue.java deleted file mode 100644 index 62779b5..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/events/EventQueue.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.events; - - -import net.sf.robocode.security.HiddenAccess; -import robocode.Event; - -import java.util.ArrayList; -import java.util.Collections; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class EventQueue extends ArrayList { - - public void clear(boolean includingSystemEvents) { - if (includingSystemEvents) { - super.clear(); - return; - } - - for (int i = 0; i < size(); i++) { - Event e = get(i); - - if (!HiddenAccess.isCriticalEvent(e)) { - remove(i--); - } - } - } - - public void clear(long clearTime) { - for (int i = 0; i < size(); i++) { - Event e = get(i); - - if ((e.getTime() <= clearTime) && !HiddenAccess.isCriticalEvent(e)) { - remove(i--); - } - } - } - - void sort() { - Collections.sort(this); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/events/IEventManager.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/events/IEventManager.java deleted file mode 100644 index 0d8a85e..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/events/IEventManager.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.events; - - -import robocode.*; - -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public interface IEventManager { - void addCustomEvent(Condition condition); - - void removeCustomEvent(Condition condition); - - void clearAllEvents(boolean includingSystemEvents); - - void setEventPriority(String eventClass, int priority); - - int getEventPriority(String eventClass); - - java.util.List getAllEvents(); - - List getBulletMissedEvents(); - - List getBulletHitBulletEvents(); - - List getBulletHitEvents(); - - List getHitByBulletEvents(); - - List getHitRobotEvents(); - - List getHitWallEvents(); - - List getRobotDeathEvents(); - - List getScannedRobotEvents(); - - // team - List getMessageEvents(); -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/BufferedPipedInputStream.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/BufferedPipedInputStream.java deleted file mode 100644 index 9e7c191..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/BufferedPipedInputStream.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.io; - - -import java.io.IOException; -import java.io.InputStream; - - -/** - * @author Mathew A. Nelson (original) - */ -class BufferedPipedInputStream extends InputStream { - - private final BufferedPipedOutputStream out; - - protected BufferedPipedInputStream(BufferedPipedOutputStream out) { - this.out = out; - } - - @Override - public int read() throws IOException { - return out.read(); - } - - @Override - public int read(byte b[], int off, int len) throws IOException { - return out.read(b, off, len); - } - - @Override - public int available() { - return out.available(); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/BufferedPipedOutputStream.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/BufferedPipedOutputStream.java deleted file mode 100644 index 448e50c..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/BufferedPipedOutputStream.java +++ /dev/null @@ -1,169 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.io; - - -import java.io.IOException; -import java.io.OutputStream; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -class BufferedPipedOutputStream extends OutputStream { - - private final Object monitor = new Object(); - private final byte[] buf; - private volatile int readIndex; - private volatile int writeIndex; - private volatile boolean waiting; - private volatile boolean closed; - private BufferedPipedInputStream in; - private final boolean skipLines; - - BufferedPipedOutputStream(int bufferSize, boolean skipLines) { - this.buf = new byte[bufferSize]; - this.skipLines = skipLines; - } - - /* - * @see OutputStream#write(int) - */ - @Override - public void write(int b) throws IOException { - synchronized (monitor) { - if (closed) { - throw new IOException("Stream is closed."); - } - - buf[writeIndex++] = (byte) (b & 0xff); - if (writeIndex == buf.length) { - writeIndex = 0; - } - if (writeIndex == readIndex) { - // skipping a line! - if (skipLines) { - boolean writeIndexReached = false; - - while (buf[readIndex] != '\n') { - readIndex++; - if (readIndex == buf.length) { - readIndex = 0; - } - if (readIndex == writeIndex) { - writeIndexReached = true; - } - } - if (!writeIndexReached) { - readIndex++; - if (readIndex == buf.length) { - readIndex = 0; - } - } - } else { - throw new IOException("Buffer is full."); - } - } - if (waiting) { - monitor.notifyAll(); - } - } - } - - protected int read() throws IOException { - synchronized (monitor) { - while (readIndex == writeIndex) { - waiting = true; - try { - if (!closed) { - monitor.wait(10000); - } - if (closed) { - return -1; - } - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - - IOException ioException = new IOException("read interrupted"); - - ioException.initCause(e); - throw ioException; - } - } - int result = buf[readIndex++]; - - if (readIndex == buf.length) { - readIndex = 0; - } - - return result; - } - } - - int read(byte b[], int off, int len) throws IOException { - if (b == null) { - throw new NullPointerException(); - } else if (off < 0 || len < 0 || off >= b.length || (off + len) > b.length) { - throw new IndexOutOfBoundsException(); - } else if (len == 0) { - return 0; - } - int first = read(); - - if (first == -1) { - return -1; - } - - b[off] = (byte) (first & 0xff); - int count = 1; - - synchronized (monitor) { - for (int i = 1; readIndex != writeIndex && i < len; i++) { - b[off + i] = buf[readIndex++]; - count++; - if (readIndex == buf.length) { - readIndex = 0; - } - } - } - return count; - } - - protected int available() { - synchronized (monitor) { - if (writeIndex == readIndex) { - return 0; - } else if (writeIndex > readIndex) { - return writeIndex - readIndex; - } else { - return buf.length - readIndex + writeIndex; - } - } - } - - public BufferedPipedInputStream getInputStream() { - synchronized (monitor) { - if (in == null) { - in = new BufferedPipedInputStream(this); - } - return in; - } - } - - @Override - public void close() { - synchronized (monitor) { - closed = true; - if (waiting) { - monitor.notifyAll(); - } - } - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/RobotFileOutputStream.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/RobotFileOutputStream.java deleted file mode 100644 index 3895021..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/RobotFileOutputStream.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.io; - - -import java.io.FileOutputStream; -import java.io.IOException; - - -/** - * @author Pavel Savara (original) - */ -public class RobotFileOutputStream extends FileOutputStream { - - private RobotFileSystemManager fileSystemManager; - - public RobotFileOutputStream(String filename, boolean append, RobotFileSystemManager fileSystemManager) throws IOException { - super(filename, append); - this.fileSystemManager = fileSystemManager; - fileSystemManager.addStream(this); - } - - @Override - public final void close() throws IOException { - fileSystemManager.removeStream(this); - super.close(); - } - - @Override - public final void write(byte[] b) throws IOException { - try { - fileSystemManager.checkQuota(b.length); - super.write(b); - } catch (IOException e) { - try { - close(); - } catch (IOException ignored) {} - throw e; - } - } - - @Override - public final void write(byte[] b, int off, int len) throws IOException { - if (len < 0) { - throw new IndexOutOfBoundsException(); - } - try { - fileSystemManager.checkQuota(len); - super.write(b, off, len); - } catch (IOException e) { - try { - close(); - } catch (IOException ignored) {} - throw e; - } - } - - @Override - public final void write(int b) throws IOException { - try { - fileSystemManager.checkQuota(1); - super.write(b); - } catch (IOException e) { - try { - close(); - } catch (IOException ignored) {} - throw e; - } - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/RobotFileSystemManager.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/RobotFileSystemManager.java deleted file mode 100644 index 7ffb8d4..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/RobotFileSystemManager.java +++ /dev/null @@ -1,336 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.io; - - -import net.sf.robocode.host.IHostedThread; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.version.Version; - -import java.io.*; -import java.net.JarURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.Enumeration; -import java.util.List; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -public class RobotFileSystemManager { - private final IHostedThread robotProxy; - private long quotaUsed; - private boolean quotaMessagePrinted; - private final List streams = new ArrayList(); - private final long maxQuota; - private final String writableRootDirectory; - private final String readableRootDirectory; - private final String rootPath; - private final String dataDir; - - public RobotFileSystemManager(IHostedThread robotProxy, long maxQuota, String writableRootDirectory, String readableRootDirectory, String rootPath) { - this.robotProxy = robotProxy; - this.maxQuota = maxQuota; - this.writableRootDirectory = writableRootDirectory; - this.readableRootDirectory = readableRootDirectory; - this.rootPath = rootPath; - - this.dataDir = robotProxy.getStatics().getFullClassName().replace('.', '/') + ".data/"; - } - - public void initialize() { - initializeQuota(); - updateDataFiles(); - } - - void addStream(RobotFileOutputStream s) throws IOException { - if (s == null) { - throw new SecurityException("You may not add a null stream."); - } - if (!streams.contains(s)) { - if (streams.size() < 5) { - streams.add(s); - } else { - throw new SecurityException( - "You may only have 5 streams open at a time.\n Make sure you call close() on your streams when you are finished with them."); - } - } - } - - public synchronized void adjustQuota(long len) { - quotaUsed += len; - } - - public void checkQuota() throws IOException { - checkQuota(0); - } - - void checkQuota(long numBytes) throws IOException { - if (numBytes < 0) { - throw new IllegalArgumentException("checkQuota on negative numBytes!"); - } - if (quotaUsed + numBytes <= maxQuota) { - adjustQuota(numBytes); - } else { - final String msg = "You have reached your filesystem quota of: " + maxQuota + " bytes."; - - if (!quotaMessagePrinted) { - robotProxy.println("SYSTEM: " + msg); - quotaMessagePrinted = true; - } - throw new IOException(msg); // Must be IOException due to bug fix [2960894] - } - } - - public long getMaxQuota() { - return maxQuota; - } - - public long getQuotaUsed() { - return quotaUsed; - } - - public File getReadableDirectory() { - try { - return (readableRootDirectory == null) ? null : new File(readableRootDirectory).getCanonicalFile(); - } catch (IOException e) { - Logger.logError(e); - return null; - } - } - - public File getWritableDirectory() { - try { - return (writableRootDirectory == null) - ? null - : new File(writableRootDirectory, robotProxy.getStatics().getShortClassName() + ".data").getCanonicalFile(); - } catch (IOException e) { - Logger.logError(e); - return null; - } - } - - public File getDataFile(String filename) { - filename = filename.replaceAll("\\*", ""); - - final File parent = getWritableDirectory(); - File file = new File(parent, filename); - - // TODO the file is never replaced from jar or directory after it was created - // TODO it would be good to replace it when it have bigger last modified date - if (!file.exists()) { - if (parent != null && !parent.exists() && !parent.mkdirs()) { - return file; - } - InputStream is = null; - OutputStream os = null; - - try { - URL url = new URL(rootPath + dataDir + filename); - - URLConnection connection = url.openConnection(); - connection.setUseCaches(false); - try { - is = connection.getInputStream(); - } catch (FileNotFoundException ex) { // Expected as no file might exists with the specified input 'filename' - // #380 yet another historical bot related bug - Version robocodeVersion = toVersion(robotProxy.getStatics().getRobocodeVersion()); - if (robocodeVersion != null && robocodeVersion.compareTo("1.8.2.0") < 0) { - throw ex; - } - } - os = new FileOutputStream(file); - if (is != null) { - copyStream(is, os); - } - } catch (IOException e) { - // #380 yet another historical bot related bug - boolean legacyRobot = false; - if (e instanceof FileNotFoundException) { - Version robocodeVersion = toVersion(robotProxy.getStatics().getRobocodeVersion()); - if (robocodeVersion != null && robocodeVersion.compareTo("1.8.2.0") < 0) { - legacyRobot = true; - } - } - if (!legacyRobot) { - // Always log error, unless an legacy robot got a FileNotFoundException - Logger.logError(e); - } - } finally { - FileUtil.cleanupStream(is); - FileUtil.cleanupStream(os); - } - } - return file; - } - - private void initializeQuota() { - quotaUsed = 0; - quotaMessagePrinted = false; - - File dataDirectory = getWritableDirectory(); - - if (dataDirectory != null && dataDirectory.exists()) { - File[] dataFiles = dataDirectory.listFiles(); - - for (File file : dataFiles) { - quotaUsed += file.length(); - } - } - } - - public boolean isReadable(String fileName) { - File allowedDirectory = getReadableDirectory(); - if (allowedDirectory == null) { - return false; - } - - File attemptedFile; - try { - attemptedFile = new File(fileName).getCanonicalFile(); - } catch (IOException e) { - return false; - } - - if (attemptedFile.equals(allowedDirectory)) { - return true; // recursive check - } - - if (attemptedFile.getParent().indexOf(allowedDirectory.toString()) == 0) { - String fs = attemptedFile.toString(); - int dataIndex = fs.indexOf(".data", allowedDirectory.toString().length()); - - if (dataIndex >= 0) { - if (isWritable(fileName) || attemptedFile.equals(getWritableDirectory())) { - return true; - } - throw new java.security.AccessControlException( - "Preventing " + Thread.currentThread().getName() + " from access to: " + fileName - + ": You may not read another robot's data directory."); - } - return true; - } - - return false; - } - - public boolean isWritable(String fileName) { - File allowedDirectory = getWritableDirectory(); - - if (allowedDirectory == null) { - return false; - } - - File attemptedFile; - - try { - attemptedFile = new File(fileName).getCanonicalFile(); - } catch (IOException e) { - return false; - } - - return attemptedFile.equals(allowedDirectory) || attemptedFile.getParentFile().equals(allowedDirectory); - } - - void removeStream(RobotFileOutputStream s) { - if (s == null) { - throw new SecurityException("You may not remove a null stream."); - } - if (streams.contains(s)) { - streams.remove(s); - } - } - - private void updateDataFiles() { - try { - if (rootPath.startsWith("jar:")) { - updateDataFilesFromJar(); - } - } catch (IOException e) { - e.printStackTrace(); - } - } - - private void updateDataFilesFromJar() throws IOException { - URL url = new URL(rootPath); - JarURLConnection jarConnection = (JarURLConnection) url.openConnection(); - - jarConnection.setUseCaches(false); - - JarFile jarFile = jarConnection.getJarFile(); - - Enumeration entries = jarFile.entries(); - - final File parent = getWritableDirectory(); - - if (!parent.exists() && !parent.mkdirs()) { - throw new IOException("Could not create writeable directory for " + robotProxy.getStatics().getName()); - } - - InputStream is = null; - OutputStream os = null; - - while (entries.hasMoreElements()) { - JarEntry jarEntry = (JarEntry) entries.nextElement(); - - String filename = jarEntry.getName(); - - if (filename.startsWith(dataDir)) { - filename = filename.substring(dataDir.length()); - if (filename.length() == 0) { // Bugfix [2845608] - FileNotFoundException - continue; - } - - is = null; - os = null; - try { - is = jarFile.getInputStream(jarEntry); - os = new FileOutputStream(new File(parent, filename)); - copyStream(is, os); - } finally { - FileUtil.cleanupStream(is); - FileUtil.cleanupStream(os); - } - } - } - } - - private void copyStream(InputStream is, OutputStream os) throws IOException { - BufferedInputStream bis = new BufferedInputStream(is); - BufferedOutputStream bos = new BufferedOutputStream(os); - - byte[] buf = new byte[8192]; - int len; - - while ((len = bis.read(buf)) > 0) { - bos.write(buf, 0, len); - } - bos.flush(); - } - - private static Version toVersion(String vers) { - if (vers != null) { - vers = vers.trim(); - if (vers.length() > 0) { - try { - return new Version(vers); - } catch (IllegalArgumentException ex) { - return null; - } - } - } - return null; - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/RobotOutputStream.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/RobotOutputStream.java deleted file mode 100644 index 74cd65f..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/io/RobotOutputStream.java +++ /dev/null @@ -1,294 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.io; - - -import java.io.PrintWriter; -import java.io.StringWriter; - -import net.sf.robocode.io.RobocodeProperties; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class RobotOutputStream extends java.io.PrintStream { - - private static final int MAX_CHARS = 50000; - - private int count = 0; - private boolean messaged = false; - private final StringBuilder text; - private final Object syncRoot = new Object(); - - public RobotOutputStream() { - super(new BufferedPipedOutputStream(128, true)); - this.text = new StringBuilder(8192); - } - - public String readAndReset() { - synchronized (syncRoot) { - - // Out's counter must be reset before processing event. - // Otherwise, it will not be reset when printing in the onScannedEvent() - // before a scan() call, which will potentially cause a new onScannedEvent() - // and therefore not be able to reset the counter. - count = 0; - - if (text.length() > 0) { - final String result = text.toString(); - - text.setLength(0); - return result; - } - return ""; - } - } - - private boolean isOkToPrint() { - synchronized (syncRoot) { - if (RobocodeProperties.isDebuggingOn()) { // It is always allowed to print when debugging is enabled. - return true; - } - if (count > MAX_CHARS) { - if (!messaged) { - text.append( - "\nSYSTEM: This robot is printing too much between actions. Output stopped until next action.\n"); - messaged = true; - } - return false; - } - messaged = false; - return true; - } - } - - @Override - public void print(char[] s) { - synchronized (syncRoot) { - if (isOkToPrint()) { - int origLen = text.length(); - - text.append(s); - count += text.length() - origLen; - } - } - } - - @Override - public void print(char c) { - synchronized (syncRoot) { - if (isOkToPrint()) { - text.append(c); - count++; - } - } - } - - @Override - public void print(double d) { - synchronized (syncRoot) { - if (isOkToPrint()) { - int origLen = text.length(); - - text.append(d); - count += text.length() - origLen; - } - } - } - - @Override - public void print(float f) { - synchronized (syncRoot) { - if (isOkToPrint()) { - int origLen = text.length(); - - text.append(f); - count += text.length() - origLen; - } - } - } - - @Override - public void print(int i) { - synchronized (syncRoot) { - if (isOkToPrint()) { - int origLen = text.length(); - - text.append(i); - count += text.length() - origLen; - } - } - } - - @Override - public void print(long l) { - synchronized (syncRoot) { - if (isOkToPrint()) { - int origLen = text.length(); - - text.append(l); - count += text.length() - origLen; - } - } - } - - @Override - public void print(Object obj) { - synchronized (syncRoot) { - if (isOkToPrint()) { - int origLen = text.length(); - - if (obj != null) { - String s = obj.toString(); - - text.append(s); - } else { - text.append((Object) null); - } - count += text.length() - origLen; - } - } - } - - @Override - public void print(String s) { - synchronized (syncRoot) { - if (isOkToPrint()) { - int origLen = text.length(); - - text.append(s); - count += text.length() - origLen; - } - } - } - - @Override - public void print(boolean b) { - synchronized (syncRoot) { - if (isOkToPrint()) { - int origLen = text.length(); - - text.append(b); - count += text.length() - origLen; - } - } - } - - @Override - public void println() { - print('\n'); - } - - @Override - public void println(char[] x) { - print(x); - print('\n'); - } - - @Override - public void println(char x) { - print(x); - print('\n'); - } - - @Override - public void println(double x) { - print(x); - print('\n'); - } - - @Override - public void println(float x) { - print(x); - print('\n'); - } - - @Override - public void println(int x) { - print(x); - print('\n'); - } - - @Override - public void println(long x) { - print(x); - print('\n'); - } - - @Override - public void println(Object x) { - print(x); - print('\n'); - } - - @Override - public void println(String x) { - print(x); - print('\n'); - } - - @Override - public void println(boolean x) { - print(x); - print('\n'); - } - - @Override - public void write(byte[] buf) { - write(buf, 0, buf.length); - } - - @Override - public void write(byte[] buf, int off, int len) { - synchronized (syncRoot) { - if (isOkToPrint()) { - if (buf != null) { - int origLen = text.length(); - - for (int i = 0; i < len; i++) { - text.append((char) buf[off + i]); - } - count += text.length() - origLen; - } - } - } - } - - @Override - public void write(int b) { - synchronized (syncRoot) { - if (isOkToPrint()) { - int origLen = text.length(); - - text.append((char) b); - count += text.length() - origLen; - } - } - } - - public void printStackTrace(Throwable t) { - if (t != null) { - synchronized (syncRoot) { - if (isOkToPrint()) { - StringWriter sw = new StringWriter(); - final PrintWriter writer = new PrintWriter(sw); - - t.printStackTrace(writer); - writer.flush(); - - int origLen = text.length(); - - text.append(sw.toString()); - count += text.length() - origLen; - } - } - } - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/jarjar/JarJarURLConnection.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/jarjar/JarJarURLConnection.java deleted file mode 100644 index bce050c..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/jarjar/JarJarURLConnection.java +++ /dev/null @@ -1,182 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -// NOTE: JarJarURLStreamHandler is just tweaked version of jar handler from OpenJDK. - -package net.sf.robocode.host.jarjar; - - -import net.sf.robocode.io.URLJarCollector; -import net.sf.robocode.io.JarJar; - -import java.io.InputStream; -import java.io.IOException; -import java.net.*; - - -// TODO: Update to new version from OpenJDK - -/** - * @author Sun Microsystems, Inc (original) - * @author Pavel Savara (contributor) - */ -public class JarJarURLConnection extends URLConnection { - - private final static char SEPARATOR_CHAR = JarJar.SEPARATOR_CHAR; // this is '^' now - private final static String SEPARATOR = SEPARATOR_CHAR + "/"; - - private URLConnection connection; - private static boolean registered; - - private JarJarURLConnection(URL url) - throws IOException { - super(url); - final String file = url.getFile(); - URL inner = new URL(file); - - // this is same as - // connection = inner.openConnection() - // we just cache the connection in URLJarCollector - // because we need to be able to close it to release jar files - connection = URLJarCollector.openConnection(inner); - } - - public void connect() throws IOException { - if (!connected) { - connection.connect(); - connected = true; - } - } - - public InputStream getInputStream() throws IOException { - connect(); - return connection.getInputStream(); - } - - public static void register() { - if (!registered) { - URL.setURLStreamHandlerFactory(new JarJarURLStreamHandlerFactory()); - registered = true; - } - } - - private static class JarJarURLStreamHandlerFactory implements URLStreamHandlerFactory { - public URLStreamHandler createURLStreamHandler(String protocol) { - if (protocol.equals("jarjar")) { - return new JarJarURLStreamHandler(); - } - return null; - } - } - - - private static class JarJarURLStreamHandler extends URLStreamHandler { - - protected URLConnection openConnection(URL u) throws IOException { - return new JarJarURLConnection(u); - } - - private int indexOfBangSlash(String spec) { - int indexOfBang = spec.length(); - - while ((indexOfBang = spec.lastIndexOf(SEPARATOR_CHAR, indexOfBang)) != -1) { - if ((indexOfBang != (spec.length() - 1)) && (spec.charAt(indexOfBang + 1) == '/')) { - return indexOfBang + 1; - } else { - indexOfBang--; - } - } - return -1; - } - - @SuppressWarnings({ "deprecation"}) - protected void parseURL(URL url, String spec, - int start, int limit) { - String file = null; - String ref = null; - // first figure out if there is an anchor - int refPos = spec.indexOf('#', limit); - boolean refOnly = refPos == start; - - if (refPos > -1) { - ref = spec.substring(refPos + 1, spec.length()); - if (refOnly) { - file = url.getFile(); - } - } - // then figure out if the spec is - // 1. absolute (jarjar:) - // 2. relative (i.e. url + foo/bar/baz.ext) - // 3. anchor-only (i.e. url + #foo), which we already did (refOnly) - boolean absoluteSpec = false; - - if (spec.length() >= 7) { - absoluteSpec = spec.substring(0, 7).equalsIgnoreCase("jarjar:"); - } - spec = spec.substring(start, limit); - - if (absoluteSpec) { - file = parseAbsoluteSpec(spec); - } else if (!refOnly) { - file = parseContextSpec(url, spec); - - // Canonize the result after the bangslash - int bangSlash = indexOfBangSlash(file); - String toBangSlash = file.substring(0, bangSlash); - String afterBangSlash = file.substring(bangSlash); - - file = toBangSlash + afterBangSlash; - } - file = file != null ? "jar:" + file.replaceFirst("\\" + SEPARATOR, "!/") : null; - setURL(url, "jarjar", "", -1, file, ref); - } - - private String parseAbsoluteSpec(String spec) { - @SuppressWarnings("unused") - URL url = null; - int index = -1; - - // check for !/ - if ((index = indexOfBangSlash(spec)) == -1) { - throw new NullPointerException("no " + SEPARATOR + " in spec"); - } - // test the inner URL - try { - String innerSpec = spec.substring(0, index - 1); - - url = new URL(innerSpec); - } catch (MalformedURLException e) { - throw new NullPointerException("invalid url: " + spec + " (" + e + ")"); - } - return spec; - } - - private String parseContextSpec(URL url, String spec) { - String ctxFile = url.getFile(); - - // if the spec begins with /, chop up the jar back !/ - if (spec.startsWith("/")) { - int bangSlash = indexOfBangSlash(ctxFile); - - if (bangSlash == -1) { - throw new NullPointerException("malformed " + "context url:" + url + ": no " + SEPARATOR); - } - ctxFile = ctxFile.substring(0, bangSlash); - } - if (!ctxFile.endsWith("/") && (!spec.startsWith("/"))) { - // chop up the last component - int lastSlash = ctxFile.lastIndexOf('/'); - - if (lastSlash == -1) { - throw new NullPointerException("malformed " + "context url:" + url); - } - ctxFile = ctxFile.substring(0, lastSlash + 1); - } - return (ctxFile + spec); - } - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/AdvancedRobotProxy.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/AdvancedRobotProxy.java deleted file mode 100644 index da868da..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/AdvancedRobotProxy.java +++ /dev/null @@ -1,216 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.proxies; - - -import net.sf.robocode.host.RobotStatics; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.peer.IRobotPeer; -import net.sf.robocode.repository.IRobotItem; -import robocode.*; -import robocode.robotinterfaces.peer.IAdvancedRobotPeer; - -import java.io.File; -import java.security.AccessControlException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.List; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class AdvancedRobotProxy extends StandardRobotProxy implements IAdvancedRobotPeer { - - public AdvancedRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, RobotStatics statics) { - super(specification, hostManager, peer, statics); - } - - public boolean isAdjustGunForBodyTurn() { - getCall(); - return commands.isAdjustGunForBodyTurn(); - } - - public boolean isAdjustRadarForGunTurn() { - getCall(); - return commands.isAdjustRadarForGunTurn(); - } - - public boolean isAdjustRadarForBodyTurn() { - getCall(); - return commands.isAdjustRadarForBodyTurn(); - } - - // asynchronous actions - public void setResume() { - setCall(); - setResumeImpl(); - } - - public void setStop(boolean overwrite) { - setCall(); - setStopImpl(overwrite); - } - - public void setMove(double distance) { - setCall(); - setMoveImpl(distance); - } - - public void setTurnBody(double radians) { - setCall(); - setTurnBodyImpl(radians); - } - - public void setTurnGun(double radians) { - setCall(); - setTurnGunImpl(radians); - } - - public void setTurnRadar(double radians) { - setCall(); - setTurnRadarImpl(radians); - } - - // blocking actions - public void waitFor(Condition condition) { - waitCondition = condition; - do { - execute(); // Always tick at least once - } while (!condition.test()); - - waitCondition = null; - } - - // fast setters - public void setMaxTurnRate(double newTurnRate) { - setCall(); - if (Double.isNaN(newTurnRate)) { - println("You cannot setMaxTurnRate to: " + newTurnRate); - return; - } - commands.setMaxTurnRate(newTurnRate); - } - - public void setMaxVelocity(double newVelocity) { - setCall(); - if (Double.isNaN(newVelocity)) { - println("You cannot setMaxVelocity to: " + newVelocity); - return; - } - commands.setMaxVelocity(newVelocity); - } - - // events manipulation - public void setInterruptible(boolean interruptable) { - setCall(); - eventManager.setInterruptible(eventManager.getCurrentTopEventPriority(), interruptable); - } - - public void setEventPriority(String eventClass, int priority) { - setCall(); - eventManager.setEventPriority(eventClass, priority); - } - - public int getEventPriority(String eventClass) { - getCall(); - return eventManager.getEventPriority(eventClass); - } - - public void removeCustomEvent(Condition condition) { - setCall(); - eventManager.removeCustomEvent(condition); - } - - public void addCustomEvent(Condition condition) { - setCall(); - eventManager.addCustomEvent(condition); - } - - public void clearAllEvents() { - setCall(); - eventManager.clearAllEvents(false); - } - - public List getAllEvents() { - getCall(); - return eventManager.getAllEvents(); - } - - public List getStatusEvents() { - getCall(); - return eventManager.getStatusEvents(); - } - - public List getBulletMissedEvents() { - getCall(); - return eventManager.getBulletMissedEvents(); - } - - public List getBulletHitBulletEvents() { - getCall(); - return eventManager.getBulletHitBulletEvents(); - } - - public List getBulletHitEvents() { - getCall(); - return eventManager.getBulletHitEvents(); - } - - public List getHitByBulletEvents() { - getCall(); - return eventManager.getHitByBulletEvents(); - } - - public List getHitRobotEvents() { - getCall(); - return eventManager.getHitRobotEvents(); - } - - public List getHitWallEvents() { - getCall(); - return eventManager.getHitWallEvents(); - } - - public List getRobotDeathEvents() { - getCall(); - return eventManager.getRobotDeathEvents(); - } - - public List getScannedRobotEvents() { - getCall(); - return eventManager.getScannedRobotEvents(); - } - - // data - public File getDataDirectory() { - getCall(); - commands.setIORobot(); - return robotFileSystemManager.getWritableDirectory(); - } - - public File getDataFile(final String filename) { - getCall(); - commands.setIORobot(); - if (filename.contains("..")) { - throw new AccessControlException("no relative path allowed"); - } - - return AccessController.doPrivileged(new PrivilegedAction() { - public File run() { - return robotFileSystemManager.getDataFile(filename); - } - }); - } - - public long getDataQuotaAvailable() { - getCall(); - return robotFileSystemManager.getMaxQuota() - robotFileSystemManager.getQuotaUsed(); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/BasicRobotProxy.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/BasicRobotProxy.java deleted file mode 100644 index 8f0fea8..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/BasicRobotProxy.java +++ /dev/null @@ -1,567 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.proxies; - - -import net.sf.robocode.host.RobotStatics; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.host.events.EventManager; -import net.sf.robocode.peer.*; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.robotpaint.Graphics2DSerialized; -import net.sf.robocode.robotpaint.IGraphicsProxy; -import net.sf.robocode.security.HiddenAccess; -import robocode.*; -import robocode.Event; -import robocode.exception.AbortedException; -import robocode.exception.DeathException; -import robocode.exception.DisabledException; -import robocode.exception.RobotException; -import robocode.exception.WinException; -import robocode.robotinterfaces.peer.IBasicRobotPeer; -import robocode.util.Utils; - -import java.awt.*; -import static java.lang.Math.max; -import static java.lang.Math.min; - -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; -import java.util.concurrent.atomic.AtomicInteger; - - -// XXX Remember to update the .NET version whenever a change is made to this class! - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class BasicRobotProxy extends HostingRobotProxy implements IBasicRobotPeer { - private static final long - MAX_SET_CALL_COUNT = 10000, - MAX_GET_CALL_COUNT = 10000; - - private IGraphicsProxy graphicsProxy; - - private RobotStatus status; - private boolean isDisabled; - protected ExecCommands commands; - private ExecResults execResults; - - private final Map bullets = new ConcurrentHashMap(); - private int nextBulletId = 1; // 0 is used for bullet explosions - - private final AtomicInteger setCallCount = new AtomicInteger(0); - private final AtomicInteger getCallCount = new AtomicInteger(0); - - protected Condition waitCondition; - private boolean testingCondition; - private double firedEnergy; - private double firedHeat; - - BasicRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, RobotStatics statics) { - super(specification, hostManager, peer, statics); - - eventManager = new EventManager(this); - - graphicsProxy = new Graphics2DSerialized(); - - // dummy - execResults = new ExecResults(null, null, null, null, null, false, false, false); - - setSetCallCount(0); - setGetCallCount(0); - } - - protected void initializeRound(ExecCommands commands, RobotStatus status) { - updateStatus(commands, status); - - eventManager.reset(); - eventManager.add(new StatusEvent(status)); // Start event - - setSetCallCount(0); - setGetCallCount(0); - } - - @Override - public void cleanup() { - super.cleanup(); - - // Cleanup and remove current wait condition - if (waitCondition != null) { - waitCondition.cleanup(); - waitCondition = null; - } - - // Cleanup and remove the event manager - if (eventManager != null) { - eventManager.cleanup(); - eventManager = null; - } - - // Cleanup graphics proxy - graphicsProxy = null; - execResults = null; - status = null; - commands = null; - } - - // asynchronous actions - public Bullet setFire(double power) { - setCall(); - return setFireImpl(power); - } - - // blocking actions - public void execute() { - executeImpl(); - } - - public void move(double distance) { - setMoveImpl(distance); - do { - execute(); // Always tick at least once - } while (getDistanceRemaining() != 0); - } - - public void turnBody(double radians) { - setTurnBodyImpl(radians); - do { - execute(); // Always tick at least once - } while (getBodyTurnRemaining() != 0); - } - - public void turnGun(double radians) { - setTurnGunImpl(radians); - do { - execute(); // Always tick at least once - } while (getGunTurnRemaining() != 0); - } - - public Bullet fire(double power) { - Bullet bullet = setFire(power); - - execute(); - return bullet; - } - - // fast setters - public void setBodyColor(Color color) { - setCall(); - commands.setBodyColor(color != null ? color.getRGB() : ExecCommands.defaultBodyColor); - } - - public void setGunColor(Color color) { - setCall(); - commands.setGunColor(color != null ? color.getRGB() : ExecCommands.defaultGunColor); - } - - public void setRadarColor(Color color) { - setCall(); - commands.setRadarColor(color != null ? color.getRGB() : ExecCommands.defaultRadarColor); - } - - public void setBulletColor(Color color) { - setCall(); - commands.setBulletColor(color != null ? color.getRGB() : ExecCommands.defaultBulletColor); - } - - public void setScanColor(Color color) { - setCall(); - commands.setScanColor(color != null ? color.getRGB() : ExecCommands.defaultScanColor); - } - - // counters - public void setCall() { - if (!isDisabled) { - final int res = setCallCount.incrementAndGet(); - - if (res >= MAX_SET_CALL_COUNT) { - isDisabled = true; - println("SYSTEM: You have made " + res + " calls to setXX methods without calling execute()"); - throw new DisabledException("Too many calls to setXX methods"); - } - } - } - - public void getCall() { - if (!isDisabled) { - final int res = getCallCount.incrementAndGet(); - - if (res >= MAX_GET_CALL_COUNT) { - isDisabled = true; - println("SYSTEM: You have made " + res + " calls to getXX methods without calling execute()"); - throw new DisabledException("Too many calls to getXX methods"); - } - } - } - - public double getDistanceRemaining() { - getCall(); - return commands.getDistanceRemaining(); - } - - public double getRadarTurnRemaining() { - getCall(); - return commands.getRadarTurnRemaining(); - } - - public double getBodyTurnRemaining() { - getCall(); - return commands.getBodyTurnRemaining(); - } - - public double getGunTurnRemaining() { - getCall(); - return commands.getGunTurnRemaining(); - } - - public double getVelocity() { - getCall(); - return status.getVelocity(); - } - - public double getGunCoolingRate() { - getCall(); - return statics.getBattleRules().getGunCoolingRate(); - } - - public String getName() { - getCall(); - return statics.getName(); - } - - public long getTime() { - getCall(); - return getTimeImpl(); - } - - public double getBodyHeading() { - getCall(); - return status.getHeadingRadians(); - } - - public double getGunHeading() { - getCall(); - return status.getGunHeadingRadians(); - } - - public double getRadarHeading() { - getCall(); - return status.getRadarHeadingRadians(); - } - - public double getEnergy() { - getCall(); - return getEnergyImpl(); - } - - public double getGunHeat() { - getCall(); - return getGunHeatImpl(); - } - - public double getX() { - getCall(); - return status.getX(); - } - - public double getY() { - getCall(); - return status.getY(); - } - - public int getOthers() { - getCall(); - return status.getOthers(); - } - - public int getNumSentries() { - getCall(); - return status.getNumSentries(); - } - - public double getBattleFieldHeight() { - getCall(); - return statics.getBattleRules().getBattlefieldHeight(); - } - - public double getBattleFieldWidth() { - getCall(); - return statics.getBattleRules().getBattlefieldWidth(); - } - - public int getNumRounds() { - getCall(); - return statics.getBattleRules().getNumRounds(); - } - - public int getRoundNum() { - getCall(); - return status.getRoundNum(); - } - - public int getSentryBorderSize() { - getCall(); - return statics.getBattleRules().getSentryBorderSize(); - } - - public Graphics2D getGraphics() { - getCall(); - commands.setTryingToPaint(true); - return getGraphicsImpl(); - } - - public void setDebugProperty(String key, String value) { - setCall(); - commands.setDebugProperty(key, value); - } - - public void rescan() { - boolean reset = false; - boolean origInterruptableValue = false; - - if (eventManager.getCurrentTopEventPriority() == eventManager.getScannedRobotEventPriority()) { - reset = true; - origInterruptableValue = eventManager.isInterruptible(eventManager.getScannedRobotEventPriority()); - eventManager.setInterruptible(eventManager.getScannedRobotEventPriority(), true); - } - - commands.setScan(true); - executeImpl(); - - if (reset) { - eventManager.setInterruptible(eventManager.getScannedRobotEventPriority(), origInterruptableValue); - } - } - - // ----------- - // implementations - // ----------- - - public long getTimeImpl() { - return status.getTime(); - } - - public Graphics2D getGraphicsImpl() { - return (Graphics2D) graphicsProxy; - } - - @Override - protected final void executeImpl() { - if (execResults == null) { - // this is to slow down undead robot after cleanup, from fast exception-loop - try { - Thread.sleep(1000); - } catch (InterruptedException ignore) {} - } - - // Entering tick - robotThreadManager.checkRunThread(); - if (testingCondition) { - throw new RobotException( - "You cannot take action inside Condition.test(). You should handle onCustomEvent instead."); - } - - setSetCallCount(0); - setGetCallCount(0); - - // This stops autoscan from scanning... - if (waitCondition != null && waitCondition.test()) { - waitCondition = null; - commands.setScan(true); - } - - commands.setOutputText(out.readAndReset()); - commands.setGraphicsCalls(graphicsProxy.readoutQueuedCalls()); - - // Call server - execResults = peer.executeImpl(commands); - - updateStatus(execResults.getCommands(), execResults.getStatus()); - - graphicsProxy.setPaintingEnabled(execResults.isPaintEnabled()); - firedEnergy = 0; - firedHeat = 0; - - // add new events - eventManager.add(new StatusEvent(execResults.getStatus())); - if (statics.isPaintRobot() && execResults.isPaintEnabled()) { - // Add paint event, if robot is a paint robot and its painting is enabled - eventManager.add(new PaintEvent()); - } - - // add other events - if (execResults.getEvents() != null) { - for (Event event : execResults.getEvents()) { - eventManager.add(event); - } - } - - if (execResults.getBulletUpdates() != null) { - for (BulletStatus bulletStatus : execResults.getBulletUpdates()) { - final Bullet bullet = bullets.get(bulletStatus.bulletId); - - if (bullet != null) { - HiddenAccess.update(bullet, bulletStatus.x, bulletStatus.y, bulletStatus.victimName, - bulletStatus.isActive); - if (!bulletStatus.isActive) { - bullets.remove(bulletStatus.bulletId); - } - } - } - } - - // add new team messages - loadTeamMessages(execResults.getTeamMessages()); - - eventManager.processEvents(); - } - - @Override - protected final void waitForBattleEndImpl() { - eventManager.clearAllEvents(false); - graphicsProxy.setPaintingEnabled(false); - do { - // Make sure remaining system events like e.g. are processed this round - try { - eventManager.processEvents(); - - // The exceptions below are expected to occur, and has already been logged in the robot console, - // but still exists in the robot's event queue. Hence we just ignore these! - // Look in the HostingRobotProxy.run() to see which robot errors that are already handled. - } catch (DeathException ignore) {} catch (WinException ignore) {// Bug fix [2952549] - } catch (AbortedException ignore) {} catch (DisabledException ignore) {// Bug fix [2976258] - } - - commands.setOutputText(out.readAndReset()); - commands.setGraphicsCalls(graphicsProxy.readoutQueuedCalls()); - - // Call server - execResults = peer.waitForBattleEndImpl(commands); - - updateStatus(execResults.getCommands(), execResults.getStatus()); - - // Add remaining events like BattleEndedEvent Otherwise, the robot might never receive those events - if (execResults.getEvents() != null) { - for (Event event : execResults.getEvents()) { - if (event instanceof BattleEndedEvent) { - eventManager.add(event); - } - } - } - eventManager.resetCustomEvents(); - } while (!execResults.isHalt() && execResults.isShouldWait()); - } - - private void updateStatus(ExecCommands commands, RobotStatus status) { - this.status = status; - this.commands = commands; - } - - protected void loadTeamMessages(java.util.List teamMessages) {} - - private final double getEnergyImpl() { - return status.getEnergy() - firedEnergy; - } - - private final double getGunHeatImpl() { - return status.getGunHeat() + firedHeat; - } - - protected final void setMoveImpl(double distance) { - if (getEnergyImpl() == 0) { - return; - } - commands.setDistanceRemaining(distance); - commands.setMoved(true); - } - - private final Bullet setFireImpl(double power) { - if (Double.isNaN(power)) { - println("SYSTEM: You cannot call fire(NaN)"); - return null; - } - if (getGunHeatImpl() > 0 || getEnergyImpl() == 0) { - return null; - } - - power = min(getEnergyImpl(), min(max(power, Rules.MIN_BULLET_POWER), Rules.MAX_BULLET_POWER)); - - Bullet bullet; - BulletCommand wrapper; - Event currentTopEvent = eventManager.getCurrentTopEvent(); - - nextBulletId++; - - if (currentTopEvent != null && currentTopEvent.getTime() == status.getTime() && !statics.isAdvancedRobot() - && status.getGunHeadingRadians() == status.getRadarHeadingRadians() - && ScannedRobotEvent.class.isAssignableFrom(currentTopEvent.getClass())) { - // this is angle assisted bullet - ScannedRobotEvent e = (ScannedRobotEvent) currentTopEvent; - double fireAssistAngle = Utils.normalAbsoluteAngle(status.getHeadingRadians() + e.getBearingRadians()); - - bullet = new Bullet(fireAssistAngle, getX(), getY(), power, statics.getName(), null, true, nextBulletId); - wrapper = new BulletCommand(power, true, fireAssistAngle, nextBulletId); - } else { - // this is normal bullet - bullet = new Bullet(status.getGunHeadingRadians(), getX(), getY(), power, statics.getName(), null, true, - nextBulletId); - wrapper = new BulletCommand(power, false, 0, nextBulletId); - } - - firedEnergy += power; - firedHeat += Rules.getGunHeat(power); - - commands.getBullets().add(wrapper); - - bullets.put(nextBulletId, bullet); - - return bullet; - } - - protected final void setTurnGunImpl(double radians) { - commands.setGunTurnRemaining(radians); - } - - protected final void setTurnBodyImpl(double radians) { - if (getEnergyImpl() > 0) { - commands.setBodyTurnRemaining(radians); - } - } - - protected final void setTurnRadarImpl(double radians) { - commands.setRadarTurnRemaining(radians); - } - - // ----------- - // battle driven methods - // ----------- - - private void setSetCallCount(int setCallCount) { - this.setCallCount.set(setCallCount); - } - - private void setGetCallCount(int getCallCount) { - this.getCallCount.set(getCallCount); - } - - // ----------- - // for robot thread - // ----------- - - public void setTestingCondition(boolean testingCondition) { - this.testingCondition = testingCondition; - } - - @Override - public String toString() { - return statics.getShortName() + "(" + (int) status.getEnergy() + ") X" + (int) status.getX() + " Y" - + (int) status.getY(); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/HostingRobotProxy.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/HostingRobotProxy.java deleted file mode 100644 index df5d591..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/HostingRobotProxy.java +++ /dev/null @@ -1,306 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.proxies; - - -import net.sf.robocode.host.events.EventManager; -import net.sf.robocode.host.io.RobotFileSystemManager; -import net.sf.robocode.host.io.RobotOutputStream; -import net.sf.robocode.host.security.RobotThreadManager; -import net.sf.robocode.host.*; -import static net.sf.robocode.io.Logger.logError; -import static net.sf.robocode.io.Logger.logMessage; -import net.sf.robocode.peer.BadBehavior; -import net.sf.robocode.peer.ExecCommands; -import net.sf.robocode.peer.IRobotPeer; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.core.Container; -import robocode.RobotStatus; -import robocode.exception.AbortedException; -import robocode.exception.DeathException; -import robocode.exception.DisabledException; -import robocode.exception.WinException; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.peer.IBasicRobotPeer; - -import java.util.Collections; -import java.util.HashSet; -import java.util.Set; - - -// XXX Remember to update the .NET version whenever a change is made to this class! - -/** - * @author Pavel Savara (original) - */ -abstract class HostingRobotProxy implements IHostingRobotProxy, IHostedThread { - - private final IRobotItem robotSpecification; - - protected EventManager eventManager; - private final IHostManager hostManager; - protected RobotThreadManager robotThreadManager; - protected RobotFileSystemManager robotFileSystemManager; - private IThreadManager threadManager; - - private IBasicRobot robot; - protected final IRobotPeer peer; - protected IRobotClassLoader robotClassLoader; - - protected final RobotStatics statics; - protected RobotOutputStream out; - - private final Set securityViolations = Collections.synchronizedSet(new HashSet()); - - HostingRobotProxy(IRobotItem robotSpecification, IHostManager hostManager, IRobotPeer peer, RobotStatics statics) { - this.peer = peer; - this.statics = statics; - this.hostManager = hostManager; - this.robotSpecification = robotSpecification; - - robotClassLoader = getHost(robotSpecification).createLoader(robotSpecification); - robotClassLoader.setRobotProxy(this); - - out = new RobotOutputStream(); - robotThreadManager = new RobotThreadManager(this); - - loadClassBattle(); - - robotFileSystemManager = new RobotFileSystemManager(this, hostManager.getRobotFilesystemQuota(), - robotSpecification.getWritableDirectory(), robotSpecification.getReadableDirectory(), - robotSpecification.getRootPath()); - - robotFileSystemManager.initialize(); - } - - private JavaHost getHost(IRobotItem robotSpecification) { - return (JavaHost) Container.cache.getComponent("robocode.host." + robotSpecification.getPlatform().toLowerCase()); - } - - public void cleanup() { - robot = null; - - // Remove the file system and the manager - robotFileSystemManager = null; - if (out != null) { - out.close(); - out = null; - } - - if (robotThreadManager != null) { - robotThreadManager.cleanup(); - } - robotThreadManager = null; - - // Cleanup and remove class manager - if (robotClassLoader != null) { - robotClassLoader.cleanup(); - robotClassLoader = null; - } - } - - public RobotOutputStream getOut() { - return out; - } - - public void println(String s) { - out.println(s); - } - - private void println(Throwable ex) { - ex.printStackTrace(out); - } - - public RobotStatics getStatics() { - return statics; - } - - public RobotFileSystemManager getRobotFileSystemManager() { - return robotFileSystemManager; - } - - public ClassLoader getRobotClassloader() { - return (ClassLoader) robotClassLoader; - } - - // ----------- - // battle driven methods - // ----------- - - protected abstract void initializeRound(ExecCommands commands, RobotStatus status); - - public void startRound(ExecCommands commands, RobotStatus status) { - initializeRound(commands, status); - threadManager = ((HostManager) hostManager).getThreadManager(); - robotThreadManager.start(threadManager); - } - - public void forceStopThread() { - if (!robotThreadManager.forceStop()) { - peer.punishBadBehavior(BadBehavior.UNSTOPPABLE); - peer.setRunning(false); - } - } - - public void waitForStopThread() { - if (!robotThreadManager.waitForStop()) { - peer.punishBadBehavior(BadBehavior.UNSTOPPABLE); - peer.setRunning(false); - } - } - - private void loadClassBattle() { - try { - robotClassLoader.loadRobotMainClass(true); - } catch (Throwable e) { - println("SYSTEM: Could not load " + statics.getName() + " : "); - println(e); - drainEnergy(); - } - } - - private boolean loadRobotRound() { - robot = null; - try { - threadManager.setLoadingRobot(this); - robot = robotClassLoader.createRobotInstance(); - if (robot == null) { - println("SYSTEM: Skipping robot: " + statics.getName()); - return false; - } - robot.setOut(out); - robot.setPeer((IBasicRobotPeer) this); - eventManager.setRobot(robot); - } catch (IllegalAccessException e) { - println("SYSTEM: Unable to instantiate this robot: " + e); - println("SYSTEM: Is your constructor marked public?"); - println(e); - robot = null; - logError(e); - return false; - } catch (Throwable e) { - println("SYSTEM: An error occurred during initialization of " + statics.getName()); - println("SYSTEM: " + e); - println(e); - robot = null; - logError(e); - return false; - } finally { - threadManager.setLoadingRobot(null); - } - return true; - } - - protected abstract void executeImpl(); - - public void run() { - // Only initialize AWT if we are not running in headless mode. - // Bugfix [2833271] IllegalThreadStateException with the AWT-Shutdown thread. - // Read more about headless mode here: - // http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/ - if (System.getProperty("java.awt.headless", "true").equals("false")) { - robotThreadManager.initAWT(); - } - - if (robotSpecification.isValid() && loadRobotRound()) { - try { - if (robot != null) { - peer.setRunning(true); - - // Process all events for the first turn. - // This is done as the first robot status event must occur before the robot - // has started running. - eventManager.processEvents(); - - // Call user code - callUserCode(); - } - while (peer.isRunning()) { - executeImpl(); - } - } catch (WinException e) {// Do nothing - } catch (AbortedException e) {// Do nothing - } catch (DeathException e) { - println("SYSTEM: " + statics.getName() + " has died"); - } catch (DisabledException e) { - drainEnergy(); - - String msg = e.getMessage(); - if (msg == null) { - msg = ""; - } else { - msg = ": " + msg; - } - println("SYSTEM: Robot disabled: " + msg); - logMessage("Robot disabled: " + statics.getName()); - } catch (Exception e) { - drainEnergy(); - println(e); - logMessage(statics.getName() + ": Exception: " + e); // without stack here - } catch (ThreadDeath e) { - drainEnergy(); - println(e); - logMessage(statics.getName() + " stopped successfully."); - throw e; // must be re-thrown in order to stop the thread - } catch (Throwable t) { - drainEnergy(); - println(t); - logMessage(statics.getName() + ": Throwable: " + t); // without stack here - } finally { - waitForBattleEndImpl(); - } - } else { - drainEnergy(); - peer.punishBadBehavior(BadBehavior.CANNOT_START); - waitForBattleEndImpl(); - } - - peer.setRunning(false); - - // If battle is waiting for us, well, all done! - synchronized (this) { - notifyAll(); - } - } - - private void callUserCode() { - Runnable runnable = robot.getRobotRunnable(); - if (runnable != null) { - runnable.run(); - } - } - - protected abstract void waitForBattleEndImpl(); - - public void drainEnergy() { - peer.drainEnergy(); - } - - public void punishSecurityViolation(String message) { - // Prevent unit tests of failing if multiple threads are calling this method in the same time. - // We only want the a specific type of security violation logged once so we only get one error - // per security violation. - synchronized (securityViolations) { - String key = message; - - if (key.startsWith("Preventing Thread-")) { - key = key.replaceAll("\\d+", "X"); - } - if (!securityViolations.contains(key)) { - securityViolations.add(key); - logError(message); - println("SYSTEM: " + message); - - if (securityViolations.size() == 1) { - peer.drainEnergy(); - peer.punishBadBehavior(BadBehavior.SECURITY_VIOLATION); - } - } - } - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/IHostingRobotProxy.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/IHostingRobotProxy.java deleted file mode 100644 index 13be4eb..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/IHostingRobotProxy.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.proxies; - - -import net.sf.robocode.peer.ExecCommands; -import robocode.RobotStatus; - - -/** - * @author Pavel Savara (original) - */ -public interface IHostingRobotProxy { - - void startRound(ExecCommands commands, RobotStatus status); - - void forceStopThread(); - - void waitForStopThread(); - - void cleanup(); - -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/JuniorRobotProxy.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/JuniorRobotProxy.java deleted file mode 100644 index 65fa414..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/JuniorRobotProxy.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.proxies; - - -import net.sf.robocode.host.RobotStatics; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.peer.IRobotPeer; -import net.sf.robocode.repository.IRobotItem; -import robocode.Rules; -import robocode.robotinterfaces.peer.IJuniorRobotPeer; - - -/** - * NOTE: This is temporary implementation of the interface. You should not build any external component on top of it. - * - * @author Flemming N. Larsen (original) - * @author Pavel Savara (contributor) - */ -public class JuniorRobotProxy extends BasicRobotProxy implements IJuniorRobotPeer { - - public JuniorRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, RobotStatics statics) { - super(specification, hostManager, peer, statics); - } - - public void turnAndMove(double distance, double radians) { - if (distance == 0) { - turnBody(radians); - return; - } - - // Save current max. velocity and max. turn rate so they can be restored - final double savedMaxVelocity = commands.getMaxVelocity(); - final double savedMaxTurnRate = commands.getMaxTurnRate(); - - final double absDegrees = Math.abs(Math.toDegrees(radians)); - final double absDistance = Math.abs(distance); - - // -- Calculate max. velocity for moving perfect in a circle -- - - // maxTurnRate = 10 * 0.75 * abs(velocity) (Robocode rule), and - // maxTurnRate = velocity * degrees / distance (curve turn rate) - // - // Hence, max. velocity = 10 / (degrees / distance + 0.75) - - final double maxVelocity = Math.min(Rules.MAX_VELOCITY, 10 / (absDegrees / absDistance + 0.75)); - - // -- Calculate number of turns for acceleration + deceleration -- - - double accDist = 0; // accumulated distance during acceleration - double decDist = 0; // accumulated distance during deceleration - - int turns = 0; // number of turns to it will take to move the distance - - // Calculate the amount of turn it will take to accelerate + decelerate - // up to the max. velocity, but stop if the distance for used for - // acceleration + deceleration gets bigger than the total distance to move - for (int t = 1; t < maxVelocity; t++) { - - // Add the current velocity to the acceleration distance - accDist += t; - - // Every 2nd time we add the deceleration distance needed to - // get to a velocity of 0 - if (t > 2 && (t % 2) > 0) { - decDist += t - 2; - } - - // Stop if the acceleration + deceleration > total distance to move - if ((accDist + decDist) >= absDistance) { - break; - } - - // Increment turn for acceleration - turns++; - - // Every 2nd time we increment time for deceleration - if (t > 2 && (t % 2) > 0) { - turns++; - } - } - - // Add number of turns for the remaining distance at max velocity - if ((accDist + decDist) < absDistance) { - turns += (int) ((absDistance - accDist - decDist) / maxVelocity + 1); - } - - // -- Move and turn in a curve -- - - // Set the calculated max. velocity - commands.setMaxVelocity(maxVelocity); - - // Set the robot to move the specified distance - setMoveImpl(distance); - // Set the robot to turn its body to the specified amount of radians - setTurnBodyImpl(radians); - - // Loop thru the number of turns it will take to move the distance and adjust - // the max. turn rate so it fit the current velocity of the robot - for (int t = turns; t >= 0; t--) { - commands.setMaxTurnRate(getVelocity() * radians / absDistance); - execute(); // Perform next turn - } - - // Restore the saved max. velocity and max. turn rate - commands.setMaxVelocity(savedMaxVelocity); - commands.setMaxTurnRate(savedMaxTurnRate); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/StandardRobotProxy.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/StandardRobotProxy.java deleted file mode 100644 index 804c379..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/StandardRobotProxy.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.proxies; - - -import net.sf.robocode.host.RobotStatics; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.peer.ExecCommands; -import net.sf.robocode.peer.IRobotPeer; -import net.sf.robocode.repository.IRobotItem; -import robocode.RobotStatus; -import robocode.robotinterfaces.peer.IStandardRobotPeer; - - -/** - * @author Pavel Savara (original) - */ -public class StandardRobotProxy extends BasicRobotProxy implements IStandardRobotPeer { - - private boolean isStopped; - private double saveAngleToTurn; - private double saveDistanceToGo; - private double saveGunAngleToTurn; - private double saveRadarAngleToTurn; - - public StandardRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, RobotStatics statics) { - super(specification, hostManager, peer, statics); - } - - @Override - protected void initializeRound(ExecCommands commands, RobotStatus status) { - super.initializeRound(commands, status); - isStopped = true; - } - - // blocking actions - public void stop(boolean overwrite) { - setStopImpl(overwrite); - execute(); - } - - public void resume() { - setResumeImpl(); - execute(); - } - - public void turnRadar(double radians) { - setTurnRadarImpl(radians); - do { - execute(); // Always tick at least once - } while (getRadarTurnRemaining() != 0); - } - - // fast setters - public void setAdjustGunForBodyTurn(boolean newAdjustGunForBodyTurn) { - setCall(); - commands.setAdjustGunForBodyTurn(newAdjustGunForBodyTurn); - } - - public void setAdjustRadarForGunTurn(boolean newAdjustRadarForGunTurn) { - setCall(); - commands.setAdjustRadarForGunTurn(newAdjustRadarForGunTurn); - if (!commands.isAdjustRadarForBodyTurnSet()) { - commands.setAdjustRadarForBodyTurn(newAdjustRadarForGunTurn); - } - } - - public void setAdjustRadarForBodyTurn(boolean newAdjustRadarForBodyTurn) { - setCall(); - commands.setAdjustRadarForBodyTurn(newAdjustRadarForBodyTurn); - commands.setAdjustRadarForBodyTurnSet(true); - } - - protected final void setResumeImpl() { - if (isStopped) { - isStopped = false; - commands.setDistanceRemaining(saveDistanceToGo); - commands.setBodyTurnRemaining(saveAngleToTurn); - commands.setGunTurnRemaining(saveGunAngleToTurn); - commands.setRadarTurnRemaining(saveRadarAngleToTurn); - } - } - - protected final void setStopImpl(boolean overwrite) { - if (!isStopped || overwrite) { - this.saveDistanceToGo = getDistanceRemaining(); - this.saveAngleToTurn = getBodyTurnRemaining(); - this.saveGunAngleToTurn = getGunTurnRemaining(); - this.saveRadarAngleToTurn = getRadarTurnRemaining(); - } - isStopped = true; - - commands.setDistanceRemaining(0); - commands.setBodyTurnRemaining(0); - commands.setGunTurnRemaining(0); - commands.setRadarTurnRemaining(0); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/TeamRobotProxy.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/TeamRobotProxy.java deleted file mode 100644 index 22b8ca0..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/proxies/TeamRobotProxy.java +++ /dev/null @@ -1,126 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.proxies; - - -import net.sf.robocode.host.RobotStatics; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.host.serialization.RobocodeObjectInputStream; -import net.sf.robocode.peer.IRobotPeer; -import net.sf.robocode.peer.TeamMessage; -import net.sf.robocode.repository.IRobotItem; -import robocode.MessageEvent; -import robocode.robotinterfaces.peer.ITeamRobotPeer; - -import java.io.*; -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public class TeamRobotProxy extends AdvancedRobotProxy implements ITeamRobotPeer { - private static final int MAX_MESSAGE_SIZE = 32768; - private final ByteArrayOutputStream byteStreamWriter; - - public TeamRobotProxy(IRobotItem specification, IHostManager hostManager, IRobotPeer peer, RobotStatics statics) { - super(specification, hostManager, peer, statics); - byteStreamWriter = new ByteArrayOutputStream(MAX_MESSAGE_SIZE); - } - - // team - public String[] getTeammates() { - getCall(); - return statics.getTeammates(); - } - - public boolean isTeammate(String name) { - getCall(); - if (name != null) { // Bugfix [2960870] - if (name.equals(statics.getName())) { - return true; - } - final String[] teammates = statics.getTeammates(); - - if (teammates != null) { - for (String mate : teammates) { - if (mate.equals(name)) { - return true; - } - } - } - } - return false; - } - - public void broadcastMessage(Serializable message) throws IOException { - sendMessage(null, message); - } - - public void sendMessage(String name, Serializable message) throws IOException { - setCall(); - - try { - if (!statics.isTeamRobot()) { - throw new IOException("You are not on a team."); - } - byteStreamWriter.reset(); - ObjectOutputStream objectStreamWriter = new ObjectOutputStream(byteStreamWriter); - - objectStreamWriter.writeObject(message); - objectStreamWriter.flush(); - byteStreamWriter.flush(); - final byte[] bytes = byteStreamWriter.toByteArray(); - - objectStreamWriter.reset(); - if (bytes.length > MAX_MESSAGE_SIZE) { - throw new IOException("Message too big. " + bytes.length + ">" + MAX_MESSAGE_SIZE); - } - commands.getTeamMessages().add(new TeamMessage(getName(), name, bytes)); - } catch (IOException e) { - out.printStackTrace(e); - throw e; - } - - } - - @Override - protected final void loadTeamMessages(List teamMessages) { - if (teamMessages == null) { - return; - } - for (TeamMessage teamMessage : teamMessages) { - try { - ByteArrayInputStream byteStreamReader = new ByteArrayInputStream(teamMessage.message); - byteStreamReader.reset(); - - RobocodeObjectInputStream objectStreamReader = null; - try { - objectStreamReader = new RobocodeObjectInputStream(byteStreamReader, (ClassLoader) robotClassLoader); - Serializable message = (Serializable) objectStreamReader.readObject(); - MessageEvent event = new MessageEvent(teamMessage.sender, message); - eventManager.add(event); - } finally { - if (objectStreamReader != null) { - objectStreamReader.close(); - } - } - } catch (IOException e) { - out.printStackTrace(e); - } catch (ClassNotFoundException e) { - out.printStackTrace(e); - } - } - } - - // events - public List getMessageEvents() { - getCall(); - return eventManager.getMessageEvents(); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/ClassAnalyzer.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/ClassAnalyzer.java deleted file mode 100644 index 36208f3..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/ClassAnalyzer.java +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.security; - - -import net.sf.robocode.io.Logger; - -import java.io.ByteArrayInputStream; -import java.io.DataInputStream; -import java.io.IOException; -import java.nio.ByteBuffer; -import java.util.ArrayList; -import java.util.List; -import java.util.Set; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -class ClassAnalyzer { - private final static byte CONSTANT_Class = 7; - private final static byte CONSTANT_Fieldref = 9; - private final static byte CONSTANT_Methodref = 10; - private final static byte CONSTANT_InterfaceMethodref = 11; - private final static byte CONSTANT_String = 8; - private final static byte CONSTANT_Integer = 3; - private final static byte CONSTANT_Float = 4; - private final static byte CONSTANT_Long = 5; - private final static byte CONSTANT_Double = 6; - private final static byte CONSTANT_NameAndType = 12; - private final static byte CONSTANT_Utf8 = 1; - - /** - * ClassAnalyzer constructor comment. - */ - public ClassAnalyzer() { - super(); - } - - static void getReferencedClasses(ByteBuffer classFile, Set collection) { - - /* - http://java.sun.com/docs/books/vmspec/2nd-edition/html/ClassFile.doc.html - - 4.1 The ClassFile Structure - A class file consists of a single ClassFile structure: - - ClassFile { - u4 magic; - u2 minor_version; - u2 major_version; - u2 constant_pool_count; - cp_info constant_pool[constant_pool_count-1]; - u2 access_flags; - u2 this_class; - u2 super_class; - u2 interfaces_count; - u2 interfaces[interfaces_count]; - u2 fields_count; - field_info fields[fields_count]; - u2 methods_count; - method_info methods[methods_count]; - u2 attributes_count; - attribute_info attributes[attributes_count]; - } - */ - String strings[]; - List classNameIndexes = new ArrayList(); - - try { - DataInputStream in = new DataInputStream(new ByteArrayInputStream(classFile.array(), 0, classFile.limit())); - long magic = in.readInt(); - - if (magic != 0xCAFEBABE) { - Logger.logError("Not a class file!"); - return; - } - in.readUnsignedShort(); // minor version - in.readUnsignedShort(); // major version - int constant_pool_count = in.readUnsignedShort(); - - strings = new String[constant_pool_count]; - - /* - - All constant_pool table entries have the following general format: - - - cp_info { - u1 tag; - u1 info[]; - } - - Constant Type Value - CONSTANT_Class 7 - CONSTANT_Fieldref 9 - CONSTANT_Methodref 10 - CONSTANT_InterfaceMethodref 11 - CONSTANT_String 8 - CONSTANT_Integer 3 - CONSTANT_Float 4 - CONSTANT_Long 5 - CONSTANT_Double 6 - CONSTANT_NameAndType 12 - CONSTANT_Utf8 1 - */ - - - for (int i = 1; i < constant_pool_count; i++) { - byte tag = in.readByte(); - - switch (tag) { - - /* - CONSTANT_Class_info { - u1 tag; - u2 name_index; - } - */ - case CONSTANT_Class: { - int name_index = in.readUnsignedShort(); - - classNameIndexes.add(name_index); - } - break; - - /* - CONSTANT_Fieldref_info { - u1 tag; - u2 class_index; - u2 name_and_type_index; - } - CONSTANT_Methodref_info { - u1 tag; - u2 class_index; - u2 name_and_type_index; - } - CONSTANT_InterfaceMethodref_info { - u1 tag; - u2 class_index; - u2 name_and_type_index; - } - */ - case CONSTANT_Fieldref: - case CONSTANT_Methodref: - case CONSTANT_InterfaceMethodref: { - in.readUnsignedShort(); // class index - in.readUnsignedShort(); // name and type index - } - break; - - /* - CONSTANT_String_info { - u1 tag; - u2 string_index; - } - */ - case CONSTANT_String: { - in.readUnsignedShort(); // string index - } - break; - - /* - CONSTANT_Integer_info { - u1 tag; - u4 bytes; - } - CONSTANT_Float_info { - u1 tag; - u4 bytes; - } - */ - case CONSTANT_Integer: - case CONSTANT_Float: { - in.readInt(); // bytes - } - break; - - /* - CONSTANT_Long_info { - u1 tag; - u4 high_bytes; - u4 low_bytes; - } - CONSTANT_Double_info { - u1 tag; - u4 high_bytes; - u4 low_bytes; - } - All 8-byte constants take up two entries in the constant_pool table of the class file. If a CONSTANT_Long_info or CONSTANT_Double_info structure is the item in the constant_pool table at index n, then the next usable item in the pool is located at index n+2. The constant_pool index n+1 must be valid but is considered unusable.2 - */ - - case CONSTANT_Long: - case CONSTANT_Double: { - in.readInt(); // high bytes - in.readInt(); // low bytes - i++; // see "all 8-byte..." comment above. - } - break; - - /* - CONSTANT_NameAndType_info { - u1 tag; - u2 name_index; - u2 descriptor_index; - } - */ - case CONSTANT_NameAndType: { - in.readUnsignedShort(); // name index - in.readUnsignedShort(); // descriptor index - } - break; - - /* - CONSTANT_Utf8_info { - u1 tag; - u2 length; - u1 bytes[length]; - } - */ - case CONSTANT_Utf8: { - String utf8_string = in.readUTF(); - - strings[i] = utf8_string; - } - break; - } // switch - } // for i - } catch (IOException e) { - return; - } - - for (Integer classNameIndex : classNameIndexes) { - String className = strings[classNameIndex].replace('\\', '.').replace('/', '.'); - - if (className.indexOf("[") != 0 && !collection.contains(className)) { - collection.add(className); - } - } - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobocodePermission.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobocodePermission.java deleted file mode 100644 index f33422f..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobocodePermission.java +++ /dev/null @@ -1,100 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.security; - - -/** - * @author Mathew A. Nelson (original) - */ -@SuppressWarnings("serial") class RobocodePermission extends java.security.Permission { - - RobocodePermission(String name) { - super(name); - } - - /** - * Checks two Permission objects for equality. - *

- * Do not use the {@code equals} method for making access control - * decisions; use the {@code implies} method. - * - * @param obj the object we are testing for equality with this object. - * @return true if both Permission objects are equivalent. - */ - @Override - public boolean equals(Object obj) { - return false; - } - - /** - * Returns the actions as a String. This is abstract - * so subclasses can defer creating a String representation until - * one is needed. Subclasses should always return actions in what they - * consider to be their - * canonical form. For example, two FilePermission objects created via - * the following: - *

- *

-	 *   perm1 = new FilePermission(p1,"read,write");
-	 *   perm2 = new FilePermission(p2,"write,read");
-	 * 
- *

- * both return - * "read,write" when the {code getActions()} method is invoked. - * - * @return the actions of this Permission. - */ - @Override - public String getActions() { - return null; - } - - /** - * Returns the hash code value for this Permission object. - *

- * The required {@code hashCode} behavior for Permission Objects is - * the following:

- *

    - *
  • Whenever it is invoked on the same Permission object more than - * once during an execution of a Java application, the - * {@code hashCode} method - * must consistently return the same integer. This integer need not - * remain consistent from one execution of an application to another - * execution of the same application.

    - *

  • If two Permission objects are equal according to the {@code equals} - * method, then calling the {@code hashCode} method on each of the - * two Permission objects must produce the same integer result. - *
- * - * @return a hash code value for this object. - */ - @Override - public int hashCode() { - return 0; - } - - /** - * Checks if the specified permission's actions are "implied by" - * this object's actions. - *

- * This must be implemented by subclasses of Permission, as they are the - * only ones that can impose semantics on a Permission object. - *

- *

The {@code implies} method is used by the AccessController to determine - * whether or not a requested permission is implied by another permission that - * is known to be valid in the current execution context. - * - * @param permission the permission to check against. - * @return true if the specified permission is implied by this object, - * false if not. - */ - @Override - public boolean implies(java.security.Permission permission) { - return false; - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobocodeSecurityManager.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobocodeSecurityManager.java deleted file mode 100644 index 3eb2988..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobocodeSecurityManager.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.security; - - -import net.sf.robocode.host.IHostedThread; -import net.sf.robocode.host.IThreadManager; -import net.sf.robocode.io.RobocodeProperties; - -import java.security.AccessControlException; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - * @author Pavel Savara (contributor) - */ -public class RobocodeSecurityManager extends SecurityManager { - - private final IThreadManager threadManager; - - public RobocodeSecurityManager(IThreadManager threadManager) { - super(); - this.threadManager = threadManager; - - ThreadGroup tg = Thread.currentThread().getThreadGroup(); - - while (tg != null) { - threadManager.addSafeThreadGroup(tg); - tg = tg.getParent(); - } - // We need to exercise it in order to load all used classes on this thread - isSafeThread(Thread.currentThread()); - if (RobocodeProperties.isSecurityOn()) { - System.setSecurityManager(this); - } - } - - @Override - public void checkAccess(Thread t) { - if (RobocodeProperties.isSecurityOff()) { - return; - } - - Thread c = Thread.currentThread(); - - if (isSafeThread(c)) { - return; - } - super.checkAccess(t); - - // Threads belonging to other thread groups is not allowed to access threads belonging to other thread groups - // Bug fix [3021140] Possible for robot to kill other robot threads. - // In the following the thread group of the current thread must be in the thread group hierarchy of the - // attacker thread; otherwise an AccessControlException must be thrown. - - boolean found = false; - - ThreadGroup cg = c.getThreadGroup(); - ThreadGroup tg = t.getThreadGroup(); - - while (tg != null) { - if (tg == cg) { - found = true; - break; - } - try { - tg = tg.getParent(); - } catch (AccessControlException e) { - // We expect an AccessControlException due to missing RuntimePermission modifyThreadGroup - break; - } - } - if (!found) { - String message = "Preventing " + c.getName() + " from access to " + t.getName(); - IHostedThread robotProxy = threadManager.getLoadedOrLoadingRobotProxy(c); - - if (robotProxy != null) { - robotProxy.punishSecurityViolation(message); - } - throw new AccessControlException(message); - } - } - - @Override - public void checkAccess(ThreadGroup g) { - if (RobocodeProperties.isSecurityOff()) { - return; - } - Thread c = Thread.currentThread(); - - if (isSafeThread(c)) { - return; - } - super.checkAccess(g); - - final ThreadGroup cg = c.getThreadGroup(); - - if (cg == null) { - // What the heck is going on here? JDK 1.3 is sending me a dead thread. - // This crashes the entire jvm if I don't return here. - return; - } - - IHostedThread robotProxy = threadManager.getLoadedOrLoadingRobotProxy(c); - - if (robotProxy == null) { - throw new AccessControlException("Preventing " + c.getName() + " from access to " + g.getName()); - } - - if (cg.activeCount() > 5) { - String message = "Robots are only allowed to create up to 5 threads!"; - - robotProxy.punishSecurityViolation(message); - throw new AccessControlException(message); - } - } - - private boolean isSafeThread(Thread c) { - return threadManager.isSafeThread(c); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobocodeSecurityPolicy.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobocodeSecurityPolicy.java deleted file mode 100644 index 0a278b9..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobocodeSecurityPolicy.java +++ /dev/null @@ -1,322 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.security; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.host.IHostedThread; -import net.sf.robocode.host.IThreadManager; -import net.sf.robocode.host.io.RobotFileSystemManager; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.RobocodeProperties; -import net.sf.robocode.repository.IRepositoryManager; - -import java.io.File; -import java.io.FilePermission; -import java.io.IOException; -import java.net.MalformedURLException; -import java.security.*; -import java.util.*; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - * @author Pavel Savara (contributor) - */ -public class RobocodeSecurityPolicy extends Policy { - private static final boolean isFileReadSecutityOff = System.getProperty("OVERRIDEFILEREADSECURITY", "false").equals( - "true"); - private static final boolean isExperimental = System.getProperty("EXPERIMENTAL", "false").equals("true"); - private final Set allowedPackages = new HashSet(); - - private final Policy parentPolicy; - private final PermissionCollection allPermissions; - private Set untrustedCodeUrls; - - private final IThreadManager threadManager; - - public RobocodeSecurityPolicy(IThreadManager threadManager) { - this.parentPolicy = Policy.getPolicy(); - this.allPermissions = new Permissions(); - this.allPermissions.add(new AllPermission()); - this.threadManager = threadManager; - - allowedPackages.add("robocode.util"); - allowedPackages.add("robocode.robotinterfaces"); - allowedPackages.add("robocode.robotpaint"); - allowedPackages.add("robocode.robocodeGL"); - if (isExperimental) { - allowedPackages.add("robocode.robotinterfaces.peer"); - } - - initUrls(); - - if (RobocodeProperties.isSecurityOn()) { - Policy.setPolicy(this); - } - } - - @Override - public PermissionCollection getPermissions(ProtectionDomain domain) { - return getPermissions(domain.getCodeSource()); - } - - @Override - public PermissionCollection getPermissions(final CodeSource codeSource) { - if (RobocodeProperties.isSecurityOff()) { - return allPermissions; - } - - final String source = codeSource.getLocation().toString(); - - if (untrustedCodeUrls.contains(source)) { - return new Permissions(); - } - - return AccessController.doPrivileged(new PrivilegedAction() { - public PermissionCollection run() { - return parentPolicy.getPermissions(codeSource); - } - }); - } - - @Override - public boolean implies(ProtectionDomain domain, final Permission permission) { - if (RobocodeProperties.isSecurityOff()) { - return true; - } - final String source = domain.getCodeSource().getLocation().toString(); - - if (!untrustedCodeUrls.contains(source)) { - return true; - } - - return AccessController.doPrivileged(new PrivilegedAction() { - public Boolean run() { - return impliesRobot(permission); - } - }); - } - - private boolean impliesRobot(Permission perm) { - // For development purposes, allow read any file if override is set. - final String actions = perm.getActions(); - final String name = perm.getName(); - - if (perm instanceof FilePermission && actions.equals("read") && isFileReadSecutityOff) { - return true; - } - - // Allow reading of properties. - if (perm instanceof PropertyPermission && actions.equals("read")) { - return true; - } - - if (perm instanceof RobocodePermission) { - if (name.equals("System.out") || name.equals("System.err") || name.equals("System.in")) { - return true; - } - } - - // Ok, we need to figure out who our robot is. - Thread c = Thread.currentThread(); - - IHostedThread robotProxy = threadManager.getLoadedOrLoadingRobotProxy(c); - - if (robotProxy == null) { - Logger.logError("Preventing unknown thread " + Thread.currentThread().getName() + " from access: " + perm); - return false; - } - - // Attempt to stop the window from displaying - if (perm instanceof java.awt.AWTPermission) { - final String message = "Preventing " + robotProxy.getStatics().getName() + " from access: " + perm; - - robotProxy.punishSecurityViolation(message); - - // this is hack, because security exception is not enough - throw new ThreadDeath(); - } - - // FilePermission access request. - if (perm instanceof FilePermission) { - FilePermission filePermission = (FilePermission) perm; - // Get the fileSystemManager - RobotFileSystemManager fileSystemManager = robotProxy.getRobotFileSystemManager(); - - // Robot wants access to read something - if (filePermission.getActions().equals("read")) { - return impliesRobotFileRead(robotProxy, fileSystemManager, filePermission); - - } // Robot wants access to write something - else if (filePermission.getActions().equals("write")) { - return impliesRobotFileWrite(robotProxy, fileSystemManager, filePermission); - - } // Robot wants access to write something - else if (filePermission.getActions().equals("delete")) { - return impliesRobotFileDelete(robotProxy, fileSystemManager, filePermission); - - } - } - - // check package access - if (perm instanceof RuntimePermission && name.startsWith("accessClassInPackage.")) { - return impliesRobotPackageAccess(robotProxy, name.substring(21)); - } - - // Permission denied. - final String message = "Preventing " + robotProxy.getStatics().getName() + " from access: " + perm; - - robotProxy.punishSecurityViolation(message); - return false; - } - - private boolean impliesRobotPackageAccess(IHostedThread robotProxy, String packageName) { - if (packageName.startsWith("robocode.control") || packageName.startsWith("net.sf.robocode")) { - if (allowedPackages.contains(packageName)) { - return true; - } - final String message = "Preventing " + Thread.currentThread().getName() - + " from access to the internal Robocode package: " + packageName; - - robotProxy.punishSecurityViolation(message); - return false; - } - return true; - } - - private boolean impliesRobotFileDelete(IHostedThread robotProxy, RobotFileSystemManager fileSystemManager, FilePermission filePermission) { - // If there is no writable directory, deny access - if (fileSystemManager.getWritableDirectory() == null) { - final String message = "Preventing " + robotProxy.getStatics().getName() + " from access: " + filePermission - + ". Robots that are not in a package may not delete any files."; - - robotProxy.punishSecurityViolation(message); - return false; - } - // If this is a writable file, permit access - if (fileSystemManager.isWritable(filePermission.getName())) { - return true; - } // else it's not writable, deny access. - - // We are deleting our data directory. - if (fileSystemManager.getWritableDirectory().toString().equals(filePermission.getName())) { - return true; - } - // Not a writable directory. - final String message = "Preventing " + robotProxy.getStatics().getName() + " from access: " + filePermission - + ". You may only delete files in your own data directory: " + fileSystemManager.getWritableDirectory(); - - robotProxy.punishSecurityViolation(message); - return false; - } - - private boolean impliesRobotFileWrite(IHostedThread robotProxy, RobotFileSystemManager fileSystemManager, FilePermission filePermission) { - // There isn't one. Deny access. - if (!threadManager.checkRobotFileStream()) { - final String message = "Preventing " + robotProxy.getStatics().getName() + " from access: " + filePermission - + ". You must use a RobocodeOutputStream."; - - robotProxy.punishSecurityViolation(message); - return false; - } - - // If there is no writable directory, deny access - if (fileSystemManager.getWritableDirectory() == null) { - final String message = "Preventing " + robotProxy.getStatics().getName() + " from access: " + filePermission - + ". Robots that are not in a package may not write any files."; - - robotProxy.punishSecurityViolation(message); - return false; - } - // If this is a writable file, permit access - if (fileSystemManager.isWritable(filePermission.getName())) { - return true; - } // else it's not writable, deny access. - - // We are creating the directory. - if (fileSystemManager.getWritableDirectory().toString().equals(filePermission.getName())) { - return true; - } - // Not a writable directory. - final String message = "Preventing " + robotProxy.getStatics().getName() + " from access: " + filePermission - + ". You may only write files in your own data directory: " + fileSystemManager.getWritableDirectory(); - - robotProxy.punishSecurityViolation(message); - return false; - } - - private boolean impliesRobotFileRead(IHostedThread robotProxy, RobotFileSystemManager fileSystemManager, FilePermission filePermission) { - // If there is no readable directory, deny access. - if (fileSystemManager.getReadableDirectory() == null) { - final String message = "Preventing " + robotProxy.getStatics().getName() + " from access: " + filePermission - + ". Robots that are not in a package may not read any files."; - - robotProxy.punishSecurityViolation(message); - return false; - } - // If this is a writtable file, return. - if (fileSystemManager.isWritable(filePermission.getName())) { - return true; - } - // If this is a readable file, return. - if (fileSystemManager.isReadable(filePermission.getName())) { - return true; - } - // Else disable robot - final String message = "Preventing " + robotProxy.getStatics().getName() + " from access: " + filePermission - + ". You may only read files in your own root package directory."; - - robotProxy.punishSecurityViolation(message); - return false; - } - - @Override - public void refresh() { - initUrls(); - parentPolicy.refresh(); - } - - private void initUrls() { - untrustedCodeUrls = new HashSet(); - untrustedCodeUrls.add(RobotClassLoader.UNTRUSTED_URL); - - String classPath = System.getProperty("robocode.class.path"); - StringTokenizer tokenizer = new StringTokenizer(classPath, File.pathSeparator); - - // TODO load URLs from new repository roots, don't forget about all robot .jar files - // TODO or check it directly against repository ? - try { - final List robots = new ArrayList(); - IRepositoryManager repositoryManager = Container.getComponent(IRepositoryManager.class); - - if (repositoryManager != null) { - robots.add(repositoryManager.getRobotsDirectory().toURI().toString()); - for (File devel : repositoryManager.getDevelDirectories()) { - robots.add(devel.toURI().toString()); - } - } - - while (tokenizer.hasMoreTokens()) { - String u = new File(tokenizer.nextToken()).getCanonicalFile().toURI().toString(); - - if (robots.contains(u)) { - if (!untrustedCodeUrls.contains(u)) { - untrustedCodeUrls.add(u); - } - } - } - } catch (MalformedURLException e) { - Logger.logError(e); - } catch (IOException e) { - Logger.logError(e); - } - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobotClassLoader.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobotClassLoader.java deleted file mode 100644 index 69dad86..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobotClassLoader.java +++ /dev/null @@ -1,424 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.security; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.host.IHostedThread; -import net.sf.robocode.host.IRobotClassLoader; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.RobocodeProperties; -import net.sf.robocode.io.URLJarCollector; -import robocode.robotinterfaces.IBasicRobot; - -import java.io.BufferedInputStream; -import java.io.IOException; -import java.io.InputStream; -import java.lang.reflect.Field; -import java.lang.reflect.Modifier; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLClassLoader; -import java.net.URLConnection; -import java.nio.ByteBuffer; -import java.security.*; -import java.security.cert.Certificate; -import java.util.ArrayList; -import java.util.HashSet; -import java.util.List; -import java.util.Set; - - -/** - * This class loader is used by robots. It isolates classes which belong to robot and load them locally. - * General java classes or robocode.api classes are loaded by parent loader and shared with Robocode engine. - * Attempts to load classes of Robocode engine are blocked. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Matthew Reeder (contributor) - * @author Robert D. Maupin (contributor) - * @author Nathaniel Troutman (contributor) - */ -public class RobotClassLoader extends URLClassLoader implements IRobotClassLoader { - - static final String UNTRUSTED_URL = "http://robocode.sf.net/untrusted"; - - private static final PermissionCollection EMPTY_PERMISSIONS = new Permissions(); - - private final String fullClassName; - - private ClassLoader parent; - private CodeSource codeSource; - - private IHostedThread robotProxy; - private Class robotClass; - - // Names on classes referenced from the robot class - private Set referencedClasses = new HashSet(); - - // Cached names on found system classes - private Set foundSystemClasses = new HashSet(); - - // Cached warning messages - private String[] staticRobotInstanceWarning; - - public RobotClassLoader(URL robotClassPath, String robotFullClassName) { - super(new URL[] { robotClassPath}, Container.systemLoader); - fullClassName = robotFullClassName; - parent = getParent(); - try { - codeSource = new CodeSource(new URL(UNTRUSTED_URL), (Certificate[]) null); - } catch (MalformedURLException ignored) {} - } - - public void setRobotProxy(Object robotProxy) { - this.robotProxy = (IHostedThread) robotProxy; - } - - public synchronized void addURL(URL url) { - super.addURL(url); - } - - public synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException { - if (name.startsWith("java.lang")) { - // we always delegate java.lang stuff to parent loader - return super.loadClass(name, resolve); - } - if (RobocodeProperties.isSecurityOn()) { - testPackages(name); - } - if (!name.startsWith("robocode")) { - Class result = loadRobotClassLocaly(name, resolve); - if (result != null) { - // yes, it is in robot's class path - // we loaded it locally - return result; - } - } - - // it is robot API - // or java class - // or security is off - // so we delegate to parent class loader - return parent.loadClass(name); - } - - private void testPackages(String name) throws ClassNotFoundException { - if (name.startsWith("net.sf.robocode")) { - String message = "Robots are not allowed to reference Robocode engine in package: net.sf.robocode"; - - punishSecurityViolation(message); - throw new ClassNotFoundException(message); - } - if (name.startsWith("robocode.control")) { - String message = "Robots are not allowed to reference Robocode engine in package: robocode.control"; - - punishSecurityViolation(message); - throw new ClassNotFoundException(message); - } - if (RobocodeProperties.isSecurityOn() && name.startsWith("javax.swing")) { - String message = "Robots are not allowed to reference Robocode engine in package: javax.swing"; - - punishSecurityViolation(message); - throw new ClassNotFoundException(message); - } - } - - private Class loadRobotClassLocaly(String name, boolean resolve) throws ClassNotFoundException { - Class result = findLoadedClass(name); - if (result == null) { - ByteBuffer resource = findLocalResource(name); - if (resource != null) { - result = defineClass(name, resource, codeSource); - if (resolve) { - resolveClass(result); - } - ClassAnalyzer.getReferencedClasses(resource, referencedClasses); - } - } - return result; - } - - // this whole fun is there to be able to provide defineClass with bytes - // we need to call defineClass to be able to set codeSource to untrustedLocation - private ByteBuffer findLocalResource(final String name) { - return AccessController.doPrivileged(new PrivilegedAction() { - public ByteBuffer run() { - // try to find it in robot's class path - // this is URL, don't change to File.pathSeparator - String path = name.replace('.', '/').concat(".class"); - URL url = findResource(path); - ByteBuffer result = null; - InputStream is = null; - BufferedInputStream bis = null; - - if (url != null) { - try { - URLConnection connection = URLJarCollector.openConnection(url); - - is = connection.getInputStream(); - bis = new BufferedInputStream(is); - - result = ByteBuffer.allocate(1024 * 8); - boolean done = false; - - do { - do { - int res = bis.read(result.array(), result.position(), result.remaining()); - - if (res == -1) { - done = true; - break; - } - result.position(result.position() + res); - } while (result.remaining() != 0); - result.flip(); - if (!done) { - result = ByteBuffer.allocate(result.capacity() * 2).put(result); - } - } while (!done); - - } catch (IOException e) { - Logger.logError(e); - return null; - } finally { - FileUtil.cleanupStream(bis); - FileUtil.cleanupStream(is); - } - } - return result; - } - }); - } - - private void punishSecurityViolation(String message) { - if (robotProxy != null) { - robotProxy.punishSecurityViolation(message); - } - } - - protected PermissionCollection getPermissions(CodeSource codesource) { - if (RobocodeProperties.isSecurityOn()) { - return EMPTY_PERMISSIONS; - } - return super.getPermissions(codesource); - } - - public String[] getReferencedClasses() { - return referencedClasses.toArray(new String[referencedClasses.size()]); - } - - public synchronized Class loadRobotMainClass(boolean resolve) throws ClassNotFoundException { - try { - if (robotClass == null) { - robotClass = loadClass(fullClassName, resolve); - - if (!IBasicRobot.class.isAssignableFrom(robotClass)) { - // that's not robot - return null; - } - if (resolve) { - // resolve methods to see more referenced classes - robotClass.getMethods(); - - // iterate thru dependencies until we didn't found any new - HashSet clone; - - do { - clone = new HashSet(referencedClasses); - for (String reference : clone) { - testPackages(reference); - if (!isSystemClass(reference)) { - loadClass(reference, true); - } - } - } while (referencedClasses.size() != clone.size()); - } - } else { - warnIfStaticRobotInstanceFields(); - } - } catch (Throwable e) { - robotClass = null; - throw new ClassNotFoundException(e.getMessage(), e); - } - return robotClass; - } - - public IBasicRobot createRobotInstance() throws ClassNotFoundException, InstantiationException, IllegalAccessException { - loadRobotMainClass(true); - return (IBasicRobot) robotClass.newInstance(); - } - - public void cleanup() { - // Bug fix [2930266] - Robot static data isn't being GCed after battle - for (String className : getReferencedClasses()) { - cleanStaticReferences(className); - } - - parent = null; - codeSource = null; - robotProxy = null; - robotClass = null; - referencedClasses = null; - foundSystemClasses = null; - } - - /** - * Cleans all static field references on a class. - * - * @param className the name of the class containing the static references to clean. - */ - private void cleanStaticReferences(String className) { - if (isSystemClass(className)) { - return; - } - Class type = null; - try { - type = loadRobotClassLocaly(className, false); - if (type != null) { - for (Field field : getAllFields(new ArrayList(), type)) { - if (isStaticReference(field)) { - cleanStaticReference(field); - } - } - } - } catch (Throwable t) { - Logger.logError(t); - } - } - - private void warnIfStaticRobotInstanceFields() { - if (staticRobotInstanceWarning == null) { - List staticRobotReferences = new ArrayList(); - - for (String className : getReferencedClasses()) { // Bug fix [3028102] - ConcurrentModificationException - if (isSystemClass(className)) { - continue; - } - Class type = null; - try { - type = loadRobotClassLocaly(className, false); - } catch (Throwable t) { - continue; - } - if (type != null) { - for (Field field : getAllFields(new ArrayList(), type)) { - if (isStaticReference(field) && IBasicRobot.class.isAssignableFrom(field.getType()) - && field.getAnnotation(robocode.annotation.SafeStatic.class) == null) { - staticRobotReferences.add(field); - } - } - } - } - if (staticRobotReferences.size() > 0) { - StringBuilder buf = new StringBuilder(); - - buf.append("Warning: ").append(fullClassName).append( - " uses static reference to a robot with the following field(s):"); - - for (Field field : staticRobotReferences) { - buf.append("\n\t").append(field.getDeclaringClass().getName()).append('.').append(field.getName()).append(", which points to a ").append( - field.getType().getName()); - } - - staticRobotInstanceWarning = new String[] { - buf.toString(), - "Static references to robots can cause unwanted behaviour with the robot using these.", - "Please change static robot references to non-static references and recompile the robot."}; - } else { - staticRobotInstanceWarning = new String[] {}; // Signal that there is no warnings to cache - } - } else if (staticRobotInstanceWarning.length == 0) { - return; // Return, as no warnings should be written out in the robot console - } - - // Write out warnings to the robot console - if (robotProxy != null) { - for (String line : staticRobotInstanceWarning) { - robotProxy.getOut().println("SYSTEM: " + line); - } - } - } - - /** - * Cleans a static field reference class, even when it is 'private static final' - * - * @param field the field to clean, if it is a static reference. - */ - private void cleanStaticReference(Field field) { - if (field.getName().startsWith("const__")) { - // Ignore 'const__' fields used with e.g. the Clojure language - return; - } - field.setAccessible(true); - try { - // In order to set a 'private static field', we need to fix the modifier, i.e. use magic! ;-) - Field modifiersField = Field.class.getDeclaredField("modifiers"); - modifiersField.setAccessible(true); - int modifiers = modifiersField.getInt(field); - modifiersField.setInt(field, modifiers & ~Modifier.FINAL); // Remove the FINAL modifier - field.set(null, null); - - } catch (Throwable ignore) {} - } - - /** - * Gets all fields of a class (public, protected, private) and the ones inherited from all super classes. - * @param fields the list where the fields will be added as a result of calling this method. - * @param type the class to retrieve all the fields from - * @return the list specified as input parameter containing all the retrieved fields - */ - private List getAllFields(List fields, Class type) { - if (type == null || isSystemClass(type.getName())) { - return fields; - } - try { - for (Field field: type.getDeclaredFields()) { - fields.add(field); - } - } catch (Throwable ignore) {// NoClassDefFoundError does occur with some robots, e.g. sgp.Drunken [1.12] - // We ignore all exceptions and errors here so we can proceed to retrieve - // field from super classes. - } - if (type.getSuperclass() != null) { - fields = getAllFields(fields, type.getSuperclass()); - } - return fields; - } - - /** - * Checks if a specified class name is a Java system class or internal Robocode class. - * @param className the class name to check. - * @return true if the class name is a system class; false otherwise. - */ - private boolean isSystemClass(String className) { - boolean isSystemClass = foundSystemClasses.contains(className); - if (!isSystemClass) { - try { - if (findSystemClass(className) != null) { - foundSystemClasses.add(className); - isSystemClass = true; - } - } catch (ClassNotFoundException ignore) {} - } - return isSystemClass; - } - - /** - * Checks if a specified field is a static reference. - * - * @param field the field to check. - * @return true if the field is static reference; false otherwise. - */ - private static boolean isStaticReference(Field field) { - return Modifier.isStatic(field.getModifiers()) - && !(field.getType().isPrimitive() || field.isEnumConstant() || field.isSynthetic()); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobotThreadManager.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobotThreadManager.java deleted file mode 100644 index d409324..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/RobotThreadManager.java +++ /dev/null @@ -1,343 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.security; - - -import net.sf.robocode.host.IHostedThread; -import net.sf.robocode.host.IThreadManager; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.RobocodeProperties; -import static net.sf.robocode.io.Logger.logError; -import static net.sf.robocode.io.Logger.logMessage; -import static net.sf.robocode.io.Logger.logWarning; -import robocode.exception.RobotException; - -import java.lang.reflect.InvocationTargetException; -import java.security.AccessController; -import java.security.PrivilegedAction; -import java.util.HashMap; -import java.util.Map; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Pavel Savara (contributor) - */ -public class RobotThreadManager { - - private final IHostedThread robotProxy; - private Thread runThread; - private ThreadGroup runThreadGroup; - private Object awtForThreadGroup; - private final Map disposeAppContextThreadMap = new HashMap(); - - public RobotThreadManager(IHostedThread robotProxy) { - this.robotProxy = robotProxy; - createThreadGroup(); - } - - public void cleanup() { - try { - if (runThread == null || !runThread.isAlive()) { - if (!discardAWT()) { - runThreadGroup.destroy(); - } - } else { - Logger.logWarning("Could not destroy " + runThread.getName()); - } - } catch (Exception e) { - Logger.logError("Could not destroy " + runThreadGroup.getName(), e); - } - } - - public void initAWT() { - if (awtForThreadGroup == null) { - awtForThreadGroup = AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - return createNewAppContext(); - } - }); - } - } - - private boolean discardAWT() { - boolean res = false; - - if (awtForThreadGroup != null && !(awtForThreadGroup instanceof Integer)) { - res = disposeAppContext(awtForThreadGroup); - awtForThreadGroup = null; - } - return res; - } - - public void checkRunThread() { - if (Thread.currentThread() != runThread) { - throw new RobotException("You cannot take action in this thread!"); - } - } - - public void start(IThreadManager threadManager) { - try { - threadManager.addThreadGroup(runThreadGroup, robotProxy); - - runThread = new Thread(runThreadGroup, robotProxy, robotProxy.getStatics().getName()); - runThread.setDaemon(true); - runThread.setPriority(Thread.NORM_PRIORITY - 1); - runThread.setContextClassLoader(this.robotProxy.getRobotClassloader()); - runThread.start(); - } catch (Exception e) { - logError("Exception starting thread", e); - } - } - - /** - * @return true as peaceful stop - */ - public boolean waitForStop() { - boolean isAlive = false; - - if (runThread != null && runThread.isAlive()) { - runThread.interrupt(); - waitForStop(runThread); - isAlive = runThread.isAlive(); - } - - Thread[] threads = new Thread[100]; - - runThreadGroup.enumerate(threads); - - for (Thread thread : threads) { - if (thread != null && thread != runThread && thread.isAlive()) { - thread.interrupt(); - waitForStop(thread); - isAlive |= thread.isAlive(); - } - } - - if (isAlive) { - if (RobocodeProperties.isSecurityOn()) { - logError("Robot " + robotProxy.getStatics().getName() + " is not stopping. Forcing a stop."); - - // Force the robot to stop - return forceStop(); - } else { - logError( - "Robot " + robotProxy.getStatics().getName() - + " is still running. Not stopping it because security is off."); - } - } - - return true; - } - - /** - * @return true as peaceful stop - */ - public boolean forceStop() { - int res = stopSteps(runThread); - - Thread[] threads = new Thread[100]; - - runThreadGroup.enumerate(threads); - - for (Thread thread : threads) { - if (thread != null && thread != runThread && thread.isAlive()) { - res += stopSteps(thread); - } - } - if (res > 0) { - robotProxy.println("SYSTEM: This robot has been stopped. No score will be generated."); - - // recycle thread group - createThreadGroup(); - } - runThread = null; - return res == 0; - } - - /** - * @param t thread to stop - * @return 0 as peaceful stop - */ - private int stopSteps(Thread t) { - if (t != null && t.isAlive()) { - interrupt(t); - if (t.isAlive()) { - stop(t); - } - if (t.isAlive()) { - // noinspection deprecation - // t.suspend(); - logWarning("Unable to stop thread: " + runThread.getName()); - } else { - logMessage(robotProxy.getStatics().getName() + " has been stopped."); - } - return 1; - } - return 0; - } - - @SuppressWarnings("deprecation") - private void stop(Thread t) { - if (t != null) { - // noinspection deprecation - t.stop(); - try { - t.join(1500); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - } - } - } - - private void interrupt(Thread t) { - if (t != null) { - try { - t.setPriority(Thread.MIN_PRIORITY); - } catch (NullPointerException e) { - logError("Sometimes this occurs in the Java core?!", e); - } - t.interrupt(); - try { - t.join(500); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - } - } - } - - private void waitForStop(Thread thread) { - for (int j = 0; j < 100 && thread.isAlive(); j++) { - if (j == 50) { - logMessage( - "Waiting for robot " + robotProxy.getStatics().getName() + " to stop thread " + thread.getName()); - } - try { - Thread.sleep(10); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - break; // We are in a loop - } - } - } - - private void createThreadGroup() { - runThreadGroup = new ThreadGroup(robotProxy.getStatics().getName()); - - // bit lower than battle have - runThreadGroup.setMaxPriority(Thread.NORM_PRIORITY - 1); - } - - private Object createNewAppContext() { - // Add the current thread to our disposeAppContextThreadMap if it does not exit already - if (!disposeAppContextThreadMap.containsKey(Thread.currentThread())) { - disposeAppContextThreadMap.put(Thread.currentThread(), new Disposal()); - } - - // same as SunToolkit.createNewAppContext(); - // we can't assume that we are always on Suns JVM, so we can't reference it directly - // why we call that ? Because SunToolkit is caching AWTQueue instance form main thread group and use it on robots threads - // and he is not asking us for checkAwtEventQueueAccess above - try { - final Class sunToolkit = ClassLoader.getSystemClassLoader().loadClass("sun.awt.SunToolkit"); - - // We need to wait for the sun.awt.AppContext.dispose() to complete for the current thread before creating - // a new AppContext for it. Otherwise the AWT EventQueue fires events like WINDOW_CLOSE to our main window - // which closes the entire application due to a System.exit() - - Disposal disposal = disposeAppContextThreadMap.get(Thread.currentThread()); - - synchronized (disposal) { - while (disposal.isDisposing) { - try { - disposal.wait(); - } catch (InterruptedException e) { - return -1; - } - } - } - - // Call sun.awt.SunToolkit.createNewAppContext() to create a new AppContext for the current thread - return sunToolkit.getDeclaredMethod("createNewAppContext").invoke(null); - - } catch (ClassNotFoundException e) { - // we are not on sun JVM - return -1; - } catch (NoSuchMethodException e) { - throw new Error("Looks like SunVM but unable to assure secured AWTQueue, sorry", e); - } catch (InvocationTargetException e) { - throw new Error("Looks like SunVM but unable to assure secured AWTQueue, sorry", e); - } catch (IllegalAccessException e) { - throw new Error("Looks like SunVM but unable to assure secured AWTQueue, sorry", e); - } - // end: same as SunToolkit.createNewAppContext(); - } - - private boolean disposeAppContext(final Object appContext) { - // This method should must not be used when the AWT is running in headless mode! - // Bugfix [2833271] IllegalThreadStateException with the AWT-Shutdown thread. - // Read more about headless mode here: - // http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/ - - // This check makes sure we exit, if the AWT is running in headless mode - if (System.getProperty("java.awt.headless", "false").equals("true")) { - return false; - } - - // same as AppContext.dispose(); - try { - final Class sunToolkit = ClassLoader.getSystemClassLoader().loadClass("sun.awt.AppContext"); - - // We run this in a thread, as invoking the AppContext.dispose() method sometimes takes several - // seconds, and thus causes the cleanup of a battle to hang, which is annoying when trying to restart - // a battle. - new Thread(new Runnable() { - public void run() { - Disposal disposal = disposeAppContextThreadMap.get(Thread.currentThread()); - - try { - // Signal that the AppContext for the current thread is being disposed (start) - if (disposal != null) { - synchronized (disposal) { - disposal.isDisposing = true; - disposal.notifyAll(); - } - } - // Call sun.awt.AppContext.dispose(appContext) to dispose the AppContext for the current thread - sunToolkit.getDeclaredMethod("dispose").invoke(appContext); - - } catch (Exception e) { - logError(e); - } finally { - // Signal that the AppContext for the current thread has been disposed (finish) - if (disposal != null) { - synchronized (disposal) { - disposal.isDisposing = false; - disposal.notifyAll(); - } - } - } - } - }, "DisposeAppContext").start(); - - return true; - } catch (ClassNotFoundException e) { - logError(e); - } - return false; - // end: same as AppContext.dispose(); - } - - private static class Disposal { - boolean isDisposing; - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/SecureInputStream.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/SecureInputStream.java deleted file mode 100644 index 4a04866..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/SecureInputStream.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.security; - - -import java.io.IOException; -import java.io.InputStream; -import java.security.AccessController; - - -/** - * @author Mathew A. Nelson (original) - */ -public class SecureInputStream extends java.io.InputStream { - private RobocodePermission inputPermission = null; - private InputStream in = null; - - /** - * SecureInputStream constructor comment. - * - * @param in original - */ - public SecureInputStream(InputStream in) { - super(); - this.in = in; - this.inputPermission = new RobocodePermission("System.in"); - } - - @Override - public final int available() throws IOException { - checkAccess(); - return in.available(); - } - - private void checkAccess() { - AccessController.checkPermission(inputPermission); - } - - @Override - public final void close() throws IOException { - checkAccess(); - in.close(); - } - - @Override - public final synchronized void mark(int readlimit) { - checkAccess(); - in.mark(readlimit); - } - - @Override - public final boolean markSupported() { - checkAccess(); - return in.markSupported(); - } - - /** - * Reads the next byte of data from the input stream. The value byte is - * returned as an {@code int} in the range 0 to 255. If no byte is available - * because the end of the stream has been reached, the value -1 is returned. - * This method blocks until input data is available, the end of the stream - * is detected, or an exception is thrown. - *

- *

A subclass must provide an implementation of this method. - * - * @return the next byte of data, or -1 if the end of the stream is reached. - * @throws IOException if an I/O error occurs. - */ - @Override - public final int read() throws java.io.IOException { - checkAccess(); - return in.read(); - } - - @Override - public final int read(byte[] b) throws IOException { - checkAccess(); - return in.read(b); - } - - @Override - public final int read(byte[] b, int off, int len) throws IOException { - checkAccess(); - return in.read(b, off, len); - } - - @Override - public final synchronized void reset() throws IOException { - checkAccess(); - in.reset(); - } - - @Override - public final long skip(long n) throws IOException { - checkAccess(); - return in.skip(n); - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/SecurePrintStream.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/SecurePrintStream.java deleted file mode 100644 index 730bcd7..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/SecurePrintStream.java +++ /dev/null @@ -1,293 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.security; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.host.IHostManager; - -import java.io.OutputStream; -import java.io.PrintStream; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class SecurePrintStream extends PrintStream { - - public SecurePrintStream(OutputStream out, boolean autoFlush) { - super(out, autoFlush); - } - - @Override - public final boolean checkError() { - PrintStream out = checkAccess(); - - return (out == this) ? super.checkError() : out.checkError(); - } - - @Override - public final void close() { - PrintStream out = checkAccess(); - - if (out == this) { - super.close(); - } else { - out.close(); - } - } - - @Override - public final void flush() { - PrintStream out = checkAccess(); - - if (out == this) { - super.flush(); - } else { - out.flush(); - } - } - - @Override - public final void print(char[] s) { - PrintStream out = checkAccess(); - - if (out == this) { - super.print(s); - } else { - out.print(s); - } - } - - @Override - public final void print(char c) { - PrintStream out = checkAccess(); - - if (out == this) { - super.print(c); - } else { - out.print(c); - } - } - - @Override - public final void print(double d) { - PrintStream out = checkAccess(); - - if (out == this) { - super.print(d); - } else { - out.print(d); - } - } - - @Override - public final void print(float f) { - PrintStream out = checkAccess(); - - if (out == this) { - super.print(f); - } else { - out.print(f); - } - } - - @Override - public final void print(int i) { - PrintStream out = checkAccess(); - - if (out == this) { - super.print(i); - } else { - out.print(i); - } - } - - @Override - public final void print(long l) { - PrintStream out = checkAccess(); - - if (out == this) { - super.print(l); - } else { - out.print(l); - } - } - - @Override - public final void print(Object obj) { - PrintStream out = checkAccess(); - - if (out == this) { - super.print(obj); - } else { - out.print(obj); - } - } - - @Override - public final void print(String s) { - PrintStream out = checkAccess(); - - if (out == this) { - super.print(s); - } else { - out.print(s); - } - } - - @Override - public final void print(boolean b) { - PrintStream out = checkAccess(); - - if (out == this) { - super.print(b); - } else { - out.print(b); - } - } - - @Override - public final void println() { - PrintStream out = checkAccess(); - - if (out == this) { - super.println(); - } else { - out.println(); - } - } - - @Override - public final void println(char[] x) { - PrintStream out = checkAccess(); - - if (out == this) { - super.println(x); - } else { - out.println(x); - } - } - - @Override - public final void println(char x) { - PrintStream out = checkAccess(); - - if (out == this) { - super.println(x); - } else { - out.println(x); - } - } - - @Override - public final void println(double x) { - PrintStream out = checkAccess(); - - if (out == this) { - super.println(x); - } else { - out.println(x); - } - } - - @Override - public final void println(float x) { - PrintStream out = checkAccess(); - - if (out == this) { - super.println(x); - } else { - out.println(x); - } - } - - @Override - public final void println(int x) { - PrintStream out = checkAccess(); - - if (out == this) { - super.println(x); - } else { - out.println(x); - } - } - - @Override - public final void println(long x) { - PrintStream out = checkAccess(); - - if (out == this) { - super.println(x); - } else { - out.println(x); - } - } - - @Override - public final void println(Object x) { - PrintStream out = checkAccess(); - - if (out == this) { - super.println(x); - } else { - out.println(x); - } - } - - @Override - public final void println(String x) { - PrintStream out = checkAccess(); - - if (out == this) { - super.println(x); - } else { - out.println(x); - } - } - - @Override - public final void println(boolean x) { - PrintStream out = checkAccess(); - - if (out == this) { - super.println(x); - } else { - out.println(x); - } - } - - @Override - public final void write(byte[] buf, int off, int len) { - PrintStream out = checkAccess(); - - if (out == this) { - super.write(buf, off, len); - } else { - out.write(buf, off, len); - } - } - - @Override - public final void write(int b) { - PrintStream out = checkAccess(); - - if (out == this) { - super.write(b); - } else { - out.write(b); - } - } - - private PrintStream checkAccess() { - PrintStream out = Container.getComponent(IHostManager.class).getRobotOutputStream(); - - return (out == null) ? this : out; - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/ThreadManager.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/ThreadManager.java deleted file mode 100644 index 6e47b48..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/security/ThreadManager.java +++ /dev/null @@ -1,213 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.security; - - -import net.sf.robocode.host.IHostedThread; -import net.sf.robocode.host.IThreadManager; -import net.sf.robocode.host.io.RobotFileOutputStream; -import net.sf.robocode.host.io.RobotFileSystemManager; -import robocode.exception.RobotException; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.PrintStream; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; -import java.security.AccessController; -import java.security.PrivilegedAction; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -public class ThreadManager implements IThreadManager { - - private final PrintStream syserr = System.err; - - private final List safeThreads = new CopyOnWriteArrayList(); - private final List safeThreadGroups = new CopyOnWriteArrayList(); - private final List groups = new CopyOnWriteArrayList(); - private final List outputStreamThreads = new CopyOnWriteArrayList(); - private final List robots = new CopyOnWriteArrayList(); - - private Thread robotLoaderThread; - private IHostedThread loadingRobot; - - public ThreadManager() {} - - public void addSafeThread(Thread safeThread) { - safeThreads.add(safeThread); - } - - public void removeSafeThread(Thread safeThread) { - safeThreads.remove(safeThread); - } - - public void addSafeThreadGroup(ThreadGroup safeThreadGroup) { - safeThreadGroups.add(safeThreadGroup); - } - - public void addThreadGroup(ThreadGroup g, IHostedThread robotProxy) { - if (!groups.contains(g)) { - groups.add(g); - robots.add(robotProxy); - } - } - - public synchronized IHostedThread getLoadingRobot() { - return loadingRobot; - } - - public synchronized IHostedThread getLoadingRobotProxy(Thread t) { - if (t != null && robotLoaderThread != null - && (t.equals(robotLoaderThread) - || (t.getThreadGroup() != null && t.getThreadGroup().equals(robotLoaderThread.getThreadGroup())))) { - return loadingRobot; - } - return null; - } - - public synchronized IHostedThread getLoadedOrLoadingRobotProxy(Thread t) { - IHostedThread robotProxy = getRobotProxy(t); - - if (robotProxy == null) { - robotProxy = getLoadingRobotProxy(t); - } - return robotProxy; - } - - public IHostedThread getRobotProxy(Thread t) { - ThreadGroup g = t.getThreadGroup(); - - if (g == null) { - return null; - } - int index = groups.indexOf(g); - - if (index == -1) { - return null; - } - return robots.get(index); - } - - public void reset() { - groups.clear(); - robots.clear(); - } - - public synchronized void setLoadingRobot(IHostedThread newLoadingRobotProxy) { - if (newLoadingRobotProxy == null) { - this.robotLoaderThread = null; - loadingRobot = null; - } else { - this.robotLoaderThread = Thread.currentThread(); - loadingRobot = newLoadingRobotProxy; - } - } - - public boolean isSafeThread() { - return isSafeThread(Thread.currentThread()); - } - - public FileOutputStream createRobotFileStream(String fileName, boolean append) throws IOException { - final Thread c = Thread.currentThread(); - - final IHostedThread robotProxy = getRobotProxy(c); - - if (robotProxy == null) { - syserr.println("RobotProxy is null"); - return null; - } - if (!robotProxy.getStatics().isAdvancedRobot()) { - throw new RobotException("Only advanced robots could create files"); - } - - final File dir = robotProxy.getRobotFileSystemManager().getWritableDirectory(); - - if (!dir.exists()) { - robotProxy.println("SYSTEM: Creating a data directory for you."); - AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - outputStreamThreads.add(c); - if (!dir.exists() && !dir.mkdirs()) { - syserr.println("Can't create dir " + dir.toString()); - } - return null; - } - }); - } - - final RobotFileSystemManager fileSystemManager = robotProxy.getRobotFileSystemManager(); - - File f = new File(fileName); - long len; - - if (f.exists()) { - len = f.length(); - } else { - fileSystemManager.checkQuota(); - len = 0; - } - - if (!append) { - fileSystemManager.adjustQuota(-len); - } - - outputStreamThreads.add(c); - return new RobotFileOutputStream(fileName, append, fileSystemManager); - } - - public boolean checkRobotFileStream() { - final Thread c = Thread.currentThread(); - - synchronized (outputStreamThreads) { - if (outputStreamThreads.contains(c)) { - outputStreamThreads.remove(c); - return true; - } - } - return false; - } - - public boolean isSafeThread(Thread c) { - try { - if (safeThreads.contains(c)) { - return true; - } - - for (ThreadGroup tg : safeThreadGroups) { - if (c.getThreadGroup() == tg) { - safeThreads.add(c); - return true; - } - } - - return false; - } catch (Exception e) { - syserr.println("Exception checking safe thread: "); - e.printStackTrace(syserr); - return false; - } - } - - public PrintStream getRobotOutputStream() { - Thread c = Thread.currentThread(); - - if (isSafeThread(c)) { - return null; - } - - IHostedThread robotProxy = getLoadedOrLoadingRobotProxy(c); - - return (robotProxy != null) ? robotProxy.getOut() : null; - } -} diff --git a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/serialization/RobocodeObjectInputStream.java b/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/serialization/RobocodeObjectInputStream.java deleted file mode 100644 index fd4824c..0000000 --- a/workspace_robo/robocode.host/src/main/java/net/sf/robocode/host/serialization/RobocodeObjectInputStream.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.serialization; - - -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectStreamClass; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class RobocodeObjectInputStream extends ObjectInputStream { - - private ClassLoader classLoader; - - public RobocodeObjectInputStream(InputStream in, ClassLoader classLoader) throws IOException { - super(in); - this.classLoader = classLoader; - } - - @Override - protected Class resolveClass(ObjectStreamClass desc) throws IOException, ClassNotFoundException { - String name = desc.getName(); - - try { - return Class.forName(name, false, classLoader); - } catch (ClassNotFoundException ex) { - return super.resolveClass(desc); - } - } -} diff --git a/workspace_robo/robocode.host/src/test/java/net/sf/robocode/host/jarjar/JarJarTest.java b/workspace_robo/robocode.host/src/test/java/net/sf/robocode/host/jarjar/JarJarTest.java deleted file mode 100644 index 6cf90e1..0000000 --- a/workspace_robo/robocode.host/src/test/java/net/sf/robocode/host/jarjar/JarJarTest.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.host.jarjar; - - -import org.junit.Test; -import org.junit.Assert; - -import java.net.URL; -import java.net.URLConnection; -import java.net.URLClassLoader; -import java.io.InputStream; -import java.io.IOException; -import java.io.InputStreamReader; - -import net.sf.robocode.io.URLJarCollector; -import net.sf.robocode.io.JarJar; - - -/** - * @author Pavel Savara (original) - */ -public class JarJarTest { - static { - JarJarURLConnection.register(); - } - - @Test - public void run() throws IOException { - - String clas = "Hello.class"; - String inner = "Inner.jar"; - String outer = "file:src/test/resources/Outer.jar"; - - final String separ = "!/"; - URL u = new URL("jar:jarjar:" + outer + JarJar.SEPARATOR + inner + separ + clas); - final URLConnection urlConnection = URLJarCollector.openConnection(u); - final InputStream inputStream = urlConnection.getInputStream(); - InputStreamReader isr = new InputStreamReader(inputStream); - char[] c = new char[4]; - - int len = isr.read(c); - - Assert.assertEquals(len, 4); - Assert.assertEquals('T', c[0]); - Assert.assertEquals('e', c[1]); - Assert.assertEquals('s', c[2]); - Assert.assertEquals('t', c[3]); - Assert.assertFalse(isr.ready()); - isr.close(); - inputStream.close(); - } - - @Test - public void runClassLoader() throws IOException, ClassNotFoundException { - String clas = "tested.robots.Ahead"; - String inner = "Inner.jar"; - String outer = "file:src/test/resources/Outer.jar"; - final String separ = "!/"; - final String root = "jar:jarjar:" + outer + JarJar.SEPARATOR + inner + separ; - URL u = new URL(root); - - ClassLoader ucl = new URLClassLoader(new URL[] { u}); - - ucl.loadClass(clas); - } -} diff --git a/workspace_robo/robocode.host/src/test/resources/Outer.jar b/workspace_robo/robocode.host/src/test/resources/Outer.jar deleted file mode 100644 index 4b539ff..0000000 Binary files a/workspace_robo/robocode.host/src/test/resources/Outer.jar and /dev/null differ diff --git a/workspace_robo/robocode.iml b/workspace_robo/robocode.iml deleted file mode 100644 index aaf2c03..0000000 --- a/workspace_robo/robocode.iml +++ /dev/null @@ -1,65 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.installer/.classpath b/workspace_robo/robocode.installer/.classpath deleted file mode 100644 index faff71b..0000000 --- a/workspace_robo/robocode.installer/.classpath +++ /dev/null @@ -1,6 +0,0 @@ - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.installer/.project b/workspace_robo/robocode.installer/.project deleted file mode 100644 index c76d339..0000000 --- a/workspace_robo/robocode.installer/.project +++ /dev/null @@ -1,14 +0,0 @@ - - - robocode.installer - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.installer/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.installer/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.installer/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.installer/pom.xml b/workspace_robo/robocode.installer/pom.xml deleted file mode 100644 index d9e283c..0000000 --- a/workspace_robo/robocode.installer/pom.xml +++ /dev/null @@ -1,27 +0,0 @@ - - - 4.0.0 - robocode.installer - Robocode Installer - - net.sf.robocode - robocode - ${robocode.version} - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - net.sf.robocode.installer.AutoExtract - - - - - - - diff --git a/workspace_robo/robocode.installer/robocode.installer.iml b/workspace_robo/robocode.installer/robocode.installer.iml deleted file mode 100644 index 613ddb1..0000000 --- a/workspace_robo/robocode.installer/robocode.installer.iml +++ /dev/null @@ -1,67 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java b/workspace_robo/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java deleted file mode 100644 index 581a88e..0000000 --- a/workspace_robo/robocode.installer/src/main/java/net/sf/robocode/installer/AutoExtract.java +++ /dev/null @@ -1,705 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.installer; - - -import javax.swing.*; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.*; -import java.net.URL; -import java.util.jar.JarEntry; -import java.util.jar.JarFile; -import java.util.jar.JarInputStream; - - -/** - * Installer for Robocode. - * - * @author Mathew A. Nelsen (original) - * @author Flemming N. Larsen (contributor) - */ -public class AutoExtract implements ActionListener { - private JDialog licenseDialog; - private boolean accepted; - private static final String[] SPINNER = { "-", "\\", "|", "/"}; - private String message = ""; - private static File installDir; - private static final String osName = System.getProperty("os.name"); - private static final double osVersion = doubleValue(System.getProperty("os.version")); - private static final String javaVersion = System.getProperty("java.version"); - - private static double doubleValue(String s) { - s = s.replaceAll("[^.0-9]", ""); // Remove invalid characters, e.g. "3.0-ARCH" become "3.0" - - int p = s.indexOf("."); - - if (p >= 0) { - p = s.indexOf(".", p + 1); - } - if (p >= 0) { - s = s.substring(0, p); - } - - double d = 0.0; - - try { - d = Double.parseDouble(s); - } catch (NumberFormatException e) { - e.printStackTrace(System.err); - } - - return d; - } - - private boolean acceptLicense() { - StringBuffer licenseText = new StringBuffer(); - - InputStream is; - - try { - JarFile extractJar = new JarFile("extract.jar"); - - is = extractJar.getInputStream(extractJar.getJarEntry("license/cpl-v10.html")); - } catch (IOException e) { - return true; - } - if (is == null) { - return true; - } - - InputStreamReader isr = null; - BufferedReader br = null; - - try { - isr = new InputStreamReader(is); - br = new BufferedReader(isr); - - String line = br.readLine(); - - while (line != null) { - licenseText.append(line); - line = br.readLine(); - } - return acceptReject(licenseText.toString()); - - } catch (IOException e) { - System.err.println("Could not read line from license file: " + e); - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (isr != null) { - try { - isr.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return true; - } - - private boolean acceptReject(String text) { - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - licenseDialog = new JDialog(); - licenseDialog.setTitle("License Agreement"); - licenseDialog.setModal(true); - licenseDialog.setLocation((screenSize.width - 500) / 2, (screenSize.height - 400) / 2); - licenseDialog.setSize(500, 400); - JTextPane t = new JTextPane(); - - t.setContentType("text/html"); - t.setText(text); - t.setFont(new Font("Dialog", Font.PLAIN, 12)); - t.setEditable(false); - - JScrollPane s = new JScrollPane(); - - s.setViewportView(t); - - licenseDialog.getContentPane().setLayout(new BorderLayout()); - licenseDialog.getContentPane().add(s, BorderLayout.CENTER); - - JPanel p = new JPanel(); - - p.setLayout(new BorderLayout()); - JButton b1 = new JButton("Accept"); - JButton b2 = new JButton("Cancel"); - - p.add(b1, BorderLayout.WEST); - p.add(b2, BorderLayout.EAST); - - b1.addActionListener(this); - b2.addActionListener(this); - - licenseDialog.getContentPane().add(p, BorderLayout.SOUTH); - - licenseDialog.setVisible(true); - - return accepted; - } - - public void actionPerformed(ActionEvent e) { - accepted = e.getActionCommand().equals("Accept"); - licenseDialog.dispose(); - licenseDialog = null; - } - - private boolean extract(File installDir) { - JDialog statusDialog = new JDialog(); - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - int width = 500; - int height = 100; - - statusDialog.setTitle("Installing"); - statusDialog.setLocation((screenSize.width - width) / 2, (screenSize.height - height) / 2); - statusDialog.setSize(width, height); - JLabel status = new JLabel(); - - statusDialog.getContentPane().setLayout(new BorderLayout()); - statusDialog.getContentPane().add(status, BorderLayout.CENTER); - - statusDialog.setVisible(true); - - FileOutputStream fos; - String entryName; - - byte buf[] = new byte[2048]; - - final String name = AutoExtract.class.getName().replaceAll("\\.", "/") + ".class"; - String urlJar = AutoExtract.class.getClassLoader().getResource(name).toString(); - final String src = urlJar.substring("jar:file:/".length(), urlJar.indexOf("!/")); - - if (src.indexOf('!') > -1) { - message = src + "\nContains an exclamation point. Please move the file to a different directory."; - JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE); - return false; - } - JarInputStream jarIS = null; - - try { - final URL url = new URL("file:/" + src); - InputStream is = url.openStream(); - - jarIS = new JarInputStream(is); - - JarEntry entry; - - while ((entry = jarIS.getNextJarEntry()) != null) { - int spin = 0; - - entryName = entry.getName(); - if (entry.isDirectory()) { - if (!entryName.startsWith("net") && !(entryName.equals("desktop") && isFreeBSD())) { - File dir = new File(installDir, entry.getName()); - if (!dir.exists() && !dir.mkdirs()) { - System.err.println("Can't create dir: " + dir); - } - } - } else if (!entryName.equals(name)) { - - // Skip .bat, .sh, and .command files depending on which OS Robocode is installed - - final String entryNameLC = entryName.toLowerCase(); - - boolean skipEntry = false; - - final boolean isBatFile = entryNameLC.length() > ".bat".length() && entryNameLC.endsWith(".bat"); - final boolean isShFile = entryNameLC.length() > ".sh".length() && entryNameLC.endsWith(".sh"); - final boolean isCommandFile = entryNameLC.length() > ".command".length() - && entryNameLC.endsWith(".command"); - final boolean isDesktopFile = entryNameLC.startsWith("desktop/"); - - // Unix systems and Mac OS X - if (File.separatorChar == '/') { - // Skip .bat files under Unix and Mac OS X - // Skip .command files under Unix - skipEntry = isBatFile || (isCommandFile && !isMacOSX()) || (isDesktopFile && !isFreeBSD()); - } else { - // Under Windows the .sh and .command files are skipped - skipEntry = isShFile || isCommandFile || isDesktopFile; - } - - // If we are not skipping the entry, then copy from our .jar into the installation dir - if (!skipEntry) { - status.setText(entryName + " " + SPINNER[spin++]); - - File out = new File(installDir, entryName); - - File parentDirectory = new File(out.getParent()); - if (!parentDirectory.exists() && !parentDirectory.mkdirs()) { - System.err.println("Can't create dir: " + parentDirectory); - } - fos = new FileOutputStream(out); - - int index = 0; - int num; - int count = 0; - - while ((num = jarIS.read(buf, 0, 2048)) != -1) { - fos.write(buf, 0, num); - index += num; - count++; - if (count > 80) { - status.setText(entryName + " " + SPINNER[spin++] + " (" + index + " bytes)"); - if (spin > 3) { - spin = 0; - } - count = 0; - } - } - fos.close(); - - // Set file permissions for .sh and .command files under Unix and Mac OS X - if (File.separatorChar == '/') { - if (isShFile || isCommandFile) { - // Grant read and execute access for everyone and also write access for the owner of the file - Runtime.getRuntime().exec("chmod 755 " + out.toString()); - } - } - - status.setText(entryName + " " + SPINNER[spin] + " (" + index + " bytes)"); - } - } - } - statusDialog.dispose(); - return true; - } catch (IOException e) { - message = "Installation failed: " + e; - JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE); - return false; - } finally { - if (jarIS != null) { - try { - jarIS.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - - public static void main(String argv[]) { - String suggestedDirName; - - if (argv.length == 1) { - suggestedDirName = argv[0]; - } else if (isWindowsOS()) { - suggestedDirName = "C:\\robocode\\"; - } else { - suggestedDirName = System.getProperty("user.home") + File.separator + "robocode" + File.separator; - } - - String message; - - if (install(new File(suggestedDirName))) { - message = "Installation successful"; - } else { - message = "Installation cancelled"; - } - - // Delete the class file with the installer and it's parent folders in the robocode home dir - if (installDir != null) { - String installerPath = AutoExtract.class.getName().replaceAll("\\.", "/") + "$1.class"; - - deleteFileAndParentDirsIfEmpty(new File(installDir, installerPath)); - } - - JOptionPane.showMessageDialog(null, message); - } - - private static boolean install(File suggestedDir) { - // Verify that the Java version is version 6 (1.6.0) or newer - if (javaVersion.startsWith("1.") && javaVersion.charAt(2) < '5') { - final String message = "Robocode requires Java 6 (1.6.0) or newer.\n" - + "Your system is currently running Java " + javaVersion + ".\n" - + "If you have not installed (or activated) at least\n" + "JRE 6 or JDK 6, please do so."; - - JOptionPane.showMessageDialog(null, message, "Error", JOptionPane.ERROR_MESSAGE); - System.err.println(message); - return false; - } - - // Set native look and feel - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable t) {// For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF - } - - AutoExtract extractor = new AutoExtract(); - - if (extractor.acceptLicense()) { - boolean done = false; - - while (!done) { - int rc = JOptionPane.showConfirmDialog(null, - "Robocode will be installed in:\n" + suggestedDir + "\nIs this ok?", "Installing Robocode", - JOptionPane.YES_NO_CANCEL_OPTION, JOptionPane.QUESTION_MESSAGE); - - if (rc == JOptionPane.YES_OPTION) { - installDir = suggestedDir; - done = true; - } else if (rc == JOptionPane.NO_OPTION) { - Object r = JOptionPane.showInputDialog(null, "Please type in the installation directory", - "Installation Directory", JOptionPane.PLAIN_MESSAGE, null, null, suggestedDir); - - if (r != null) { - suggestedDir = new File(((String) r).trim()); - } else { - return false; - } - } else if (rc == JOptionPane.CANCEL_OPTION) { - return false; - } - } - if (!installDir.exists() && !installDir.mkdirs()) { - System.err.println("Can't create dir: " + installDir); - return false; - } - deleteOldLibs(installDir); - - // The .robotcache has been renamed to .data - File robotsCacheDir = new File(installDir, "robots/.robotcache"); - File robotsDataDir = new File(installDir, "robots/.data"); - - if (robotsCacheDir.exists()) { - // Rename ".robotcache" into ".data" - robotsCacheDir.renameTo(robotsDataDir); - } - - // Fix problem with .data starting with a underscore dir by - // renaming files containing ".data/_" into ".data" - if (robotsDataDir.exists()) { - File underScoreDir = new File(robotsDataDir, "_"); - String[] list = underScoreDir.list(); - - if (list != null) { - for (String fileName : list) { - File file = new File(underScoreDir, fileName); - - file.renameTo(new File(robotsDataDir, fileName)); - } - underScoreDir.delete(); - } - } - - // Create shortcuts and file associations - if (extractor.extract(installDir)) { - extractor.createShortcuts(installDir, "robocode.bat", "Robocode", "Robocode"); - extractor.createFileAssociations(installDir); - return true; - } - } - return false; - } - - private static void deleteOldLibs(File installDir) { - File libs = new File(installDir, "libs"); - - if (libs.exists()) { - final File[] del = libs.listFiles(new FilenameFilter() { - - public boolean accept(File dir, String name) { - String test = name.toLowerCase(); - - return test.endsWith(".jar") || test.endsWith(".dll"); - } - }); - - for (File d : del) { - if (!d.delete()) { - System.err.println("Can't delete: " + d); - } - } - } - } - - private static boolean deleteDir(File dir) { - if (dir.isDirectory()) { - for (File file : dir.listFiles()) { - if (file.isDirectory()) { - // Skip directories ending with ".data" - if (file.getName().endsWith(".data")) { - continue; - } - try { - // Test for symlink and ignore. - // Robocode won't create one, but just in case a user does... - if (file.getCanonicalFile().getParentFile().equals(dir.getCanonicalFile())) { - deleteDir(file); - if (file.exists() && !file.delete()) { - System.err.println("Can't delete: " + file); - } - } else { - System.out.println("Warning: " + file + " may be a symlink. It has been ignored"); - } - } catch (IOException e) { - System.out.println( - "Warning: Cannot determine canonical file for " + file + ". It has been ignored"); - } - } else { - if (file.exists() && !file.delete()) { - System.err.println("Can't delete: " + file); - } - } - } - return dir.delete(); - } - return false; - } - - private void createShortcuts(File installDir, String runnable, String folder, String name) { - if (osName.toLowerCase().indexOf("win") == 0) { - if (createWindowsShortcuts(installDir, runnable, folder, name) == false) { - JOptionPane.showMessageDialog(null, - message + "\n" + "To start Robocode, enter the following at a command prompt:\n" + "cd " - + installDir.getAbsolutePath() + "\n" + "robocode.bat"); - } - } else if (osName.toLowerCase().indexOf("mac") == 0) { - if (osVersion >= 10.1) { - JOptionPane.showMessageDialog(null, - message + "\n" + "To start Robocode, browse to " + installDir + " then double-click robocode.sh\n"); - } else { - JOptionPane.showMessageDialog(null, - message + "\n" + "To start Robocode, enter the following at a command prompt:\n" - + installDir.getAbsolutePath() + "/robocode.sh"); - } - } else { - JOptionPane.showMessageDialog(null, - message + "\n" + "To start Robocode, enter the following at a command prompt:\n" - + installDir.getAbsolutePath() + "/robocode.sh"); - } - } - - private boolean createWindowsShortcuts(File installDir, String runnable, String folder, String name) { - int rc = JOptionPane.showConfirmDialog(null, - "Would you like to install a shortcut to Robocode in the Start menu? (Recommended)", "Create Shortcuts", - JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE); - - if (rc != JOptionPane.YES_OPTION) { - return false; - } - - final String command = getWindowsCmd() + " cscript.exe "; - - try { - File shortcutMaker = new File(installDir, "makeshortcut.vbs"); - PrintStream out = new PrintStream(new FileOutputStream(shortcutMaker)); - - out.println("WScript.Echo(\"Creating shortcuts...\")"); - out.println("Set Shell = CreateObject (\"WScript.Shell\")"); - out.println("Set fso = CreateObject(\"Scripting.FileSystemObject\")"); - out.println("ProgramsPath = Shell.SpecialFolders(\"Programs\")"); - out.println("if (not(fso.folderExists(ProgramsPath + \"\\\\" + folder + "\"))) Then"); - out.println(" fso.CreateFolder(ProgramsPath + \"\\\\" + folder + "\")"); - out.println("End If"); - out.println("Set link = Shell.CreateShortcut(ProgramsPath + \"\\\\" + folder + "\\\\" + name + ".lnk\")"); - out.println("link.Arguments = \"\""); - out.println("link.Description = \"" + name + "\""); - out.println("link.HotKey = \"\""); - out.println("link.IconLocation = \"" + escaped(installDir.getAbsolutePath()) + "\\\\" + "robocode.ico,0\""); - out.println("link.TargetPath = \"" + escaped(installDir.getAbsolutePath()) + "\\\\" + runnable + "\""); - out.println("link.WindowStyle = 1"); - out.println("link.WorkingDirectory = \"" + escaped(installDir.getAbsolutePath()) + "\""); - out.println("link.Save()"); - out.println("DesktopPath = Shell.SpecialFolders(\"Desktop\")"); - out.println("Set link = Shell.CreateShortcut(DesktopPath + \"\\\\" + name + ".lnk\")"); - out.println("link.Arguments = \"\""); - out.println("link.Description = \"" + name + "\""); - out.println("link.HotKey = \"\""); - out.println("link.IconLocation = \"" + escaped(installDir.getAbsolutePath()) + "\\\\" + "robocode.ico,0\""); - out.println("link.TargetPath = \"" + escaped(installDir.getAbsolutePath()) + "\\\\" + runnable + "\""); - out.println("link.WindowStyle = 1"); - out.println("link.WorkingDirectory = \"" + escaped(installDir.getAbsolutePath()) + "\""); - out.println("link.Save()"); - out.println("WScript.Echo(\"Shortcuts created.\")"); - - out.close(); - - Process p = Runtime.getRuntime().exec(command + " makeshortcut.vbs", null, installDir); - int rv = p.waitFor(); - - if (rv != 0) { - System.err.println("Can't create shortcut: " + shortcutMaker); - return false; - } - JOptionPane.showMessageDialog(null, - message + "\n" + "A Robocode program group has been added to your Start menu\n" - + "A Robocode icon has been added to your desktop."); - if (!shortcutMaker.delete()) { - System.err.println("Can't delete: " + shortcutMaker); - } - return true; - } catch (IOException e) { - e.printStackTrace(System.err); - } catch (InterruptedException e) { - e.printStackTrace(System.err); - } - - return false; - } - - private void createFileAssociations(File installDir) { - if (isWindowsOS()) { - createWindowsFileAssociations(installDir); - } - } - - private void createWindowsFileAssociations(File installDir) { - int rc = JOptionPane.showConfirmDialog(null, - "Would you like to create file associations for Robocode in\n" - + "the Windows Registry for the file extensions .battle and .br?\n" - + "Please notice that you might need to grant permission to add\n" - + "the file associations in the Registry, and you must be an\n" - + "administrator or granted permission to change the registry.", - "Create File Associations", - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - - if (rc != JOptionPane.YES_OPTION) { - return; - } - - File file = null; - PrintStream out = null; - - try { - file = new File(installDir + "\\FileAssoc.reg"); - - out = new PrintStream(new FileOutputStream(file)); - - String installPath = installDir.getAbsolutePath(); - - out.print( - createWindowsRegistryFileAssociation(installPath, ".battle", "Robocode.BattleSpecification", - "Robocode Battle Specification", "-battle")); - out.print( - createWindowsRegistryFileAssociation(installPath, ".br", "Robocode.BattleRecord", "Robocode Battle Record", - "-replay")); - - out.close(); - out = null; - - Process p = Runtime.getRuntime().exec(getWindowsCmd() + file.getAbsolutePath(), null, null); - int rv; - - try { - rv = p.waitFor(); - if (rv != 0) { - System.err.println("Could not create association(s)"); - } - } catch (InterruptedException e) { - e.printStackTrace(); - } - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (out != null) { - out.close(); - } - if (file != null) { - if (!file.delete()) { - System.err.println("Could not delete the file: " + file); - } - } - } - } - - private static String createWindowsRegistryFileAssociation(String installDir, String fileExt, String progId, String description, String robocodeCmdParam) { - StringBuffer sb = new StringBuffer(); - - final String HKCR = "[HKEY_CLASSES_ROOT\\"; - - sb.append("REGEDIT4\n"); - sb.append(HKCR).append(fileExt).append("]\n"); - sb.append("@=\"").append(progId).append("\"\n"); - sb.append(HKCR).append(progId).append("]\n"); - sb.append("@=\"").append(description).append("\"\n"); - sb.append(HKCR).append(progId).append("\\shell]\n"); - sb.append(HKCR).append(progId).append("\\shell\\open]\n"); - sb.append(HKCR).append(progId).append("\\shell\\open\\command]\n"); - sb.append("@=\"").append(getWindowsCmd()).append("\\\"cd \\\"").append(installDir.replaceAll("[\\\\]", "\\\\\\\\")).append("\\\" && robocode.bat ").append(robocodeCmdParam).append( - " \\\"%1\\\"\\\"\"\n"); - - return sb.toString(); - } - - private static String escaped(String s) { - StringBuffer eascaped = new StringBuffer(); - - for (int i = 0; i < s.length(); i++) { - if (s.charAt(i) == '\\') { - eascaped.append('\\'); - } - eascaped.append(s.charAt(i)); - } - return eascaped.toString(); - } - - private static boolean isWindowsOS() { - return osName.startsWith("Windows "); - } - - private static boolean isMacOSX() { - return osName.startsWith("Mac OS X"); - } - - private static boolean isFreeBSD() { - return osName.equals("FreeBSD"); - } - - private static String getWindowsCmd() { - String os = System.getProperty("os.name"); - - return ((os.equals("Windows 95") || os.equals("Windows 95") || os.equals("Windows ME")) - ? "command.com" - : "cmd.exe") - + " /C "; - } - - /** - * Deletes a file and afterwards deletes the parent directories that are empty. - * - * @param file the file or directory to delete - * @return true if success - */ - private static boolean deleteFileAndParentDirsIfEmpty(final File file) { - boolean wasDeleted = false; - - if (file != null && file.exists()) { - if (file.isDirectory()) { - wasDeleted = deleteDir(file); - } else { - wasDeleted = file.delete(); - - File parent = file; - - while (wasDeleted && (parent = parent.getParentFile()) != null) { - // Delete parent directory, but only if it is empty - File[] files = parent.listFiles(); - - if (files != null && files.length == 0) { - wasDeleted = deleteDir(parent); - } else { - wasDeleted = false; - } - } - } - } - return wasDeleted; - } -} diff --git a/workspace_robo/robocode.ipr b/workspace_robo/robocode.ipr deleted file mode 100644 index a27683a..0000000 --- a/workspace_robo/robocode.ipr +++ /dev/null @@ -1,122 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.iws b/workspace_robo/robocode.iws deleted file mode 100644 index 03c854e..0000000 --- a/workspace_robo/robocode.iws +++ /dev/null @@ -1,418 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.repository/.classpath b/workspace_robo/robocode.repository/.classpath deleted file mode 100644 index ea90720..0000000 --- a/workspace_robo/robocode.repository/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.repository/.project b/workspace_robo/robocode.repository/.project deleted file mode 100644 index 3ea6809..0000000 --- a/workspace_robo/robocode.repository/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - robocode.repository - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.api - robocode.core - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.repository/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.repository/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.repository/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.repository/pom.xml b/workspace_robo/robocode.repository/pom.xml deleted file mode 100644 index 57259bb..0000000 --- a/workspace_robo/robocode.repository/pom.xml +++ /dev/null @@ -1,29 +0,0 @@ - - - 4.0.0 - robocode.repository - Robocode Repository - - net.sf.robocode - robocode - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - net.sf.robocode - robocode.core - ${project.version} - - - net.sf.robocode - codesize - 1.1 - - - diff --git a/workspace_robo/robocode.repository/robocode.repository.iml b/workspace_robo/robocode.repository/robocode.repository.iml deleted file mode 100644 index 6b1701e..0000000 --- a/workspace_robo/robocode.repository/robocode.repository.iml +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/IRepository.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/IRepository.java deleted file mode 100644 index d8401b3..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/IRepository.java +++ /dev/null @@ -1,105 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Map; - -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.root.IRepositoryRoot; - - -/** - * Interface for a repository containing meta-data for robot and team items.

- * - * Items can be retrieved from the reposition by using {@link IRepository#getItem(String)} using "friendly URLs" - * that identifies the individual item. See {@link IRepositoryItem#getFriendlyURLs()}. An item has typically several - * friendly URLs that identifies it, e.g. a file URL to a local property file or class file, or a URL to a JAR entry. - * - * @author Flemming N. Larsen (original) - */ -public interface IRepository { - - /** - * Loads data into this repository, previously saved by {@link #save(OutputStream)}. - * - * @param in is an input stream used for reading the data. - * - * @see #save(OutputStream) - */ - public void load(InputStream in); - - /** - * Saves the data in this repository to an output stream. - * - * @param out is the output stream used for writing the data. - * - * @see #load(InputStream) - */ - public void save(OutputStream out); - - /** - * Adds or updates an item.

- * - * If the item is not present in the repository, it will be added; otherwise it will be updated, if the specified - * item has a never version than the existing item in the repository.

- * - * This method will store the item under each friendly URL (keys) by using {@link IRepositoryItem#getFriendlyURLs()}. - * - * @param item is the item to add or update. - * - * @see #getItem(String) - * @see #getItems() - */ - void addOrUpdateItem(IRepositoryItem item); - - /** - * Returns an item stored in this repository identified by a friendly URL (key). - * - * @param friendlyUrl is a key to the item used when the item was stored using {@link IRepositoryItem#getFriendlyURLs()}. - * @return an item from the repository identified by the friendly URL or null if the item does not exist. - * - * @see #addOrUpdateItem(IRepositoryItem) - * @see #getItems() - */ - IRepositoryItem getItem(String friendlyUrl); - - /** - * Returns all items stored in this repository. - * @return a map containing items, where the keys are friendly URLs used for identifying the items. - * - * @see #getItem(String) - */ - Map getItems(); - - /** - * Returns all repository roots stored in this repository.

- * - * @return a map containing repository roots, where the keys are URLs used for identifying the individual - * repository root. - * - * @see IRepositoryRoot - */ - Map getRoots(); - - /** - * Removes a repository root from this repository. - * - * @param url is the URL (key) of the repository root to remove. - */ - void removeRoot(String url); - - /** - * Removes all items from this repository that belongs to a specific repository root. - * - * @param root is the repository root containing the items to remove. - */ - void removeItemsFromRoot(IRepositoryRoot root); -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/Module.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/Module.java deleted file mode 100644 index 47d1834..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/Module.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import net.sf.robocode.core.BaseModule; -import net.sf.robocode.core.Container; -import net.sf.robocode.repository.items.handlers.ClassHandler; -import net.sf.robocode.repository.items.handlers.PropertiesHandler; -import net.sf.robocode.repository.items.handlers.SourceHandler; -import net.sf.robocode.repository.items.handlers.TeamHandler; -import net.sf.robocode.repository.root.handlers.ClassPathHandler; -import net.sf.robocode.repository.root.handlers.JarHandler; - - -/** - * @author Pavel Savara (original) - */ -public class Module extends BaseModule { - static { - Container.cache.addComponent(IRepositoryManager.class, RepositoryManager.class); - - // file handlers - Container.cache.addComponent("TeamHandler", TeamHandler.class); - Container.cache.addComponent("PropertiesHandler", PropertiesHandler.class); - Container.cache.addComponent("ClassHandler", ClassHandler.class); - Container.cache.addComponent("SourceHandler", SourceHandler.class); - - // root handlers - Container.cache.addComponent("JarHandler", JarHandler.class); - Container.cache.addComponent("ClassPathHandler", ClassPathHandler.class); - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/Repository.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/Repository.java deleted file mode 100644 index cfe3bf1..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/Repository.java +++ /dev/null @@ -1,199 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.root.BaseRoot; -import net.sf.robocode.repository.root.IRepositoryRoot; - -import java.io.IOException; -import java.io.InputStream; -import java.io.ObjectInputStream; -import java.io.ObjectOutputStream; -import java.io.OutputStream; -import java.net.URLDecoder; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashSet; -import java.util.Map; -import java.util.Set; -import java.util.concurrent.ConcurrentHashMap; - - -/** - * Repository containing robot and team repositoryItems. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -class Repository implements IRepository { - - private Map roots = new ConcurrentHashMap(); - private Map repositoryItems = new ConcurrentHashMap(); - private Map removedItems = new ConcurrentHashMap(); - - /** - * {@inheritDoc} - */ - public void save(OutputStream out) { - Set uniqueItems = new HashSet(); - Set uniqueRoots = new HashSet(); - - for (IRepositoryItem repositoryItem : repositoryItems.values()) { - uniqueItems.add(repositoryItem); - } - - for (IRepositoryRoot root : roots.values()) { - uniqueRoots.add(root); - } - - ObjectOutputStream oos = null; - try { - oos = new ObjectOutputStream(out); - oos.writeObject(uniqueRoots); - oos.writeObject(uniqueItems); - } catch (IOException e) { - Logger.logError("Can't save robot database", e); - } finally { - FileUtil.cleanupStream(oos); - } - } - - /** - * {@inheritDoc} - */ - @SuppressWarnings("unchecked") - public void load(InputStream in) { - Set uniqueItems; - Set uniqueRoots; - - ObjectInputStream ois = null; - try { - ois = new ObjectInputStream(in); - - uniqueRoots = (Set) ois.readObject(); - uniqueItems = (Set) ois.readObject(); - - for (IRepositoryRoot root : uniqueRoots) { - ((BaseRoot) root).setRepository(this); - - String key = root.getURL().toString(); - key = URLDecoder.decode(key, "UTF-8"); - - roots.put(key, root); - } - for (IRepositoryItem repositoryItem : uniqueItems) { - addOrUpdateItem(repositoryItem); - } - } catch (IOException e) { - Logger.logError("Can't load robot database: " + e.getMessage()); - } catch (ClassNotFoundException e) { - Logger.logError("Can't load robot database: " + e.getMessage()); - } finally { - FileUtil.cleanupStream(ois); - } - } - - /** - * {@inheritDoc} - */ - public void addOrUpdateItem(IRepositoryItem repositoryItem) { - Collection friendlyUrls = repositoryItem.getFriendlyURLs(); - if (friendlyUrls != null) { - // Add or update the item so it can be found using later using any friendly URL - for (String friendly : friendlyUrls) { - if (friendly != null) { - IRepositoryItem existingItem = repositoryItems.get(friendly); - // Add the item if it does not exist already, or update it if the version is newer - // than the existing item. - if (existingItem == null || repositoryItem.compareTo(existingItem) > 0) { - repositoryItems.put(friendly, repositoryItem); - } - } - } - } - } - - /** - * {@inheritDoc} - */ - public IRepositoryItem getItem(String friendlyUrl) { - IRepositoryItem repositoryItem = repositoryItems.get(friendlyUrl); - if (repositoryItem == null) { - repositoryItem = removedItems.get(friendlyUrl); - } - return repositoryItem; - } - - /** - * {@inheritDoc} - */ - public Map getItems() { - return Collections.unmodifiableMap(repositoryItems); - } - - /** - * {@inheritDoc} - */ - public Map getRoots() { - return Collections.unmodifiableMap(roots); - } - - /** - * {@inheritDoc} - */ - public void removeRoot(String friendlyUrl) { - roots.remove(friendlyUrl); - } - - /** - * {@inheritDoc} - */ - public void removeItemsFromRoot(IRepositoryRoot root) { - Collection> itemsToRemove = new ArrayList>(); - - for (Map.Entry entry : repositoryItems.entrySet()) { - if (entry.getValue().getRoot().equals(root)) { - itemsToRemove.add(entry); - } - } - - for (Map.Entry entry : itemsToRemove) { - String key = entry.getKey(); - - removedItems.put(key, entry.getValue()); - repositoryItems.remove(key); - } - } - - /** - * Replaces the repository roots with new repository roots. - * - * @param newRoots is the new repository roots for this repository. - */ - // Only for the RepositoryManager - public void setRoots(Map newRoots) { - - // Remove all items from current roots - for (IRepositoryRoot root : roots.values()) { - if (!newRoots.containsKey(root.getURL().toString())) { - removeItemsFromRoot(root); - } - } - - // Set the new roots - roots = newRoots; - - // Clear items to be removed - removedItems.clear(); - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/RepositoryManager.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/RepositoryManager.java deleted file mode 100644 index a97ad9b..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/RepositoryManager.java +++ /dev/null @@ -1,480 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.URLJarCollector; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.items.RobotItem; -import net.sf.robocode.repository.items.TeamItem; -import net.sf.robocode.repository.items.RepositoryItem; -import net.sf.robocode.repository.packager.JarCreator; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.repository.root.handlers.RootHandler; -import net.sf.robocode.security.HiddenAccess; -import net.sf.robocode.settings.ISettingsListener; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.ui.IWindowManager; -import robocode.control.RobotSpecification; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Collection; -import java.util.Collections; -import java.util.HashMap; -import java.util.List; -import java.util.Map; -import java.util.StringTokenizer; - - -/** - * @author Pavel Savara (original) - */ -public class RepositoryManager implements IRepositoryManager { // NO_UCD (use default) - - private static final String DATABASE_FILENAME = "robot.database"; - - private final ISettingsManager properties; - private Repository repository; - - public RepositoryManager(ISettingsManager properties) { // NO_UCD (unused code) - this.properties = properties; - properties.addPropertyListener(new SettingsListener()); - } - - // ------------------------------------------ - // interfaces - // ------------------------------------------ - - @Override - public File getRobotsDirectory() { - return FileUtil.getRobotsDir(); - } - - @Override - public List getDevelDirectories() { - List develDirectories = new ArrayList(); - - for (String path : properties.getOptionsEnabledDevelopmentPaths()) { - try { - develDirectories.add(new File(path).getCanonicalFile()); - } catch (IOException e) { - Logger.logError(e); - } - } - return develDirectories; - } - - public void refresh(String friendlyUrl) { - if (!updateItemRoot(friendlyUrl, true)) { - refresh(true); - } - URLJarCollector.gc(); - } - - public boolean refresh() { - return refresh(false); - } - - public boolean refresh(boolean force) { - boolean refreshed = update(getRobotsDirectory(), getDevelDirectories(), force); - if (refreshed) { - setStatus("Saving robot database"); - save(); - } - - setStatus(""); - URLJarCollector.gc(); - - return refreshed; - } - - private boolean update(File robotsDir, Collection devDirs, boolean force) { - final int prev = repository.getItems().size(); - - RootHandler.openHandlers(); - try { - Map newRoots = new HashMap(); - - RootHandler.visitDirectories(robotsDir, false, newRoots, repository, force); - for (File dir : devDirs) { - RootHandler.visitDirectories(dir, true, newRoots, repository, force); - } - repository.setRoots(newRoots); - } finally { - RootHandler.closeHandlers(); - } - - return prev != repository.getItems().size(); - } - - private boolean updateItemRoot(String friendlyUrl, boolean force) { - IRepositoryItem repositoryItem = repository.getItems().get(friendlyUrl); - if (repositoryItem != null) { - repositoryItem.getRoot().updateItem(repositoryItem, force); - return true; - } - return false; - } - - private void save() { - FileOutputStream fos = null; - try { - fos = new FileOutputStream(new File(getRobotsDirectory(), DATABASE_FILENAME)); - repository.save(fos); - } catch (IOException e) { - Logger.logError("Can't save robot database", e); - } finally { - FileUtil.cleanupStream(fos); - } - } - - private Repository load() { - Repository repository = new Repository(); - - FileInputStream fis = null; - try { - File file = new File(getRobotsDirectory(), DATABASE_FILENAME); - if (file.exists()) { - fis = new FileInputStream(file); - repository.load(fis); - } - } catch (IOException e) { - Logger.logError("Can't load robot database", e); - repository = null; - } finally { - FileUtil.cleanupStream(fis); - } - return repository; - } - - public void reload(boolean rebuild) { - // Bug fix [2867326] - Lockup on start if too many bots in robots dir (cont'd). - URLJarCollector.enableGc(true); - URLJarCollector.gc(); - - if (rebuild) { - Logger.logMessage("Rebuilding robot database..."); - repository = new Repository(); - } else if (repository == null) { - setStatus("Reading robot database"); - repository = load(); - if (repository == null) { - setStatus("Building robot database"); - repository = new Repository(); - } - } - refresh(true); - setStatus(""); - } - - public RobotSpecification[] getSpecifications() { - checkDbExists(); - final Collection list = getAllValidItems(); - Collection res = new ArrayList(); - - for (IRobotSpecItem s : list) { - res.add(s.createRobotSpecification()); - } - return res.toArray(new RobotSpecification[res.size()]); - } - - /** - * Expand teams, validate robots - * @param selectedRobots, names of robots and teams, comma separated - * @return robots in teams - */ - public RobotSpecification[] loadSelectedRobots(RobotSpecification[] selectedRobots) { - checkDbExists(); - Collection battlingRobotsList = new ArrayList(); - int teamNum = 0; - - for (RobotSpecification spec: selectedRobots) { - IRobotSpecItem item = (IRobotSpecItem) HiddenAccess.getFileSpecification(spec); - - if (item == null) { - item = getRobot(spec.getNameAndVersion()); - } - loadItem(battlingRobotsList, spec, item, teamNum); - teamNum++; - } - return battlingRobotsList.toArray(new RobotSpecification[battlingRobotsList.size()]); - } - - /** - * Expand teams, validate robots - * @param selectedRobots, names of robots and teams, comma separated - * @return robots in teams - */ - public RobotSpecification[] loadSelectedRobots(String selectedRobots) { - checkDbExists(); - Collection battlingRobotsList = new ArrayList(); - final Collection list = getValidItems(selectedRobots); - int teamNum = 0; - - for (IRobotSpecItem item: list) { - loadItem(battlingRobotsList, null, item, teamNum); - teamNum++; - } - return battlingRobotsList.toArray(new RobotSpecification[battlingRobotsList.size()]); - } - - private boolean loadItem(Collection battlingRobotsList, RobotSpecification spec, IRobotSpecItem item, int teamNum) { - String teamId = String.format("%4d", teamNum); - - if (item != null) { - if (item.isTeam()) { - teamId = item.getFullClassNameWithVersion() + "[" + teamId + "]"; - final Collection members = getRobotItems((TeamItem) item); - - for (IRobotSpecItem member : members) { - final RobotItem robot = (RobotItem) member; - - boolean tested = false; - - for (RobotSpecification loaded : battlingRobotsList) { - if (HiddenAccess.getFileSpecification(loaded).equals(robot)) { - tested = true; - break; - } - } - - if (tested || robot.validate()) { - battlingRobotsList.add(robot.createRobotSpecification(null, teamId)); - } - } - } else { - final RobotItem robot = (RobotItem) item; - - if (robot.validate()) { - battlingRobotsList.add(robot.createRobotSpecification(spec, null)); - } else { - Logger.logError("Could not load robot: " + robot.getFullClassName()); - return false; - } - } - return true; - } - return false; - } - - public List getSelectedSpecifications(String selectedRobots) { - checkDbExists(); - return getValidItems(selectedRobots); - } - - private Collection getAllValidItems() { - final ArrayList res = new ArrayList(); - - for (IRepositoryItem repositoryItem : repository.getItems().values()) { - final IRobotSpecItem spec = (IRobotSpecItem) repositoryItem; - if (repositoryItem.isValid() && !res.contains(spec)) { - res.add(spec); - } - } - return res; - } - - private List getValidItems(String friendlyUrls) { - List result = new ArrayList(); - StringTokenizer tokenizer = new StringTokenizer(friendlyUrls, ","); - - while (tokenizer.hasMoreTokens()) { - String friendlyUrl = tokenizer.nextToken().trim(); - - IRepositoryItem repositoryItem = repository.getItem(friendlyUrl); - if (repositoryItem != null) { - if (repositoryItem.isValid()) { - result.add((IRobotSpecItem) repositoryItem); - } else { - Logger.logError("Can't load '" + friendlyUrl + "' because it is an invalid robot or team."); - } - } else { - Logger.logError("Can't find '" + friendlyUrl + '\''); - } - } - return result; - } - - public List getRepositoryItems(boolean onlyWithSource, boolean onlyWithPackage, boolean onlyRobots, boolean onlyDevelopment, boolean onlyNotDevelopment, boolean ignoreTeamRobots, boolean onlyInJar) { - checkDbExists(); - - final List res = new ArrayList(); - - for (IRepositoryItem repositoryItem : repository.getItems().values()) { - final IRobotSpecItem spec = (IRobotSpecItem) repositoryItem; - - if (!repositoryItem.isValid()) { - continue; - } - if (onlyWithSource && !spec.isSourceIncluded()) { - continue; - } - if (onlyWithPackage && spec.getFullPackage() == null) { - continue; - } - if (onlyInJar && !spec.isInJAR()) { - continue; - } - if (onlyRobots && !(repositoryItem instanceof RobotItem)) { - continue; - } - if (onlyDevelopment && !spec.isDevelopmentVersion()) { - continue; - } - if (onlyNotDevelopment && spec.isDevelopmentVersion()) { - continue; - } - if (res.contains(spec)) { - continue; - } - res.add(spec); - } - Collections.sort(res); - return res; - } - - public boolean verifyRobotName(String robotName, String shortClassName) { - return RobotItem.verifyRobotName(robotName, shortClassName, true); - } - - public int extractJar(IRobotSpecItem item) { - if (!item.isInJAR()) { - return -2; - } - ((RepositoryItem) item).getRoot().extractJAR(); - return 0; - } - - public void createTeam(File target, TeamProperties teamProps) throws IOException { - checkDbExists(); - - TeamItem.createOrUpdateTeam(target, teamProps); - refresh(target.toURI().toString()); - } - - public String createPackage(File jarFile, List selectedRobots, RobotProperties robotProps) { - checkDbExists(); - List robotItems = getAllRobotItems(selectedRobots); - TeamItem teamItem = getTeamItem(selectedRobots); - - String res = JarCreator.createPackage(jarFile, robotItems, teamItem, robotProps); - refresh(jarFile.toURI().toString()); - - return res; - } - - private Collection getRobotItems(TeamItem team) { - Collection result = new ArrayList(); - StringTokenizer teamTokenizer = new StringTokenizer(team.getMembers(), ","); - - while (teamTokenizer.hasMoreTokens()) { - String botNameAndVersion = teamTokenizer.nextToken(); - int versionIndex = botNameAndVersion.indexOf(' '); - String botPath = versionIndex < 0 ? botNameAndVersion : botNameAndVersion.substring(0, versionIndex); - - botPath = botPath.replace('.', '/').replaceAll("\\*", ""); - - // first load from same classPath - String teamBot = team.getRoot().getURL() + botPath; - IRepositoryItem res = repository.getItem(teamBot); - - if (res != null && res instanceof RobotItem) { - result.add((RobotItem) res); - continue; - } - - // try general search - res = repository.getItem(botNameAndVersion); - if (res != null && res instanceof RobotItem) { - result.add((RobotItem) res); - continue; - } - - // not found - Logger.logError("Can't find robot: " + botNameAndVersion); - } - return result; - } - - private List getAllRobotItems(Collection items) { - List result = new ArrayList(); - - for (IRobotSpecItem item : items) { - if (item.isTeam()) { - result.addAll(getRobotItems((TeamItem) item)); - } else { - result.add((RobotItem) item); - } - } - return result; - } - - private static TeamItem getTeamItem(Collection items) { - for (IRobotSpecItem item : items) { - if (item.isTeam()) { - return (TeamItem) item; - } - } - return null; - } - - private IRobotSpecItem getRobot(String fullClassNameWithVersion) { - final IRepositoryItem repositoryItem = repository.getItem(fullClassNameWithVersion); - - if (repositoryItem == null || !repositoryItem.isValid()) { - return null; - } - return (IRobotSpecItem) repositoryItem; - } - - private void setStatus(String message) { - IWindowManager windowManager = Container.getComponent(IWindowManager.class); - - if (windowManager != null) { - windowManager.setStatus(message); - } - if (message.length() > 0) { - Logger.logMessage(message); - } - } - - private void checkDbExists() { - if (repository == null) { - reload(false); - } - } - - // ------------------------------------------ - // settings listener - // ------------------------------------------ - - private class SettingsListener implements ISettingsListener { - - private Collection lastEnabledDevelPaths; - - public void settingChanged(String property) { - if (property.equals(ISettingsManager.OPTIONS_DEVELOPMENT_PATH) - || property.equals(ISettingsManager.OPTIONS_DEVELOPMENT_PATH_EXCLUDED)) { - - Collection enabledDevelPaths = properties.getOptionsEnabledDevelopmentPaths(); - - if (lastEnabledDevelPaths == null || !enabledDevelPaths.equals(lastEnabledDevelPaths)) { - lastEnabledDevelPaths = enabledDevelPaths; - reload(true); - } - } - } - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/IRepositoryItem.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/IRepositoryItem.java deleted file mode 100644 index c83e9d1..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/IRepositoryItem.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.items; - - -import net.sf.robocode.repository.root.IRepositoryRoot; - -import java.net.URL; -import java.util.Set; - - -/** - * @author Pavel Savara (original) - */ -public interface IRepositoryItem extends Comparable { - URL getItemURL(); - IRepositoryRoot getRoot(); - Set getFriendlyURLs(); - - /** - * Updates the repository item if specified 'last modified' date is newer than the one recorded on this item, - * or if it is a forced update. - * - * @param lastModified is a 'last modified' date (millis since 1970). If this parameter is newer than the one - * previously set on this item, then this item will be updated. - * @param force is a flag specifying if this item is forced to be updated. - * If this parameter is true, then this item will be updated. - */ - void update(long lastModified, boolean force); - - long getLastModified(); - boolean isValid(); -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/RepositoryItem.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/RepositoryItem.java deleted file mode 100644 index d8e9592..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/RepositoryItem.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.items; - - -import net.sf.robocode.repository.root.IRepositoryRoot; - -import java.io.Serializable; -import java.net.URL; - - -/** - * @author Pavel Savara (original) - */ -public abstract class RepositoryItem implements IRepositoryItem, Serializable { - private static final long serialVersionUID = 1L; - - protected URL itemUrl; - protected IRepositoryRoot root; - protected long lastModified; - protected boolean isValid; - - RepositoryItem(URL itemURL, IRepositoryRoot root) { - this.itemUrl = itemURL; - this.root = root; - this.lastModified = 0; - } - - public URL getItemURL() { - return itemUrl; - } - - public IRepositoryRoot getRoot() { - return root; - } - - public boolean isInJAR() { - return root.isJAR(); - } - - public long getLastModified() { - return lastModified; - } - - public boolean isValid() { - return isValid; - } - - public void setValid(boolean valid) { - isValid = valid; - } - - @Override - public int hashCode() { - return 31 + ((itemUrl == null) ? 0 : itemUrl.hashCode()); - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null || !(obj instanceof RepositoryItem)) { - return false; - } - RepositoryItem other = (RepositoryItem) obj; - if (itemUrl == null && other.itemUrl != null) { - return false; - } - return itemUrl.equals(other.itemUrl); - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/RobotItem.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/RobotItem.java deleted file mode 100644 index d9b00a6..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/RobotItem.java +++ /dev/null @@ -1,608 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.items; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.RobocodeProperties; -import net.sf.robocode.io.URLJarCollector; -import static net.sf.robocode.io.Logger.logError; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.repository.RobotProperties; -import net.sf.robocode.repository.RobotType; -import net.sf.robocode.repository.root.ClasspathRoot; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.security.HiddenAccess; -import net.sf.robocode.core.Container; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.version.IVersionManager; -import robocode.control.RobotSpecification; - -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.HashSet; -import java.util.Set; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class RobotItem extends RobotSpecItem implements IRobotItem { - private static final long serialVersionUID = 1L; - - // Allowed maximum length for a robot's full package name - private static final int MAX_FULL_PACKAGE_NAME_LENGTH = 32; - // Allowed maximum length for a robot's short class name - private static final int MAX_SHORT_CLASS_NAME_LENGTH = 32; - - protected static final String ROBOT_PLATFORM = "robot.platform"; - private static final String ROBOT_CLASSNAME = "robot.classname"; - private static final String ROBOT_VERSION = "robot.version"; - private static final String ROBOT_DESCRIPTION = "robot.description"; - private static final String ROBOT_AUTHOR_NAME = "robot.author.name"; - private static final String ROBOT_WEBPAGE = "robot.webpage"; - private static final String ROBOCODE_VERSION = "robocode.version"; - private static final String ROBOT_INCLUDE_SOURCE = "robot.include.source"; - private static final String ROBOT_INCLUDE_DATA = "robot.include.data"; - private static final String ROBOT_CODESIZE = "robot.codesize"; - - // File extensions - private static final String CLASS_EXTENSION = ".class"; - private static final String PROPERTIES_EXTENSION = ".properties"; - private static final String HTML_EXTENSION = ".html"; - - private static final boolean ALWAYS_USE_CACHE_FOR_DATA = System.getProperty("ALWAYSUSECACHEFORDATA", "false").equals( - "true"); - - private RobotType robotType; - - private URL classPathURL; - private Set sourcePathURLs; // This is a Set in order to avoid duplicates - - private URL classURL; - private URL propertiesURL; - - private String className; - protected boolean isPropertiesLoaded; - - public RobotItem(URL itemURL, IRepositoryRoot root) { - super(itemURL, root); - - isValid = true; - - classPathURL = root.getURL(); - sourcePathURLs = new HashSet(); - } - - private void populate() { - populatePropertiesURLFromClassURL(); - populateClassURLFromPropertiesURL(); - loadProperties(); - } - - public void setClassURL(URL classUrl) { - this.classURL = classUrl; - populate(); - } - - public void setPropertiesURL(URL propertiesUrl) { - this.propertiesURL = propertiesUrl; - populate(); - } - - public void setClassPathURL(URL classPathUrl) { - this.classPathURL = classPathUrl; - } - - public void addSourcePathURL(URL sourcePathUrl) { - sourcePathURLs.add(sourcePathUrl); - } - - // ------------------------------------- - // URL initialization - // ------------------------------------- - - private void populatePropertiesURLFromClassURL() { - if (propertiesURL == null && classURL != null) { - final String path = classURL.toString().replaceFirst("\\" + CLASS_EXTENSION, PROPERTIES_EXTENSION); - - try { - propertiesURL = new URL(path); - } catch (MalformedURLException e) { - Logger.logError(e); - } - if (isInvalidURL(propertiesURL)) { - propertiesURL = null; - } - } - } - - private void populateClassURLFromPropertiesURL() { - if (classURL == null && propertiesURL != null) { - final String path = propertiesURL.toString().replaceAll("\\" + PROPERTIES_EXTENSION, CLASS_EXTENSION); - - try { - classURL = new URL(path); - } catch (MalformedURLException e) { - Logger.logError(e); - } - if (isInvalidURL(classURL)) { - classURL = null; - } - } - } - - private void populateClassNameFromClassURL() { - populate(); - - if (className == null && classURL != null) { - final String path = classURL.toString(); - - // .dll file? - int index = (path.toLowerCase().indexOf(".dll!/")); - - if (index > 0) { - className = path.substring(index + 6); - return; - } - - // Class within .jar or regular file path? - - index = path.lastIndexOf('!'); - - if (index > 0) { - // .jar file - className = path.substring(index + 2); - } else { - // file path - className = path.substring(root.getURL().toString().length()); - } - - // Remove the file extension from the class name - index = className.lastIndexOf('.'); - - if (index > 0) { - className = className.substring(0, index); - } - - // Replace all file separators with dots (from file path the package/namespace) - className = className.replaceAll("[\\\\\\/]", "."); - } - } - - private void populateHtmlURL() { - populate(); - - if (htmlURL == null && classURL != null) { - try { - htmlURL = new URL(classURL.toString().replaceFirst(CLASS_EXTENSION, HTML_EXTENSION)); - } catch (MalformedURLException ignore) {} - } - if (htmlURL == null && propertiesURL != null) { - try { - htmlURL = new URL(propertiesURL.toString().replaceFirst(PROPERTIES_EXTENSION, HTML_EXTENSION)); - } catch (MalformedURLException ignore) {} - } - if (isInvalidURL(htmlURL)) { - htmlURL = null; - } - } - - private boolean isInvalidURL(URL url) { - if (url != null) { - InputStream is = null; - try { - URLConnection conn = URLJarCollector.openConnection(url); - is = conn.getInputStream(); - return false; - } catch (IOException e) { - return true; - } finally { - FileUtil.cleanupStream(is); - } - } - return true; - } - - // / ------------------------------------- - // / public - // / ------------------------------------- - - public boolean isTeam() { - return false; - } - - public URL getHtmlURL() { - // Lazy - if (htmlURL == null) { - populateHtmlURL(); - } - return htmlURL; - } - - public URL getPropertiesURL() { - if (propertiesURL == null) { - populatePropertiesURLFromClassURL(); - } - return propertiesURL; - } - - public Set getFriendlyURLs() { - populate(); - - Set urls = new HashSet(); - - URL url = null; - if (classURL != null) { - url = classURL; - } else if (propertiesURL != null) { - url = propertiesURL; - } - if (url != null) { - String sUrl = url.toString(); - String urlNoType = sUrl.substring(0, sUrl.lastIndexOf('.')); - - String path = url.getPath(); - String pathNoType = path.substring(0, path.lastIndexOf('.')); - - urls.add(urlNoType); - urls.add(pathNoType); - } - if (getFullClassName() != null) { - if (RobocodeProperties.isTestingOn()) { - urls.add(getFullClassName()); - } else { - urls.add(getUniqueFullClassName()); - } - urls.add(getUniqueFullClassNameWithVersion()); - } - if (root.isJAR()) { - urls.add(root.getURL().toString()); - } - if (root instanceof ClasspathRoot) { - String friendly = ((ClasspathRoot) root).getFriendlyProjectURL(itemUrl); - - if (friendly != null) { - urls.add(friendly); - } - } - return urls; - } - - /** - * {@inheritDoc} - */ - public void update(long lastModified, boolean force) { - if (lastModified > this.lastModified || force) { - if (force) { - isValid = true; - } - - // trying to guess all correct file locations - populate(); - - this.lastModified = lastModified; - if (classURL == null) { - isValid = false; - } - loadProperties(); - if (root.isJAR() && !isPropertiesLoaded) { - isValid = false; - } - if (isValid) { - validateType(false); - } - if (isValid) { - verifyName(); - } - } - } - - protected void validateType(boolean resolve) { - populate(); - - final IHostManager hostManager = Container.getComponent(IHostManager.class); - - robotType = hostManager.getRobotType(this, resolve, classURL != null); - if (!robotType.isValid()) { - isValid = false; - } - } - - // Stronger than update - public boolean validate() { - validateType(true); - return isValid; - } - - // Note that ROBOCODE_CLASSNAME can be invalid, an hence can't be trusted when loaded! - // Hence, we read the fullClassName field instead and NOT the ROBOCODE_CLASSNAME property. - private boolean loadProperties() { - if (!isPropertiesLoaded && propertiesURL != null) { - InputStream ios = null; - try { - URLConnection con = URLJarCollector.openConnection(propertiesURL); - - ios = con.getInputStream(); - properties.load(ios); - isPropertiesLoaded = true; - return true; - } catch (IOException e) { - return false; - } finally { - FileUtil.cleanupStream(ios); - } - } - return false; - } - - private boolean verifyName() { - String robotName = getFullClassName(); - String shortClassName = getShortClassName(); - - final boolean valid = verifyRobotName(robotName, shortClassName, false); - - if (!valid) { - isValid = false; - } - return valid; - } - - public static boolean verifyRobotName(String fullClassName, String shortClassName, boolean silent) { - if (fullClassName == null || fullClassName.length() == 0 || fullClassName.contains("$")) { - return false; - } - - int lIndex = fullClassName.indexOf("."); - if (lIndex > 0) { - String rootPackage = fullClassName.substring(0, lIndex); - - if (rootPackage.equalsIgnoreCase("robocode")) { - if (!silent) { - logError("Robot " + fullClassName + " ignored. You cannot use package " + rootPackage); - } - return false; - } - if (rootPackage.length() > MAX_FULL_PACKAGE_NAME_LENGTH) { - if (!silent) { - logError( - "Robot " + fullClassName + " has package name too long. " + MAX_FULL_PACKAGE_NAME_LENGTH - + " characters maximum please."); - } - return false; - } - } - if (shortClassName != null && shortClassName.length() > MAX_SHORT_CLASS_NAME_LENGTH) { - if (!silent) { - logError( - "Robot " + fullClassName + " has classname too long. " + MAX_SHORT_CLASS_NAME_LENGTH - + " characters maximum please."); - } - return false; - } - return true; - } - - public void storeProperties(OutputStream os, RobotProperties robotProps) throws IOException { - if (className != null) { - properties.setProperty(ROBOT_CLASSNAME, className); - } - if (robotProps.getVersion() != null) { - properties.setProperty(ROBOT_VERSION, robotProps.getVersion()); - } - if (robotProps.getDescription() != null) { - properties.setProperty(ROBOT_DESCRIPTION, robotProps.getDescription()); - } - if (robotProps.getAuthor() != null) { - properties.setProperty(ROBOT_AUTHOR_NAME, robotProps.getAuthor()); - } - if (robotProps.getWebPage() != null) { - properties.setProperty(ROBOT_WEBPAGE, robotProps.getWebPage().toExternalForm()); - } - if (robotProps.getCodeSize() != null) { - properties.setProperty(ROBOT_CODESIZE, "" + robotProps.getCodeSize()); - } - properties.setProperty(ROBOT_INCLUDE_SOURCE, "" + robotProps.isIncludeSource()); - - String version = Container.getComponent(IVersionManager.class).getVersion(); - properties.setProperty(ROBOCODE_VERSION, version); - - saveProperties(os); - - saveProperties(); - } - - private void saveProperties(OutputStream os) throws IOException { - properties.store(os, "Robocode Robot"); - } - - private void saveProperties() { - File file = new File(root.getPath(), className.replaceAll("\\.", "/") + PROPERTIES_EXTENSION); - FileOutputStream fos = null; - - try { - fos = new FileOutputStream(file); - saveProperties(fos); - } catch (IOException e) { - e.printStackTrace(); - } finally { - FileUtil.cleanupStream(fos); - } - populatePropertiesURLFromClassURL(); - } - - public boolean isJuniorRobot() { - return robotType.isJuniorRobot(); - } - - public boolean isStandardRobot() { - return robotType.isStandardRobot(); - } - - public boolean isAdvancedRobot() { - return robotType.isAdvancedRobot(); - } - - public boolean isTeamRobot() { - return robotType.isTeamRobot(); - } - - public boolean isDroid() { - return robotType.isDroid(); - } - - public boolean isSentryRobot() { - return robotType.isSentryRobot(); - } - - public boolean isInteractiveRobot() { - return robotType.isInteractiveRobot(); - } - - public boolean isPaintRobot() { - return robotType.isPaintRobot(); - } - - public URL getClassPathURL() { - return classPathURL; - } - - public URL[] getSourcePathURLs() { - // If no source path URL exists, we must use the class path URL - if (sourcePathURLs.size() == 0) { - return new URL[] { classPathURL }; - } - return sourcePathURLs.toArray(new URL[] {}); - } - - public String getFullClassName() { - // Lazy - if (className == null) { - populateClassNameFromClassURL(); - } - return className; - } - - public String getVersion() { - return properties.getProperty(ROBOT_VERSION, null); - } - - public String getDescription() { - return properties.getProperty(ROBOT_DESCRIPTION, null); - } - - public String getAuthorName() { - return properties.getProperty(ROBOT_AUTHOR_NAME, null); - } - - public String getPlatform() { - return properties.getProperty(ROBOT_PLATFORM, "Java"); - } - - public URL getWebpage() { - try { - String webPage = properties.getProperty(ROBOT_WEBPAGE, null); - if (webPage == null || webPage.trim().isEmpty()) { - return null; - } - return new URL(webPage); - } catch (MalformedURLException e) { - return null; - } - } - - public Integer getCodeSize() { - String value = properties.getProperty(ROBOT_CODESIZE); - if (value == null) { - return null; - } - try { - return Integer.parseInt(value); - } catch (NumberFormatException e) { - return null; - } - } - - public boolean getIncludeSource() { - return properties.getProperty(ROBOT_INCLUDE_SOURCE, "true").equalsIgnoreCase("true"); - } - - public boolean getIncludeData() { - return properties.getProperty(ROBOT_INCLUDE_DATA, "true").equalsIgnoreCase("true"); - } - - public boolean isSourceIncluded() { - return sourcePathURLs.size() > 0; - } - - public String getRobocodeVersion() { - return properties.getProperty(ROBOCODE_VERSION, null); - } - - public String getReadableDirectory() { - String path; - if (root.isJAR()) { - String jarFile = getClassPathURL().getFile(); - jarFile = jarFile.substring(jarFile.lastIndexOf('/') + 1, jarFile.length()); - path = FileUtil.getRobotsDataDir().getPath(); - if (jarFile.length() > 0) { - path += File.separator + jarFile + '_'; - } - } else { - path = getClassPathURL().getFile(); - } - if (getFullPackage() != null) { - path += File.separator + getFullPackage().replace('.', File.separatorChar); - } - return path; - } - - public String getWritableDirectory() { - String path; - if (root.isJAR()) { - String jarFile = getClassPathURL().getFile(); - jarFile = jarFile.substring(jarFile.lastIndexOf('/') + 1, jarFile.length()); - path = FileUtil.getRobotsDataDir().getPath(); - if (jarFile.length() > 0) { - path += File.separator + jarFile + '_'; - } - } else { - path = ALWAYS_USE_CACHE_FOR_DATA ? FileUtil.getRobotsDataDir().getPath() : getClassPathURL().getFile(); - } - if (getFullPackage() != null) { - path += File.separator + getFullPackage().replace('.', File.separatorChar); - } - return path; - } - - public RobotSpecification createRobotSpecification(RobotSpecification battleRobotSpec, String teamId) { - RobotSpecification specification; - - if (battleRobotSpec != null) { - specification = battleRobotSpec; - } else { - specification = createRobotSpecification(); - } - if (teamId != null) { - HiddenAccess.setTeamId(specification, teamId); - } - return specification; - } - - public String toString() { - return itemUrl.toString(); - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/RobotSpecItem.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/RobotSpecItem.java deleted file mode 100644 index 953d63d..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/RobotSpecItem.java +++ /dev/null @@ -1,259 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.items; - - -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.security.HiddenAccess; -import net.sf.robocode.util.AlphanumericComparator; -import robocode.control.RobotSpecification; - -import java.net.URL; -import java.util.Properties; -import java.util.StringTokenizer; - - -/** - * @author Pavel Savara (original) - */ -public abstract class RobotSpecItem extends RepositoryItem implements IRobotSpecItem { - private static final long serialVersionUID = 1L; - - protected Properties properties = new Properties(); - protected URL htmlURL; - - RobotSpecItem(URL itemURL, IRepositoryRoot root) { - super(itemURL, root); - } - - public abstract URL getPropertiesURL(); - - public abstract String getFullClassName(); - - public abstract String getVersion(); - - public abstract URL getWebpage(); - - public abstract String getAuthorName(); - - public abstract String getRobocodeVersion(); - - public abstract String getDescription(); - - public abstract URL getHtmlURL(); - - public boolean isDevelopmentVersion() { - return root.isDevelopmentRoot() - && !(getFullClassName().startsWith("sample") || getFullClassName().startsWith("tested.")); - } - - public String getRootPath() { - return root.getURL().toString(); - } - - public String getRootPackage() { - int lIndex = getFullClassName().indexOf("."); - String rootPackage = null; - - if (lIndex > 0) { - rootPackage = getFullClassName().substring(0, lIndex); - } - return rootPackage; - } - - public String getFullPackage() { - if (getFullClassName() == null) { - return null; - } - final int index = getFullClassName().lastIndexOf('.'); - - return (index >= 0) ? getFullClassName().substring(0, index) : null; - } - - // same as package but with slash - public String getRelativePath() { - final int index = getFullClassName().lastIndexOf('.'); - - return (index < 0) ? "" : getFullClassName().substring(0, index).replaceAll("\\.", "/"); - } - - public String getShortClassName() { - if (getFullClassName() == null) { - return null; - } - final int index = getFullClassName().lastIndexOf('.'); - - if (index == -1) { - return getFullClassName(); - } - return getFullClassName().substring(index + 1); - } - - public String getFullClassNameWithVersion() { - String fullClassName = getFullClassName(); - - if (getVersion() != null) { - fullClassName += " " + getVersion(); - } - return fullClassName; - } - - public String getUniqueFullClassName() { - String uniqueFullClassName = getFullClassName(); - - if (isDevelopmentVersion()) { - uniqueFullClassName += '*'; - } - return uniqueFullClassName; - } - - public String getUniqueFullClassNameWithVersion() { - String uniqueFullClassName = (getVersion() == null) ? getFullClassName() : getFullClassNameWithVersion(); - - if (isDevelopmentVersion()) { - uniqueFullClassName += '*'; - } - return uniqueFullClassName; - } - - public String getUniqueShortClassNameWithVersion() { - String uniqueShortClassName = (getVersion() == null) ? getShortClassName() : getShortClassNameWithVersion(); - - if (isDevelopmentVersion()) { - uniqueShortClassName += '*'; - } - return uniqueShortClassName; - } - - public String getUniqueVeryShortClassNameWithVersion() { - String veryShortClassName = (getVersion() == null) - ? getVeryShortClassName() - : getVeryShortClassNameWithVersion(); - - if (isDevelopmentVersion()) { - veryShortClassName += '*'; - } - return veryShortClassName; - } - - public String getShortClassNameWithVersion() { - String shortClassName = getShortClassName(); - - if (getVersion() != null) { - shortClassName += " " + getVersion(); - } - return shortClassName; - } - - public String getVeryShortClassNameWithVersion() { - String veryShortClassName = getVeryShortClassName(); - - if (getVersion() != null) { - veryShortClassName += " " + getVersion(); - } - return veryShortClassName; - } - - public String getVeryShortClassName() { - String veryShortClassName = getShortClassName(); - - if (veryShortClassName.length() > 12) { - veryShortClassName = veryShortClassName.substring(0, 12) + "..."; - } - return veryShortClassName; - } - - public RobotSpecification createRobotSpecification() { - return HiddenAccess.createSpecification(this, getUniqueFullClassName(), getAuthorName(), - (getWebpage() != null) ? getWebpage().toString() : null, getVersion(), getRobocodeVersion(), - root.getURL().toString(), getFullClassName(), getDescription()); - } - - public int compareTo(Object other) { - if (other == this) { - return 0; - } - if (other instanceof IRobotSpecItem) { - IRobotSpecItem otherRI = (IRobotSpecItem) other; - - return compare(getFullPackage(), getFullClassName(), getVersion(), otherRI.getFullPackage(), - otherRI.getFullClassName(), otherRI.getVersion()); - } - - // for IgnoredItem - return 0; - } - - private static int compare(String p1, String c1, String v1, String p2, String c2, String v2) { - AlphanumericComparator alphaNumComparator = new AlphanumericComparator(); - - // Compare packages - int result = alphaNumComparator.compare(p1, p2); - - if (result != 0) { - return result; - } - - // Same package, so compare classes - result = alphaNumComparator.compare(c1, c2); - if (result != 0) { - return result; - } - - // Same robot, so compare versions - if (v1 == null && v2 == null) { - return 0; - } - if (v1 == null) { - return 1; - } - if (v2 == null) { - return -1; - } - - if (v1.equals(v2)) { - return 0; - } - - if (v1.indexOf(".") < 0 || v2.indexOf(".") < 0) { - return alphaNumComparator.compare(v1, v2); - } - - // Dot separated versions. - StringTokenizer s1 = new StringTokenizer(v1, "."); - StringTokenizer s2 = new StringTokenizer(v2, "."); - - while (s1.hasMoreTokens() && s2.hasMoreTokens()) { - String tok1 = s1.nextToken(); - String tok2 = s2.nextToken(); - - try { - int i1 = Integer.parseInt(tok1); - int i2 = Integer.parseInt(tok2); - - if (i1 != i2) { - return i1 - i2; - } - } catch (NumberFormatException e) { - int tc = alphaNumComparator.compare(tok1, tok2); - - if (tc != 0) { - return tc; - } - } - } - if (s1.hasMoreTokens()) { - return 1; - } - if (s2.hasMoreTokens()) { - return -1; - } - return 0; - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/TeamItem.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/TeamItem.java deleted file mode 100644 index 1f5b8fc..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/TeamItem.java +++ /dev/null @@ -1,258 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.items; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.RobocodeProperties; -import net.sf.robocode.io.URLJarCollector; -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.repository.RobotProperties; -import net.sf.robocode.repository.TeamProperties; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.core.Container; -import net.sf.robocode.version.IVersionManager; - -import java.io.*; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; - - -/** - * @author Pavel Savara (original) - */ -public class TeamItem extends RobotSpecItem implements IRobotSpecItem { - private static final long serialVersionUID = 1L; - - private static final String TEAM_DESCRIPTION = "team.description"; - private static final String TEAM_AUTHOR_NAME = "team.author.name"; - private static final String TEAM_VERSION = "team.version"; - private static final String TEAM_WEBPAGE = "team.webpage"; - private static final String TEAM_MEMBERS = "team.members"; - private static final String ROBOCODE_VERSION = "robocode.version"; - - private final String fullTeamName; - - public TeamItem(URL itemURL, IRepositoryRoot root) { - super(itemURL, root); - String tUrl = itemURL.toString(); - - tUrl = tUrl.substring(0, tUrl.lastIndexOf(".team")); - final int versionSeparator = tUrl.lastIndexOf(" "); - final int rootLen = root.getURL().toString().length(); - - if (versionSeparator != -1) { - fullTeamName = tUrl.substring(rootLen, versionSeparator).replace('/', '.').replace('\\', '.'); - } else { - fullTeamName = tUrl.substring(rootLen).replace('/', '.').replace('\\', '.'); - } - if (loadProperties()) { - isValid = true; - } - } - - private void htmlURLFromPropertiesURL() { - try { - htmlURL = new URL(itemUrl.toString().replaceAll("\\.team", ".html")); - - // test that html file exists - final URLConnection conn = URLJarCollector.openConnection(htmlURL); - - conn.getInputStream().close(); - } catch (IOException ignored) { - // doesn't exist - htmlURL = null; - } - } - - public Set getFriendlyURLs() { - Set urls = new HashSet(); - - if (itemUrl != null) { - String url = itemUrl.toString(); - String urlNoType = url.substring(0, url.lastIndexOf('.')); - - String path = itemUrl.getPath(); - String pathNoType = path.substring(0, path.lastIndexOf('.')); - - urls.add(urlNoType); - urls.add(pathNoType); - } - if (RobocodeProperties.isTestingOn()) { - urls.add(getFullClassName()); - } else { - urls.add(getUniqueFullClassName()); - } - urls.add(getUniqueFullClassNameWithVersion()); - - return urls; - } - - /** - * {@inheritDoc} - */ - public void update(long lastModified, boolean force) { - if (lastModified > this.lastModified || force) { - this.lastModified = lastModified; - loadProperties(); - } - } - - private boolean loadProperties() { - if (itemUrl != null) { - InputStream ios = null; - - try { - final URLConnection connection = URLJarCollector.openConnection(itemUrl); - - ios = connection.getInputStream(); - - properties.load(ios); - return true; - } catch (IOException e) { - Logger.logError(e); - } finally { - FileUtil.cleanupStream(ios); - } - } - return false; - } - - public URL getHtmlURL() { - // lazy - if (htmlURL == null) { - htmlURLFromPropertiesURL(); - } - return htmlURL; - } - - public URL getPropertiesURL() { - return itemUrl; - } - - public boolean isTeam() { - return true; - } - - public String getFullClassName() { - return fullTeamName; - } - - public String getMembers() { - return properties.getProperty(TEAM_MEMBERS, null); - } - - public String getVersion() { - return properties.getProperty(TEAM_VERSION, null); - } - - public String getDescription() { - return properties.getProperty(TEAM_DESCRIPTION, null); - } - - public String getAuthorName() { - return properties.getProperty(TEAM_AUTHOR_NAME, null); - } - - public URL getWebpage() { - try { - return new URL(properties.getProperty(TEAM_WEBPAGE, null)); - } catch (MalformedURLException e) { - return null; - } - } - - public boolean getIncludeSource() { - return false; - } - - public boolean getIncludeData() { - return false; - } - - public boolean isSourceIncluded() { - return false; - } - - public String getRobocodeVersion() { - return properties.getProperty(ROBOCODE_VERSION, null); - } - - public String toString() { - return itemUrl.toString(); - } - - public void storeProperties(OutputStream os, RobotProperties props) throws IOException { - if (props.getVersion() != null) { - properties.setProperty(TEAM_VERSION, props.getVersion()); - } - if (props.getDescription() != null) { - properties.setProperty(TEAM_DESCRIPTION, props.getDescription()); - } - if (props.getAuthor() != null) { - properties.setProperty(TEAM_AUTHOR_NAME, props.getAuthor()); - } - if (props.getWebPage() != null) { - properties.setProperty(TEAM_WEBPAGE, props.getWebPage().toExternalForm()); - } - properties.setProperty(ROBOCODE_VERSION, Container.getComponent(IVersionManager.class).getVersion()); - - properties.store(os, "Robocode Robot Team"); - } - - public static void createOrUpdateTeam(File target, TeamProperties props) throws IOException { - FileOutputStream os = null; - - try { - Properties team = loadTeamProperties(target); - - if (props.getMembers() != null) { - team.setProperty(TEAM_MEMBERS, props.getMembers()); - } - if (props.getAuthor() != null) { - team.setProperty(TEAM_AUTHOR_NAME, props.getAuthor()); - } - if (props.getDescription() != null) { - team.setProperty(TEAM_DESCRIPTION, props.getDescription()); - } - if (props.getWebPage() != null) { - team.setProperty(TEAM_WEBPAGE, props.getWebPage().toExternalForm()); - } - String version = Container.getComponent(IVersionManager.class).getVersion(); - team.setProperty(ROBOCODE_VERSION, version); - - os = new FileOutputStream(target); - team.store(os, "Robocode robot team"); - } finally { - FileUtil.cleanupStream(os); - } - } - - private static Properties loadTeamProperties(File target) { - Properties team = new Properties(); - - if (target.exists()) { - FileInputStream fis = null; - - try { - fis = new FileInputStream(target); - team.load(fis); - } catch (Exception e) { - Logger.logError(e); - } finally { - FileUtil.cleanupStream(fis); - } - } - return team; - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/ClassHandler.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/ClassHandler.java deleted file mode 100644 index d1389a0..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/ClassHandler.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.items.handlers; - - -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.items.RobotItem; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.util.UrlUtil; - -import java.net.URL; - - -/** - * Item handler for accepting and registering Java class files. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class ClassHandler extends ItemHandler { - - /** - * {@inheritDoc} - */ - @Override - protected IRepositoryItem acceptItem(URL itemURL, IRepositoryRoot root, IRepository repository) { - // Accept and register the item if it is a Java class file, but not an inner class file - String name = itemURL.toString().toLowerCase(); - if (name.endsWith(".class") && !name.contains("$")) { - return register(itemURL, root, repository); - } - return null; - } - - /** - * Registers the class file with the specified URL as a RobotItem. - * - * @param classFileUrl is the URL of the class file to register. - * @param root is the repository root containing the class file to register. - * @param repository is the repository, where the class file is automatically added or updated, - * when the class file is registered. - * @return a RobotItem that has been created or updated in the repository. - */ - private RobotItem register(URL classFileUrl, IRepositoryRoot root, IRepository repository) { - RobotItem item = null; - - // Check if the class file is already registered in the repository - String friendlyUrl = UrlUtil.removeFileExtension(classFileUrl.toString()); - - IRepositoryItem repositoryItem = repository.getItem(friendlyUrl); - if (repositoryItem instanceof RobotItem) { - item = (RobotItem) repositoryItem; - } - - // If the class file has not been registered then create a new RobotItem based on the class file URL - if (item == null) { - item = new RobotItem(classFileUrl, root); - } - - // Set the class path URL and class URL on the RobotItem - item.setClassPathURL(root.getURL()); - item.setClassURL(classFileUrl); - - // Add or update the item in the repository and return it - repository.addOrUpdateItem(item); - return item; - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/ItemHandler.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/ItemHandler.java deleted file mode 100644 index 8567bff..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/ItemHandler.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.items.handlers; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.root.IRepositoryRoot; - -import java.net.URL; -import java.util.List; - - -/** - * Abstract item handler used for accepting and registering specific item types. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public abstract class ItemHandler { - - /** - * Tests whether or not the item with at the specified item URL is accepted and can be handled by this item handler. - * - * @param itemUrl is the URL of the item to test. - * @param root is the repository root containing the item to test. - * @param repository is the repository, where the item is automatically added or updated, if the item is accepted. - * @return a repository item that has been created or updated in the repository or null if the item was not - * accepted by this item handler. - */ - protected abstract IRepositoryItem acceptItem(URL itemUrl, IRepositoryRoot root, IRepository repository); - - /** - * Tests whether or not the item with at the specified item URL is accepted and can be handled by any - * available item handler. - * - * @param itemUrl is the URL of the item to test. - * @param root is the repository root containing the item to test. - * @param repository is the repository, where the item is automatically added or updated, if the item is accepted. - * @return a repository item that has been created or updated in the repository or null if the item was not - * accepted by an item handler. - */ - public final static IRepositoryItem registerItem(URL itemUrl, IRepositoryRoot root, IRepository repository) { - // Test if any available item handler will accept and register the item - List itemHandlers = Container.getComponents(ItemHandler.class); - for (ItemHandler handler : itemHandlers) { - IRepositoryItem repositoryItem = handler.acceptItem(itemUrl, root, repository); - if (repositoryItem != null) { - return repositoryItem; - } - } - return null; - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/PropertiesHandler.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/PropertiesHandler.java deleted file mode 100644 index f7d168b..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/PropertiesHandler.java +++ /dev/null @@ -1,104 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.items.handlers; - - -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.items.RobotItem; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.util.UrlUtil; -import net.sf.robocode.core.Container; - -import java.net.URL; - - -/** - * Handler for accepting and registering Java properties files. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class PropertiesHandler extends ItemHandler { - - /** - * {@inheritDoc} - */ - @Override - protected IRepositoryItem acceptItem(URL itemURL, IRepositoryRoot root, IRepository repository) { - // Accept and register the item if it is a Java properties file - String name = itemURL.toString().toLowerCase(); - if (name.endsWith(".properties")) { - return register(itemURL, root, repository); - } - return null; - } - - /** - * Registers the properties file with the specified URL as a RobotItem. - * - * @param propertiesFileUrl is the URL of the properties file to register. - * @param root is the repository root containing the properties file to register. - * @param repository is the repository, where the properties file is automatically added or updated, - * when the properties file is registered. - * @return a RobotItem that has been created or updated in the repository. - */ - private RobotItem register(URL propertiesFileUrl, IRepositoryRoot root, IRepository repository) { - RobotItem item = null; - - // Check if the properties file is already registered in the repository - String friendlyUrl = UrlUtil.removeFileExtension(propertiesFileUrl.toString()); - - IRepositoryItem repositoryItem = repository.getItem(friendlyUrl); - if (repositoryItem instanceof RobotItem) { - item = (RobotItem) repositoryItem; - } - - // If the properties file has not been registered then create a new RobotItem based on the properties file URL - if (item == null) { - item = createRobotItem(propertiesFileUrl, root, repository); - } - - // Add or update the item in the repository and return it - if (item != null) { - repository.addOrUpdateItem(item); - } - return item; - } - - /** - * Creates a new RobotItem based on the properties file URL. - * This method will dispatch creating and registering the properties file to another handler, - * if the platform is not Java. - * - * @param propertiesFileUrl is the URL of the properties file. - * @param root is the repository root containing the properties file to create the RobotItem from. - * @param repository is the repository, where the properties file is automatically added or updated, - * when the properties file is registered. - * @return a new RobotItem that has been created or null if the RobotItem could not be created. - */ - private RobotItem createRobotItem(URL propertiesFileUrl, IRepositoryRoot root, IRepository repository) { - // Create a RobotItem based on the properties file URL - RobotItem item = new RobotItem(propertiesFileUrl, root); - - // Check if the robot is for the Java platform - String platform = item.getPlatform(); - if (platform.equalsIgnoreCase("Java")) { - // Java platform -> set the properties URL on the RobotItem - item.setPropertiesURL(propertiesFileUrl); - } else { - // Another platform -> Look for another properties handler - PropertiesHandler otherHandler = Container.getComponent(PropertiesHandler.class, - platform + "PropertiesHandler"); - - // If the another properties handler was found then let create the RobotItem; otherwise return null - return (otherHandler == null) ? null : otherHandler.createRobotItem(propertiesFileUrl, root, repository); - } - return item; - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/SourceHandler.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/SourceHandler.java deleted file mode 100644 index 86176a9..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/SourceHandler.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.items.handlers; - - -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.items.RobotItem; -import net.sf.robocode.repository.root.ClasspathRoot; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.util.UrlUtil; - -import java.net.URL; - - -/** - * Item handler for accepting and registering source files, e.g. Java source files. - * - * @author Flemming N. Larsen (original) - */ -public class SourceHandler extends ItemHandler { - - /** - * {@inheritDoc} - */ - @Override - protected IRepositoryItem acceptItem(URL itemURL, IRepositoryRoot root, IRepository repository) { - // Accept and register the item if it is a Java source file, but not an inner Java source file (e.g. mechanical generated) - String name = itemURL.toString().toLowerCase(); - if (name.endsWith(".java") && !name.contains("$")) { - return register(itemURL, root, repository); - } - return null; - } - - /** - * Registers the source file with the specified URL as a RobotItem. - * - * @param sourceFileUrl is the URL of the source file to register. - * @param root is the repository root containing the source file to register. - * @param repository is the repository, where the source file is automatically added or updated, - * when the source file is registered. - * @return a RobotItem that has been created or updated in the repository. - */ - private RobotItem register(URL sourceFileUrl, IRepositoryRoot root, IRepository repository) { - RobotItem item = null; - - // Check if the source file is already registered in the repository with a project URL - if (root instanceof ClasspathRoot) { - String projectUrl = ((ClasspathRoot) root).getFriendlyProjectURL(sourceFileUrl); - if (projectUrl != null) { - IRepositoryItem repositoryItem = repository.getItem(projectUrl); - if (repositoryItem instanceof RobotItem) { - item = (RobotItem) repositoryItem; - } - } - } - - // If no project URL was registered with the source file then check if the source file is registered - // in the repository. - if (item == null) { - String friendlyUrl = UrlUtil.removeFileExtension(sourceFileUrl.toString()); - - IRepositoryItem repositoryItem = repository.getItem(friendlyUrl); - if (repositoryItem instanceof RobotItem) { - item = (RobotItem) repositoryItem; - } - } - - // If the source file has not been registered then create a new RobotItem based on the source file URL - if (item == null) { - item = new RobotItem(sourceFileUrl, root); - } - - // Add the root URL as source path with the RobotIteam - item.addSourcePathURL(root.getURL()); - - // Add or update the item in the repository and return it - repository.addOrUpdateItem(item); - return item; - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/TeamHandler.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/TeamHandler.java deleted file mode 100644 index 7b5fcfd..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/items/handlers/TeamHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.items.handlers; - - -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.items.TeamItem; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.util.UrlUtil; - -import java.net.URL; - - -/** - * Item handler for accepting and registering robot team files. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class TeamHandler extends ItemHandler { - - /** - * {@inheritDoc} - */ - @Override - protected IRepositoryItem acceptItem(URL itemURL, IRepositoryRoot root, IRepository repository) { - // Accept and register the item if it is a robot team file - String name = itemURL.toString().toLowerCase(); - if (name.endsWith(".team")) { - return register(itemURL, root, repository); - } - return null; - } - - /** - * Registers the team file with the specified URL as a TeamItem. - * - * @param teamFileUrl is the URL of the team file to register. - * @param root is the repository root containing the team file to register. - * @param repository is the repository, where the team file is automatically added or updated, - * when the team file is registered. - * @return a TeamItem that has been created or updated in the repository. - */ - private TeamItem register(URL teamFileUrl, IRepositoryRoot root, IRepository repository) { - TeamItem item = null; - - // Check if the team file is already registered in the repository - String friendlyUrl = UrlUtil.removeFileExtension(teamFileUrl.toString()); - - IRepositoryItem repositoryItem = repository.getItem(friendlyUrl); - if (repositoryItem instanceof TeamItem) { - item = (TeamItem) repositoryItem; - } - - // If the team file has not been registered then create a new TeamItem based on the team file URL - if (item == null) { - item = new TeamItem(teamFileUrl, root); - } - - // Add or update the item in the repository and return it - repository.addOrUpdateItem(item); - return item; - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/packager/JarCreator.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/packager/JarCreator.java deleted file mode 100644 index fb96df8..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/packager/JarCreator.java +++ /dev/null @@ -1,267 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.packager; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.host.IHostManager; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.CodeSizeCalculator; -import net.sf.robocode.repository.IRobotItem; -import net.sf.robocode.repository.RobotProperties; -import net.sf.robocode.repository.items.RobotItem; -import net.sf.robocode.repository.items.TeamItem; -import net.sf.robocode.version.IVersionManager; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.util.HashSet; -import java.util.List; -import java.util.Set; -import java.util.jar.Attributes; -import java.util.jar.JarEntry; -import java.util.jar.JarOutputStream; -import java.util.jar.Manifest; -import java.net.URL; -import java.net.URLDecoder; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class JarCreator { - - public static String createPackage(File jarFile, List robotItems, TeamItem teamItem, RobotProperties props) { - JarOutputStream jarOut = null; - FileOutputStream fos = null; - Set jarEntries = new HashSet(); - try { - fos = new FileOutputStream(jarFile); - jarOut = new JarOutputStream(fos, createManifest(robotItems)); - - String rVersion = Container.getComponent(IVersionManager.class).getVersion(); - jarOut.setComment(rVersion + " - Robocode version"); - - boolean isTeam = teamItem != null; - - // Add robot items - addRobotItemToJar(jarOut, jarEntries, robotItems, props, isTeam); - - // Add team item, if it exists - if (isTeam) { - addTeamItemToJar(jarOut, jarEntries, teamItem, props); - } - } catch (IOException e) { - Logger.logError(e); - } finally { - FileUtil.cleanupStream(jarOut); - FileUtil.cleanupStream(fos); - } - - StringBuilder sb = new StringBuilder(); - for (String entry : jarEntries) { - sb.append(entry).append('\n'); - } - appendCodeSize(jarFile, sb); - return sb.toString(); - } - - private static Manifest createManifest(List robots) { - Manifest manifest; - - manifest = new Manifest(); - manifest.getMainAttributes().put(Attributes.Name.MANIFEST_VERSION, "1.0"); - StringBuilder robotsString = new StringBuilder(); - - for (int i = 0; i < robots.size(); i++) { - robotsString.append(robots.get(i).getFullClassName()); - if (i < robots.size() - 1) { - robotsString.append(','); - } - } - manifest.getMainAttributes().put(new Attributes.Name("robots"), robotsString.toString()); - return manifest; - } - - private static void addRobotItemToJar(JarOutputStream target, Set jarEntries, List robotItems, RobotProperties props, boolean isTeam) throws IOException { - for (IRobotItem robotItem : robotItems) { - String path = robotItem.getRelativePath() + '/' + robotItem.getShortClassName() + ".properties"; - - // Add the code size to the robot properties before storing them - String classPath = robotItem.getClassPathURL().getPath(); // Takes the dev.path into account! - File dir = new File(classPath, robotItem.getRelativePath()); - Integer codeSize = CodeSizeCalculator.getDirectoryCodeSize(dir); - props.setCodeSize(codeSize); - - if (!isTeam) { - // Store local .properties file - FileOutputStream fis = null; - try { - File file = new File(classPath, path); - fis = new FileOutputStream(file); - robotItem.storeProperties(fis, props); - } finally { - FileUtil.cleanupStream(fis); - } - } - // Package robot files (.class, .properties, .java) into jar file - addRobotFilesToJar(target, jarEntries, robotItem, props); - } - } - - private static void addTeamItemToJar(JarOutputStream target, Set jarEntries, TeamItem teamItem, RobotProperties props) throws IOException { - String robotPathWithoutFileExt = teamItem.getRelativePath() + '/' + teamItem.getShortClassName(); - - File file = new File(FileUtil.getRobotsDir(), robotPathWithoutFileExt); - - // Store .team file into local robot dir - FileOutputStream fis = null; - try { - fis = new FileOutputStream(file); - teamItem.storeProperties(fis, props); - } finally { - FileUtil.cleanupStream(fis); - } - // Store .team file into jar file - addToJar(target, jarEntries, FileUtil.getRobotsDir().getPath(), robotPathWithoutFileExt, ".team"); - } - - private static void addRobotFilesToJar(JarOutputStream target, Set jarEntries, IRobotItem robotItem, RobotProperties props) throws IOException { - IHostManager host = Container.getComponent(IHostManager.class); - for (String className : host.getReferencedClasses(robotItem)) { - if (!className.startsWith("java") && !className.startsWith("robocode")) { - String robotPath = className.replace('.', '/'); - addRobotFilesToJar(target, jarEntries, robotPath, robotItem, props); - } - } - } - - private static void addRobotFilesToJar(JarOutputStream target, Set jarEntries, String robotPathWithoutFileExt, IRobotItem robotItem, RobotProperties props) throws IOException { - addClassFileToJar(target, jarEntries, robotPathWithoutFileExt, robotItem); - addPropertiesFileToJar(target, jarEntries, robotPathWithoutFileExt, robotItem); - addJavaFileToJar(target, jarEntries, robotPathWithoutFileExt, robotItem, props); - addDataDirToJar(target, jarEntries, robotPathWithoutFileExt, robotItem, props); - } - - private static void addClassFileToJar(JarOutputStream target, Set jarEntries, String robotPathWithoutFileExt, IRobotItem robotItem) throws IOException { - String classRootPath = robotItem.getClassPathURL().getPath(); - addToJar(target, jarEntries, classRootPath, robotPathWithoutFileExt, ".class"); - } - - private static void addPropertiesFileToJar(JarOutputStream target, Set jarEntries, String robotPathWithoutFileExt, IRobotItem robotItem) throws IOException { - String classRootPath = robotItem.getClassPathURL().getPath(); - addToJar(target, jarEntries, classRootPath, robotPathWithoutFileExt, ".properties"); - } - - private static void addJavaFileToJar(JarOutputStream target, Set jarEntries, String robotFilePath, IRobotItem robotItem, RobotProperties props) throws IOException { - if (props.isIncludeSource() && !robotFilePath.contains("$")) { - for (URL sourcePathURL : robotItem.getSourcePathURLs()) { - addToJar(target, jarEntries, sourcePathURL.getPath(), robotFilePath, ".java"); - } - } - } - - private static void addDataDirToJar(JarOutputStream target, Set jarEntries, String robotPathWithoutFileExt, IRobotItem robotItem, RobotProperties props) throws IOException { - if (props.isIncludeData()) { - String rootPath = robotItem.getRootPath().replace('\\', '/'); - if (rootPath.startsWith("file:/")) { - rootPath = rootPath.substring("file:/".length()); - } - addToJar(target, jarEntries, rootPath, robotPathWithoutFileExt, ".data"); - } - } - - private static void addToJar(JarOutputStream target, Set jarEntries, String rootPath, String robotPathWithoutFileExt, String fileExt) throws IOException { - String filePath = robotPathWithoutFileExt + fileExt; - try { - rootPath = URLDecoder.decode(rootPath, "UTF-8"); - } catch (UnsupportedEncodingException e) { - Logger.logError(e); - } - File file = new File(rootPath, filePath); - if (file.exists() && !jarEntries.contains(filePath)) { - addFileToJar(file, filePath, target); - jarEntries.add(filePath); - } - } - - private static void addFileToJar(File source, String entryPath, JarOutputStream target) throws IOException { - // Jar/zip files only allows '/' as file separator - String path = entryPath.replace("\\", "/"); - - // No jar/zip entry must start with an '/' - while (path.startsWith("/")) { - path = path.substring(1); - } - - if (source.isDirectory()) { - // Directory entries must end with an '/' - if (!path.isEmpty() && !path.endsWith("/")) { - path += "/"; - } - // Add all files in the directory to the target jar - for (File nestedFile: source.listFiles()) { - String newEntryPath = entryPath + '/' + nestedFile.getName(); - addFileToJar(nestedFile, newEntryPath, target); - } - } else { - JarEntry entry = new JarEntry(path); - entry.setTime(source.lastModified()); - target.putNextEntry(entry); - - // Source is a file - - FileInputStream fis = null; - BufferedInputStream bis = null; - try { - fis = new FileInputStream(source); - bis = new BufferedInputStream(fis); - - byte[] buffer = new byte[1024]; - while (true) { - int count = bis.read(buffer); - if (count == -1) { - break; - } - target.write(buffer, 0, count); - } - } finally { - target.closeEntry(); - - FileUtil.cleanupStream(bis); - FileUtil.cleanupStream(fis); - } - } - } - - private static void appendCodeSize(File jarFile, StringBuilder sb) { - Integer codesize = CodeSizeCalculator.getJarFileCodeSize(jarFile); - if (codesize != null) { - String weightClass = null; - - if (codesize >= 1500) { - weightClass = "MegaBot (codesize >= 1500 bytes)"; - } else if (codesize >= 750) { - weightClass = "MiniBot (codesize < 1500 bytes)"; - } else if (codesize >= 250) { - weightClass = "MicroBot (codesize < 750 bytes)"; - } else { - weightClass = "NanoBot (codesize < 250 bytes)"; - } - sb.append("\n\n---- Codesize ----\n"); - sb.append("Codesize: ").append(codesize).append(" bytes\n"); - sb.append("Robot weight class: ").append(weightClass).append('\n'); - } - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/packager/JarExtractor.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/packager/JarExtractor.java deleted file mode 100644 index 1997f1c..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/packager/JarExtractor.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.packager; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.URLJarCollector; - -import java.io.BufferedInputStream; -import java.io.BufferedOutputStream; -import java.io.File; -import java.io.InputStream; -import java.io.IOException; -import java.io.FileOutputStream; -import java.util.jar.JarInputStream; -import java.util.jar.JarEntry; -import java.net.URLConnection; -import java.net.URL; - - -/** - * @author Pavel Savara (original) - */ -public class JarExtractor { - public static void extractJar(URL url) { - File dest = FileUtil.getRobotsDir(); - InputStream is = null; - BufferedInputStream bis = null; - JarInputStream jarIS = null; - - try { - final URLConnection con = URLJarCollector.openConnection(url); - - is = con.getInputStream(); - bis = new BufferedInputStream(is); - jarIS = new JarInputStream(bis); - - JarEntry entry = jarIS.getNextJarEntry(); - - while (entry != null) { - if (entry.isDirectory()) { - File dir = new File(dest, entry.getName()); - - if (!dir.exists() && !dir.mkdirs()) { - Logger.logError("Cannot create dir: " + dir); - } - } else { - extractFile(dest, jarIS, entry); - } - entry = jarIS.getNextJarEntry(); - } - } catch (IOException e) { - Logger.logError(e); - } finally { - FileUtil.cleanupStream(jarIS); - FileUtil.cleanupStream(bis); - FileUtil.cleanupStream(is); - } - } - - public static void extractFile(File dest, JarInputStream jarIS, JarEntry entry) throws IOException { - File out = new File(dest, entry.getName()); - File parentDirectory = new File(out.getParent()); - - if (!parentDirectory.exists() && !parentDirectory.mkdirs()) { - Logger.logError("Cannot create dir: " + parentDirectory); - } - FileOutputStream fos = null; - BufferedOutputStream bos = null; - byte buf[] = new byte[2048]; - - try { - fos = new FileOutputStream(out); - bos = new BufferedOutputStream(fos); - - int num; - - while ((num = jarIS.read(buf, 0, 2048)) != -1) { - bos.write(buf, 0, num); - } - } finally { - FileUtil.cleanupStream(bos); - FileUtil.cleanupStream(fos); - } - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/parsers/ClasspathFileParser.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/parsers/ClasspathFileParser.java deleted file mode 100644 index b464500..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/parsers/ClasspathFileParser.java +++ /dev/null @@ -1,63 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.parsers; - - -import java.io.IOException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParserFactory; - -import org.xml.sax.Attributes; -import org.xml.sax.SAXException; -import org.xml.sax.helpers.DefaultHandler; - - -/** - * Class used for parsing a .classpath file in an Eclipse project. - * - * @author Flemming N. Larsen (original) - */ -public class ClasspathFileParser { - - private ClasspathHandler classpathHandler = new ClasspathHandler(); - - public void parse(URL url) { - try { - SAXParserFactory.newInstance().newSAXParser().parse(url.toString(), classpathHandler); - } catch (SAXException ignore) {} catch (IOException ignore) {} catch (ParserConfigurationException ignore) {} - } - - public String[] getSourcePaths() { - return classpathHandler.sourcePaths.toArray(new String[] {}); - } - - public String getClassPath() { - return classpathHandler.outputPath; - } - - private static class ClasspathHandler extends DefaultHandler { - String outputPath = null; - List sourcePaths = new ArrayList(); - - public void startElement(String uri, String localName, String qName, Attributes attributes) throws SAXException { - if ("classpathentry".equals(qName)) { - String kind = attributes.getValue("kind"); - - if ("src".equals(kind)) { - sourcePaths.add(attributes.getValue("path")); - } else if ("output".equals(kind)) { - outputPath = attributes.getValue("path"); - } - } - } - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/BaseRoot.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/BaseRoot.java deleted file mode 100644 index 14b6c89..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/BaseRoot.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.root; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.ui.IWindowManager; - -import java.io.File; -import java.io.Serializable; -import java.net.MalformedURLException; -import java.net.URL; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public abstract class BaseRoot implements Serializable, IRepositoryRoot { - private static final long serialVersionUID = 1L; - - protected transient IRepository repository; - protected final File rootPath; - protected final URL rootURL; - - public BaseRoot(IRepository repository, File rootPath) { - this.repository = repository; - this.rootPath = rootPath; - - URL url = null; - try { - url = rootPath.toURI().toURL(); - } catch (MalformedURLException e) { - Logger.logError(e); - } - this.rootURL = url; - } - - public URL getURL() { - return rootURL; - } - - public File getPath() { - return rootPath; - } - - public void setRepository(IRepository repository) { - this.repository = repository; - } - - public String toString() { - return rootURL != null ? rootURL.toString() : null; - } - - public void extractJAR() { - throw new UnsupportedOperationException(); - } - - public boolean equals(Object obj) { - if (obj instanceof IRepositoryRoot) { - return ((IRepositoryRoot) obj).getURL().equals(rootURL); - } - return false; - } - - protected static void setStatus(String message) { - IWindowManager windowManager = net.sf.robocode.core.Container.getComponent(IWindowManager.class); - if (windowManager != null) { - windowManager.setStatus(message); - } - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/ClasspathRoot.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/ClasspathRoot.java deleted file mode 100644 index 974b510..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/ClasspathRoot.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.root; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.items.handlers.ItemHandler; -import net.sf.robocode.util.UrlUtil; - -import java.io.File; -import java.io.FileFilter; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.ArrayList; -import java.util.List; - - -/** - * Represents a classpath root. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public final class ClasspathRoot extends BaseRoot implements IRepositoryRoot { - private static final long serialVersionUID = 1L; - - private final File projectPath; - - public ClasspathRoot(IRepository repository, File rootPath, File projectPath) { - super(repository, rootPath); - this.projectPath = projectPath; - } - - /** - * {@inheritDoc} - */ - public void updateItems(boolean force) { - setStatus("Updating classpath: " + rootPath.toString()); - - // We remove all items from the root so we don't need to check, which items that might have been deleted. - // This is fast to do, as items are simple referenced by friendly URLs in a map. - // Items will be re-added or updated later in this method. - repository.removeItemsFromRoot(this); - - // Retrieve all items accessible from this classpath root along with their 'last modified' date - List items = new ArrayList(); - List itemsLastModification = new ArrayList(); - - visitDirectory(rootPath, items, itemsLastModification); - - // Run thru all found repository items and update these according to their 'last modified' date - for (int i = 0; i < items.size(); i++) { - IRepositoryItem repositoryItem = items.get(i); - repositoryItem.update(itemsLastModification.get(i), force); - } - } - - private void visitDirectory(File path, final List items, final List itemsLastModification) { - - path.listFiles( - new FileFilter() { - public boolean accept(File pathname) { - if (pathname.isFile()) { - try { - IRepositoryItem repositoryItem = ItemHandler.registerItem(pathname.toURI().toURL(), - ClasspathRoot.this, repository); - if (repositoryItem != null) { - items.add(repositoryItem); - itemsLastModification.add(pathname.lastModified()); - } - } catch (MalformedURLException e) { - Logger.logError(e); - } - } - return false; - } - }); - - // find sub-directories - File[] subDirs = path.listFiles( - new FileFilter() { - public boolean accept(File pathname) { - return pathname.isDirectory() && !pathname.getName().toLowerCase().endsWith(".data") - && !pathname.getName().toLowerCase().endsWith(".robotcache"); - } - }); - - if (subDirs != null) { - for (File subDir : subDirs) { - visitDirectory(subDir, items, itemsLastModification); - } - } - } - - public void updateItem(IRepositoryItem item, boolean force) { - setStatus("Updating classpath: " + rootPath); - - File file = new File(item.getItemURL().toString()); - item.update(file.lastModified(), force); - } - - public boolean isChanged(IRepositoryItem repositoryItem) { - File file = new File(repositoryItem.getItemURL().toString()); - return file.lastModified() > repositoryItem.getLastModified(); - } - - public boolean isDevelopmentRoot() { - return true; - } - - public boolean isJAR() { - return false; - } - - public String getFriendlyProjectURL(URL itemURL) { - String url = null; - - if (projectPath != null) { - try { - String rootPath = projectPath.toURI().toURL().toString(); - String itemPath = itemURL.toString().substring(getURL().toString().length()); - - url = rootPath + UrlUtil.removeFileExtension(itemPath); - - } catch (MalformedURLException e) { - Logger.logError(e); - } - } - return url; - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/IRepositoryRoot.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/IRepositoryRoot.java deleted file mode 100644 index fb99e70..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/IRepositoryRoot.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.root; - - -import net.sf.robocode.repository.items.IRepositoryItem; - -import java.io.File; -import java.net.URL; - - -/** - * @author Pavel Savara (original) - */ -public interface IRepositoryRoot { - URL getURL(); - File getPath(); - - /** - * Updates all items accessible from this repository root. - * Only items that needs to be updated will be updated, e.g. by checking the 'last modified' date on the item. - * - * @param force is a flag specifying if the items are forced to be updated. - * If this parameter is true, then all items will be updated. - */ - void updateItems(boolean force); - - void updateItem(IRepositoryItem repositoryItem, boolean force); - - boolean isJAR(); - boolean isDevelopmentRoot(); - void extractJAR(); -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/JarRoot.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/JarRoot.java deleted file mode 100644 index 18f7cf6..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/JarRoot.java +++ /dev/null @@ -1,177 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.root; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.URLJarCollector; -import net.sf.robocode.io.JarJar; -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.packager.JarExtractor; -import net.sf.robocode.repository.items.IRepositoryItem; -import net.sf.robocode.repository.items.RobotItem; -import net.sf.robocode.repository.items.handlers.ItemHandler; - -import java.io.BufferedInputStream; -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.ArrayList; -import java.util.List; -import java.util.jar.JarEntry; -import java.util.jar.JarInputStream; - - -/** - * Represents a JAR file. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public final class JarRoot extends BaseRoot implements IRepositoryRoot { - private static final long serialVersionUID = 1L; - - private final String jarPath; // without a separator ("/!") - private final URL jarUrl; - - private long lastModified; - - public JarRoot(IRepository repository, File rootPath) { - super(repository, rootPath); - String jarPath = null; - URL jarUrl = null; - try { - jarPath = "jar:" + rootPath.toURI().toString(); - jarUrl = new URL(jarPath + "!/"); - } catch (MalformedURLException e) { - Logger.logError(e); - } - this.jarPath = jarPath; - this.jarUrl = jarUrl; - } - - /** - * {@inheritDoc} - */ - public void updateItems(boolean force) { - setStatus("Updating JAR: " + rootPath.toString()); - - long lastModified = rootPath.lastModified(); - - if (lastModified > this.lastModified) { - repository.removeItemsFromRoot(this); - this.lastModified = lastModified; - - List repositoryItems = new ArrayList(); - - visitItems(repositoryItems); - for (IRepositoryItem repositoryItem : repositoryItems) { - repositoryItem.update(lastModified, force); - } - } - } - - private void visitItems(List repositoryItems) { - String root = jarPath; - InputStream is = null; - BufferedInputStream bis = null; - JarInputStream jarIS = null; - - try { - URLConnection con = URLJarCollector.openConnection(rootURL); - - is = con.getInputStream(); - bis = new BufferedInputStream(is); - jarIS = new JarInputStream(bis); - readJarStream(repositoryItems, root, jarIS); - - } catch (Exception e) { - Logger.logError(rootURL + " is probably corrupted (" + e.getClass().getName() + " " + e.getMessage() + ")"); - } finally { - FileUtil.cleanupStream(jarIS); - FileUtil.cleanupStream(bis); - FileUtil.cleanupStream(is); - } - } - - private void readJarStream(List repositoryItems, String root, JarInputStream jarIS) throws IOException { - JarEntry entry = jarIS.getNextJarEntry(); - - while (entry != null) { - String name = entry.getName().toLowerCase(); - - if (!entry.isDirectory()) { - if (name.contains(".data/") && !name.contains(".robotcache/")) { - JarExtractor.extractFile(FileUtil.getRobotsDataDir(), jarIS, entry); - } else { - if (name.endsWith(".jar") || name.endsWith(".zip")) { - JarInputStream inner = null; - - try { - inner = new JarInputStream(jarIS); - readJarStream(repositoryItems, "jar:jar" + root + JarJar.SEPARATOR + entry.getName(), inner); - } finally { - if (inner != null) { - inner.closeEntry(); - } - } - } else { - createItem(repositoryItems, new URL(root + "!/"), entry); - } - } - } - entry = jarIS.getNextJarEntry(); - } - } - - private void createItem(List repositoryItems, URL root, JarEntry entry) { - try { - String pUrl = root.toString() + entry.getName(); - IRepositoryItem repositoryItem = ItemHandler.registerItem(new URL(pUrl), JarRoot.this, repository); - - if (repositoryItem != null) { - if (repositoryItem instanceof RobotItem) { - RobotItem robotItem = (RobotItem) repositoryItem; - - robotItem.setClassPathURL(root); - } - repositoryItems.add(repositoryItem); - } - } catch (MalformedURLException e) { - Logger.logError(e); - } - } - - public void updateItem(IRepositoryItem repositoryItem, boolean force) { - repositoryItem.update(rootPath.lastModified(), force); - } - - public boolean isChanged(IRepositoryItem repositoryItem) { - return rootPath.lastModified() > lastModified; - } - - public URL getURL() { - return jarUrl; - } - - public boolean isDevelopmentRoot() { - return false; - } - - public boolean isJAR() { - return true; - } - - public void extractJAR() { - JarExtractor.extractJar(rootURL); - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/handlers/ClassPathHandler.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/handlers/ClassPathHandler.java deleted file mode 100644 index fb5b16e..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/handlers/ClassPathHandler.java +++ /dev/null @@ -1,85 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.root.handlers; - - -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.parsers.ClasspathFileParser; -import net.sf.robocode.repository.root.ClasspathRoot; -import net.sf.robocode.repository.root.IRepositoryRoot; - -import java.io.File; -import java.net.MalformedURLException; -import java.util.Map; - - -/** - * Handler for registering class path roots. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class ClassPathHandler extends RootHandler { - public void visitDirectory(File dir, boolean isDevel, Map newRoots, IRepository repository, boolean force) { - if (isDevel) { - File classpathFile = new File(dir, ".classpath"); - - if (classpathFile.exists()) { - ClasspathFileParser classpathParser = new ClasspathFileParser(); - - boolean parsed = true; - - try { - classpathParser.parse(classpathFile.toURI().toURL()); - } catch (MalformedURLException e) { - parsed = false; - } - if (parsed) { - String classPath = classpathParser.getClassPath(); - - if (classPath != null) { - File classPathDir = new File(dir, classPath); - - handleDirectory(classPathDir, dir, newRoots, repository, force); - } - - for (String sourcePath : classpathParser.getSourcePaths()) { - if (sourcePath != null) { - File sourcePathDir = new File(dir, sourcePath); - - handleDirectory(sourcePathDir, dir, newRoots, repository, force); - } - } - - return; // we are done! - } - } - } - handleDirectory(dir, null, newRoots, repository, force); - } - - private void handleDirectory(File dir, File projectDir, Map newRoots, IRepository repository, boolean force) { - String key; - - try { - key = dir.toURI().toURL().toString(); - } catch (MalformedURLException e) { - return; - } - - IRepositoryRoot root = repository.getRoots().get(key); - if (root == null) { - root = new ClasspathRoot(repository, dir, projectDir); - } else { - repository.removeRoot(key); - } - - root.updateItems(force); - newRoots.put(key, root); - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/handlers/JarHandler.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/handlers/JarHandler.java deleted file mode 100644 index d27d0c3..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/handlers/JarHandler.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.root.handlers; - - -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.root.IRepositoryRoot; -import net.sf.robocode.repository.root.JarRoot; -import net.sf.robocode.io.Logger; -import net.sf.robocode.io.URLJarCollector; - -import java.io.File; -import java.io.FileFilter; -import java.net.MalformedURLException; -import java.util.Map; - - -/** - * @author Pavel Savara (original) - */ -public class JarHandler extends RootHandler { - public void visitDirectory(File dir, boolean isDevel, Map newRoots, IRepository repository, boolean force) { - if (!isDevel) { - // find jar files - final File[] jars = dir.listFiles(new FileFilter() { - public boolean accept(File pathname) { - String path = pathname.toString().toLowerCase(); - return pathname.isFile() && (path.endsWith(".jar") || path.endsWith(".zip")); - } - }); - - if (jars == null) { - return; // Avoid NPE by returning - } - - // update jar files - for (File jar : jars) { - String key; - - try { - key = "jar:" + jar.toURI().toURL().toString() + "!/"; - } catch (MalformedURLException e) { - e.printStackTrace(); - continue; - } - IRepositoryRoot root = repository.getRoots().get(key); - if (root == null) { - root = new JarRoot(repository, jar); - } else { - repository.removeRoot(key); - } - - root.updateItems(force); - newRoots.put(key, root); - - try { - URLJarCollector.closeJarURLConnection(jar.toURI().toURL()); - } catch (MalformedURLException e) { - Logger.logError(e); - } - URLJarCollector.gc(); - } - } - } -} diff --git a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/handlers/RootHandler.java b/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/handlers/RootHandler.java deleted file mode 100644 index f9e3f09..0000000 --- a/workspace_robo/robocode.repository/src/main/java/net/sf/robocode/repository/root/handlers/RootHandler.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.repository.root.handlers; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.repository.IRepository; -import net.sf.robocode.repository.root.IRepositoryRoot; - -import java.io.File; -import java.util.List; -import java.util.Map; - - -/** - * @author Pavel Savara (original) - */ -public abstract class RootHandler { - public abstract void visitDirectory(File dir, boolean isDevel, Map newRoots, IRepository repository, boolean force); - - public void open() {} - - public void close() {} - - public static void visitDirectories(File dir, boolean isDevel, Map newRoots, IRepository repository, boolean force) { - // walk thru all plugins - final List itemHandlerList = Container.getComponents(RootHandler.class); - - for (RootHandler handler : itemHandlerList) { - handler.visitDirectory(dir, isDevel, newRoots, repository, force); - } - } - - public static void openHandlers() { - List rootHandlers = Container.getComponents(RootHandler.class); - for (RootHandler handler : rootHandlers) { - handler.open(); - } - } - - public static void closeHandlers() { - List rootHandlers = Container.getComponents(RootHandler.class); - for (RootHandler handler : rootHandlers) { - handler.close(); - } - } -} diff --git a/workspace_robo/robocode.roborumble/.classpath b/workspace_robo/robocode.roborumble/.classpath deleted file mode 100644 index a355dc2..0000000 --- a/workspace_robo/robocode.roborumble/.classpath +++ /dev/null @@ -1,13 +0,0 @@ - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.roborumble/.project b/workspace_robo/robocode.roborumble/.project deleted file mode 100644 index 9bd56e1..0000000 --- a/workspace_robo/robocode.roborumble/.project +++ /dev/null @@ -1,20 +0,0 @@ - - - robocode.roborumble - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.api - robocode.battle - robocode.core - robocode.host - robocode.repository - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.roborumble/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.roborumble/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.roborumble/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.roborumble/MeleeRumble.launch b/workspace_robo/robocode.roborumble/MeleeRumble.launch deleted file mode 100644 index 593e4df..0000000 --- a/workspace_robo/robocode.roborumble/MeleeRumble.launch +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.roborumble/RoboRumble.launch b/workspace_robo/robocode.roborumble/RoboRumble.launch deleted file mode 100644 index b1e6cf8..0000000 --- a/workspace_robo/robocode.roborumble/RoboRumble.launch +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.roborumble/TeamRumble.launch b/workspace_robo/robocode.roborumble/TeamRumble.launch deleted file mode 100644 index 8aa9b19..0000000 --- a/workspace_robo/robocode.roborumble/TeamRumble.launch +++ /dev/null @@ -1,20 +0,0 @@ - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.roborumble/pom.xml b/workspace_robo/robocode.roborumble/pom.xml deleted file mode 100644 index 9b66c50..0000000 --- a/workspace_robo/robocode.roborumble/pom.xml +++ /dev/null @@ -1,51 +0,0 @@ - - - 4.0.0 - robocode.roborumble - Roborumble Client - - net.sf.robocode - robocode - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - net.sf.robocode - robocode.core - ${project.version} - - - net.sf.robocode - codesize - 1.1 - - - net.sf.robocode - robocode.battle - ${project.version} - runtime - - - - - - org.apache.maven.plugins - maven-jar-plugin - - roborumble - - - roborumble.RoboRumbleAtHome - - - - - - - diff --git a/workspace_robo/robocode.roborumble/robocode.roborumble.iml b/workspace_robo/robocode.roborumble/robocode.roborumble.iml deleted file mode 100644 index 986c6f3..0000000 --- a/workspace_robo/robocode.roborumble/robocode.roborumble.iml +++ /dev/null @@ -1,86 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java b/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java deleted file mode 100644 index 433cff6..0000000 --- a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/BattlesRunner.java +++ /dev/null @@ -1,235 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.roborumble.battlesengine; - - -import net.sf.robocode.io.Logger; -import static net.sf.robocode.roborumble.util.PropertiesUtil.getProperties; -import robocode.control.*; -import robocode.control.events.BattleAdaptor; -import robocode.control.events.BattleCompletedEvent; -import robocode.control.events.BattleErrorEvent; - -import java.io.*; -import java.util.*; - - -/** - * The BattlesRunner is running battles. - * Reads a file with the battles to be runned and outputs the results in another file. - * Controlled by properties files. - * - * @author Albert Pérez (original) - * @author Flemming N. Larsen (contributor) - * @author Joachim Hofer (contributor) - */ -public class BattlesRunner { - private final String inputfile; - private final int numrounds; - private final int fieldlen; - private final int fieldhei; - private final String outfile; - private final String user; - private String game; - private static RobotResults[] lastResults; - private static IRobocodeEngine engine; - - public BattlesRunner(String propertiesfile) { - // Read parameters - Properties parameters = getProperties(propertiesfile); - - inputfile = parameters.getProperty("INPUT", ""); - numrounds = Integer.parseInt(parameters.getProperty("ROUNDS", "10")); - fieldlen = Integer.parseInt(parameters.getProperty("FIELDL", "800")); - fieldhei = Integer.parseInt(parameters.getProperty("FIELDH", "600")); - outfile = parameters.getProperty("OUTPUT", ""); - user = parameters.getProperty("USER", ""); - - game = propertiesfile; - while (game.indexOf("/") != -1) { - game = game.substring(game.indexOf("/") + 1); - } - game = game.substring(0, game.indexOf(".")); - - initialize(); - } - - private void initialize() { - if (engine == null) { - engine = new RobocodeEngine(); - engine.addBattleListener(new BattleObserver()); - } - } - - public String getVersion() { - return (engine != null) ? engine.getVersion() : null; - } - - public void runBattlesImpl(boolean melee) { - // Initialize objects - BattlefieldSpecification field = new BattlefieldSpecification(fieldlen, fieldhei); - BattleSpecification battle = new BattleSpecification(numrounds, field, (new RobotSpecification[2])); - - // Read input file - ArrayList robots = new ArrayList(); - if (readRobots(robots)) { - return; - } - - // open output file - PrintStream outtxt = getRedirectedOutput(); - if (outtxt == null) { - return; - } - - // run battle - int index = 0; - - while (index < robots.size()) { - String[] param = (robots.get(index)).split(","); - - String enemies = getEnemies(melee, param); - - System.out.println("Fighting battle " + (index) + " ... " + enemies); - - final RobotSpecification[] robotsList = engine.getLocalRepository(enemies); - - if (robotsList.length > 1) { - final String team0 = robotsList[0].getTeamId(); - final String teamLast = robotsList[robotsList.length - 1].getTeamId(); - - if (team0 == null || !team0.equals(teamLast)) { - final BattleSpecification specification = new BattleSpecification(battle.getNumRounds(), - battle.getBattlefield(), robotsList); - - lastResults = null; - engine.runBattle(specification, true); - if (lastResults != null && lastResults.length > 1) { - dumpResults(outtxt, lastResults, param[param.length - 1], melee); - } - } - } else { - System.err.println("Skipping battle because can't load robots: " + enemies); - } - index++; - } - - // close - outtxt.close(); - } - - private String getEnemies(boolean melee, String[] param) { - String enemies; - - if (melee) { - StringBuilder eb = new StringBuilder(); - - for (int i = 0; i < param.length - 1; i++) { - if (i > 0) { - eb.append(','); - } - eb.append(param[i]); - } - enemies = eb.toString(); - } else { - enemies = param[0] + "," + param[1]; - } - return enemies; - } - - private PrintStream getRedirectedOutput() { - try { - return new PrintStream(new BufferedOutputStream(new FileOutputStream(outfile, true)), true); - } catch (IOException e) { - System.out.println("Not able to open output file ... Aborting"); - System.out.println(e); - return null; - } - } - - private boolean readRobots(ArrayList robots) { - BufferedReader br = null; - try { - FileReader fr = new FileReader(inputfile); - br = new BufferedReader(fr); - - String record; - while ((record = br.readLine()) != null) { - robots.add(record); - } - } catch (IOException e) { - System.out.println("Battles input file not found ... Aborting"); - System.out.println(e); - return true; - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignore) {} - } - } - return false; - } - - private void dumpResults(PrintStream outtxt, RobotResults[] results, String last, boolean melee) { - final String BOT_INDEX_PATTERN = "\\[.*\\]"; - - for (int i = 0; i < results.length; i++) { - for (int j = 0; j < results.length; j++) { - if (i < j) { - RobotSpecification bot1 = results[i].getRobot(); - RobotSpecification bot2 = results[j].getRobot(); - - String name1 = bot1.getTeamId() != null - ? bot1.getTeamId().replaceAll(BOT_INDEX_PATTERN, "") - : bot1.getNameAndVersion(); - String name2 = bot2.getTeamId() != null - ? bot2.getTeamId().replaceAll(BOT_INDEX_PATTERN, "") - : bot2.getNameAndVersion(); - int points1 = results[i].getScore(); - int points2 = results[j].getScore(); - int bullets1 = results[i].getBulletDamage(); - int bullets2 = results[j].getBulletDamage(); - int survival1 = results[i].getFirsts(); - int survival2 = results[j].getFirsts(); - - outtxt.println( - game + "," + numrounds + "," + fieldlen + "x" + fieldhei + "," + user + "," - + System.currentTimeMillis() + "," + last); - outtxt.println(name1 + "," + points1 + "," + bullets1 + "," + survival1); - outtxt.println(name2 + "," + points2 + "," + bullets2 + "," + survival2); - } - } - } - if (melee) { - System.out.println( - "RESULT = " + results[0].getRobot().getNameAndVersion() + " wins, " - + results[1].getRobot().getNameAndVersion() + " is second."); - } else { - RobotSpecification winnerBot = results[0].getRobot(); - String winnerBotName = winnerBot.getTeamId() != null - ? winnerBot.getTeamId().replaceAll(BOT_INDEX_PATTERN, "") - : winnerBot.getNameAndVersion(); - - System.out.println( - "RESULT = " + winnerBotName + " wins " + results[0].getScore() + " to " + results[1].getScore()); - } - } - - class BattleObserver extends BattleAdaptor { - @Override - public void onBattleError(final BattleErrorEvent event) { - Logger.realErr.println(event.getError()); - } - - @Override - public void onBattleCompleted(final BattleCompletedEvent event) { - lastResults = RobotResults.convertResults(event.getSortedResults()); - } - } -} diff --git a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/CompetitionsSelector.java b/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/CompetitionsSelector.java deleted file mode 100644 index 96a9e88..0000000 --- a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/CompetitionsSelector.java +++ /dev/null @@ -1,77 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.roborumble.battlesengine; - - -import static net.sf.robocode.roborumble.util.PropertiesUtil.getProperties; -import static net.sf.robocode.roborumble.util.PropertiesUtil.storeProperties; - -import java.io.File; -import java.util.Properties; - -import net.sf.robocode.repository.CodeSizeCalculator; - - -/** - * This class is used to control which competitions a robot is allowed to - * participate in. - * Reads a file with the battles to be runned and outputs the results in - * another file. - * Controlled by properties files. - * - * @author Albert Pérez (original) - * @author Flemming N. Larsen (contributor) - */ -public class CompetitionsSelector { - private final String repository; - private final String sizesfile; - private final Properties sizes; - - public CompetitionsSelector(String sizesfile, String repository) { - this.repository = repository; - // open sizes file - this.sizesfile = sizesfile; - - sizes = getProperties(sizesfile); - } - - public boolean checkCompetitorForSize(String botName, long maxSize) { - String name = botName.replace(' ', '_'); - - // Read sizes - long codeSize = Long.parseLong(sizes.getProperty(name, "0")); - - // Find out the size if not in the file - boolean fileNeedsUpdate = false; - - if (codeSize == 0) { - File f = new File(repository + name + ".jar"); - if (f.exists()) { - fileNeedsUpdate = true; // Bug-362 - - Integer jarFileCodeSize = CodeSizeCalculator.getJarFileCodeSize(f); - if (jarFileCodeSize != null) { - codeSize = jarFileCodeSize; - sizes.setProperty(name, Long.toString(codeSize)); - } - } - } - - // If the file needs update, then save the file - if (fileNeedsUpdate && codeSize > 0) { - storeProperties(sizes, sizesfile, "Bots code size"); - } - - // Check the code size - return (codeSize < maxSize); // Bug-362 - } - - public boolean checkCompetitorsForSize(String bot1, String bot2, long maxsize) { - return checkCompetitorForSize(bot1, maxsize) && checkCompetitorForSize(bot2, maxsize); - } -} diff --git a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java b/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java deleted file mode 100644 index b594e67..0000000 --- a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/battlesengine/PrepareBattles.java +++ /dev/null @@ -1,579 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.roborumble.battlesengine; - - -import static net.sf.robocode.roborumble.util.ExcludesUtil.*; -import static net.sf.robocode.roborumble.util.PropertiesUtil.getProperties; - -import java.io.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Properties; -import java.util.Random; - - -/** - * PrepareBattles is used for preparing battles. - * Controlled by properties files. - * - * @author Albert Pérez (original) - * @author Flemming N. Larsen (contributor) - * @author Jerome Lavigne (contributor) - */ -public class PrepareBattles { - - private final String botsrepository; - private final String participantsfile; - private final String battlesfile; - private final int numbattles; - private final CompetitionsSelector size; - private final String runonly; - private final Properties generalratings; - private final Properties miniratings; - private final Properties microratings; - private final Properties nanoratings; - private final String priority; - private final int prioritynum; - private final int meleebots; - - private final static Random RANDOM = new Random(); - - public PrepareBattles(String propertiesfile) { - // Read parameters - Properties parameters = getProperties(propertiesfile); - - botsrepository = parameters.getProperty("BOTSREP", ""); - participantsfile = parameters.getProperty("PARTICIPANTSFILE", ""); - battlesfile = parameters.getProperty("INPUT", ""); - numbattles = Integer.parseInt(parameters.getProperty("NUMBATTLES", "100")); - String sizesfile = parameters.getProperty("CODESIZEFILE", ""); - - size = new CompetitionsSelector(sizesfile, botsrepository); - runonly = parameters.getProperty("RUNONLY", "GENERAL"); - prioritynum = Integer.parseInt(parameters.getProperty("BATTLESPERBOT", "500")); - meleebots = Integer.parseInt(parameters.getProperty("MELEEBOTS", "10")); - generalratings = getProperties(parameters.getProperty("RATINGS.GENERAL", "")); - miniratings = getProperties(parameters.getProperty("RATINGS.MINIBOTS", "")); - microratings = getProperties(parameters.getProperty("RATINGS.MICROBOTS", "")); - nanoratings = getProperties(parameters.getProperty("RATINGS.NANOBOTS", "")); - priority = parameters.getProperty("PRIORITYBATTLESFILE", ""); - - // Read and prepare exclude filters - setExcludes(parameters); - } - - public boolean createBattlesList() { - List names = new ArrayList(); - - // Read participants - - BufferedReader br = null; - - try { - FileReader fr = new FileReader(participantsfile); - - br = new BufferedReader(fr); - String participant; - - while ((participant = br.readLine()) != null) { - if (participant.indexOf(",") != -1) { - String name = participant.substring(0, participant.indexOf(",")); - - if (isExcluded(name)) { - continue; // ignore excluded participant - } - String jar = name.replace(' ', '_') + ".jar"; - boolean exists = (new File(botsrepository + jar)).exists(); - - if (exists) { - if ((runonly.equals("MINI") && size.checkCompetitorForSize(name, 1500)) - || (runonly.equals("MICRO") && size.checkCompetitorForSize(name, 750)) - || (runonly.equals("NANO") && size.checkCompetitorForSize(name, 250)) - || (!runonly.equals("MINI") && !runonly.equals("MICRO") && !runonly.equals("NANO"))) { - names.add(name); - } - } - } - } - } catch (IOException e) { - System.out.println("Participants file not found ... Aborting"); - System.out.println(e); - return false; - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignored) {} - } - } - // Open battles file - PrintStream outtxt; - - try { - outtxt = new PrintStream(new BufferedOutputStream(new FileOutputStream(battlesfile)), false); - } catch (IOException e) { - System.out.println("Not able to open battles file " + battlesfile + " ... Aborting"); - System.out.println(e); - return false; - } - // Create the participants file - Random random = new Random(); - int count = 0; - - while (count < numbattles && names.size() > 1) { - int bot1 = random.nextInt(names.size()); - int bot2 = random.nextInt(names.size()); - - if (bot1 != bot2) { - outtxt.println(names.get(bot1) + "," + names.get(bot2) + "," + runonly); - count++; - } - } - outtxt.close(); - return true; - } - - public boolean createSmartBattlesList() { - List namesAll = new ArrayList(); - List namesMini = new ArrayList(); - List namesMicro = new ArrayList(); - List namesNano = new ArrayList(); - List namesNoRanking = new ArrayList(); - List priorityAll = new ArrayList(); - List priorityMini = new ArrayList(); - List priorityMicro = new ArrayList(); - List priorityNano = new ArrayList(); - - List priorityBattles = new ArrayList(); - - // Read participants - - BufferedReader br = null; - - try { - FileReader fr = new FileReader(participantsfile); - - br = new BufferedReader(fr); - String participant; - - while ((participant = br.readLine()) != null) { - if (participant.indexOf(",") != -1) { - String name = participant.substring(0, participant.indexOf(",")); - - if (isExcluded(name)) { - continue; // ignore excluded participant - } - String jar = name.replace(' ', '_') + ".jar"; - boolean exists = (new File(botsrepository + jar)).exists(); - - if (exists) { - namesAll.add(name); - if (size.checkCompetitorForSize(name, 1500)) { - namesMini.add(name); - } - if (size.checkCompetitorForSize(name, 750)) { - namesMicro.add(name); - } - if (size.checkCompetitorForSize(name, 250)) { - namesNano.add(name); - } - if (robotHasPriority(name, generalratings)) { - priorityAll.add(name); - } - if (size.checkCompetitorForSize(name, 1500) && robotHasPriority(name, miniratings)) { - priorityMini.add(name); - } - if (size.checkCompetitorForSize(name, 750) && robotHasPriority(name, microratings)) { - priorityMicro.add(name); - } - if (size.checkCompetitorForSize(name, 250) && robotHasPriority(name, nanoratings)) { - priorityNano.add(name); - } - if (!isRobotInRatings(name)) { - namesNoRanking.add(name); - } - } - } - } - } catch (IOException e) { - System.out.println("Participants file not found ... Aborting"); - System.out.println(e); - return false; - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignored) {} - } - } - - // Read priority battles - - br = null; - - try { - FileReader fr = new FileReader(priority); - - br = new BufferedReader(fr); - String record; - - while ((record = br.readLine()) != null) { - String[] items = record.split(","); - - if (items.length == 3) { - // Check that competitors exist - String jar1 = items[0].replace(' ', '_') + ".jar"; - boolean exists1 = (new File(botsrepository + jar1)).exists() && namesAll.contains(items[0]); - String jar2 = items[1].replace(' ', '_') + ".jar"; - boolean exists2 = (new File(botsrepository + jar2)).exists() && namesAll.contains(items[1]); - - // Add battles to priority battles list - if (exists1 && exists2 && !priorityBattles.contains(record)) { - priorityBattles.add(record); - } else { - System.out.println("Ignoring: " + record); - } - } - } - } catch (IOException e) { - System.out.println("Priority battles file not found ... "); - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignore) {} - } - } - - // Delete priority battles (avoid duplication) - File r = new File(priority); - - if (r.exists() && !r.delete()) { - System.out.println("Cannot delete: " + priority); - } - - // Open battles file - PrintStream outtxt; - - try { - outtxt = new PrintStream(new BufferedOutputStream(new FileOutputStream(battlesfile)), false); - } catch (IOException e) { - System.out.println("Not able to open battles file " + battlesfile + " ... Aborting"); - System.out.println(e); - return false; - } - - // Create the participants file - int count = 0; - - // Add priority battles - while (count < numbattles && count < priorityBattles.size()) { - String battle = priorityBattles.get(count); - outtxt.println(battle); - count++; - } - // Add bots with less than 500 battles, or a random battle if all bots have enough battles - if (namesAll.size() > 1) { - while (count < numbattles) { - String[] bots; - if (namesNoRanking.size() > 0) { - // Bug [3547611] - New bots not given priority - List listWithSingleItem = new ArrayList(); - String bot = namesNoRanking.get(0); - listWithSingleItem.add(bot); - bots = getRandomBots(listWithSingleItem, namesAll); - namesNoRanking.remove(0); - } else if (priorityAll.size() > 0) { - bots = getRandomBots(priorityAll, namesAll); - } else if (priorityMini.size() > 0 && namesMini.size() > 1) { - bots = getRandomBots(priorityMini, namesMini); - } else if (priorityMicro.size() > 0 && namesMicro.size() > 1) { - bots = getRandomBots(priorityMicro, namesMicro); - } else if (priorityNano.size() > 0 && namesNano.size() > 1) { - bots = getRandomBots(priorityNano, namesNano); - } else { - bots = getRandomBots(namesAll, namesAll); - } - if (bots != null) { - outtxt.println(bots[0] + "," + bots[1] + "," + runonly); - count++; - } - } - } - outtxt.close(); - return true; - } - - private String[] getRandomBots(List list1, List list2) { - int bot1 = RANDOM.nextInt(list1.size()); - int bot2 = RANDOM.nextInt(list2.size()); - - while ((list1.get(bot1)).equals(list2.get(bot2))) { - bot1 = RANDOM.nextInt(list1.size()); - bot2 = RANDOM.nextInt(list2.size()); - } - String[] bots = new String[2]; - - bots[0] = list1.get(bot1); - bots[1] = list2.get(bot2); - return bots; - } - - private boolean robotHasPriority(String name, Properties ratings) { - if (name == null || ratings == null) { - return false; - } - String bot = name.replaceAll(" ", "_"); - String values = ratings.getProperty(bot); - - if (values == null) { - return false; // must be false (Bug 3474173) - } - String[] value = values.split(","); - double battles = Double.parseDouble(value[1]); - - return (battles < prioritynum); - } - - private boolean isRobotInRatings(String name) { - if (name == null || name.trim().length() == 0) { - return false; - } - String bot = name.replaceAll(" ", "_"); - - Properties[] ratingLists = new Properties[] { generalratings, miniratings, microratings, nanoratings }; - - for (Properties ratings : ratingLists) { - if (ratings.getProperty(bot) != null) { - return true; - } - } - return false; - } - - public boolean createMeleeBattlesList() { - List namesAll = new ArrayList(); - List namesMini = new ArrayList(); - List namesMicro = new ArrayList(); - List namesNano = new ArrayList(); - List namesNoRanking = new ArrayList(); - List priorityAll = new ArrayList(); - List priorityMini = new ArrayList(); - List priorityMicro = new ArrayList(); - List priorityNano = new ArrayList(); - - List priorityPairs = new ArrayList(); - - // Read participants - - BufferedReader br = null; - - try { - FileReader fr = new FileReader(participantsfile); - - br = new BufferedReader(fr); - String participant; - - while ((participant = br.readLine()) != null) { - if (participant.indexOf(",") != -1) { - String name = participant.substring(0, participant.indexOf(",")); - - if (isExcluded(name)) { - continue; // ignore excluded participant - } - String jar = name.replace(' ', '_') + ".jar"; - boolean exists = (new File(botsrepository + jar)).exists(); - - if (exists) { - namesAll.add(name); - if (size.checkCompetitorForSize(name, 1500)) { - namesMini.add(name); - } - if (size.checkCompetitorForSize(name, 750)) { - namesMicro.add(name); - } - if (size.checkCompetitorForSize(name, 250)) { - namesNano.add(name); - } - if (robotHasPriority(name, generalratings)) { - priorityAll.add(name); - } - if (size.checkCompetitorForSize(name, 1500) && robotHasPriority(name, miniratings)) { - priorityMini.add(name); - } - if (size.checkCompetitorForSize(name, 750) && robotHasPriority(name, microratings)) { - priorityMicro.add(name); - } - if (size.checkCompetitorForSize(name, 250) && robotHasPriority(name, nanoratings)) { - priorityNano.add(name); - } - if (!isRobotInRatings(name)) { - namesNoRanking.add(name); - } - } - } - } - } catch (IOException e) { - System.out.println("Participants file not found ... Aborting"); - System.out.println(e); - return false; - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignored) {} - } - } - - // Read priority battles - - br = null; - - try { - FileReader fr = new FileReader(priority); - - br = new BufferedReader(fr); - String record; - - while ((record = br.readLine()) != null) { - String[] items = record.split(","); - - if (items.length == 3) { - // Check that competitors exist - String jar1 = items[0].replace(' ', '_') + ".jar"; - boolean exists1 = (new File(botsrepository + jar1)).exists() && namesAll.contains(items[0]); - String jar2 = items[1].replace(' ', '_') + ".jar"; - boolean exists2 = (new File(botsrepository + jar2)).exists() && namesAll.contains(items[1]); - - // Add battles to priority battles vector - if (exists1 && exists2 && !priorityPairs.contains(items)) { - priorityPairs.add(items); - } else { - System.out.println("Ignoring: " + record); - } - } - } - } catch (IOException e) { - System.out.println("Priority battles file not found ... "); - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignore) {} - } - } - - // Delete priority battles (avoid duplication) - File r = new File(priority); - - if (r.exists() && !r.delete()) { - System.out.println("Cannot delete: " + priority); - } - - // Open battles file - PrintStream outtxt; - - try { - outtxt = new PrintStream(new BufferedOutputStream(new FileOutputStream(battlesfile)), false); - } catch (IOException e) { - System.out.println("Not able to open battles file " + battlesfile + " ... Aborting"); - System.out.println(e); - return false; - } - - // Create the participants file - int count = 0; - - // Add bots with less than 500 battles, or a random battle if all bots have enough battles - if (namesAll.size() > meleebots) { - while (count < numbattles) { - String[] bots = null; - if (namesNoRanking.size() > 0) { - // Bug [3547611] - New bots not given priority - List listWithSingleItem = new ArrayList(); - String bot = namesNoRanking.get(0); - listWithSingleItem.add(bot); - bots = getRandomMeleeBots(listWithSingleItem, namesAll); - namesNoRanking.remove(0); - } else if (count < priorityPairs.size()) { - String[] prioritybots = priorityPairs.get(count); - bots = getRandomMeleeBots(prioritybots[0], prioritybots[1], namesAll); - } else if (priorityAll.size() > 0 && namesAll.size() >= meleebots) { - bots = getRandomMeleeBots(priorityAll, namesAll); - } else if (priorityMini.size() > 0 && namesMini.size() >= meleebots) { - bots = getRandomMeleeBots(priorityMini, namesMini); - } else if (priorityMicro.size() > 0 && namesMicro.size() >= meleebots) { - bots = getRandomMeleeBots(priorityMicro, namesMicro); - } else if (priorityNano.size() > 0 && namesNano.size() >= meleebots) { - bots = getRandomMeleeBots(priorityNano, namesNano); - } else if (namesAll.size() >= meleebots) { - bots = getRandomMeleeBots(namesAll, namesAll); - } - if (bots != null) { - StringBuilder battle = new StringBuilder(bots[0]); - - for (int i = 1; i < bots.length; i++) { - battle.append(',').append(bots[i]); - } - battle.append(',').append(runonly); - - outtxt.println(battle); - count++; - } - } - } - outtxt.close(); - return true; - } - - private String[] getRandomMeleeBots(List list1, List list2) { - String[] bots = new String[meleebots]; - - bots[0] = list1.get(RANDOM.nextInt(list1.size())); - int count = 1; - - while (count < meleebots) { - bots[count] = list2.get(RANDOM.nextInt(list2.size())); - boolean exists = false; - - for (int i = 0; i < count; i++) { - if (bots[i].equals(bots[count])) { - exists = true; - } - } - if (!exists) { - count++; - } - } - return bots; - } - - private String[] getRandomMeleeBots(String bot1, String bot2, List list2) { - String[] bots = new String[meleebots]; - - bots[0] = bot1; - bots[1] = bot2; - int count = 2; - - while (count < meleebots) { - bots[count] = list2.get(RANDOM.nextInt(list2.size())); - boolean exists = false; - - for (int i = 0; i < count; i++) { - if (bots[i].equals(bots[count])) { - exists = true; - } - } - if (!exists) { - count++; - } - } - return bots; - } -} diff --git a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java b/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java deleted file mode 100644 index b8c2d87..0000000 --- a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/BotsDownload.java +++ /dev/null @@ -1,625 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.roborumble.netengine; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.roborumble.battlesengine.CompetitionsSelector; -import static net.sf.robocode.roborumble.netengine.FileTransfer.DownloadStatus; -import static net.sf.robocode.roborumble.util.ExcludesUtil.*; -import static net.sf.robocode.roborumble.util.PropertiesUtil.getProperties; - -import java.io.*; -import java.net.HttpURLConnection; -import java.net.MalformedURLException; -import java.net.URL; -import java.net.URLConnection; -import java.util.Enumeration; -import java.util.HashSet; -import java.util.Properties; -import java.util.Set; -import java.util.Vector; -import java.util.jar.JarFile; -import java.util.zip.ZipEntry; - - -/** - * Class used for downloading participating robots from the Internet. - * Manages the download operations (participants and JAR files). - * Controlled by properties files. - * - * @author Albert Pérez (original) - * @author Flemming N. Larsen (contributor) - */ -public class BotsDownload { - - // private String internetrepository; - private final String botsrepository; - private final String participantsfile; - private final String participantsurl; - private final String tempdir; - private final String tag; - private final String isteams; - private final String sizesfile; - private final CompetitionsSelector size; - private final String ratingsurl; - private String generalBots; - private final String miniBots; - private final String microBots; - private final String nanoBots; - private final String generalbotsfile; - private final String minibotsfile; - private final String microbotsfile; - private final String nanobotsfile; - private final String removeboturl; - - public BotsDownload(String propertiesfile) { - // Read parameters - Properties parameters = getProperties(propertiesfile); - - botsrepository = parameters.getProperty("BOTSREP", ""); - isteams = parameters.getProperty("TEAMS", "NOT"); - participantsurl = parameters.getProperty("PARTICIPANTSURL", ""); - participantsfile = parameters.getProperty("PARTICIPANTSFILE", ""); - tag = parameters.getProperty("STARTAG", "pre"); - tempdir = parameters.getProperty("TEMP", ""); - - // Code size - sizesfile = parameters.getProperty("CODESIZEFILE", ""); - size = new CompetitionsSelector(sizesfile, botsrepository); - - // Ratings files - ratingsurl = parameters.getProperty("RATINGS.URL", ""); - generalBots = propertiesfile; - while (generalBots.indexOf("/") != -1) { - generalBots = generalBots.substring(generalBots.indexOf("/") + 1); - } - generalBots = generalBots.substring(0, generalBots.indexOf(".")); - miniBots = parameters.getProperty("MINIBOTS", ""); - microBots = parameters.getProperty("MICROBOTS", ""); - nanoBots = parameters.getProperty("NANOBOTS", ""); - generalbotsfile = parameters.getProperty("RATINGS.GENERAL", ""); - minibotsfile = parameters.getProperty("RATINGS.MINIBOTS", ""); - microbotsfile = parameters.getProperty("RATINGS.MICROBOTS", ""); - nanobotsfile = parameters.getProperty("RATINGS.NANOBOTS", ""); - // remove old bots - removeboturl = parameters.getProperty("UPDATEBOTSURL", ""); - - // Read and prepare exclude filters - setExcludes(parameters); - } - - public boolean downloadRatings() { - File file; - - // delete previous files - if (generalbotsfile.length() != 0) { - file = new File(generalbotsfile); - if (file.exists() && !file.delete()) { - Logger.logError("Can't delete file: " + file); - } - } - if (minibotsfile.length() != 0) { - file = new File(minibotsfile); - if (file.exists() && !file.delete()) { - Logger.logError("Can't delete file: " + file); - } - } - if (microbotsfile.length() != 0) { - file = new File(microbotsfile); - if (file.exists() && !file.delete()) { - Logger.logError("Can't delete file: " + file); - } - } - if (nanobotsfile.length() != 0) { - file = new File(nanobotsfile); - if (file.exists() && !file.delete()) { - Logger.logError("Can't delete file: " + file); - } - } - // download new ones - if (ratingsurl.length() == 0) { - return false; - } - boolean downloaded = true; - - if (generalBots.length() != 0 && generalbotsfile.length() != 0) { - downloaded = downloadRatingsFile(generalBots, generalbotsfile) & downloaded; - } - if (miniBots.length() != 0 && minibotsfile.length() != 0) { - downloaded = downloadRatingsFile(miniBots, minibotsfile) & downloaded; - } - if (microBots.length() != 0 && microbotsfile.length() != 0) { - downloaded = downloadRatingsFile(microBots, microbotsfile) & downloaded; - } - if (nanoBots.length() != 0 && nanobotsfile.length() != 0) { - downloaded = downloadRatingsFile(nanoBots, nanobotsfile) & downloaded; - } - return downloaded; - } - - public boolean downloadParticipantsList() { - String begin = "<" + tag + ">"; - String end = ""; - Vector bots = new Vector(); - - InputStream in = null; - InputStreamReader inputStreamReader = null; - BufferedReader bufferedReader = null; - HttpURLConnection conn = null; - - try { - URL url = new URL(participantsurl); - - conn = FileTransfer.connectToHttpInputConnection(url); - - // Check that we received a HTTP_OK response code. - // Bugfix [2779557] - Client tries to remove all participants. - if (conn.getResponseCode() != HttpURLConnection.HTTP_OK) { - System.out.print("Unable to retrieve participants list. Response is " + conn.getResponseCode()); - if (conn.getResponseMessage() != null) { - System.out.print(": " + conn.getResponseMessage()); - } - System.out.println(); - - return false; // Error - } - - boolean arebots = false; - - in = FileTransfer.getInputStream(conn); - inputStreamReader = new InputStreamReader(in); - bufferedReader = new BufferedReader(inputStreamReader); - - for (String participant; (participant = bufferedReader.readLine()) != null;) { - if (participant.indexOf(begin) >= 0) { - arebots = true; - } else if (participant.indexOf(end) >= 0) { - arebots = false; - } else if (arebots) { - String bot = participant.split("[,]")[0]; - - if (!isExcluded(bot)) { - if (!verifyParticipantFormat(participant)) { - if (participant.trim().length() > 0) { - System.out.println("Participant ignored due to invalid line: " + bot); - } - } else { - bots.add(participant); - } - } else { - System.out.println("Ignored excluded: " + bot); - } - } - } - - // Prevent our local participants file to be overwritten, if the downloaded list is empty. - // Bugfix [2779557] - Client tries to remove all participants. - if (bots.size() == 0) { - System.out.println("The participants list is empty"); - return false; // Error - } - - final File dir = new File(participantsfile).getParentFile(); - - if (!dir.exists() && !dir.mkdirs()) { - Logger.logError("Can't create directory: " + dir); - } - - PrintStream outtxt = new PrintStream(new BufferedOutputStream(new FileOutputStream(participantsfile)), false); - - for (String bot : bots) { - outtxt.println(bot); - } - outtxt.close(); - - } catch (IOException e) { - System.out.println("Unable to retrieve participants list:"); - System.out.println(e); - return false; // Error - } finally { - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (IOException ignored) {} - } - if (conn != null) { - conn.disconnect(); - } - } - return true; // Success - } - - public void downloadMissingBots() { - Vector jars = new Vector(); - Vector ids = new Vector(); - Vector names = new Vector(); - - // Read participants - - BufferedReader br = null; - - try { - FileReader fr = new FileReader(participantsfile); - br = new BufferedReader(fr); - - for (String record; (record = br.readLine()) != null;) { - if (record.indexOf(",") >= 0) { - String id = record.substring(record.indexOf(",") + 1).trim(); - String name = record.substring(0, record.indexOf(",")).trim(); - String jar = name.replace(' ', '_') + ".jar"; - - jars.add(jar); - ids.add(id); - names.add(name); - } - } - } catch (IOException e) { - System.out.println("Participants file not found ... Aborting"); - System.out.println(e); - return; - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignored) {} - } - } - - // check if the file exists in the repository and download if not present - for (int i = 0; i < jars.size(); i++) { - String botjar = jars.get(i); - String botid = ids.get(i); - String botname = names.get(i); - String botpath = botsrepository + botjar; - boolean exists = (new File(botpath)).exists(); - - if (!exists) { - boolean downloaded = downloadBot(botname, botjar, botid, botsrepository, tempdir); - if (!downloaded) { - System.out.println("Could not download " + botjar); - } - } - } - } - - public void updateCodeSize() { - if (sizesfile.length() != 0) { - BufferedReader br = null; - try { - FileReader fr = new FileReader(participantsfile); - br = new BufferedReader(fr); - - for (String record; (record = br.readLine()) != null;) { - String name = record.substring(0, record.indexOf(",")); - size.checkCompetitorForSize(name, 1500); - } - } catch (IOException e) { - System.out.println("Battles input file not found ... Aborting"); - System.out.println(e); - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignored) {} - } - } - } - } - - private boolean downloadBot(String botname, String file, String id, String destination, String tempdir) { - String tempFileName = tempdir + file; - String repositoryFileName = destination + file; - - // check if the bot exists in the repository - - boolean exists = (new File(repositoryFileName)).exists(); - if (exists) { - System.out.println("The bot already exists in the repository."); - return false; - } - - // Download the bot - - String url; - String sessionId = null; - - if (id.indexOf("://") == -1) { - url = "http://robocoderepository.com/Controller.jsp?submitAction=downloadClass&id=" + id; - - sessionId = FileTransfer.getSessionId( - "http://robocoderepository.com/BotSearch.jsp?botName=''&authorName=''&uploadDate="); - } else { - url = id; - } - - DownloadStatus downloadStatus = FileTransfer.download(url, tempFileName, sessionId); - - if (downloadStatus == DownloadStatus.FILE_NOT_FOUND) { - System.out.println("Could not find " + botname + " from " + url); - return false; - } else if (downloadStatus == DownloadStatus.COULD_NOT_CONNECT) { - System.out.println("Could not connect to " + url); - return false; - } - - // Check the bot and save it into the repository - - if (checkJarFile(tempFileName, botname)) { - if (!FileTransfer.copy(tempFileName, repositoryFileName)) { - System.out.println("Unable to copy " + tempFileName + " into the repository"); - return false; - } - } else { - System.out.println("Downloaded file is wrong or corrupted: " + file); - return false; - } - - System.out.println("Downloaded " + botname + " into " + repositoryFileName); - return true; - } - - private boolean checkJarFile(String file, String botname) { - if (botname.indexOf(" ") == -1) { - System.out.println("Are you sure " + botname + " is a bot/team? Can't download it."); - return false; - } - - String bot = botname.substring(0, botname.indexOf(" ")); - - bot = bot.replace('.', '/'); - if (isteams.equals("YES")) { - bot += ".team"; - } else { - bot += ".properties"; - } - - try { - JarFile jarf = new JarFile(file); - ZipEntry zipe = jarf.getJarEntry(bot); - - if (zipe == null) { - System.out.println("Not able to read properties"); - return false; - } - InputStream properties = jarf.getInputStream(zipe); - - Properties parameters = getProperties(properties); - - if (!isteams.equals("YES")) { - String classname = parameters.getProperty("robot.classname", ""); - String version = parameters.getProperty("robot.version", ""); - - return (botname.equals(classname + " " + version)); - } - String version = parameters.getProperty("team.version", ""); - - return (botname.equals(botname.substring(0, botname.indexOf(" ")) + " " + version)); - } catch (Exception e) { - System.out.println(e); - return false; - } - } - - // ---------------------------------------------------------------------------------- - // download ratings file - // ---------------------------------------------------------------------------------- - private boolean downloadRatingsFile(String competition, String file) { - - InputStream in = null; - InputStreamReader inputStreamReader = null; - BufferedReader bufferedReader = null; - PrintStream outtxt = null; - - try { - URL url = new URL(ratingsurl + "?version=1&game=" + competition); - - HttpURLConnection conn = FileTransfer.connectToHttpInputConnection(url); - - final File dir = new File(file).getParentFile(); - - if (!dir.exists() && !dir.mkdirs()) { - Logger.logError("Can't create directory: " + dir); - } - - outtxt = new PrintStream(new BufferedOutputStream(new FileOutputStream(file)), false); - - in = FileTransfer.getInputStream(conn); - inputStreamReader = new InputStreamReader(in); - bufferedReader = new BufferedReader(inputStreamReader); - - for (String str; (str = bufferedReader.readLine()) != null;) { - outtxt.println(str); - } - conn.disconnect(); - - } catch (IOException e) { - System.out.println("Unable to ratings for " + competition); - System.out.println(e); - return false; - } finally { - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (IOException ignored) {} - } - if (outtxt != null) { - outtxt.close(); - } - } - return true; - } - - // ---------------------------------------------------------------------------------- - // download ratings file - // ---------------------------------------------------------------------------------- - - public void notifyServerForOldParticipants() { - // Load participants names - Set namesAll = new HashSet(); - Set namesMini = new HashSet(); - Set namesMicro = new HashSet(); - Set namesNano = new HashSet(); - - BufferedReader br = null; - try { - FileReader fr = new FileReader(participantsfile); - br = new BufferedReader(fr); - - for (String record; (record = br.readLine()) != null;) { - if (record.indexOf(",") != -1) { - String name = record.substring(0, record.indexOf(",")).replace(' ', '_'); - - namesAll.add(name); - if (size.checkCompetitorForSize(name, 1500)) { - namesMini.add(name); - } - if (size.checkCompetitorForSize(name, 750)) { - namesMicro.add(name); - } - if (size.checkCompetitorForSize(name, 250)) { - namesNano.add(name); - } - } - } - } catch (IOException e) { - System.out.println("Participants file not found when removing old participants ... Aborting"); - System.out.println(e); - return; - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignored) {} - } - } - - // Load ratings files - Properties generalRatings = getProperties(generalbotsfile); - Properties miniRatings = getProperties(minibotsfile); - Properties microRatings = getProperties(microbotsfile); - Properties nanoRatings = getProperties(nanobotsfile); - - // Check general ratings - for (Enumeration e = generalRatings.propertyNames(); e.hasMoreElements();) { - String bot = (String) e.nextElement(); - - if (!(isExcluded(bot) || namesAll.contains(bot))) { - // Remove the bot from the ratings file - System.out.println("Removing entry ... " + bot + " from " + generalBots); - removeBot(generalBots, bot); - } - } - // Check mini ratings - for (Enumeration e = miniRatings.propertyNames(); e.hasMoreElements();) { - String bot = (String) e.nextElement(); - - if (!(isExcluded(bot) || namesMini.contains(bot))) { - // Remove the bot from the ratings file - System.out.println("Removing entry ... " + bot + " from " + miniBots); - removeBot(miniBots, bot); - } - } - - // Check micro ratings - for (Enumeration e = microRatings.propertyNames(); e.hasMoreElements();) { - String bot = (String) e.nextElement(); - - if (!(isExcluded(bot) || namesMicro.contains(bot))) { - // Remove the bot from the ratings file - System.out.println("Removing entry ... " + bot + " from " + microBots); - removeBot(microBots, bot); - } - } - - // Check nano ratings - for (Enumeration e = nanoRatings.propertyNames(); e.hasMoreElements();) { - String bot = (String) e.nextElement(); - - if (!(isExcluded(bot) || namesNano.contains(bot))) { - // Remove the bot from the ratings file - System.out.println("Removing entry ... " + bot + " from " + nanoBots); - removeBot(nanoBots, bot); - } - } - } - - private void removeBot(String game, String bot) { - if (removeboturl.length() == 0) { - System.out.println("UPDATEBOTS URL not defined!"); - return; - } - - String data = "version=1&game=" + game + "&name=" + bot.trim() + "&dummy=NA"; - - OutputStream out = null; - OutputStreamWriter outputStreamWriter = null; - PrintWriter wr = null; - InputStream in = null; - InputStreamReader inputStreamReader = null; - BufferedReader bufferedReader = null; - - try { - // Send data - URLConnection conn = FileTransfer.openOutputURLConnection(new URL(removeboturl)); - - out = FileTransfer.getOutputStream(conn); - outputStreamWriter = new OutputStreamWriter(out); - wr = new PrintWriter(outputStreamWriter); - - wr.println(data); - wr.flush(); - - // Get the response - in = FileTransfer.getInputStream(conn); - inputStreamReader = new InputStreamReader(in); - bufferedReader = new BufferedReader(inputStreamReader); - - for (String line; (line = bufferedReader.readLine()) != null;) { - System.out.println(line); - } - } catch (IOException e) { - System.out.println(e); - } finally { - if (wr != null) { - wr.close(); - } - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (IOException ignored) {} - } - } - } - - // Checks if a participant format from the participant list is valid - private boolean verifyParticipantFormat(String participant) { - String[] split = participant.split("[,]"); - - boolean matches = false; - - if (split.length == 2) { - String robot = split[0].trim(); - String link = split[1].trim(); - - if (robot.matches("[\\w\\.]+[ ][\\w\\.-]+")) { - if (link.startsWith("http")) { - try { - new URL(link); - matches = true; - } catch (MalformedURLException e) { - matches = false; - } - } else if (link.matches("[\\d]+")) { - matches = true; - } - } - } - return matches; - } -} diff --git a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/FileTransfer.java b/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/FileTransfer.java deleted file mode 100644 index c686e5a..0000000 --- a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/FileTransfer.java +++ /dev/null @@ -1,657 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.roborumble.netengine; - - -import java.io.*; -import java.net.HttpURLConnection; -import java.net.URL; -import java.net.URLConnection; -import java.util.Properties; -import java.util.zip.GZIPInputStream; -import java.util.zip.InflaterInputStream; - -import static net.sf.robocode.roborumble.util.PropertiesUtil.getProperties; - - -/** - * Utility class for downloading files from the net and copying files. - * - * @author Flemming N. Larsen (original) - */ -public class FileTransfer { - - private final static int DEFAULT_CONNECTION_TIMEOUT = 10000; // 10 seconds - private final static int DEFAULT_READ_TIMEOUT = 10000; // 10 seconds - private final static int DEFAULT_SESSION_TIMEOUT = 10000; // 10 seconds - - private static int connectionTimeout = DEFAULT_CONNECTION_TIMEOUT; - private static int readTimeout = DEFAULT_READ_TIMEOUT; - private static int sessionTimeout = DEFAULT_SESSION_TIMEOUT; - - static { - readProperties(); - } - - /** - * Represents the download status returned when downloading files. - */ - public enum DownloadStatus { - OK, // The download was succesful - COULD_NOT_CONNECT, // Connection problem - FILE_NOT_FOUND, // The file to download was not found - } - - - /** - * Daemon worker thread containing a 'finish' flag for waiting and notifying when the thread has finished it's job. - */ - private static class WorkerThread extends Thread { - - final Object monitor = new Object(); - - volatile boolean isFinished; - - public WorkerThread(String name) { - super(name); - setDaemon(true); - } - - void notifyFinish() { - // Notify that this thread is finish - synchronized (monitor) { - isFinished = true; - monitor.notifyAll(); - } - } - } - - /* - * Returns a session id for keeping a session on a HTTP site. - * - * @param url is the url of the HTTP site. - * - * @return a session id for keeping a session on a HTTP site or null if no session is available. - */ - public static String getSessionId(String url) { - HttpURLConnection conn = null; - - try { - // Open connection - conn = FileTransfer.connectToHttpInputConnection(new URL(url)); - if (conn == null) { - throw new IOException("Could not open connection to '" + url + "'"); - } - - // Get a session id if available - final GetSessionIdThread sessionIdThread = new GetSessionIdThread(conn); - - sessionIdThread.start(); - - // Wait for the session id - synchronized (sessionIdThread.monitor) { - while (!sessionIdThread.isFinished) { - try { - sessionIdThread.monitor.wait(sessionTimeout); - sessionIdThread.interrupt(); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - - return null; - } - } - } - - // Return the session id - return sessionIdThread.sessionId; - - } catch (final IOException e) { - return null; - } finally { - // Make sure the connection is disconnected. - // This will cause threads using the connection to throw an exception - // and thereby terminate if they were hanging. - if (conn != null) { - conn.disconnect(); - } - } - } - - /** - * Worker thread used for getting the session id of an already open HTTP connection. - */ - private final static class GetSessionIdThread extends WorkerThread { - - // The resulting session id to read out - String sessionId; - - final HttpURLConnection conn; - - GetSessionIdThread(HttpURLConnection conn) { - super("FileTransfer: Get session ID"); - this.conn = conn; - } - - @Override - public void run() { - try { - // Get the cookie value - final String cookieVal = conn.getHeaderField("Set-Cookie"); - - // Extract the session id from the cookie value - if (cookieVal != null) { - sessionId = cookieVal.substring(0, cookieVal.indexOf(";")); - } - } catch (final Exception e) { - sessionId = null; - } - // Notify that this thread is finish - notifyFinish(); - } - } - - /** - * Downloads a file from a HTTP site. - * - * @param url is the url of the HTTP site to download the file from. - * @param filename is the filename of the destination file. - * @param sessionId is an optional session id if the download is session based. - * @return the download status, which is DownloadStatus.OK if the download completed successfully; otherwise an - * error occurred. - */ - public static DownloadStatus download(String url, String filename, String sessionId) { - HttpURLConnection conn = null; - - try { - // Create connection - conn = connectToHttpInputConnection(new URL(url), sessionId); - if (conn == null) { - throw new IOException("Could not open connection to: " + url); - } - - // Begin the download - final DownloadThread downloadThread = new DownloadThread(conn, filename); - - downloadThread.start(); - - // Wait for the download to complete - synchronized (downloadThread.monitor) { - while (!downloadThread.isFinished) { - try { - downloadThread.monitor.wait(); - } catch (InterruptedException e) { - return DownloadStatus.COULD_NOT_CONNECT; - } - } - } - - // Return the download status - return downloadThread.status; - - } catch (final IOException e) { - return DownloadStatus.COULD_NOT_CONNECT; - } finally { - // Make sure the connection is disconnected. - // This will cause threads using the connection to throw an exception - // and thereby terminate if they were hanging. - try { - if (conn != null) { - conn.disconnect(); - } - } catch (Throwable ignore) {// we expect this, right ? - } - } - } - - /** - * Worker thread used for downloading a file from an already open HTTP connection. - */ - private final static class DownloadThread extends WorkerThread { - - // The download status to be read out - DownloadStatus status = DownloadStatus.COULD_NOT_CONNECT; // Default error - - final HttpURLConnection conn; - final String filename; - - InputStream in; - OutputStream out; - - DownloadThread(HttpURLConnection conn, String filename) { - super("FileTransfer: Download"); - this.conn = conn; - this.filename = filename; - } - - @Override - public void run() { - try { - // Start getting the response code - final GetResponseCodeThread responseThread = new GetResponseCodeThread(conn); - - responseThread.start(); - - // Wait for the response to finish - synchronized (responseThread.monitor) { - while (!responseThread.isFinished) { - try { - responseThread.monitor.wait(sessionTimeout); - responseThread.interrupt(); - } catch (InterruptedException e) { - notifyFinish(); - return; - } - } - } - - final int responseCode = responseThread.responseCode; - - if (responseCode == -1) { - // Terminate if we did not get the response code - notifyFinish(); - return; - - } else if (responseCode == HttpURLConnection.HTTP_NOT_FOUND) { - // Terminate if the HTTP page containing the file was not found - status = DownloadStatus.FILE_NOT_FOUND; - notifyFinish(); - return; - - } else if (responseCode != HttpURLConnection.HTTP_OK) { - // Generally, terminate if did not receive a OK response - notifyFinish(); - return; - } - - // Start getting the size of the file to download - final GetContentLengthThread contentLengthThread = new GetContentLengthThread(conn); - - contentLengthThread.start(); - - // Wait for the file size - synchronized (contentLengthThread.monitor) { - while (!contentLengthThread.isFinished) { - try { - contentLengthThread.monitor.wait(sessionTimeout); - contentLengthThread.interrupt(); - } catch (InterruptedException e) { - notifyFinish(); - return; - } - } - } - - final int size = contentLengthThread.contentLength; - - if (size == -1) { - // Terminate if we did not get the content length - notifyFinish(); - return; - } - - // Get the input stream from the connection - in = getInputStream(conn); - - // Prepare the output stream for the file output - out = new FileOutputStream(filename); - - // Download the file - - final byte[] buf = new byte[4096]; - - int totalRead = 0; - int bytesRead; - - // Start thread for reading bytes into the buffer - - while (totalRead < size) { - // Start reading bytes into the buffer - final ReadInputStreamToBufferThread readThread = new ReadInputStreamToBufferThread(in, buf); - - readThread.start(); - - // Wait for the reading to finish - synchronized (readThread.monitor) { - while (!readThread.isFinished) { - try { - readThread.monitor.wait(sessionTimeout); - readThread.interrupt(); - } catch (InterruptedException e) { - notifyFinish(); - return; - } - } - } - - bytesRead = readThread.bytesRead; - if (bytesRead == -1) { - // Read completed has completed - notifyFinish(); - break; - } - - // Write the byte buffer to the output - out.write(buf, 0, bytesRead); - - totalRead += bytesRead; - } - - // If we reached this point, the download was successful - status = DownloadStatus.OK; - - notifyFinish(); - - } catch (final IOException e) { - status = DownloadStatus.COULD_NOT_CONNECT; - } finally { - // Make sure the input stream is closed - if (in != null) { - try { - in.close(); - } catch (final IOException e) { - e.printStackTrace(); - } - } - // Make sure the output stream is closed - if (out != null) { - try { - out.close(); - } catch (final IOException e) { - e.printStackTrace(); - } - } - } - } - } - - - /** - * Worker thread used for getting the response code of an already open HTTP connection. - */ - final static class GetResponseCodeThread extends WorkerThread { - - // The response code to read out - int responseCode; - - final HttpURLConnection conn; - - GetResponseCodeThread(HttpURLConnection conn) { - super("FileTransfer: Get response code"); - this.conn = conn; - } - - @Override - public void run() { - try { - // Get the response code - responseCode = conn.getResponseCode(); - } catch (final Exception e) { - responseCode = -1; - } - // Notify that this thread is finish - notifyFinish(); - } - } - - - /** - * Worker thread used for getting the content length of an already open HTTP connection. - */ - final static class GetContentLengthThread extends WorkerThread { - - // The content length to read out - int contentLength; - - final HttpURLConnection conn; - - GetContentLengthThread(HttpURLConnection conn) { - super("FileTransfer: Get content length"); - this.conn = conn; - } - - @Override - public void run() { - try { - // Get the content length - contentLength = conn.getContentLength(); - } catch (final Exception e) { - contentLength = -1; - } - // Notify that this thread is finish - notifyFinish(); - } - } - - - /** - * Worker thread used for reading bytes from an already open input stream into a byte buffer. - */ - final static class ReadInputStreamToBufferThread extends WorkerThread { - - int bytesRead; - - final InputStream in; - - final byte[] buf; - - ReadInputStreamToBufferThread(InputStream in, byte[] buf) { - super("FileTransfer: Read input stream to buffer"); - this.in = in; - this.buf = buf; - } - - @Override - public void run() { - try { - // Read bytes into the buffer - bytesRead = in.read(buf); - } catch (final Exception e) { - bytesRead = -1; - } - // Notify that this thread is finish - notifyFinish(); - } - } - - /** - * Copies a file into another file. - * - * @param srcFile is the filename of the source file to copy. - * @param destFile is the filename of the destination file to copy the file into. - * @return true if the file was copied; false otherwise - */ - public static boolean copy(String srcFile, String destFile) { - FileInputStream in = null; - FileOutputStream out = null; - - try { - if (srcFile.equals(destFile)) { - throw new IOException("You cannot copy a file onto itself"); - } - final byte[] buf = new byte[4096]; - - in = new FileInputStream(srcFile); - out = new FileOutputStream(destFile); - - while (in.available() > 0) { - out.write(buf, 0, in.read(buf, 0, buf.length)); - } - } catch (final IOException e) { - return false; - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - if (out != null) { - try { - out.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return true; - } - - /** - * Opens and connects to a {@link java.net.HttpURLConnection} for input only, and where the connection timeout and - * read timeout are controlled by properties. - * - * @param url is the URL to open a connection to. - * @return a HttpURLConnection intended for reading input only. - * @throws IOException if an I/O exception occurs. - */ - public static HttpURLConnection connectToHttpInputConnection(URL url) throws IOException { - return connectToHttpInputConnection(url, null); - } - - /** - * Opens and connects to a {@link java.net.HttpURLConnection} for input only, and where the connection timeout and - * read timeout are controlled by properties. - * - * @param url is the URL to open a connection to. - * @param sessionId is a optional session id. - * @return a HttpURLConnection intended for reading input only. - * @throws IOException if an I/O exception occurs. - */ - public static HttpURLConnection connectToHttpInputConnection(URL url, String sessionId) throws IOException { - HttpURLConnection conn = (HttpURLConnection) openURLConnection(url, false); // not for output - - conn.setRequestMethod("GET"); - if (sessionId != null) { - conn.setRequestProperty("Cookie", sessionId); - } - conn.connect(); - return conn; - } - - /** - * Opens a {link {@link java.net.URLConnection} for output (and input) where the connection timeout and read timeout - * are controlled by properties. - * - * @param url is the URL to open. - * @return a URLConnection for output. - * @throws IOException if an I/O exception occurs. - */ - public static URLConnection openOutputURLConnection(URL url) throws IOException { - return openURLConnection(url, true); // for output - } - - /** - * Convenient method used for getting an input stream from an URLConnection. - * This method checks if a GZIPInputStream or InflaterInputStream should be used to wrap the input stream from the - * URLConnection depending on the content encoding. - * - * @param conn is the URLConnection - * @return an input stream from the URLConnection, which can be a GZIPInputStream or InflaterInputStream. - * @throws IOException if an I/O exception occurs. - */ - public static InputStream getInputStream(URLConnection conn) throws IOException { - // Get input stream - InputStream in = conn.getInputStream(); - - // Get the encoding returned by the server - String encoding = conn.getContentEncoding(); - - // Check if we need to use a gzip or inflater input stream depending on the content encoding - if ("gzip".equalsIgnoreCase(encoding)) { - in = new GZIPInputStream(in); - } else if ("deflate".equalsIgnoreCase(encoding)) { - in = new InflaterInputStream(in); - } - return in; - } - - /** - * Convenient method used for getting an output stream from an URLConnection. - * This method checks if a GZIPOutputStream or DeflaterOutputStream should be used to wrap the output stream from - * the URLConnection depending on the content encoding. - * - * @param conn is the URLConnection - * @return an output stream from the URLConnection, which can be a GZIPOutputStream or DeflaterOutputStream. - * @throws IOException if an I/O exception occurs. - */ - public static OutputStream getOutputStream(URLConnection conn) throws IOException { - // Get output stream - OutputStream out = conn.getOutputStream(); - - // // Get the encoding returned by the server - // String encoding = conn.getContentEncoding(); - // - // // Check if we need to use a gzip or inflater input stream depending on the content encoding - // if ("gzip".equalsIgnoreCase(encoding)) { - // out = new GZIPOutputStream(out); - // } else if ("deflate".equalsIgnoreCase(encoding)) { - // out = new DeflaterOutputStream(out); - // } - return out; - } - - /** - * Opens a {link {@link java.net.URLConnection} for input and optional output where the connection timeout and read - * timeout are controlled by properties. - * - * @param url is the URL to open. - * @param isOutput is a flag specifying if the opened connection is for output. - * @return a URLConnection. - * @throws IOException if an I/O exception occurs. - */ - public static URLConnection openURLConnection(URL url, boolean isOutput) throws IOException { - URLConnection conn = url.openConnection(); - - conn.setDoInput(true); - conn.setDoOutput(isOutput); - - conn.setConnectTimeout(connectionTimeout); - conn.setReadTimeout(readTimeout); - - if (!isOutput) { - // Allow both GZip and Deflate (ZLib) encodings - conn.setRequestProperty("Accept-Encoding", "gzip, deflate"); - conn.setRequestProperty("User-Agent", "RoboRumble@Home - gzip, deflate"); - } - return conn; - } - - /** - * Reads the roborumble.properties file and stores property values into global variables. - */ - private static void readProperties() { - Properties props = getProperties("./roborumble/roborumble.properties"); - - // Get connection timeout - String value = props.getProperty("connection.open.timeout"); - - if (value != null) { - try { - connectionTimeout = Integer.parseInt(value); - } catch (NumberFormatException ignore) {} - } - - // Get connection read timeout - value = props.getProperty("connection.read.timeout"); - if (value != null) { - try { - readTimeout = Integer.parseInt(value); - } catch (NumberFormatException ignore) {} - } - - // Get download session timeout - value = props.getProperty("download.session.timeout"); - if (value != null) { - try { - sessionTimeout = Integer.parseInt(value); - } catch (NumberFormatException ignore) {} - } - } -} diff --git a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/ResultsUpload.java b/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/ResultsUpload.java deleted file mode 100644 index aaa5246..0000000 --- a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/ResultsUpload.java +++ /dev/null @@ -1,328 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.roborumble.netengine; - - -import net.sf.robocode.roborumble.battlesengine.CompetitionsSelector; -import static net.sf.robocode.roborumble.util.PropertiesUtil.getProperties; - -import java.io.*; -import java.net.URL; -import java.net.URLConnection; -import java.util.Properties; -import java.util.Vector; - - -/** - * Class used for uploading results to a server. - * Controlled by properties files. - * - * @author Albert Pérez (original) - * @author Flemming N. Larsen (contributor) - */ -public class ResultsUpload { - - private final String client; - private final String resultsfile; - private final String resultsurl; - private final String tempdir; - private String game; - private final String user; - private final String sizesfile; - private final String minibots; - private final String microbots; - private final String nanobots; - private final CompetitionsSelector size; - private final String battlesnumfile; - private final String priority; - private final String teams; - private final String melee; - - public ResultsUpload(String propertiesfile, String clientVersion) { - // Read parameters - Properties parameters = getProperties(propertiesfile); - - resultsfile = parameters.getProperty("OUTPUT", ""); - resultsurl = parameters.getProperty("RESULTSURL", ""); - tempdir = parameters.getProperty("TEMP", ""); - user = parameters.getProperty("USER", ""); - game = propertiesfile; - String botsrepository = parameters.getProperty("BOTSREP", ""); - - while (game.indexOf("/") != -1) { - game = game.substring(game.indexOf("/") + 1); - } - game = game.substring(0, game.indexOf(".")); - sizesfile = parameters.getProperty("CODESIZEFILE", ""); - minibots = parameters.getProperty("MINIBOTS", ""); - microbots = parameters.getProperty("MICROBOTS", ""); - nanobots = parameters.getProperty("NANOBOTS", ""); - battlesnumfile = parameters.getProperty("BATTLESNUMFILE", ""); - priority = parameters.getProperty("PRIORITYBATTLESFILE", ""); - client = clientVersion; - teams = parameters.getProperty("TEAMS", "NOT"); - melee = parameters.getProperty("MELEE", "NOT"); - - // Open competitions selector - size = new CompetitionsSelector(sizesfile, botsrepository); - } - - public void uploadResults() { - - boolean errorsfound = false; - - // Read the results file - - Vector results = new Vector(); - String match = ""; - String bot1 = ""; - String bot2; - int status = 0; - BufferedReader br = null; - - try { - FileReader fr = new FileReader(resultsfile); - - br = new BufferedReader(fr); - String record; - - while ((record = br.readLine()) != null) { - if (record.indexOf(game) != -1) { - match = record; - status = 0; - } else if (status == 0) { - bot1 = record; - status = 1; - } else if (status == 1) { - bot2 = record; - results.add(match); - results.add(bot1); - results.add(bot2); - } - } - } catch (IOException e) { - System.out.println("Can't open result file for upload"); - return; - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignored) {} - } - } - - // Open the temp file to put the unuploaded results - PrintStream outtxt; - - try { - outtxt = new PrintStream(new BufferedOutputStream(new FileOutputStream(tempdir + "results.txt")), false); - } catch (IOException e) { - System.out.println("Not able to open output file ... Aborting"); - System.out.println(e); - return; - } - - // Open the file to put the battles number for each participant - PrintStream battlesnum; - - try { - battlesnum = new PrintStream(new BufferedOutputStream(new FileOutputStream(battlesnumfile)), false); - } catch (IOException e) { - System.out.println("Not able to open battles number file ... Aborting"); - System.out.println(e); - - outtxt.close(); - return; - } - - // Open the file to put the battles which have priority - PrintStream prioritybattles; - - try { - prioritybattles = new PrintStream(new BufferedOutputStream(new FileOutputStream(priority)), false); - } catch (IOException e) { - System.out.println("Not able to open priorities file ... Aborting"); - System.out.println(e); - - outtxt.close(); - battlesnum.close(); - return; - } - - // Post the results - - for (int i = 0; i < results.size() / 3; i++) { - - // Create the parameters String - String[] header = results.get(i * 3).split(","); - String[] first = results.get(i * 3 + 1).split(","); - String[] second = results.get(i * 3 + 2).split(","); - - // find the match mode - String matchtype = "GENERAL"; - - if (header.length >= 6) { - matchtype = header[5]; - } - - // if the match mode was general, then send the results to all competitions (assuming codesize is used). - // if its not, then send results only to smaller size competitions - - final String commonData = "&version=1" + "&client=" + client + "&teams=" + teams + "&melee=" + melee - + "&rounds=" + header[1] + "&field=" + header[2] + "&user=" + user + "&time=" + header[4] + "&fname=" - + first[0] + "&fscore=" + first[1] + "&fbulletd=" + first[2] + "&fsurvival=" + first[3] + "&sname=" - + second[0] + "&sscore=" + second[1] + "&sbulletd=" + second[2] + "&ssurvival=" + second[3]; - - String data = "game=" + game + commonData; - - if (matchtype.equals("GENERAL") || matchtype.equals("SERVER")) { - errorsfound = errorsfound | senddata(game, data, outtxt, true, results, i, battlesnum, prioritybattles); - } - - if (sizesfile.length() != 0) { // upload also related competitions - if (minibots.length() != 0 && !matchtype.equals("NANO") && !matchtype.equals("MICRO") - && size.checkCompetitorsForSize(first[0], second[0], 1500)) { - data = "game=" + minibots + commonData; - errorsfound = errorsfound - | senddata(minibots, data, outtxt, true, results, i, battlesnum, prioritybattles); - } - if (microbots.length() != 0 && !matchtype.equals("NANO") - && size.checkCompetitorsForSize(first[0], second[0], 750)) { - data = "game=" + microbots + commonData; - errorsfound = errorsfound - | senddata(microbots, data, outtxt, true, results, i, battlesnum, prioritybattles); - } - if (nanobots.length() != 0 && size.checkCompetitorsForSize(first[0], second[0], 250)) { - data = "game=" + nanobots + commonData; - errorsfound = errorsfound - | senddata(nanobots, data, outtxt, true, results, i, battlesnum, prioritybattles); - } - } - } - - // close files - outtxt.close(); - battlesnum.close(); - prioritybattles.close(); - - // delete results file - File r = new File(resultsfile); - boolean b = r.delete(); - - if (!b) { - System.out.println("Unable to delete results file."); - } - - // copy temp file into results file if there was some error - if (errorsfound) { - if (!FileTransfer.copy(tempdir + "results.txt", resultsfile)) { - System.out.println("Error when copying results errors file."); - } - } - } - - private void saveError(PrintStream outtxt, String match, String bot1, String bot2, boolean saveonerror) { - if (saveonerror) { - outtxt.println(match); - outtxt.println(bot1); - outtxt.println(bot2); - } - System.out.println("Unable to upload results " + match + " " + bot1 + " " + bot2); - } - - private boolean senddata(String game, String data, PrintStream outtxt, boolean saveonerror, Vector results, int i, PrintStream battlesnum, PrintStream prioritybattles) { - boolean errorsfound = false; - OutputStream out = null; - OutputStreamWriter outputStreamWriter = null; - PrintWriter wr = null; - InputStream in = null; - InputStreamReader inputStreamReader = null; - BufferedReader bufferedReader = null; - - try { - // Send data - URLConnection conn = FileTransfer.openOutputURLConnection(new URL(resultsurl)); - - out = FileTransfer.getOutputStream(conn); - outputStreamWriter = new OutputStreamWriter(out); - wr = new PrintWriter(outputStreamWriter); - - wr.println(data); - wr.flush(); - - // Get the response - in = FileTransfer.getInputStream(conn); - inputStreamReader = new InputStreamReader(in); - bufferedReader = new BufferedReader(inputStreamReader); - - String line; - boolean ok = false; - - while ((line = bufferedReader.readLine()) != null) { - if (line.indexOf("OK") != -1) { - ok = true; - System.out.println(line); - } else if (line.indexOf("<") != -1 && line.indexOf(">") != -1) { - // System.out.println(line); - // Save the number of battles for the bots into battlesnum !!!!!!!!!!!!! - String bot1 = results.get(i * 3 + 1); - - bot1 = bot1.substring(0, bot1.indexOf(",")); - String bot2 = results.get(i * 3 + 2); - - bot2 = bot2.substring(0, bot2.indexOf(",")); - line = line.replaceAll("<", ""); - line = line.replaceAll(">", ""); - String[] b = line.split(" "); - - if (b.length == 2) { - battlesnum.println(game + "," + bot1 + "," + b[0]); - battlesnum.println(game + "," + bot2 + "," + b[1]); - } - } else if (line.indexOf("[") != -1 && line.indexOf("]") != -1) { - line = line.substring(1); - line = line.substring(0, line.length() - 1); - String[] items = line.split(","); - String bot1 = items[0].substring(0, items[0].lastIndexOf("_")) + " " - + items[0].substring(items[0].lastIndexOf("_") + 1); - String bot2 = items[1].substring(0, items[1].lastIndexOf("_")) + " " - + items[1].substring(items[1].lastIndexOf("_") + 1); - String battle = bot1 + "," + bot2 + "," + "SERVER"; - - if (prioritybattles != null) { - prioritybattles.println(battle); - } - } else { - System.out.println(line); - } - } - if (!ok) { - saveError(outtxt, results.get(i * 3), results.get(i * 3 + 1), results.get(i * 3 + 2), saveonerror); - if (saveonerror) { - errorsfound = true; - } - } - } catch (IOException e) { - System.out.println(e); - if (saveonerror) { - errorsfound = true; - } - saveError(outtxt, results.get(i * 3), results.get(i * 3 + 1), results.get(i * 3 + 2), saveonerror); - } finally { - if (wr != null) { - wr.close(); - } - if (bufferedReader != null) { - try { - bufferedReader.close(); - } catch (IOException ignored) {} - } - } - return errorsfound; - } -} diff --git a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/UpdateRatingFiles.java b/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/UpdateRatingFiles.java deleted file mode 100644 index ea9c212..0000000 --- a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/netengine/UpdateRatingFiles.java +++ /dev/null @@ -1,130 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.roborumble.netengine; - - -import static net.sf.robocode.roborumble.util.PropertiesUtil.getProperties; -import static net.sf.robocode.roborumble.util.PropertiesUtil.storeProperties; - -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.util.Properties; -import java.util.Vector; - - -/** - * Class used for updating the local rating files. - * Controlled by properties files. - * - * @author Albert Pérez (original) - * @author Flemming N. Larsen (contributor) - */ -public class UpdateRatingFiles { - - private String game; - private final String minibots; - private final String microbots; - private final String nanobots; - private final String battlesnumfile; - private final String generalratings; - private final String miniratings; - private final String microratings; - private final String nanoratings; - - public UpdateRatingFiles(String propertiesfile) { - // Read parameters - Properties parameters = getProperties(propertiesfile); - - game = propertiesfile; - while (game.indexOf("/") != -1) { - game = game.substring(game.indexOf("/") + 1); - } - game = game.substring(0, game.indexOf(".")); - minibots = parameters.getProperty("MINIBOTS", ""); - microbots = parameters.getProperty("MICROBOTS", ""); - nanobots = parameters.getProperty("NANOBOTS", ""); - - battlesnumfile = parameters.getProperty("BATTLESNUMFILE", ""); - - generalratings = parameters.getProperty("RATINGS.GENERAL", ""); - miniratings = parameters.getProperty("RATINGS.MINIBOTS", ""); - microratings = parameters.getProperty("RATINGS.MICROBOTS", ""); - nanoratings = parameters.getProperty("RATINGS.NANOBOTS", ""); - } - - public boolean updateRatings() { - - // read all the records to be updated - Vector battles = new Vector(); - BufferedReader br = null; - - try { - FileReader fr = new FileReader(battlesnumfile); - - br = new BufferedReader(fr); - String record; - - while ((record = br.readLine()) != null) { - battles.add(record); - } - } catch (IOException e) { - System.out.println("Can't open # battles file ... Aborting # battles update"); - return false; - } finally { - if (br != null) { - try { - br.close(); - } catch (IOException ignored) {} - } - } - - // read the ratings files - Properties all = getProperties(generalratings); - Properties mini = getProperties(miniratings); - Properties micro = getProperties(microratings); - Properties nano = getProperties(nanoratings); - - // update #battles - for (String battle : battles) { - String[] battleSpec = battle.split(","); - - battleSpec[1] = battleSpec[1].replaceAll(" ", "_"); - double num = Double.parseDouble(battleSpec[2]); - - if (battleSpec[0].equals(game)) { - updateRecord(battleSpec[1], num, all); - } else if (battleSpec[0].equals(minibots) && mini != null) { - updateRecord(battleSpec[1], num, mini); - } else if (battleSpec[0].equals(microbots) && micro != null) { - updateRecord(battleSpec[1], num, micro); - } else if (battleSpec[0].equals(nanobots) && nano != null) { - updateRecord(battleSpec[1], num, nano); - } - } - - // save ratings files - return storeProperties(all, generalratings, "General ratings updated with new battles number") - && storeProperties(all, miniratings, "Mini ratings updated with new battles number") - && storeProperties(all, microratings, "Micro ratings updated with new battles number") - && storeProperties(all, nanoratings, "Nano ratings updated with new battles number"); - } - - private void updateRecord(String bot, double battles, Properties ratings) { - String values = ratings.getProperty(bot); - - if (values == null) { - return; - } - - String[] value = values.split(","); - - values = value[0] + "," + Double.toString(battles) + "," + value[2]; - ratings.setProperty(bot, values); - } -} diff --git a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/util/ExcludesUtil.java b/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/util/ExcludesUtil.java deleted file mode 100644 index fd8bb56..0000000 --- a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/util/ExcludesUtil.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.roborumble.util; - - -import java.util.Properties; - - -/** - * Utility class for working with the EXCLUDE property for excluding robots from download and battles. - * - * @author Flemming N. Larsen (original) - */ -public class ExcludesUtil { - - private static String[] excludes; - - /** - * Read and prepared exclude filters for robots that should not be downloaded or participate in battles. - * - * @param properties the properties to store. - * @return a string array containing the excluded robots or null if no excludes are defined. - */ - public static void setExcludes(Properties properties) { - if (excludes != null) { - return; - } - - // Read and prepare exclude filters - String exclude = properties.getProperty("EXCLUDE"); - - if (exclude != null) { - // Convert into regular expression - - // Dots must be dots, not "any character" in the regular expression - exclude = exclude.replaceAll("\\.", "\\\\."); - - // The wildcard character ? corresponds to the regular expression .? - exclude = exclude.replaceAll("\\?", ".?"); - - // The wildcard character * corresponds to the regular expression .* - exclude = exclude.replaceAll("\\*", ".*"); - - // Split the exclude line into independent exclude filters that are trimmed for white-spaces - excludes = exclude.split("[,;]+"); // white spaces are allowed in the filter due to robot version numbers - } - } - - /** - * Checks if a participant is excluded. - * - * @param botNameVersion the name and version of the participant. - * @return true if the participant is excluded; false otherwise. - */ - public static boolean isExcluded(String botNameVersion) { - if (excludes == null) { - return false; - } - - // Check the name against all exclude filters - for (int i = excludes.length - 1; i >= 0; i--) { - try { - if (botNameVersion.matches(excludes[i])) { - return true; - } - } catch (java.util.regex.PatternSyntaxException e) { - // Clear the current exclude if the syntax is illegal (for next time this method is called) - excludes[i] = ""; - } - } - - // Not excluded - return false; - } -} diff --git a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/util/PropertiesUtil.java b/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/util/PropertiesUtil.java deleted file mode 100644 index 2527f1d..0000000 --- a/workspace_robo/robocode.roborumble/src/main/java/net/sf/robocode/roborumble/util/PropertiesUtil.java +++ /dev/null @@ -1,102 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.roborumble.util; - - -import java.io.FileInputStream; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.util.Properties; - - -/** - * @author Flemming N. Larsen (original) - */ -public final class PropertiesUtil { - - /** - * Returns a new Properties instance that is initialized to the specified properties file. - * - * @param filename the filename of the properties file to load - * @return a new java.util.Properties instance - */ - public static Properties getProperties(String filename) { - Properties props = new Properties(); - - if (filename != null && filename.trim().length() > 0) { - FileInputStream fis = null; - - try { - fis = new FileInputStream(filename); - props.load(fis); - } catch (IOException e) { - System.err.println("Could not load properties file: " + filename); - } finally { - if (fis != null) { - try { - fis.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } - return props; - } - - /** - * Returns a new Properties instance that is initialized to the specified properties input stream. - * - * @param is the input stream of the properties to load - * @return a new java.util.Properties instance - */ - public static Properties getProperties(InputStream is) { - Properties props = new Properties(); - - try { - props.load(is); - } catch (Exception e) { - System.err.println("Could not load properties input stream: " + is); - } - return props; - } - - /** - * Stores a Properties instance to the specified properties file. - * - * @param properties the properties to store - * @param filename the filename of the file to store the properties into - * @param comments comments to include in the properties file - * @return true if the properties were stored; false otherwise - */ - public static boolean storeProperties(Properties properties, String filename, String comments) { - if (properties == null || filename == null || filename.trim().length() == 0) { - return false; - } - - FileOutputStream fos = null; - - try { - fos = new FileOutputStream(filename); - properties.store(fos, comments); - } catch (IOException e) { - System.err.println("Could not store properties to file: " + filename); - return false; - } finally { - if (fos != null) { - try { - fos.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - return true; - } -} diff --git a/workspace_robo/robocode.roborumble/src/main/java/roborumble/RoboRumbleAtHome.java b/workspace_robo/robocode.roborumble/src/main/java/roborumble/RoboRumbleAtHome.java deleted file mode 100644 index ab15763..0000000 --- a/workspace_robo/robocode.roborumble/src/main/java/roborumble/RoboRumbleAtHome.java +++ /dev/null @@ -1,152 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package roborumble; - - -import net.sf.robocode.roborumble.battlesengine.BattlesRunner; -import net.sf.robocode.roborumble.battlesengine.PrepareBattles; -import net.sf.robocode.roborumble.netengine.BotsDownload; -import net.sf.robocode.roborumble.netengine.ResultsUpload; -import net.sf.robocode.roborumble.netengine.UpdateRatingFiles; -import static net.sf.robocode.roborumble.util.PropertiesUtil.getProperties; - -import java.util.Properties; - - -/** - * Implements the client side of RoboRumble@Home. - * Controlled by properties files. - * - * @author Albert Pérez (original) - * @author Flemming N. Larsen (contributor) - * @author Jerome Lavigne (contributor) - */ -public class RoboRumbleAtHome { - - public static void main(String args[]) { - - // Get the associated parameters file - String parameters = "./roborumble/roborumble.txt"; - - try { - parameters = args[0]; - } catch (Exception e) { - System.out.println("No argument found specifying properties file. \"roborumble.txt\" assumed."); - } - - // Read parameters for running the app - Properties param = getProperties(parameters); - - String downloads = param.getProperty("DOWNLOAD", "NOT"); - String executes = param.getProperty("EXECUTE", "NOT"); - String uploads = param.getProperty("UPLOAD", "NOT"); - String iterates = param.getProperty("ITERATE", "NOT"); - String runonly = param.getProperty("RUNONLY", "GENERAL"); - String melee = param.getProperty("MELEE", "NOT"); - - int iterations = 0; - long lastdownload = 0; - boolean ratingsdownloaded = false; - boolean participantsdownloaded; - String version = null; - - do { - final BattlesRunner engine = new BattlesRunner(parameters); - - if (version == null) { - version = engine.getVersion(); - } - - System.out.println("Iteration number " + iterations); - - // Download data from Internet if downloads is YES and it has not been download for two hours - if (downloads.equals("YES")) { - BotsDownload download = new BotsDownload(parameters); - - if (runonly.equals("SERVER")) { - // Download rating files and update ratings downloaded - System.out.println("Downloading rating files ..."); - ratingsdownloaded = download.downloadRatings(); - } - if ((System.currentTimeMillis() - lastdownload) > 2 * 3600 * 1000) { - System.out.println("Downloading participants list ..."); - participantsdownloaded = download.downloadParticipantsList(); - System.out.println("Downloading missing bots ..."); - download.downloadMissingBots(); - download.updateCodeSize(); - // Send the order to the server to remove old participants from the ratings file - if (ratingsdownloaded && participantsdownloaded) { - System.out.println("Removing old participants from server ..."); - // Send unwanted participants to the server - download.notifyServerForOldParticipants(); - } - - lastdownload = System.currentTimeMillis(); - } - } - - // Create battles file (and delete old ones), and execute battles - if (executes.equals("YES")) { - final boolean isMelee = melee.equals("YES"); - - boolean ready; - PrepareBattles battles = new PrepareBattles(parameters); - - if (isMelee) { - System.out.println("Preparing melee battles list ..."); - ready = battles.createMeleeBattlesList(); - } else { - final boolean isSmartBattles = ratingsdownloaded && runonly.equals("SERVER"); - - if (isSmartBattles) { - System.out.println("Preparing battles list using smart battles..."); - ready = battles.createSmartBattlesList(); - } else { - System.out.println("Preparing battles list..."); - ready = battles.createBattlesList(); - } - } - - // Disable the -DPRARALLEL and -DRANDOMSEED options - System.setProperty("PARALLEL", "false"); // TODO: Remove when robot thread CPU time can be measured - System.setProperty("RANDOMSEED", "none"); // In tournaments, robots should not be deterministic! - - // Execute battles - if (ready) { - if (isMelee) { - System.out.println("Executing melee battles ..."); - } else { - System.out.println("Executing battles ..."); - } - - engine.runBattlesImpl(isMelee); - } - } - - // Upload results - if (uploads.equals("YES") && version != null) { - System.out.println("Uploading results ..."); - ResultsUpload upload = new ResultsUpload(parameters, version); - - // Uploads the results to the server - upload.uploadResults(); - - // Updates the number of battles from the info received from the server - System.out.println("Updating number of battles fought ..."); - UpdateRatingFiles updater = new UpdateRatingFiles(parameters); - - ratingsdownloaded = updater.updateRatings(); - } - - iterations++; - } while (iterates.equals("YES")); - - // With Java 5 this causes a IllegalThreadStateException, but not in Java 6 - // System.exit(0); - } -} diff --git a/workspace_robo/robocode.samples/.classpath b/workspace_robo/robocode.samples/.classpath deleted file mode 100644 index 2dfe70b..0000000 --- a/workspace_robo/robocode.samples/.classpath +++ /dev/null @@ -1,8 +0,0 @@ - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.samples/.project b/workspace_robo/robocode.samples/.project deleted file mode 100644 index d30f541..0000000 --- a/workspace_robo/robocode.samples/.project +++ /dev/null @@ -1,16 +0,0 @@ - - - robocode.samples - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.api - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.samples/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.samples/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.samples/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.samples/pom.xml b/workspace_robo/robocode.samples/pom.xml deleted file mode 100644 index 6ee25a0..0000000 --- a/workspace_robo/robocode.samples/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - 4.0.0 - robocode.samples - Robocode Samples - - net.sf.robocode - robocode - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - - - - org.apache.maven.plugins - maven-jar-plugin - - - - - src/main/java - false - - **/*.java - - - - src/main/resources - false - - **/*.properties - **/*.team - **/*.html - - - - - diff --git a/workspace_robo/robocode.samples/robocode.samples.iml b/workspace_robo/robocode.samples/robocode.samples.iml deleted file mode 100644 index bfdd4ee..0000000 --- a/workspace_robo/robocode.samples/robocode.samples.iml +++ /dev/null @@ -1,69 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.samples/src/main/java/sample/Corners.java b/workspace_robo/robocode.samples/src/main/java/sample/Corners.java deleted file mode 100644 index 935467e..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/Corners.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.DeathEvent; -import robocode.Robot; -import robocode.ScannedRobotEvent; -import static robocode.util.Utils.normalRelativeAngleDegrees; - -import java.awt.*; - - -/** - * Corners - a sample robot by Mathew Nelson. - *

- * This robot moves to a corner, then swings the gun back and forth. - * If it dies, it tries a new corner in the next round. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class Corners extends Robot { - int others; // Number of other robots in the game - static int corner = 0; // Which corner we are currently using - // static so that it keeps it between rounds. - boolean stopWhenSeeRobot = false; // See goCorner() - - /** - * run: Corners' main run function. - */ - public void run() { - // Set colors - setBodyColor(Color.red); - setGunColor(Color.black); - setRadarColor(Color.yellow); - setBulletColor(Color.green); - setScanColor(Color.green); - - // Save # of other bots - others = getOthers(); - - // Move to a corner - goCorner(); - - // Initialize gun turn speed to 3 - int gunIncrement = 3; - - // Spin gun back and forth - while (true) { - for (int i = 0; i < 30; i++) { - turnGunLeft(gunIncrement); - } - gunIncrement *= -1; - } - } - - /** - * goCorner: A very inefficient way to get to a corner. Can you do better? - */ - public void goCorner() { - // We don't want to stop when we're just turning... - stopWhenSeeRobot = false; - // turn to face the wall to the "right" of our desired corner. - turnRight(normalRelativeAngleDegrees(corner - getHeading())); - // Ok, now we don't want to crash into any robot in our way... - stopWhenSeeRobot = true; - // Move to that wall - ahead(5000); - // Turn to face the corner - turnLeft(90); - // Move to the corner - ahead(5000); - // Turn gun to starting point - turnGunLeft(90); - } - - /** - * onScannedRobot: Stop and fire! - */ - public void onScannedRobot(ScannedRobotEvent e) { - // Should we stop, or just fire? - if (stopWhenSeeRobot) { - // Stop everything! You can safely call stop multiple times. - stop(); - // Call our custom firing method - smartFire(e.getDistance()); - // Look for another robot. - // NOTE: If you call scan() inside onScannedRobot, and it sees a robot, - // the game will interrupt the event handler and start it over - scan(); - // We won't get here if we saw another robot. - // Okay, we didn't see another robot... start moving or turning again. - resume(); - } else { - smartFire(e.getDistance()); - } - } - - /** - * smartFire: Custom fire method that determines firepower based on distance. - * - * @param robotDistance the distance to the robot to fire at - */ - public void smartFire(double robotDistance) { - if (robotDistance > 200 || getEnergy() < 15) { - fire(1); - } else if (robotDistance > 50) { - fire(2); - } else { - fire(3); - } - } - - /** - * onDeath: We died. Decide whether to try a different corner next game. - */ - public void onDeath(DeathEvent e) { - // Well, others should never be 0, but better safe than sorry. - if (others == 0) { - return; - } - - // If 75% of the robots are still alive when we die, we'll switch corners. - if ((others - getOthers()) / (double) others < .75) { - corner += 90; - if (corner == 270) { - corner = -90; - } - out.println("I died and did poorly... switching corner to " + corner); - } else { - out.println("I died but did well. I will still use corner " + corner); - } - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/Crazy.java b/workspace_robo/robocode.samples/src/main/java/sample/Crazy.java deleted file mode 100644 index 4508d33..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/Crazy.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.*; - -import java.awt.*; - - -/** - * Crazy - a sample robot by Mathew Nelson. - *

- * This robot moves around in a crazy pattern. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class Crazy extends AdvancedRobot { - boolean movingForward; - - /** - * run: Crazy's main run function - */ - public void run() { - // Set colors - setBodyColor(new Color(0, 200, 0)); - setGunColor(new Color(0, 150, 50)); - setRadarColor(new Color(0, 100, 100)); - setBulletColor(new Color(255, 255, 100)); - setScanColor(new Color(255, 200, 200)); - - // Loop forever - while (true) { - // Tell the game we will want to move ahead 40000 -- some large number - setAhead(40000); - movingForward = true; - // Tell the game we will want to turn right 90 - setTurnRight(90); - // At this point, we have indicated to the game that *when we do something*, - // we will want to move ahead and turn right. That's what "set" means. - // It is important to realize we have not done anything yet! - // In order to actually move, we'll want to call a method that - // takes real time, such as waitFor. - // waitFor actually starts the action -- we start moving and turning. - // It will not return until we have finished turning. - waitFor(new TurnCompleteCondition(this)); - // Note: We are still moving ahead now, but the turn is complete. - // Now we'll turn the other way... - setTurnLeft(180); - // ... and wait for the turn to finish ... - waitFor(new TurnCompleteCondition(this)); - // ... then the other way ... - setTurnRight(180); - // .. and wait for that turn to finish. - waitFor(new TurnCompleteCondition(this)); - // then back to the top to do it all again - } - } - - /** - * onHitWall: Handle collision with wall. - */ - public void onHitWall(HitWallEvent e) { - // Bounce off! - reverseDirection(); - } - - /** - * reverseDirection: Switch from ahead to back & vice versa - */ - public void reverseDirection() { - if (movingForward) { - setBack(40000); - movingForward = false; - } else { - setAhead(40000); - movingForward = true; - } - } - - /** - * onScannedRobot: Fire! - */ - public void onScannedRobot(ScannedRobotEvent e) { - fire(1); - } - - /** - * onHitRobot: Back up! - */ - public void onHitRobot(HitRobotEvent e) { - // If we're moving the other robot, reverse! - if (e.isMyFault()) { - reverseDirection(); - } - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/Fire.java b/workspace_robo/robocode.samples/src/main/java/sample/Fire.java deleted file mode 100644 index f15b29f..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/Fire.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.HitByBulletEvent; -import robocode.HitRobotEvent; -import robocode.Robot; -import robocode.ScannedRobotEvent; -import static robocode.util.Utils.normalRelativeAngleDegrees; - -import java.awt.*; - - -/** - * Fire - a sample robot by Mathew Nelson, and maintained. - *

- * Sits still. Spins gun around. Moves when hit. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class Fire extends Robot { - int dist = 50; // distance to move when we're hit - - /** - * run: Fire's main run function - */ - public void run() { - // Set colors - setBodyColor(Color.orange); - setGunColor(Color.orange); - setRadarColor(Color.red); - setScanColor(Color.red); - setBulletColor(Color.red); - - // Spin the gun around slowly... forever - while (true) { - turnGunRight(5); - } - } - - /** - * onScannedRobot: Fire! - */ - public void onScannedRobot(ScannedRobotEvent e) { - // If the other robot is close by, and we have plenty of life, - // fire hard! - if (e.getDistance() < 50 && getEnergy() > 50) { - fire(3); - } // otherwise, fire 1. - else { - fire(1); - } - // Call scan again, before we turn the gun - scan(); - } - - /** - * onHitByBullet: Turn perpendicular to the bullet, and move a bit. - */ - public void onHitByBullet(HitByBulletEvent e) { - turnRight(normalRelativeAngleDegrees(90 - (getHeading() - e.getHeading()))); - - ahead(dist); - dist *= -1; - scan(); - } - - /** - * onHitRobot: Aim at it. Fire Hard! - */ - public void onHitRobot(HitRobotEvent e) { - double turnGunAmt = normalRelativeAngleDegrees(e.getBearing() + getHeading() - getGunHeading()); - - turnGunRight(turnGunAmt); - fire(3); - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/Interactive.java b/workspace_robo/robocode.samples/src/main/java/sample/Interactive.java deleted file mode 100644 index 51dcbc5..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/Interactive.java +++ /dev/null @@ -1,223 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.AdvancedRobot; -import static robocode.util.Utils.normalAbsoluteAngle; -import static robocode.util.Utils.normalRelativeAngle; - -import java.awt.*; -import java.awt.event.KeyEvent; -import static java.awt.event.KeyEvent.*; -import java.awt.event.MouseEvent; -import java.awt.event.MouseWheelEvent; - - -/** - * Interactive - a sample robot by Flemming N. Larsen. - *

- * This is a robot that is controlled using the arrow keys and mouse only. - *

- * Keys: - * - W or arrow up: Move forward - * - S or arrow down: Move backward - * - A or arrow right: Turn right - * - D or arrow left: Turn left - * Mouse: - * - Moving: Moves the aim, which the gun will follow - * - Wheel up: Move forward - * - Wheel down: Move backward - * - Button 1: Fire a bullet with power = 1 - * - Button 2: Fire a bullet with power = 2 - * - Button 3: Fire a bullet with power = 3 - *

- * The bullet color depends on the fire power: - * - Power = 1: Yellow - * - Power = 2: Orange - * - Power = 3: Red - *

- * Note that the robot will continue firing as long as the mouse button is - * pressed down. - *

- * By enabling the "Paint" button on the robot console window for this robot, - * a cross hair will be painted for the robots current aim (controlled by the - * mouse). - * - * @author Flemming N. Larsen (original) - * - * @version 1.2 - * - * @since 1.3.4 - */ -public class Interactive extends AdvancedRobot { - - // Move direction: 1 = move forward, 0 = stand still, -1 = move backward - int moveDirection; - - // Turn direction: 1 = turn right, 0 = no turning, -1 = turn left - int turnDirection; - - // Amount of pixels/units to move - double moveAmount; - - // The coordinate of the aim (x,y) - int aimX, aimY; - - // Fire power, where 0 = don't fire - int firePower; - - // Called when the robot must run - public void run() { - - // Sets the colors of the robot - // body = black, gun = white, radar = red - setColors(Color.BLACK, Color.WHITE, Color.RED); - - // Loop forever - for (;;) { - // Sets the robot to move forward, backward or stop moving depending - // on the move direction and amount of pixels to move - setAhead(moveAmount * moveDirection); - - // Decrement the amount of pixels to move until we reach 0 pixels - // This way the robot will automatically stop if the mouse wheel - // has stopped it's rotation - moveAmount = Math.max(0, moveAmount - 1); - - // Sets the robot to turn right or turn left (at maximum speed) or - // stop turning depending on the turn direction - setTurnRight(45 * turnDirection); // degrees - - // Turns the gun toward the current aim coordinate (x,y) controlled by - // the current mouse coordinate - double angle = normalAbsoluteAngle(Math.atan2(aimX - getX(), aimY - getY())); - - setTurnGunRightRadians(normalRelativeAngle(angle - getGunHeadingRadians())); - - // Fire the gun with the specified fire power, unless the fire power = 0 - if (firePower > 0) { - setFire(firePower); - } - - // Execute all pending set-statements - execute(); - - // Next turn is processed in this loop.. - } - } - - // Called when a key has been pressed - public void onKeyPressed(KeyEvent e) { - switch (e.getKeyCode()) { - case VK_UP: - case VK_W: - // Arrow up key: move direction = forward (infinitely) - moveDirection = 1; - moveAmount = Double.POSITIVE_INFINITY; - break; - - case VK_DOWN: - case VK_S: - // Arrow down key: move direction = backward (infinitely) - moveDirection = -1; - moveAmount = Double.POSITIVE_INFINITY; - break; - - case VK_RIGHT: - case VK_D: - // Arrow right key: turn direction = right - turnDirection = 1; - break; - - case VK_LEFT: - case VK_A: - // Arrow left key: turn direction = left - turnDirection = -1; - break; - } - } - - // Called when a key has been released (after being pressed) - public void onKeyReleased(KeyEvent e) { - switch (e.getKeyCode()) { - case VK_UP: - case VK_W: - case VK_DOWN: - case VK_S: - // Arrow up and down keys: move direction = stand still - moveDirection = 0; - moveAmount = 0; - break; - - case VK_RIGHT: - case VK_D: - case VK_LEFT: - case VK_A: - // Arrow right and left keys: turn direction = stop turning - turnDirection = 0; - break; - } - } - - // Called when the mouse wheel is rotated - public void onMouseWheelMoved(MouseWheelEvent e) { - // If the wheel rotation is negative it means that it is moved forward. - // Set move direction = forward, if wheel is moved forward. - // Otherwise, set move direction = backward - moveDirection = (e.getWheelRotation() < 0) ? 1 : -1; - - // Set the amount to move = absolute wheel rotation amount * 5 (speed) - // Here 5 means 5 pixels per wheel rotation step. The higher value, the - // more speed - moveAmount += Math.abs(e.getWheelRotation()) * 5; - } - - // Called when the mouse has been moved - public void onMouseMoved(MouseEvent e) { - // Set the aim coordinate = the mouse pointer coordinate - aimX = e.getX(); - aimY = e.getY(); - } - - // Called when a mouse button has been pressed - public void onMousePressed(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON3) { - // Button 3: fire power = 3 energy points, bullet color = red - firePower = 3; - setBulletColor(Color.RED); - } else if (e.getButton() == MouseEvent.BUTTON2) { - // Button 2: fire power = 2 energy points, bullet color = orange - firePower = 2; - setBulletColor(Color.ORANGE); - } else { - // Button 1 or unknown button: - // fire power = 1 energy points, bullet color = yellow - firePower = 1; - setBulletColor(Color.YELLOW); - } - } - - // Called when a mouse button has been released (after being pressed) - public void onMouseReleased(MouseEvent e) { - // Fire power = 0, which means "don't fire" - firePower = 0; - } - - // Called in order to paint graphics for this robot. - // "Paint" button on the robot console window for this robot must be - // enabled in order to see the paintings. - public void onPaint(Graphics2D g) { - // Draw a red cross hair with the center at the current aim - // coordinate (x,y) - g.setColor(Color.RED); - g.drawOval(aimX - 15, aimY - 15, 30, 30); - g.drawLine(aimX, aimY - 4, aimX, aimY + 4); - g.drawLine(aimX - 4, aimY, aimX + 4, aimY); - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/Interactive_v2.java b/workspace_robo/robocode.samples/src/main/java/sample/Interactive_v2.java deleted file mode 100644 index dcddb3b..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/Interactive_v2.java +++ /dev/null @@ -1,263 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.AdvancedRobot; -import robocode.util.Utils; -import static robocode.util.Utils.normalAbsoluteAngle; -import static robocode.util.Utils.normalRelativeAngle; - -import java.awt.*; -import java.awt.event.KeyEvent; -import static java.awt.event.KeyEvent.*; -import java.awt.event.MouseEvent; -import java.awt.event.MouseWheelEvent; -import java.util.HashSet; -import java.util.Set; - - -/** - * Interactive_v2 - a modified version of the sample robot Interactive by Flemming N. Larsen - * to use absolute movements (up, right, down, left) by Tuan Anh Nguyen. - *

- * This is a robot that is controlled using the arrow keys (or WASD) and mouse only. - *

- * Keys: - * - W or arrow up: Move up - * - S or arrow down: Move down - * - A or arrow right: Move right - * - D or arrow left: Move left - * Mouse: - * - Moving: Moves the aim, which the gun will follow - * - Button 1: Fire a bullet with power = 1 - * - Button 2: Fire a bullet with power = 2 - * - Button 3: Fire a bullet with power = 3 - *

- * The bullet color depends on the fire power: - * - Power = 1: Yellow - * - Power = 2: Orange - * - Power = 3: Red - *

- * Note that the robot will continue firing as long as the mouse button is - * pressed down. - *

- * By enabling the "Paint" button on the robot console window for this robot, - * a cross hair will be painted for the robots current aim (controlled by the - * mouse). - * - * @author Flemming N. Larsen (original) - * @author Tuan Anh Nguyen (contributor) - * - * @version 1.0 - * - * @since 1.7.2.2 - */ -public class Interactive_v2 extends AdvancedRobot { - - // The coordinate of the aim (x,y) - int aimX, aimY; - - // Fire power, where 0 = don't fire - int firePower; - - // Absolute directions on the screen - private enum Direction { - UP, - DOWN, - LEFT, - RIGHT - } - - // Current move directions - private final Set directions = new HashSet(); - - // Called when the robot must run - public void run() { - - // Sets the colors of the robot - // body = black, gun = white, radar = red - setColors(Color.BLACK, Color.WHITE, Color.RED); - - // Loop forever - for (;;) { - // Move the robot compared to the distance to move - setAhead(distanceToMove()); - - // Turn the body to it points in the correct direction - setTurnRight(angleToTurnInDegrees()); - - // Turns the gun toward the current aim coordinate (x,y) controlled by - // the current mouse coordinate - double angle = normalAbsoluteAngle(Math.atan2(aimX - getX(), aimY - getY())); - - setTurnGunRightRadians(normalRelativeAngle(angle - getGunHeadingRadians())); - - // Fire the gun with the specified fire power, unless the fire power = 0 - if (firePower > 0) { - setFire(firePower); - } - - // Execute all pending set-statements - execute(); - - // Next turn is processed in this loop.. - } - } - - // Called when a key has been pressed - public void onKeyPressed(KeyEvent e) { - switch (e.getKeyCode()) { - case VK_UP: - case VK_W: - directions.add(Direction.UP); - break; - - case VK_DOWN: - case VK_S: - directions.add(Direction.DOWN); - break; - - case VK_RIGHT: - case VK_D: - directions.add(Direction.RIGHT); - break; - - case VK_LEFT: - case VK_A: - directions.add(Direction.LEFT); - break; - } - } - - // Called when a key has been released (after being pressed) - public void onKeyReleased(KeyEvent e) { - switch (e.getKeyCode()) { - case VK_UP: - case VK_W: - directions.remove(Direction.UP); - break; - - case VK_DOWN: - case VK_S: - directions.remove(Direction.DOWN); - break; - - case VK_RIGHT: - case VK_D: - directions.remove(Direction.RIGHT); - break; - - case VK_LEFT: - case VK_A: - directions.remove(Direction.LEFT); - break; - } - } - - // Called when the mouse wheel is rotated - public void onMouseWheelMoved(MouseWheelEvent e) {// Do nothing - } - - // Called when the mouse has been moved - public void onMouseMoved(MouseEvent e) { - // Set the aim coordinate = the mouse pointer coordinate - aimX = e.getX(); - aimY = e.getY(); - } - - // Called when a mouse button has been pressed - public void onMousePressed(MouseEvent e) { - if (e.getButton() == MouseEvent.BUTTON3) { - // Button 3: fire power = 3 energy points, bullet color = red - firePower = 3; - setBulletColor(Color.RED); - } else if (e.getButton() == MouseEvent.BUTTON2) { - // Button 2: fire power = 2 energy points, bullet color = orange - firePower = 2; - setBulletColor(Color.ORANGE); - } else { - // Button 1 or unknown button: - // fire power = 1 energy points, bullet color = yellow - firePower = 1; - setBulletColor(Color.YELLOW); - } - } - - // Called when a mouse button has been released (after being pressed) - public void onMouseReleased(MouseEvent e) { - // Fire power = 0, which means "don't fire" - firePower = 0; - } - - // Called in order to paint graphics for this robot. - // "Paint" button on the robot console window for this robot must be - // enabled in order to see the paintings. - public void onPaint(Graphics2D g) { - // Draw a red cross hair with the center at the current aim - // coordinate (x,y) - g.setColor(Color.RED); - g.drawOval(aimX - 15, aimY - 15, 30, 30); - g.drawLine(aimX, aimY - 4, aimX, aimY + 4); - g.drawLine(aimX - 4, aimY, aimX + 4, aimY); - } - - // Returns the angle to turn, which is the delta between the desired - // direction and the current heading of the robot - private double angleToTurnInDegrees() { - if (directions.isEmpty()) { - return 0; - } - return Utils.normalRelativeAngleDegrees(desiredDirection() - getHeading()); - } - - // Returns the distance to move - private double distanceToMove() { - // If no keys are pressed, we should not move at all - if (directions.isEmpty()) { - return 0; - } - // If the robot has more than 45 degrees to turn, move only 5 pixel - if (Math.abs(angleToTurnInDegrees()) > 45) { - return 5; - } - // Otherwise, move at full speed - return Double.POSITIVE_INFINITY; - } - - // Return the desired direction depending on the pending move directions. - // With one arrow key pressed, the move to N, E, S, W. - // With two keys pressed, the robot also move to NE, NW, SE, SW. - private double desiredDirection() { - if (directions.contains(Direction.UP)) { - if (directions.contains(Direction.RIGHT)) { - return 45; - } - if (directions.contains(Direction.LEFT)) { - return 315; - } - return 0; - } - if (directions.contains(Direction.DOWN)) { - if (directions.contains(Direction.RIGHT)) { - return 135; - } - if (directions.contains(Direction.LEFT)) { - return 225; - } - return 180; - } - if (directions.contains(Direction.RIGHT)) { - return 90; - } - if (directions.contains(Direction.LEFT)) { - return 270; - } - return 0; - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/MyFirstJuniorRobot.java b/workspace_robo/robocode.samples/src/main/java/sample/MyFirstJuniorRobot.java deleted file mode 100644 index 7931009..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/MyFirstJuniorRobot.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.JuniorRobot; - - -/** - * MyFirstJuniorRobot - a sample robot by Flemming N. Larsen - *

- * Moves in a seesaw motion, and spins the gun around at each end - * when it cannot see any enemy robot. When the robot sees and enemy - * robot, it will immediately turn the gun and fire at it. - * - * @author Flemming N. Larsen (original) - */ -public class MyFirstJuniorRobot extends JuniorRobot { - - /** - * MyFirstJuniorRobot's run method - Seesaw as default - */ - public void run() { - // Set robot colors - setColors(green, black, blue); - - // Seesaw forever - while (true) { - ahead(100); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(100); // Move back 100 - turnGunRight(360); // Spin gun around - } - } - - /** - * When we see a robot, turn the gun towards it and fire - */ - public void onScannedRobot() { - // Turn gun to point at the scanned robot - turnGunTo(scannedAngle); - - // Fire! - fire(1); - } - - /** - * We were hit! Turn and move perpendicular to the bullet, - * so our seesaw might avoid a future shot. - */ - public void onHitByBullet() { - // Move ahead 100 and in the same time turn left papendicular to the bullet - turnAheadLeft(100, 90 - hitByBulletBearing); - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/MyFirstRobot.java b/workspace_robo/robocode.samples/src/main/java/sample/MyFirstRobot.java deleted file mode 100644 index d9013d0..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/MyFirstRobot.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.HitByBulletEvent; -import robocode.Robot; -import robocode.ScannedRobotEvent; - - -/** - * MyFirstRobot - a sample robot by Mathew Nelson. - *

- * Moves in a seesaw motion, and spins the gun around at each end. - * - * @author Mathew A. Nelson (original) - */ -public class MyFirstRobot extends Robot { - - /** - * MyFirstRobot's run method - Seesaw - */ - public void run() { - - while (true) { - ahead(100); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(100); // Move back 100 - turnGunRight(360); // Spin gun around - } - } - - /** - * Fire when we see a robot - */ - public void onScannedRobot(ScannedRobotEvent e) { - fire(1); - } - - /** - * We were hit! Turn perpendicular to the bullet, - * so our seesaw might avoid a future shot. - */ - public void onHitByBullet(HitByBulletEvent e) { - turnLeft(90 - e.getBearing()); - } -} - diff --git a/workspace_robo/robocode.samples/src/main/java/sample/PaintingRobot.java b/workspace_robo/robocode.samples/src/main/java/sample/PaintingRobot.java deleted file mode 100644 index 638d04b..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/PaintingRobot.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.HitByBulletEvent; -import robocode.Robot; -import robocode.ScannedRobotEvent; - -import java.awt.*; - - -/** - * PaintingRobot - a sample robot that demonstrates the onPaint() and - * getGraphics() methods. - * Also demonstrate feature of debugging properties on RobotDialog - *

- * Moves in a seesaw motion, and spins the gun around at each end. - * When painting is enabled for this robot, a red circle will be painted - * around this robot. - * - * @author Stefan Westen (original SGSample) - * @author Pavel Savara (contributor) - */ -public class PaintingRobot extends Robot { - - /** - * PaintingRobot's run method - Seesaw - */ - public void run() { - while (true) { - ahead(100); - turnGunRight(360); - back(100); - turnGunRight(360); - } - } - - /** - * Fire when we see a robot - */ - public void onScannedRobot(ScannedRobotEvent e) { - // demonstrate feature of debugging properties on RobotDialog - setDebugProperty("lastScannedRobot", e.getName() + " at " + e.getBearing() + " degrees at time " + getTime()); - - fire(1); - } - - /** - * We were hit! Turn perpendicular to the bullet, - * so our seesaw might avoid a future shot. - * In addition, draw orange circles where we were hit. - */ - public void onHitByBullet(HitByBulletEvent e) { - // demonstrate feature of debugging properties on RobotDialog - setDebugProperty("lastHitBy", e.getName() + " with power of bullet " + e.getPower() + " at time " + getTime()); - - // show how to remove debugging property - setDebugProperty("lastScannedRobot", null); - - // gebugging by painting to battle view - Graphics2D g = getGraphics(); - - g.setColor(Color.orange); - g.drawOval((int) (getX() - 55), (int) (getY() - 55), 110, 110); - g.drawOval((int) (getX() - 56), (int) (getY() - 56), 112, 112); - g.drawOval((int) (getX() - 59), (int) (getY() - 59), 118, 118); - g.drawOval((int) (getX() - 60), (int) (getY() - 60), 120, 120); - - turnLeft(90 - e.getBearing()); - } - - /** - * Paint a red circle around our PaintingRobot - */ - public void onPaint(Graphics2D g) { - g.setColor(Color.red); - g.drawOval((int) (getX() - 50), (int) (getY() - 50), 100, 100); - g.setColor(new Color(0, 0xFF, 0, 30)); - g.fillOval((int) (getX() - 60), (int) (getY() - 60), 120, 120); - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/RamFire.java b/workspace_robo/robocode.samples/src/main/java/sample/RamFire.java deleted file mode 100644 index d33c269..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/RamFire.java +++ /dev/null @@ -1,86 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.HitRobotEvent; -import robocode.Robot; -import robocode.ScannedRobotEvent; - -import java.awt.*; - - -/** - * RamFire - a sample robot by Mathew Nelson. - *

- * Drives at robots trying to ram them. - * Fires when it hits them. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class RamFire extends Robot { - int turnDirection = 1; // Clockwise or counterclockwise - - /** - * run: Spin around looking for a target - */ - public void run() { - // Set colors - setBodyColor(Color.lightGray); - setGunColor(Color.gray); - setRadarColor(Color.darkGray); - - while (true) { - turnRight(5 * turnDirection); - } - } - - /** - * onScannedRobot: We have a target. Go get it. - */ - public void onScannedRobot(ScannedRobotEvent e) { - - if (e.getBearing() >= 0) { - turnDirection = 1; - } else { - turnDirection = -1; - } - - turnRight(e.getBearing()); - ahead(e.getDistance() + 5); - scan(); // Might want to move ahead again! - } - - /** - * onHitRobot: Turn to face robot, fire hard, and ram him again! - */ - public void onHitRobot(HitRobotEvent e) { - if (e.getBearing() >= 0) { - turnDirection = 1; - } else { - turnDirection = -1; - } - turnRight(e.getBearing()); - - // Determine a shot that won't kill the robot... - // We want to ram him instead for bonus points - if (e.getEnergy() > 16) { - fire(3); - } else if (e.getEnergy() > 10) { - fire(2); - } else if (e.getEnergy() > 4) { - fire(1); - } else if (e.getEnergy() > 2) { - fire(.5); - } else if (e.getEnergy() > .4) { - fire(.1); - } - ahead(40); // Ram him again! - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/SittingDuck.html b/workspace_robo/robocode.samples/src/main/java/sample/SittingDuck.html deleted file mode 100644 index 9f4d522..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/SittingDuck.html +++ /dev/null @@ -1,24 +0,0 @@ - - - - - - SittingDuck's Webpage - - - - - -

Hi! I'm a sitting duck.
- - - - \ No newline at end of file diff --git a/workspace_robo/robocode.samples/src/main/java/sample/SittingDuck.java b/workspace_robo/robocode.samples/src/main/java/sample/SittingDuck.java deleted file mode 100644 index 78d7878..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/SittingDuck.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.AdvancedRobot; -import robocode.RobocodeFileOutputStream; - -import java.awt.*; -import java.io.BufferedReader; -import java.io.FileReader; -import java.io.IOException; -import java.io.PrintStream; - - -/** - * SittingDuck - a sample robot by Mathew Nelson. - *

- * Along with sitting still doing nothing, this robot demonstrates persistency. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Andrew Magargle (contributor) - */ -public class SittingDuck extends AdvancedRobot { - static boolean incrementedBattles = false; - - public void run() { - setBodyColor(Color.yellow); - setGunColor(Color.yellow); - - int roundCount, battleCount; - - try { - BufferedReader reader = null; - try { - // Read file "count.dat" which contains 2 lines, a round count, and a battle count - reader = new BufferedReader(new FileReader(getDataFile("count.dat"))); - - // Try to get the counts - roundCount = Integer.parseInt(reader.readLine()); - battleCount = Integer.parseInt(reader.readLine()); - - } finally { - if (reader != null) { - reader.close(); - } - } - } catch (IOException e) { - // Something went wrong reading the file, reset to 0. - roundCount = 0; - battleCount = 0; - } catch (NumberFormatException e) { - // Something went wrong converting to ints, reset to 0 - roundCount = 0; - battleCount = 0; - } - - // Increment the # of rounds - roundCount++; - - // If we haven't incremented # of battles already, - // Note: Because robots are only instantiated once per battle, member variables remain valid throughout it. - if (!incrementedBattles) { - // Increment # of battles - battleCount++; - incrementedBattles = true; - } - - PrintStream w = null; - try { - w = new PrintStream(new RobocodeFileOutputStream(getDataFile("count.dat"))); - - w.println(roundCount); - w.println(battleCount); - - // PrintStreams don't throw IOExceptions during prints, they simply set a flag.... so check it here. - if (w.checkError()) { - out.println("I could not write the count!"); - } - } catch (IOException e) { - out.println("IOException trying to write: "); - e.printStackTrace(out); - } finally { - if (w != null) { - w.close(); - } - } - out.println("I have been a sitting duck for " + roundCount + " rounds, in " + battleCount + " battles."); - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/SpinBot.java b/workspace_robo/robocode.samples/src/main/java/sample/SpinBot.java deleted file mode 100644 index 4f4f3d0..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/SpinBot.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.AdvancedRobot; -import robocode.HitRobotEvent; -import robocode.ScannedRobotEvent; - -import java.awt.*; - - -/** - * SpinBot - a sample robot by Mathew Nelson. - *

- * Moves in a circle, firing hard when an enemy is detected. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class SpinBot extends AdvancedRobot { - - /** - * SpinBot's run method - Circle - */ - public void run() { - // Set colors - setBodyColor(Color.blue); - setGunColor(Color.blue); - setRadarColor(Color.black); - setScanColor(Color.yellow); - - // Loop forever - while (true) { - // Tell the game that when we take move, - // we'll also want to turn right... a lot. - setTurnRight(10000); - // Limit our speed to 5 - setMaxVelocity(5); - // Start moving (and turning) - ahead(10000); - // Repeat. - } - } - - /** - * onScannedRobot: Fire hard! - */ - public void onScannedRobot(ScannedRobotEvent e) { - fire(3); - } - - /** - * onHitRobot: If it's our fault, we'll stop turning and moving, - * so we need to turn again to keep spinning. - */ - public void onHitRobot(HitRobotEvent e) { - if (e.getBearing() > -10 && e.getBearing() < 10) { - fire(3); - } - if (e.isMyFault()) { - turnRight(10); - } - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/Target.java b/workspace_robo/robocode.samples/src/main/java/sample/Target.java deleted file mode 100644 index 0c34b2a..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/Target.java +++ /dev/null @@ -1,65 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.AdvancedRobot; -import robocode.Condition; -import robocode.CustomEvent; - -import java.awt.*; - - -/** - * Target - a sample robot by Mathew Nelson. - *

- * Sits still. Moves every time energy drops by 20. - * This Robot demonstrates custom events. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class Target extends AdvancedRobot { - - int trigger; // Keeps track of when to move - - /** - * TrackFire's run method - */ - public void run() { - // Set colors - setBodyColor(Color.white); - setGunColor(Color.white); - setRadarColor(Color.white); - - // Initially, we'll move when life hits 80 - trigger = 80; - // Add a custom event named "trigger hit", - addCustomEvent(new Condition("triggerhit") { - public boolean test() { - return (getEnergy() <= trigger); - } - }); - } - - /** - * onCustomEvent handler - */ - public void onCustomEvent(CustomEvent e) { - // If our custom event "triggerhit" went off, - if (e.getCondition().getName().equals("triggerhit")) { - // Adjust the trigger value, or - // else the event will fire again and again and again... - trigger -= 20; - out.println("Ouch, down to " + (int) (getEnergy() + .5) + " energy."); - // move around a bit. - turnLeft(65); - ahead(100); - } - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/TrackFire.java b/workspace_robo/robocode.samples/src/main/java/sample/TrackFire.java deleted file mode 100644 index 70ca780..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/TrackFire.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.Robot; -import robocode.ScannedRobotEvent; -import robocode.WinEvent; -import static robocode.util.Utils.normalRelativeAngleDegrees; - -import java.awt.*; - - -/** - * TrackFire - a sample robot by Mathew Nelson. - *

- * Sits still. Tracks and fires at the nearest robot it sees. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class TrackFire extends Robot { - - /** - * TrackFire's run method - */ - public void run() { - // Set colors - setBodyColor(Color.pink); - setGunColor(Color.pink); - setRadarColor(Color.pink); - setScanColor(Color.pink); - setBulletColor(Color.pink); - - // Loop forever - while (true) { - turnGunRight(10); // Scans automatically - } - } - - /** - * onScannedRobot: We have a target. Go get it. - */ - public void onScannedRobot(ScannedRobotEvent e) { - // Calculate exact location of the robot - double absoluteBearing = getHeading() + e.getBearing(); - double bearingFromGun = normalRelativeAngleDegrees(absoluteBearing - getGunHeading()); - - // If it's close enough, fire! - if (Math.abs(bearingFromGun) <= 3) { - turnGunRight(bearingFromGun); - // We check gun heat here, because calling fire() - // uses a turn, which could cause us to lose track - // of the other robot. - if (getGunHeat() == 0) { - fire(Math.min(3 - Math.abs(bearingFromGun), getEnergy() - .1)); - } - } // otherwise just set the gun to turn. - // Note: This will have no effect until we call scan() - else { - turnGunRight(bearingFromGun); - } - // Generates another scan event if we see a robot. - // We only need to call this if the gun (and therefore radar) - // are not turning. Otherwise, scan is called automatically. - if (bearingFromGun == 0) { - scan(); - } - } - - public void onWin(WinEvent e) { - // Victory dance - turnRight(36000); - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/Tracker.java b/workspace_robo/robocode.samples/src/main/java/sample/Tracker.java deleted file mode 100644 index 1cdc19c..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/Tracker.java +++ /dev/null @@ -1,144 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.HitRobotEvent; -import robocode.Robot; -import robocode.ScannedRobotEvent; -import robocode.WinEvent; -import static robocode.util.Utils.normalRelativeAngleDegrees; - -import java.awt.*; - - -/** - * Tracker - a sample robot by Mathew Nelson. - *

- * Locks onto a robot, moves close, fires when close. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class Tracker extends Robot { - int count = 0; // Keeps track of how long we've - // been searching for our target - double gunTurnAmt; // How much to turn our gun when searching - String trackName; // Name of the robot we're currently tracking - - /** - * run: Tracker's main run function - */ - public void run() { - // Set colors - setBodyColor(new Color(128, 128, 50)); - setGunColor(new Color(50, 50, 20)); - setRadarColor(new Color(200, 200, 70)); - setScanColor(Color.white); - setBulletColor(Color.blue); - - // Prepare gun - trackName = null; // Initialize to not tracking anyone - setAdjustGunForRobotTurn(true); // Keep the gun still when we turn - gunTurnAmt = 10; // Initialize gunTurn to 10 - - // Loop forever - while (true) { - // turn the Gun (looks for enemy) - turnGunRight(gunTurnAmt); - // Keep track of how long we've been looking - count++; - // If we've haven't seen our target for 2 turns, look left - if (count > 2) { - gunTurnAmt = -10; - } - // If we still haven't seen our target for 5 turns, look right - if (count > 5) { - gunTurnAmt = 10; - } - // If we *still* haven't seen our target after 10 turns, find another target - if (count > 11) { - trackName = null; - } - } - } - - /** - * onScannedRobot: Here's the good stuff - */ - public void onScannedRobot(ScannedRobotEvent e) { - - // If we have a target, and this isn't it, return immediately - // so we can get more ScannedRobotEvents. - if (trackName != null && !e.getName().equals(trackName)) { - return; - } - - // If we don't have a target, well, now we do! - if (trackName == null) { - trackName = e.getName(); - out.println("Tracking " + trackName); - } - // This is our target. Reset count (see the run method) - count = 0; - // If our target is too far away, turn and move toward it. - if (e.getDistance() > 150) { - gunTurnAmt = normalRelativeAngleDegrees(e.getBearing() + (getHeading() - getRadarHeading())); - - turnGunRight(gunTurnAmt); // Try changing these to setTurnGunRight, - turnRight(e.getBearing()); // and see how much Tracker improves... - // (you'll have to make Tracker an AdvancedRobot) - ahead(e.getDistance() - 140); - return; - } - - // Our target is close. - gunTurnAmt = normalRelativeAngleDegrees(e.getBearing() + (getHeading() - getRadarHeading())); - turnGunRight(gunTurnAmt); - fire(3); - - // Our target is too close! Back up. - if (e.getDistance() < 100) { - if (e.getBearing() > -90 && e.getBearing() <= 90) { - back(40); - } else { - ahead(40); - } - } - scan(); - } - - /** - * onHitRobot: Set him as our new target - */ - public void onHitRobot(HitRobotEvent e) { - // Only print if he's not already our target. - if (trackName != null && !trackName.equals(e.getName())) { - out.println("Tracking " + e.getName() + " due to collision"); - } - // Set the target - trackName = e.getName(); - // Back up a bit. - // Note: We won't get scan events while we're doing this! - // An AdvancedRobot might use setBack(); execute(); - gunTurnAmt = normalRelativeAngleDegrees(e.getBearing() + (getHeading() - getRadarHeading())); - turnGunRight(gunTurnAmt); - fire(3); - back(50); - } - - /** - * onWin: Do a victory dance - */ - public void onWin(WinEvent e) { - for (int i = 0; i < 50; i++) { - turnRight(30); - turnLeft(30); - } - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/VelociRobot.java b/workspace_robo/robocode.samples/src/main/java/sample/VelociRobot.java deleted file mode 100644 index 8eadf8b..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/VelociRobot.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.HitByBulletEvent; -import robocode.HitWallEvent; -import robocode.RateControlRobot; -import robocode.ScannedRobotEvent; - - -/** - * This is a sample of a robot using the RateControlRobot class - * - * @author Joshua Galecki (original) - */ -public class VelociRobot extends RateControlRobot { - - int turnCounter; - public void run() { - - turnCounter = 0; - setGunRotationRate(15); - - while (true) { - if (turnCounter % 64 == 0) { - // Straighten out, if we were hit by a bullet and are turning - setTurnRate(0); - // Go forward with a velocity of 4 - setVelocityRate(4); - } - if (turnCounter % 64 == 32) { - // Go backwards, faster - setVelocityRate(-6); - } - turnCounter++; - execute(); - } - } - - public void onScannedRobot(ScannedRobotEvent e) { - fire(1); - } - - public void onHitByBullet(HitByBulletEvent e) { - // Turn to confuse the other robot - setTurnRate(5); - } - - public void onHitWall(HitWallEvent e) { - // Move away from the wall - setVelocityRate(-1 * getVelocityRate()); - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sample/Walls.java b/workspace_robo/robocode.samples/src/main/java/sample/Walls.java deleted file mode 100644 index f122c7b..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sample/Walls.java +++ /dev/null @@ -1,94 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sample; - - -import robocode.HitRobotEvent; -import robocode.Robot; -import robocode.ScannedRobotEvent; - -import java.awt.*; - - -/** - * Walls - a sample robot by Mathew Nelson, and maintained by Flemming N. Larsen - *

- * Moves around the outer edge with the gun facing in. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class Walls extends Robot { - - boolean peek; // Don't turn if there's a robot there - double moveAmount; // How much to move - - /** - * run: Move around the walls - */ - public void run() { - // Set colors - setBodyColor(Color.black); - setGunColor(Color.black); - setRadarColor(Color.orange); - setBulletColor(Color.cyan); - setScanColor(Color.cyan); - - // Initialize moveAmount to the maximum possible for this battlefield. - moveAmount = Math.max(getBattleFieldWidth(), getBattleFieldHeight()); - // Initialize peek to false - peek = false; - - // turnLeft to face a wall. - // getHeading() % 90 means the remainder of - // getHeading() divided by 90. - turnLeft(getHeading() % 90); - ahead(moveAmount); - // Turn the gun to turn right 90 degrees. - peek = true; - turnGunRight(90); - turnRight(90); - - while (true) { - // Look before we turn when ahead() completes. - peek = true; - // Move up the wall - ahead(moveAmount); - // Don't look now - peek = false; - // Turn to the next wall - turnRight(90); - } - } - - /** - * onHitRobot: Move away a bit. - */ - public void onHitRobot(HitRobotEvent e) { - // If he's in front of us, set back up a bit. - if (e.getBearing() > -90 && e.getBearing() < 90) { - back(100); - } // else he's in back of us, so set ahead a bit. - else { - ahead(100); - } - } - - /** - * onScannedRobot: Fire! - */ - public void onScannedRobot(ScannedRobotEvent e) { - fire(2); - // Note that scan is called automatically when the robot is moving. - // By calling it manually here, we make sure we generate another scan event if there's a robot on the next - // wall, so that we do not start moving up it until it's gone. - if (peek) { - scan(); - } - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sampleex/Alien.java b/workspace_robo/robocode.samples/src/main/java/sampleex/Alien.java deleted file mode 100644 index b963ca6..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sampleex/Alien.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sampleex; - - -import robocode.*; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.peer.IBasicRobotPeer; -import robocode.robotinterfaces.peer.IStandardRobotPeer; - -import java.io.PrintStream; - - -/** - * A sample robot. - * Is not inherited from classic base robots, uses new experimental access to RobotPeer. - * Use -DEXPERIMENTAL=true to start robocode for this robot. - * - * @author Pavel Savara (original) - */ -public class Alien implements IBasicEvents, IBasicRobot, Runnable { - - PrintStream out; - IStandardRobotPeer peer; - - public Runnable getRobotRunnable() { - return this; - } - - public IBasicEvents getBasicEventListener() { - return this; - } - - public void setPeer(IBasicRobotPeer iRobotPeer) { - peer = (IStandardRobotPeer) iRobotPeer; - } - - public void setOut(PrintStream printStream) { - out = printStream; - } - - public void run() { - while (true) { - peer.move(100); // Move ahead 100 - peer.turnGun(Math.PI * 2); // Spin gun around - peer.move(-100); // Move back 100 - peer.turnGun(Math.PI * 2); // Spin gun around - } - } - - public void onScannedRobot(ScannedRobotEvent e) { - peer.setFire(1); - } - - public void onHitByBullet(HitByBulletEvent e) { - peer.turnBody(Math.PI / 2 + e.getBearingRadians()); - } - - public void onStatus(StatusEvent e) {} - - public void onBulletHit(BulletHitEvent e) {} - - public void onBulletHitBullet(BulletHitBulletEvent e) {} - - public void onBulletMissed(BulletMissedEvent e) {} - - public void onDeath(DeathEvent e) {} - - public void onHitRobot(HitRobotEvent e) {} - - public void onHitWall(HitWallEvent e) {} - - public void onRobotDeath(RobotDeathEvent e) {} - - public void onWin(WinEvent e) {} -} diff --git a/workspace_robo/robocode.samples/src/main/java/sampleex/AlienComposition.java b/workspace_robo/robocode.samples/src/main/java/sampleex/AlienComposition.java deleted file mode 100644 index 6e0f113..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sampleex/AlienComposition.java +++ /dev/null @@ -1,95 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sampleex; - - -import robocode.*; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IBasicRobot; -import robocode.robotinterfaces.peer.IBasicRobotPeer; -import robocode.robotinterfaces.peer.IStandardRobotPeer; - -import java.io.PrintStream; - - -/** - * A sample robot. - * Is not inherited from classic base robots, uses new experimental access to RobotPeer. - * Use -DEXPERIMENTAL=true to start robocode for this robot. - * This composition version is showing possible decomposition of robot, main runnable and event handler to different classes. - * - * @author Pavel Savara (original) - */ -public class AlienComposition implements IBasicRobot { - PrintStream out; - IStandardRobotPeer peer; - final AlienMain main; - final AlienEventHandler handler; - - public AlienComposition() { - main = new AlienMain(); - handler = new AlienEventHandler(); - } - - public void setPeer(IBasicRobotPeer iRobotPeer) { - peer = (IStandardRobotPeer) iRobotPeer; - } - - public void setOut(PrintStream printStream) { - out = printStream; - } - - public Runnable getRobotRunnable() { - return main; - } - - public IBasicEvents getBasicEventListener() { - return handler; - } - - class AlienMain implements Runnable { - public void run() { - while (true) { - peer.move(100); // Move ahead 100 - peer.turnGun(Math.PI * 2); // Spin gun around - peer.move(-100); // Move back 100 - peer.turnGun(Math.PI * 2); // Spin gun around - } - } - } - - - class AlienEventHandler implements IBasicEvents { - public void onScannedRobot(ScannedRobotEvent e) { - peer.setFire(1); - } - - public void onHitByBullet(HitByBulletEvent e) { - peer.turnBody(Math.PI / 2 + e.getBearingRadians()); - } - - public void onStatus(StatusEvent e) {} - - public void onBulletHit(BulletHitEvent e) {} - - public void onBulletHitBullet(BulletHitBulletEvent e) {} - - public void onBulletMissed(BulletMissedEvent e) {} - - public void onDeath(DeathEvent e) {} - - public void onHitRobot(HitRobotEvent e) {} - - public void onHitWall(HitWallEvent e) {} - - public void onRobotDeath(RobotDeathEvent e) {} - - public void onWin(WinEvent e) {} - } -} - diff --git a/workspace_robo/robocode.samples/src/main/java/sampleex/MasterAndSlave.java b/workspace_robo/robocode.samples/src/main/java/sampleex/MasterAndSlave.java deleted file mode 100644 index b862ff5..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sampleex/MasterAndSlave.java +++ /dev/null @@ -1,115 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sampleex; - - -import robocode.AdvancedRobot; -import robocode.HitByBulletEvent; -import robocode.ScannedRobotEvent; -import robocode.robotinterfaces.IAdvancedEvents; -import robocode.robotinterfaces.IAdvancedRobot; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IInteractiveEvents; -import robocode.robotinterfaces.peer.IBasicRobotPeer; - -import java.io.PrintStream; - - -/** - * @author Pavel Savara (original) - */ -public class MasterAndSlave extends MasterBase implements IAdvancedRobot { - - /** - * This is not showing any aditional qualities over normal MyFirst robot. - * But it could, because architecture is no more tied by inheritance from Robot base class. - */ - public void run() { - while (true) { - ahead(100); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(100); // Move back 100 - turnGunRight(360); // Spin gun around - } - } - - public void onScannedRobot(ScannedRobotEvent e) { - fire(1); - } - - public void onHitByBullet(HitByBulletEvent e) { - turnLeft(90 - e.getBearing()); - } - - public IInteractiveEvents getInteractiveEventListener() { - return null; - } -} - - -/** - * Infrastructure base class, for helpers and boring implementation details - */ -abstract class MasterBase { - - public MasterBase() { - helperRobot = new Slave(this); - } - - private final AdvancedRobot helperRobot; - - public IAdvancedEvents getAdvancedEventListener() { - return helperRobot; - } - - public IInteractiveEvents getSystemEventListener() { - return helperRobot; - } - - public Runnable getRobotRunnable() { - return helperRobot; - } - - public IBasicEvents getBasicEventListener() { - return helperRobot; - } - - public void setPeer(IBasicRobotPeer robotPeer) { - helperRobot.setPeer(robotPeer); - } - - public void setOut(PrintStream printStream) { - helperRobot.setOut(printStream); - } - - public void turnGunRight(double degrees) { - helperRobot.turnGunRight(degrees); - } - - public void turnLeft(double degrees) { - helperRobot.turnLeft(degrees); - } - - public void ahead(double distance) { - helperRobot.ahead(distance); - } - - public void back(double distance) { - helperRobot.back(distance); - } - - public void fire(double power) { - helperRobot.fire(power); - } - - public void onScannedRobot(ScannedRobotEvent e) {} - - public void onHitByBullet(HitByBulletEvent e) {} - - public void run() {} -} diff --git a/workspace_robo/robocode.samples/src/main/java/sampleex/ProxyOfGreyEminence.java b/workspace_robo/robocode.samples/src/main/java/sampleex/ProxyOfGreyEminence.java deleted file mode 100644 index 9c2864b..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sampleex/ProxyOfGreyEminence.java +++ /dev/null @@ -1,73 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sampleex; - - -import robocode.AdvancedRobot; -import robocode.HitByBulletEvent; -import robocode.ScannedRobotEvent; - - -/** - * This is just dummy proxy, it's hiding the Eminence and - * giving it more freedom to inherit from Monk rather than from Robot. - * - * @author Pavel Savara (original) - */ -public class ProxyOfGreyEminence extends AdvancedRobot { - private final GreyEminence monk; - - public ProxyOfGreyEminence() { - monk = new GreyEminence(this); - } - - public void onHitByBullet(HitByBulletEvent event) { - monk.onHitByBullet(event); - } - - public void onScannedRobot(ScannedRobotEvent event) { - monk.onScannedRobot(event); - } - - public void run() { - monk.run(); - } -} - - -/** - * The power behind the throne. - */ -class GreyEminence extends RegullarMonk { - private final ProxyOfGreyEminence proxy; - - public GreyEminence(ProxyOfGreyEminence proxy) { - this.proxy = proxy; - } - - /** - * This is not showing any aditional qualities over normal MyFirst robot. - * But it could, because architecture is no more tied by inheritance from Robot base class. - */ - public void run() { - while (true) { - proxy.ahead(100); // Move ahead 100 - proxy.turnGunRight(360); // Spin gun around - proxy.back(100); // Move back 100 - proxy.turnGunRight(360); // Spin gun around - } - } - - public void onScannedRobot(ScannedRobotEvent e) { - proxy.fire(1); - } - - public void onHitByBullet(HitByBulletEvent e) { - proxy.turnLeft(90 - e.getBearing()); - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sampleex/RegullarMonk.java b/workspace_robo/robocode.samples/src/main/java/sampleex/RegullarMonk.java deleted file mode 100644 index 253f53c..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sampleex/RegullarMonk.java +++ /dev/null @@ -1,17 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sampleex; - - -/** - * Monk of a order. Implements anything too boring for Eminence. - * The infractructure base class. - * - * @author Pavel Savara (original) - */ -abstract class RegullarMonk {} diff --git a/workspace_robo/robocode.samples/src/main/java/sampleex/Slave.java b/workspace_robo/robocode.samples/src/main/java/sampleex/Slave.java deleted file mode 100644 index d5e47ab..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sampleex/Slave.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sampleex; - - -import robocode.AdvancedRobot; -import robocode.HitByBulletEvent; -import robocode.ScannedRobotEvent; - - -/** - * This is robot derived from AdvancedRobot. - * Only reason to use this inheritance and this class is that external robots are unable to call RobotPeer directly. - * - * @author Pavel Savara (original) - */ -class Slave extends AdvancedRobot { - final MasterBase parent; - - public Slave(MasterBase parent) { - this.parent = parent; - } - - public void run() { - parent.run(); - } - - public void onScannedRobot(ScannedRobotEvent e) { - parent.onScannedRobot(e); - } - - public void onHitByBullet(HitByBulletEvent e) { - parent.onHitByBullet(e); - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/samplesentry/BorderGuard.java b/workspace_robo/robocode.samples/src/main/java/samplesentry/BorderGuard.java deleted file mode 100644 index 8fc6ac7..0000000 --- a/workspace_robo/robocode.samples/src/main/java/samplesentry/BorderGuard.java +++ /dev/null @@ -1,716 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package samplesentry; - - -import robocode.*; -import robocode.util.Utils; - -import java.awt.BasicStroke; -import java.awt.Color; -import java.awt.Graphics2D; -import java.awt.geom.Point2D; -import java.util.*; - - -/** - * BorderGuard - is a sample robot that demonstrates how the BorderSentry interface can be used for - * creating a robot that guards the border area of the battle field, and which is efficient against - * robots trying to hide at corners and robots sneaking around near the borders. - *

- * This robot is somewhat advanced due to:
- * 1) it uses linear targeting for predicting how to hit robots that moves in straight lines.
- * 2) it will only fire at a robot, if it figures out that its bullets will do damage to that - * particular robot, e.g. when the robots predicted future position will be within the sentry border - * attack range.
- * 3) it has an efficient scanner that keeps the scan angle as little as possible to get as new - * scanned data for enemy robots as possible.
- * 4) it picks a target robot to fire at, which is the nearest robot our robot will be able to - * damage (by predicting its future position using linear targeting).
- * 5) it only moves along the borders of the battle field and constantly changes its direction, so - * it is not an easy target, and it will try to get as close to its target robot as possible.
- *

- * Lots of improvements can be made to this robot by copying it - making it even stronger. The - * intention with of this sample robot is to serve as a more advanced example of how a AdvancedRobot - * can be made, and how it can be structured as most sample robots are far simpler. - *

- * - * Credits goes to the hard working Robocoders at the RoboWiki. :-) - *

- * - * This robot makes use of the Oldest Scanned melee scanner from the RoboWiki:
- * http://robowiki.net/wiki/Melee_Radar - *

- * - * In addition, it makes use of the Exact Non-iterative Solution for Linear Targeting from the - * RoboWiki:
- * http://robowiki.net/wiki/Linear_Targeting - * - * @author Flemming N. Larsen - * - * @version 1.0 - * - * @since 1.9.0.0 - */ -public class BorderGuard extends AdvancedRobot implements BorderSentry { - - // Constants - final double FIREPOWER = 3; // Max. power => violent as this robot can afford it! - final double HALF_ROBOT_SIZE = 18; // Robot size is 36x36 units, so the half size is 18 units - - // Map containing data for all scanned robots. - // The key to the map is a robot name and the value is an object containing robot data. - final Map enemyMap; - - // Scanning direction, where the radar turns to the right with positive values, and turns - // to the left with negative values. - double scanDir = 1; - - // Oldest scanned robot. Can be null. - RobotData oldestScanned; - - // Target robot for the gun. Can be null meaning that there is currently no target robot. - RobotData target; - - // Last time when the robot shifted its direction - long lastDirectionShift; - - // Current direction, where 1 means ahead (forward) and -1 means back - int direction = 1; - - /** - * Constructs this robot. - */ - public BorderGuard() { - // We initialize a specialized HashMap that uses a linked list for the access order. - // This means that the last accessed robot entry is listed first, when we iterate over its - // values. This robot always sweep the radar towards the oldest scanned robot. - enemyMap = new LinkedHashMap(5, 2, true); - } - - /** - * Main method that is called by the game when the robot engage in the next round of a battle. - */ - @Override - public void run() { - // Do initialization stuff here before the loop - initialize(); - - // Loop forever. If the robot does not take action, the game will disable our robot! - while (true) { - // Handle a single turn... - - // Handle the radar that scans enemy robots - handleRadar(); - // Handle the gun by turning it and fire at our target - handleGun(); - // Move the robot around on the battlefield - moveRobot(); - - // Scan for other robots. Note that this method will execute all pending commands for - // the next turn. Hence, scan() ends the turn for our robot. - scan(); - } - } - - /** - * This method is called by the game when your robot sees another robot, i.e. when the robot's - * radar scan "hits" another robot. - * - * @param scannedRobotEvent - * is a ScannedRobotEvent event. - */ - @Override - public void onScannedRobot(ScannedRobotEvent scannedRobotEvent) { - // Check that the scanned robot is not a sentry robot - if (!scannedRobotEvent.isSentryRobot()) { - // The scanned robot is not a sentry robot... - - // Update the enemy map - updateEnemyMap(scannedRobotEvent); - - // Update the scan direction - updateScanDirection(scannedRobotEvent); - - // Update enemy target positions - updateEnemyTargetPositions(); - } - } - - /** - * This method is called by the game when another robot dies. - * - * @param robotDeathEvent - * is the RobotDeathEvent that occurs, when another robot dies, which contains data - * for the robot that died. - */ - @Override - public void onRobotDeath(RobotDeathEvent robotDeathEvent) { - // Gets the name of the robot that died - final String deadRobotName = robotDeathEvent.getName(); - - // Remove the robot data for the robot that died from the enemy map - enemyMap.remove(deadRobotName); - - // Remove the data entry for the oldest scanned robot, if we have such an entry - if (oldestScanned != null && oldestScanned.name.equals(deadRobotName)) { - oldestScanned = null; - } - if (target != null && target.name.equals(deadRobotName)) { - target = null; - } - } - - /** - * This method is called by the every time the robot is painted. In order to see the painting, - * make sure to enable the Paint button on the robot console for this robot. - * - * @param g - * is the {@link Graphics2D} object, which is the graphics context used for painting - * various shapes like rectangles, circles, lines etc. on top of the battlefield for - * debugging graphics. - */ - @Override - public void onPaint(Graphics2D g) { - // Set the line width to 2 pixels - g.setStroke(new BasicStroke(2f)); - - // Prepare colors for painting the scanned coordinate and target coordinate - Color color1 = new Color(0x00, 0xFF, 0x00, 0x40); // Green with 25% alpha blending - Color color2 = new Color(0xFF, 0xFF, 0x00, 0x40); // Yellow with 25% alhpa blending - - // Paint a two circles for each robot in the enemy map. One circle where the robot was - // scanned the last time, and another circle where our robot must point the gun in order to - // hit it (target coordinate). In addition, a line is drawn between these circles. - for (RobotData robot : enemyMap.values()) { - // Paint the two circles and a line - fillCircle(g, robot.scannedX, robot.scannedY, color1); // scanned coordinate - fillCircle(g, robot.targetX, robot.targetY, color2); // target coordinate - g.setColor(color1); - g.drawLine((int) robot.scannedX, (int) robot.scannedY, (int) robot.targetX, (int) robot.targetY); - } - - // Paint a two circles for the target robot. One circle where the robot was - // scanned the last time, and another circle where our robot must point the gun in order to - // hit it (target coordinate). In addition, a line is drawn between these circles. - if (target != null) { - // Prepare colors for painting the scanned coordinate and target coordinate - color1 = new Color(0xFF, 0x7F, 0x00, 0x40); // Orange with 25% alpha blending - color2 = new Color(0xFF, 0x00, 0x00, 0x80); // Red with 50% alpha blending - - // Paint the two circles and a line - fillCircle(g, target.scannedX, target.scannedY, color1); // scanned coordinate - fillCircle(g, target.targetX, target.targetY, color2); // target coordinate - g.setColor(color1); - g.drawLine((int) target.scannedX, (int) target.scannedY, (int) target.targetX, (int) target.targetY); - } - } - - /** - * Initializes this robot before a new round in a battle. - */ - private void initialize() { - // Let the robot body, gun, and radar turn independently of each other - setAdjustRadarForGunTurn(true); - setAdjustGunForRobotTurn(true); - - // Set robot colors - setBodyColor(new Color(0x5C, 0x33, 0x17)); // Chocolate Brown - setGunColor(new Color(0x45, 0x8B, 0x74)); // Aqua Marine - setRadarColor(new Color(0xD2, 0x69, 0x1E)); // Orange Chocolate - setBulletColor(new Color(0xFF, 0xD3, 0x9B)); // Burly wood - setScanColor(new Color(0xCA, 0xFF, 0x70)); // Olive Green - } - - /** - * This method handles the radar that scans for enemy robots. - */ - private void handleRadar() { - // Set the radar to turn infinitely to the right if the scan direction is positive; - // otherwise the radar is moved to the left, if the scan direction is negative. - // Notice that onScannedRobot(ScannedRobotEvent) is responsible for determining the scan - // direction. - setTurnRadarRightRadians(scanDir * Double.POSITIVE_INFINITY); - } - - /** - * Method that handles the gun be turning it and fire at a target. - */ - private void handleGun() { - // Update our target robot to fire at - updateTarget(); - // Update the gun direction - updateGunDirection(); - // Fires the gun, when it is ready - fireGunWhenReady(); - } - - /** - * Method that moves our robot around the battlefield. - */ - private void moveRobot() { - - // The movement strategy is to move as close to our target robot as possible. - // Our robot should move along the borders all the time, vertically or horizontally. - // When we get close to our target, or have no where to go, our robot should shift its - // direction from side to side so it does not stand still at any time. - // If the robot stands still, it will be an easy target for enemy robots. - - int newDirection = direction; - - // Get closer to our target if we have a target robot - if (target != null) { - // Calculate the range from the walls/borders, our robot should keep within - int borderRange = getSentryBorderSize() - 20; - - // The horizontal and vertical flags are used for determining, if our robot should - // move horizontal or vertical. - boolean horizontal = false; - boolean vertical = false; - - // Initialize the new heading of the robot to the current heading of the robot - double newHeading = getHeadingRadians(); - - // Check if our robot is at the upper or lower border and hence should move horizontally - if (getY() < borderRange || getY() > getBattleFieldHeight() - borderRange) { - horizontal = true; - } - // Check if our robot is at the left or right border and hence should move vertically - if (getX() < borderRange || getX() > getBattleFieldWidth() - borderRange) { - vertical = true; - } - - // If we are in one of the corners of the battlefield, we could move both horizontally - // or vertically. - // In this situation, we need to choose one of the two directions. - if (horizontal && vertical) { - // If the horizontal distance to our target is lesser than the vertical distance, - // then we choose to move vertically, and hence we clear the horizontal flag. - if (Math.abs(target.targetX - getX()) <= Math.abs(target.targetY - getY())) { - horizontal = false; // Do not move horizontally => move vertically - } - } - // Adjust the heading of our robot with 90 degrees, if it must move horizontally. - // Otherwise the calculated heading is towards moving vertically. - if (horizontal) { - newHeading -= Math.PI / 2; - } - // Set the robot to turn left the amount of radians we have just calculated - setTurnLeftRadians(Utils.normalRelativeAngle(newHeading)); - - // Check if our robot has finished turning, i.e. has less than 1 degrees left to turn - if (Math.abs(getTurnRemaining()) < 1 || Math.abs(getVelocity()) < 0.01) { - // If we should move horizontally, the set the robot to move ahead with the - // horizontal distance to the target robot. Otherwise, use the vertical distance. - double delta; // delta is the delta distance to move - if (horizontal) { - delta = target.targetX - getX(); - } else { - delta = target.targetY - getY(); - } - setAhead(delta); - - // Set the new direction of our robot to 1 (meaning move forward) if the delta - // distance is positive; otherwise it is set to -1 (meaning move backward). - newDirection = delta > 0 ? 1 : -1; - - // Check if more than 10 turns have past since we changed the direction the last - // time - if (getTime() - lastDirectionShift > 10) { - // If so, set the new direction to be the reverse direction if the velocity < 1 - if (Math.abs(getVelocity()) < 1) { - newDirection = direction * -1; - } - // Check if the direction really changed - if (newDirection != direction) { - // If the new direction != current direction, then set the current direction - // to be the new direction and save the current time so we know when we - // changed the direction the last time. - direction = newDirection; - lastDirectionShift = getTime(); - } - } - } - } - // Set ahead 100 units forward or backward depending on the direction - setAhead(100 * direction); - } - - /** - * Method the updates the enemy map based on new scan data for a scanned robot. - * - * @param scannedRobotEvent - * is a ScannedRobotEvent event containing data about a scanned robot. - */ - private void updateEnemyMap(ScannedRobotEvent scannedRobotEvent) { - // Gets the name of the scanned robot - final String scannedRobotName = scannedRobotEvent.getName(); - - // Get robot data for the scanned robot, if we have an entry in the enemy map - RobotData scannedRobot = enemyMap.get(scannedRobotName); - - // Check if data entry exists for the scanned robot - if (scannedRobot == null) { - // No data entry exists => Create a new data entry for the scanned robot - scannedRobot = new RobotData(scannedRobotEvent); - // Put the new data entry into the enemy map - enemyMap.put(scannedRobotName, scannedRobot); - } else { - // Data entry exists => Update the current entry with new scanned data - scannedRobot.update(scannedRobotEvent); - } - } - - /** - * Method that updates the direction of the radar based on new scan data for a scanned robot. - * - * @param scannedRobotEvent - * is a ScannedRobotEvent event containing data about a scanned robot. - */ - private void updateScanDirection(ScannedRobotEvent scannedRobotEvent) { - // Gets the name of the scanned robot - final String scannedRobotName = scannedRobotEvent.getName(); - - // Change the scanning direction if and only if we have no record for the oldest scanned - // robot or the scanned robot IS the oldest scanned robot (based on the name) AND the enemy - // map contains scanned data entries for ALL robots (the size of the enemy map is equal to - // the number of opponent robots found by calling the getOthers() method). - if ((oldestScanned == null || scannedRobotName.equals(oldestScanned.name)) && enemyMap.size() == getOthers()) { - - // Get the oldest scanned robot data from our LinkedHashMap, where the first value - // contains the oldest accessed entry, which is the robot we need to get. - RobotData oldestScannedRobot = enemyMap.values().iterator().next(); - - // Get the recent scanned position (x,y) of the oldest scanned robot - double x = oldestScannedRobot.scannedX; - double y = oldestScannedRobot.scannedY; - - // Get the heading of our robot - double ourHeading = getRadarHeadingRadians(); - - // Calculate the bearing to the oldest scanned robot. - // The bearing is the delta angle between the heading of our robot and the other robot, - // which can be a positive or negative angle. - double bearing = bearingTo(ourHeading, x, y); - - // Update the scan direction based on the bearing. - // If the bearing is positive, the radar will be moved to the right. - // If the bearing is negative, the radar will be moved to the left. - scanDir = bearing; - } - } - - /** - * Updates the target positions for all enemies. The target position is the position our robot - * must fire at in order to hit the target robot. This robot uses Linear Targeting (Exact - * Non-iterative Solution) as described on the RoboWiki here: - * http://robowiki.net/wiki/Linear_Targeting - */ - private void updateEnemyTargetPositions() { - // Go thru all robots in the enemy map - for (RobotData enemy : enemyMap.values()) { - - // Variables prefixed with e- refer to enemy and b- refer to bullet - double bV = Rules.getBulletSpeed(FIREPOWER); - double eX = enemy.scannedX; - double eY = enemy.scannedY; - double eV = enemy.scannedVelocity; - double eH = enemy.scannedHeading; - - // These constants make calculating the quadratic coefficients below easier - double A = (eX - getX()) / bV; - double B = (eY - getY()) / bV; - double C = eV / bV * Math.sin(eH); - double D = eV / bV * Math.cos(eH); - - // Quadratic coefficients: a*(1/t)^2 + b*(1/t) + c = 0 - double a = A * A + B * B; - double b = 2 * (A * C + B * D); - double c = (C * C + D * D - 1); - - // If the discriminant of the quadratic formula is >= 0, we have a solution meaning that - // at some time, t, the bullet will hit the enemy robot if we fire at it now. - double discrim = b * b - 4 * a * c; - if (discrim >= 0) { - // Reciprocal of quadratic formula. Calculate the two possible solution for the - // time, t - double t1 = 2 * a / (-b - Math.sqrt(discrim)); - double t2 = 2 * a / (-b + Math.sqrt(discrim)); - - // Choose the minimum positive time or select the one closest to 0, if the time is - // negative - double t = Math.min(t1, t2) >= 0 ? Math.min(t1, t2) : Math.max(t1, t2); - - // Calculate the target position (x,y) for the enemy. That is the point that our gun - // should point at in order to hit the enemy at the time, t. - double targetX = eX + eV * t * Math.sin(eH); - double targetY = eY + eV * t * Math.cos(eH); - - // Assume enemy stops at walls. Hence, we limit that target position at the walls. - double minX = HALF_ROBOT_SIZE; - double minY = HALF_ROBOT_SIZE; - double maxX = getBattleFieldWidth() - HALF_ROBOT_SIZE; - double maxY = getBattleFieldHeight() - HALF_ROBOT_SIZE; - - enemy.targetX = limit(targetX, minX, maxX); - enemy.targetY = limit(targetY, minY, maxY); - } - } - } - - /** - * Updates which enemy robot from the enemy map that should be our current target. - */ - private void updateTarget() { - // Set target to null, meaning that we have no target robot yet - target = null; - - // Create a list over possible target robots that is a copy of robot data from the enemy map - List targets = new ArrayList(enemyMap.values()); - - // Run thru all the possible target robots and remove those that are outside the attack - // range for this border sentry robot as our robot cannot do harm to robots outside its - // range. - Iterator it = targets.iterator(); - while (it.hasNext()) { - RobotData robot = it.next(); - if (isOutsideAttackRange(robot.targetX, robot.targetY)) { - it.remove(); - } - } - - // Set the target robot to be the one among all possible target robots that is closest to - // our robot. - double minDist = Double.POSITIVE_INFINITY; - for (RobotData robot : targets) { - double dist = distanceTo(robot.targetX, robot.targetY); - if (dist < minDist) { - minDist = dist; - target = robot; - } - } - - // If we still haven't got a target robot, then take the first one from our list of target - // robots if the list is not empty. - if (target == null && targets.size() > 0) { - target = targets.get(0); - } - } - - /** - * Method that updates the gun direction to point at the current target. - */ - private void updateGunDirection() { - // Only update the gun direction, if we have a current target - if (target != null) { - // Calculate the bearing between the gun and the target, which can be positive or - // negative - double targetBearing = bearingTo(getGunHeadingRadians(), target.targetX, target.targetY); - // Set the gun to turn right the amount of radians defined by the bearing to the target - setTurnGunRightRadians(targetBearing); // positive => turn right, negative => turn left - } - } - - /** - * Method that fires a bullet when the gun is ready to fire. - */ - private void fireGunWhenReady() { - // We only fire the fun, when we have a target robot - if (target != null) { - // Only fire when the angle of the gun is pointing at our (virtual) target robot - - // Calculate the distance between between our robot and the target robot - double dist = distanceTo(target.targetX, target.targetY); - // Angle that "covers" the the target robot from its center to its edge - double angle = Math.atan(HALF_ROBOT_SIZE / dist); - - // Check if the remaining angle (turn) to move the gun is less than our calculated cover - // angle - if (Math.abs(getGunTurnRemaining()) < angle) { - // If so, our gun should be pointing at our target so we can hit it => fire!! - setFire(FIREPOWER); - } - } - } - - /** - * Method that checks if a coordinate (x,y) is outside the Border Sentry's attack range. - * - * @param x - * is the x coordinate. - * @param y - * is the y coordinate. - * @return true if the coordinate is outside the attack range; false otherwise. - */ - private boolean isOutsideAttackRange(double x, double y) { - double minBorderX = getSentryBorderSize(); - double minBorderY = getSentryBorderSize(); - double maxBorderX = getBattleFieldWidth() - getSentryBorderSize(); - double maxBorderY = getBattleFieldHeight() - getSentryBorderSize(); - - return (x > minBorderX) && (y > minBorderY) && (x < maxBorderX) && (y < maxBorderY); - } - - /** - * Method that returns a value that is guaranteed to be within a value range defined by a - * minimum and maximum value based on an input value.
- * If the input value is lesser than the minimum value, the returned value will be set to the - * minimum value.
- * If the input value is greater than the maximum value, the returned value will be set to the - * maximum value.
- * Otherwise the returned value will be equal to the input value. - * - * @param value - * is the input value to limit. - * @param min - * is the allowed minimum value. - * @param max - * is the allowed maximum value. - * @return the limited input value that is guaranteed to be within the specified minimum and - * maximum range. - */ - private double limit(double value, double min, double max) { - return Math.min(max, Math.max(min, value)); - } - - /** - * Methods that returns the distance to a coordinate (x,y) from our robot. - * - * @param x - * is the x coordinate. - * @param y - * is the y coordinate. - * @return the distance to the coordinate (x,y). - */ - private double distanceTo(double x, double y) { - return Math.hypot(x - getX(), y - getY()); - } - - /** - * Method that returns the angle to a coordinate (x,y) from our robot. - * - * @param x - * is the x coordinate. - * @param y - * is the y coordinate. - * @return the angle to the coordinate (x,y). - */ - private double angleTo(double x, double y) { - return Math.atan2(x - getX(), y - getY()); - } - - /** - * Method that returns the bearing to a coordinate (x,y) from the position and heading of our - * robot. The bearing is the delta angle between the heading of our robot and the angle of the - * specified coordinate. - * - * @param x - * is the x coordinate. - * @param y - * is the y coordinate. - * @return the angle to the coordinate (x,y). - */ - private double bearingTo(double heading, double x, double y) { - return Utils.normalRelativeAngle(angleTo(x, y) - heading); - } - - /** - * Method that paints a filled circle at the specified coordinate (x,y) and given color. The - * circle will have a radius of 20 pixels (meaning that the diameter will be 40 pixels). - * - * @param gfx - * is the graphics context to draw within. - * @param x - * is the x coordinate for the center of the circle. - * @param y - * is the y coordinate for the center of the circle. - * @param color - * is the color of the filled circle. - */ - private void fillCircle(Graphics2D gfx, double x, double y, Color color) { - // Set the pen color - gfx.setColor(color); - // Paint a filled circle (oval) that has a radius of 20 pixels with a center at the input - // coordinates. - gfx.fillOval((int) x - 20, (int) y - 20, 40, 40); - } - - /** - * This class is used for storing data about a robot that has been scanned.
- * The data is mainly a snapshot of specific scanned data like the scanned position (x,y), - * velocity and heading, put also the calculated predicted target position of the robot when our - * robot needs to fire at the scanned robot.
- * Note that this class calculates the position (x,y) of the scanned robot as our robot moves, - * and hence data like the angle and distance to the scanned robot will change over time. by - * using the position, it is easy to calculate a new angle and distance to the robot. - */ - class RobotData { - final String name; // name of the scanned robot - double scannedX; // x coordinate of the scanned robot based on the last update - double scannedY; // y coordinate of the scanned robot based on the last update - double scannedVelocity; // velocity of the scanned robot from the last update - double scannedHeading; // heading of the scanned robot from the last update - double targetX; // predicated x coordinate to aim our gun at, when firing at the robot - double targetY; // predicated y coordinate to aim our gun at, when firing at the robot - - /** - * Creates a new robot data entry based on new scan data for a scanned robot. - * - * @param event - * is a ScannedRobotEvent event containing data about a scanned robot. - */ - RobotData(ScannedRobotEvent event) { - // Store the name of the scanned robot - name = event.getName(); - // Updates all scanned facts like position, velocity, and heading - update(event); - // Initialize the coordinates (x,y) to fire at to the updated scanned position - targetX = scannedX; - targetY = scannedY; - } - - /** - * Updates the scanned data based on new scan data for a scanned robot. - * - * @param event - * is a ScannedRobotEvent event containing data about a scanned robot. - */ - void update(ScannedRobotEvent event) { - // Get the position of the scanned robot based on the ScannedRobotEvent - Point2D.Double pos = getPosition(event); - // Store the scanned position (x,y) - scannedX = pos.x; - scannedY = pos.y; - // Store the scanned velocity and heading - scannedVelocity = event.getVelocity(); - scannedHeading = event.getHeadingRadians(); - } - - /** - * Returns the position of the scanned robot based on new scan data for a scanned robot. - * - * @param event - * is a ScannedRobotEvent event containing data about a scanned robot. - * @return the position (x,y) of the scanned robot. - */ - Point2D.Double getPosition(ScannedRobotEvent event) { - // Gets the distance to the scanned robot - double distance = event.getDistance(); - // Calculate the angle to the scanned robot (our robot heading + bearing to scanned - // robot) - double angle = getHeadingRadians() + event.getBearingRadians(); - - // Calculate the coordinates (x,y) of the scanned robot - double x = getX() + Math.sin(angle) * distance; - double y = getY() + Math.cos(angle) * distance; - - // Return the position as a point (x,y) - return new Point2D.Double(x, y); - } - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sampleteam/MyFirstDroid.java b/workspace_robo/robocode.samples/src/main/java/sampleteam/MyFirstDroid.java deleted file mode 100644 index c57d0d2..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sampleteam/MyFirstDroid.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sampleteam; - - -import robocode.Droid; -import robocode.MessageEvent; -import robocode.TeamRobot; -import static robocode.util.Utils.normalRelativeAngleDegrees; - - -/** - * SimpleDroid - a sample robot by Mathew Nelson. - *

- * Follows orders of team leader. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class MyFirstDroid extends TeamRobot implements Droid { - - /** - * run: Droid's default behavior - */ - public void run() { - out.println("MyFirstDroid ready."); - } - - /** - * onMessageReceived: What to do when our leader sends a message - */ - public void onMessageReceived(MessageEvent e) { - // Fire at a point - if (e.getMessage() instanceof Point) { - Point p = (Point) e.getMessage(); - // Calculate x and y to target - double dx = p.getX() - this.getX(); - double dy = p.getY() - this.getY(); - // Calculate angle to target - double theta = Math.toDegrees(Math.atan2(dx, dy)); - - // Turn gun to target - turnGunRight(normalRelativeAngleDegrees(theta - getGunHeading())); - // Fire hard! - fire(3); - } // Set our colors - else if (e.getMessage() instanceof RobotColors) { - RobotColors c = (RobotColors) e.getMessage(); - - setBodyColor(c.bodyColor); - setGunColor(c.gunColor); - setRadarColor(c.radarColor); - setScanColor(c.scanColor); - setBulletColor(c.bulletColor); - } - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sampleteam/MyFirstLeader.java b/workspace_robo/robocode.samples/src/main/java/sampleteam/MyFirstLeader.java deleted file mode 100644 index 140a94a..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sampleteam/MyFirstLeader.java +++ /dev/null @@ -1,89 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sampleteam; - - -import robocode.HitByBulletEvent; -import robocode.ScannedRobotEvent; -import robocode.TeamRobot; - -import java.awt.*; -import java.io.IOException; - - -/** - * MyFirstLeader - a sample team robot by Mathew Nelson. - *

- * Looks around for enemies, and orders teammates to fire - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class MyFirstLeader extends TeamRobot { - - /** - * run: Leader's default behavior - */ - public void run() { - // Prepare RobotColors object - RobotColors c = new RobotColors(); - - c.bodyColor = Color.red; - c.gunColor = Color.red; - c.radarColor = Color.red; - c.scanColor = Color.yellow; - c.bulletColor = Color.yellow; - - // Set the color of this robot containing the RobotColors - setBodyColor(c.bodyColor); - setGunColor(c.gunColor); - setRadarColor(c.radarColor); - setScanColor(c.scanColor); - setBulletColor(c.bulletColor); - try { - // Send RobotColors object to our entire team - broadcastMessage(c); - } catch (IOException ignored) {} - // Normal behavior - while (true) { - setTurnRadarRight(10000); - ahead(100); - back(100); - } - } - - /** - * onScannedRobot: What to do when you see another robot - */ - public void onScannedRobot(ScannedRobotEvent e) { - // Don't fire on teammates - if (isTeammate(e.getName())) { - return; - } - // Calculate enemy bearing - double enemyBearing = this.getHeading() + e.getBearing(); - // Calculate enemy's position - double enemyX = getX() + e.getDistance() * Math.sin(Math.toRadians(enemyBearing)); - double enemyY = getY() + e.getDistance() * Math.cos(Math.toRadians(enemyBearing)); - - try { - // Send enemy position to teammates - broadcastMessage(new Point(enemyX, enemyY)); - } catch (IOException ex) { - out.println("Unable to send order: "); - ex.printStackTrace(out); - } - } - - /** - * onHitByBullet: Turn perpendicular to bullet path - */ - public void onHitByBullet(HitByBulletEvent e) { - turnLeft(90 - e.getBearing()); - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sampleteam/Point.java b/workspace_robo/robocode.samples/src/main/java/sampleteam/Point.java deleted file mode 100644 index 79f9c1b..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sampleteam/Point.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sampleteam; - - -/** - * Point - a serializable point class - */ -public class Point implements java.io.Serializable { - - private static final long serialVersionUID = 1L; - - private double x = 0.0; - private double y = 0.0; - - public Point(double x, double y) { - this.x = x; - this.y = y; - } - - public double getX() { - return x; - } - - public double getY() { - return y; - } -} diff --git a/workspace_robo/robocode.samples/src/main/java/sampleteam/RobotColors.java b/workspace_robo/robocode.samples/src/main/java/sampleteam/RobotColors.java deleted file mode 100644 index 079bc60..0000000 --- a/workspace_robo/robocode.samples/src/main/java/sampleteam/RobotColors.java +++ /dev/null @@ -1,29 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package sampleteam; - - -import java.awt.*; - - -/** - * RobotColors - A serializable class to send Colors to teammates. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class RobotColors implements java.io.Serializable { - - private static final long serialVersionUID = 1L; - - public Color bodyColor; - public Color gunColor; - public Color radarColor; - public Color scanColor; - public Color bulletColor; -} diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/Corners.properties b/workspace_robo/robocode.samples/src/main/resources/sample/Corners.properties deleted file mode 100644 index 86a295d..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/Corners.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Aug 20 21:14:27 EST 2006 -robot.description=\ A sample robot\n Moves to a corner, then swings the gun back and forth.\n If it dies, it tries a new corner in the next round. -robot.webpage= -robocode.version=1.1.2 -robot.java.source.included=true -robot.author.name=Mathew Nelson and Flemming N. Larsen -robot.classname=sample.Corners -robot.name=Corners diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/Crazy.properties b/workspace_robo/robocode.samples/src/main/resources/sample/Crazy.properties deleted file mode 100644 index adc9001..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/Crazy.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Aug 20 21:16:04 EST 2006 -robot.description=\ A sample robot\n\n Moves around in a crazy pattern -robot.webpage= -robocode.version=1.1.2 -robot.java.source.included=true -robot.author.name=Mathew Nelson and Flemming N. Larsen -robot.classname=sample.Crazy -robot.name=Crazy diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/Fire.properties b/workspace_robo/robocode.samples/src/main/resources/sample/Fire.properties deleted file mode 100644 index db0f3a7..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/Fire.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Aug 20 21:16:33 EST 2007 -robot.description=\ A sample robot\n\n Sits still. Spins gun around. Moves when hit. Ooh\! -robot.webpage= -robocode.version=1.1.2 -robot.java.source.included=true -robot.author.name=Mathew Nelson and Flemming N. Larsen -robot.classname=sample.Fire -robot.name=Fire diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/Interactive.properties b/workspace_robo/robocode.samples/src/main/resources/sample/Interactive.properties deleted file mode 100644 index 66603d1..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/Interactive.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Wed Jun 27 23:08:48 EST 2007 -robot.description=\ A sample robot\n\n This is a robot that is controlled using the arrow keys and mouse only -robot.webpage= -robocode.version=1.3.4 -robot.java.source.included=true -robot.author.name=Flemming N. Larsen -robot.classname=sample.Interactive -robot.name=Interactive \ No newline at end of file diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/Interactive_v2.properties b/workspace_robo/robocode.samples/src/main/resources/sample/Interactive_v2.properties deleted file mode 100644 index aab1784..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/Interactive_v2.properties +++ /dev/null @@ -1,8 +0,0 @@ -#Robot Properties -robot.description=\ A sample robot\n\n This is a robot that is controlled using the arrow keys and mouse only -robot.webpage= -robocode.version=1.3.4 -robot.java.source.included=true -robot.author.name=Tuan Anh Nguyen and Flemming N. Larsen -robot.classname=sample.Interactive_v2 -robot.name=Interactive_v2 \ No newline at end of file diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/MyFirstJuniorRobot.properties b/workspace_robo/robocode.samples/src/main/resources/sample/MyFirstJuniorRobot.properties deleted file mode 100644 index 2cafbdc..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/MyFirstJuniorRobot.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Jul 29 00:07:28 EST 2007 -robot.description=\ A sample robot\n Moves in a seesaw motion, and spins the gun around at each end\n Moves perpendicular to the direction of a bullet that hits it -robot.webpage= -robocode.version=1.4 -robot.java.source.included=true -robot.author.name=Flemming N. Larsen -robot.classname=sample.MyFirstJuniorRobot -robot.name=MyFirstJuniorRobot \ No newline at end of file diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/MyFirstRobot.properties b/workspace_robo/robocode.samples/src/main/resources/sample/MyFirstRobot.properties deleted file mode 100644 index 1d298da..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/MyFirstRobot.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Fri Nov 02 17:17:44 EST 2001 -robot.description=\ A sample robot\n Moves in a seesaw motion, and spins the gun around at each end\n Turns perpendicular to the direction of a bullet that hits it -robot.webpage=http\://robocode.sourceforge.net/myfirstrobot/MyFirstRobot.html -robocode.version=1.0 -robot.java.source.included=true -robot.author.name=Mathew Nelson -robot.classname=sample.MyFirstRobot -robot.name=MyFirstRobot diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/PaintingRobot.properties b/workspace_robo/robocode.samples/src/main/resources/sample/PaintingRobot.properties deleted file mode 100644 index df0c29e..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/PaintingRobot.properties +++ /dev/null @@ -1,10 +0,0 @@ -#Robot Properties -#Sat Apr 12 14:47:44 EST 2008 -robot.description=\ A sample robot\n Demonstrates how to do custom painting and debugging properties. -robot.webpage= -robocode.version=1.6 -robot.java.source.included=true -robot.author.name=Stefan Westen -robot.classname=sample.PaintingRobot -robot.name=PaintingRobot - diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/RamFire.properties b/workspace_robo/robocode.samples/src/main/resources/sample/RamFire.properties deleted file mode 100644 index e48d0d4..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/RamFire.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Aug 20 21:17:21 EST 2007 -robot.description=\ A sample robot\n Drives at robots trying to ram them.\n Fires when it hits them. -robot.webpage= -robocode.version=1.1.2 -robot.java.source.included=true -robot.author.name=Mathew Nelson and Flemming N. Larsen -robot.classname=sample.RamFire -robot.name=RamFire diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/SittingDuck.properties b/workspace_robo/robocode.samples/src/main/resources/sample/SittingDuck.properties deleted file mode 100644 index c3aab1e..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/SittingDuck.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Aug 20 21:18:07 EST 2007 -robot.description=\ A sample robot\nThis robot sits still, and waits to be fired upon. Exciting stuff\!\nAlso counts how many times he has been a sitting duck. -robot.webpage= -robocode.version=1.1.2 -robot.java.source.included=true -robot.author.name=Mathew Nelson and Flemming N. Larsen -robot.classname=sample.SittingDuck -robot.name=SittingDuck diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/SpinBot.properties b/workspace_robo/robocode.samples/src/main/resources/sample/SpinBot.properties deleted file mode 100644 index c80fa0b..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/SpinBot.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Aug 20 21:18:07 EST 2006 -robot.description=\ A sample robot\n\n Moves in a circle, firing hard when an enemy is detected -robot.webpage= -robocode.version=1.1.2 -robot.java.source.included=true -robot.author.name=Mathew Nelson and Flemming N. Larsen -robot.classname=sample.SpinBot -robot.name=SpinBot diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/Target.properties b/workspace_robo/robocode.samples/src/main/resources/sample/Target.properties deleted file mode 100644 index 4537956..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/Target.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Aug 20 21:18:46 EST 2006 -robot.description=\ A sample robot\n Sits still. Moves every time energy drops by 20.\n This Robot demonstrates custom events. -robot.webpage= -robocode.version=1.1.2 -robot.java.source.included=true -robot.author.name=Mathew Nelson and Flemming N. Larsen -robot.classname=sample.Target -robot.name=Target diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/TrackFire.properties b/workspace_robo/robocode.samples/src/main/resources/sample/TrackFire.properties deleted file mode 100644 index be9b3e8..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/TrackFire.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Aug 20 21:21:08 EST 2006 -robot.description=\ A sample robot\n\n Tracks and fires at the nearest robot it sees -robot.webpage= -robocode.version=1.1.2 -robot.java.source.included=true -robot.author.name=Mathew Nelson and Flemming N. Larsen -robot.classname=sample.TrackFire -robot.name=TrackFire diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/Tracker.properties b/workspace_robo/robocode.samples/src/main/resources/sample/Tracker.properties deleted file mode 100644 index 1e510a5..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/Tracker.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Aug 20 21:20:26 EST 2006 -robot.description=\ A sample robot\n\n Locks onto a robot, moves close, fires when close. -robot.webpage= -robocode.version=1.1.2 -robot.java.source.included=true -robot.author.name=Mathew Nelson and Flemming N. Larsen -robot.classname=sample.Tracker -robot.name=Tracker diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/VelociRobot.properties b/workspace_robo/robocode.samples/src/main/resources/sample/VelociRobot.properties deleted file mode 100644 index a48dbb8..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/VelociRobot.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Tue May 27 14:21:08 EST 2009 -robot.description=\ A sample robot\n\n Demonstrates the RateControlRobot -robot.webpage= -robocode.version=1.7.1.3 -robot.java.source.included=true -robot.author.name=Joshua Galecki -robot.classname=sample.VelociRobot -robot.name=VelociRobot diff --git a/workspace_robo/robocode.samples/src/main/resources/sample/Walls.properties b/workspace_robo/robocode.samples/src/main/resources/sample/Walls.properties deleted file mode 100644 index 7549037..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sample/Walls.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Aug 20 21:21:53 EST 2006 -robot.description=\ A sample robot\n\n Moves around the outer edge with the gun facing in -robot.webpage= -robocode.version=1.1.2 -robot.java.source.included=true -robot.author.name=Mathew Nelson and Flemming N. Larsen -robot.classname=sample.Walls -robot.name=Walls diff --git a/workspace_robo/robocode.samples/src/main/resources/sampleex/Alien.properties b/workspace_robo/robocode.samples/src/main/resources/sampleex/Alien.properties deleted file mode 100644 index 292c411..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sampleex/Alien.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Feb 20 21:16:33 EST 2008 -robot.description=\ A sample robot\n\n Is not inherited from classic base robots,\n uses new experimental access to RobotPeer. -robot.webpage=zamboch.blogspot.com -robocode.version=1.6 -robot.java.source.included=true -robot.author.name=Pavel Savara -robot.classname=sampleex.Alien -robot.name=Alien diff --git a/workspace_robo/robocode.samples/src/main/resources/sampleex/MasterAndSlave.properties b/workspace_robo/robocode.samples/src/main/resources/sampleex/MasterAndSlave.properties deleted file mode 100644 index 539d240..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sampleex/MasterAndSlave.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Feb 20 21:16:33 EST 2008 -robot.description=\ A sample robot\n\n Is not inherited from classic base robots,\n uses new experimental access to RobotPeer. -robot.webpage=zamboch.blogspot.com -robocode.version=1.6 -robot.java.source.included=true -robot.author.name=Pavel Savara -robot.classname=sampleex.MasterAndSlave -robot.name=MasterAndSlave diff --git a/workspace_robo/robocode.samples/src/main/resources/sampleex/ProxyOfGreyEminence.properties b/workspace_robo/robocode.samples/src/main/resources/sampleex/ProxyOfGreyEminence.properties deleted file mode 100644 index e47c5a0..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sampleex/ProxyOfGreyEminence.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sun Feb 20 21:16:33 EST 2008 -robot.description=\ A sample robot\n\n Is not inherited from classic base robots,\n uses new experimental access to RobotPeer. -robot.webpage=zamboch.blogspot.com -robocode.version=1.6 -robot.java.source.included=true -robot.author.name=Pavel Savara -robot.classname=sampleex.ProxyOfGreyEminence -robot.name=ProxyOfGreyEminence diff --git a/workspace_robo/robocode.samples/src/main/resources/samplesentry/BorderGuard.properties b/workspace_robo/robocode.samples/src/main/resources/samplesentry/BorderGuard.properties deleted file mode 100644 index 4224bae..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/samplesentry/BorderGuard.properties +++ /dev/null @@ -1,9 +0,0 @@ -#Robot Properties -#Sat May 25 22:15:07 EST 2013 -robot.description=\ A sample robot\n\n This is a robot that guards the borders of the battlefield\n\nUse it against \"wall crawlers\" like e.g. sample.Walls and sample.Corners -robot.webpage= -robocode.version=1.9.0.0 -robot.java.source.included=true -robot.author.name=Flemming N. Larsen -robot.classname=samplesentry.BorderGuard -robot.name=BorderGuard \ No newline at end of file diff --git a/workspace_robo/robocode.samples/src/main/resources/sampleteam/MyFirstTeam.team b/workspace_robo/robocode.samples/src/main/resources/sampleteam/MyFirstTeam.team deleted file mode 100644 index f9878e8..0000000 --- a/workspace_robo/robocode.samples/src/main/resources/sampleteam/MyFirstTeam.team +++ /dev/null @@ -1,7 +0,0 @@ -#Robocode robot team -#Sun Aug 20 23:26:53 EST 2006 -team.members=sampleteam.MyFirstLeader,sampleteam.MyFirstDroid,sampleteam.MyFirstDroid,sampleteam.MyFirstDroid,sampleteam.MyFirstDroid -team.author.name=Mathew Nelson and Flemming N. Larsen -robocode.version=1.1.2 -team.webpage= -team.description=\ A sample team.\n MyFirstLeader scans for enemies,\n and orders the 4 droids to fire. diff --git a/workspace_robo/robocode.sound/.classpath b/workspace_robo/robocode.sound/.classpath deleted file mode 100644 index f924dfd..0000000 --- a/workspace_robo/robocode.sound/.classpath +++ /dev/null @@ -1,10 +0,0 @@ - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.sound/.project b/workspace_robo/robocode.sound/.project deleted file mode 100644 index d9a53a7..0000000 --- a/workspace_robo/robocode.sound/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - robocode.sound - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.core - robocode.api - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.sound/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.sound/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.sound/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.sound/pom.xml b/workspace_robo/robocode.sound/pom.xml deleted file mode 100644 index b10ad26..0000000 --- a/workspace_robo/robocode.sound/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - 4.0.0 - robocode.sound - Robocode Sound - - net.sf.robocode - robocode - ${robocode.version} - - - - net.sf.robocode - robocode.core - ${project.version} - - - diff --git a/workspace_robo/robocode.sound/robocode.sound.iml b/workspace_robo/robocode.sound/robocode.sound.iml deleted file mode 100644 index be8c06b..0000000 --- a/workspace_robo/robocode.sound/robocode.sound.iml +++ /dev/null @@ -1,77 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.sound/src/main/java/net/sf/robocode/sound/Module.java b/workspace_robo/robocode.sound/src/main/java/net/sf/robocode/sound/Module.java deleted file mode 100644 index 2cb58c0..0000000 --- a/workspace_robo/robocode.sound/src/main/java/net/sf/robocode/sound/Module.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.sound; - - -import net.sf.robocode.core.BaseModule; -import net.sf.robocode.core.Container; - - -/** - * @author Pavel Savara (original) - */ -public class Module extends BaseModule { - static { - Container.cache.addComponent(ISoundManager.class, SoundManager.class); - } -} diff --git a/workspace_robo/robocode.sound/src/main/java/net/sf/robocode/sound/SoundCache.java b/workspace_robo/robocode.sound/src/main/java/net/sf/robocode/sound/SoundCache.java deleted file mode 100644 index fae8191..0000000 --- a/workspace_robo/robocode.sound/src/main/java/net/sf/robocode/sound/SoundCache.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.sound; - - -import net.sf.robocode.io.Logger; - -import javax.sound.sampled.*; -import java.io.IOException; -import java.net.URL; -import java.util.HashMap; -import java.util.Map; - - -/** - * SoundCache maintains a table of sound clips. More than one instance of the same - * sample can be stored, so a given sound effect can be played more than once - * symultaneously. - * - * @author Luis Crespo (original) - * @author Flemming N. Larsen (contributor) - */ -class SoundCache { - - /** - * Table containing all sound clips - */ - private final Map soundTable; - - /** - * Mixer used for creating clip instances - */ - private final Mixer mixer; - - /** - * Holds data, length and format for a given sound effect, which can be used to create - * multiple instances of the same clip. - */ - private static class SoundData { - private final AudioFormat format; - private final int length; - private final byte[] byteData; - - private SoundData(AudioInputStream ais) throws IOException { - int bytesRead, pos; - - format = ais.getFormat(); - length = (int) (ais.getFrameLength() * format.getFrameSize()); - byteData = new byte[length]; - pos = 0; - - do { - bytesRead = ais.read(byteData, pos, length - pos); - if (bytesRead > 0) { - pos += bytesRead; - } - } while (bytesRead > 0 && pos < length); - - ais.close(); - } - } - - - /** - * Holds an array of clips from the same sample stream, and takes care of - * returning the next available clip. If all clips are active, the least - * recently used clip will be returned. - */ - private static class ClipClones { - private final Clip[] clips; - private int idx; - - private ClipClones(Mixer mixer, SoundData soundData, int size) throws LineUnavailableException { - idx = 0; - clips = new Clip[size]; - - DataLine.Info info = new DataLine.Info(Clip.class, soundData.format); - - if (!AudioSystem.isLineSupported(info)) { - throw new LineUnavailableException("Required data line is not supported by the audio system"); - } - - for (int i = 0; i < size; i++) { - clips[i] = (Clip) mixer.getLine(info); - clips[i].open(soundData.format, soundData.byteData, 0, soundData.length); - } - } - - private void dispose() { - for (Clip c : clips) { - c.close(); - } - } - - private Clip next() { - Clip c = clips[idx]; - - idx = (idx + 1) % clips.length; - c.stop(); - c.setFramePosition(0); - return c; - } - } - - /** - * Constructs a sound cache to hold sound clips that is created based on the - * specified mixer. - * - * @param mixer the mixer to be used for creating the clip instances - */ - public SoundCache(Mixer mixer) { - this.mixer = mixer; - soundTable = new HashMap(); - } - - /** - * Adds a number of clip clones for a given resource holding the audio data. - * If there is any error, the method returns silently, and clip instances will - * not be found later for the provided key. - * - * @param key the key to be used for later retrieval of the sound - * @param resourceName the resource holding the audio data - * @param numClones the number of copies of the clip to be created - */ - public void addSound(Object key, String resourceName, int numClones) { - if (mixer == null || resourceName == null || (resourceName.trim().length() == 0)) { - return; - } - - SoundData data = createSoundData(resourceName); - - if (data == null) { - return; - } - - ClipClones clones; - - try { - clones = new ClipClones(mixer, data, numClones); - soundTable.put(key, clones); - } catch (LineUnavailableException e) { - Logger.logError( - "The audio mixer " + mixer.getMixerInfo().getName() - + " does not support the audio format of the sound clip: " + resourceName); - } - } - - /** - * Creates an instance of SoundData, to be used later for creating the clip clones. - * - * @param resourceName the name of the resource holding the audio data - * @return the newly created sound data - */ - private SoundData createSoundData(String resourceName) { - SoundData data; - URL url = SoundCache.class.getResource(resourceName); - - if (url == null) { - Logger.logError("Could not load sound because of invalid resource name: " + resourceName); - return null; - } - try { - AudioInputStream ais = AudioSystem.getAudioInputStream(url); - - data = new SoundData(ais); - } catch (Exception e) { - Logger.logError("Error while reading sound from resource: " + resourceName, e); - data = null; - } - return data; - } - - /** - * Gets the next available clip instance of a given sound. If all clips for that - * sound are active (playing), the least recently used will be returned. - * - * @param key the key that was used when adding the sound - * @return a clip instance ready to be played through Clip.start() - */ - public Clip getSound(Object key) { - ClipClones clones = soundTable.get(key); - - if (clones == null) { - return null; - } - return clones.next(); - } - - /** - * Removes all clip copies of a given sound, closing all its dependent resources - * - * @param key the key that was used when adding the sound - */ - public void removeSound(Object key) { - ClipClones clones = soundTable.get(key); - - if (clones == null) { - return; - } - clones.dispose(); - - soundTable.remove(key); - } - - /** - * Empties all clips from the sound cache - */ - public void clear() { - for (ClipClones clones : soundTable.values()) { - clones.dispose(); - } - soundTable.clear(); - } -} diff --git a/workspace_robo/robocode.sound/src/main/java/net/sf/robocode/sound/SoundManager.java b/workspace_robo/robocode.sound/src/main/java/net/sf/robocode/sound/SoundManager.java deleted file mode 100644 index 9886d13..0000000 --- a/workspace_robo/robocode.sound/src/main/java/net/sf/robocode/sound/SoundManager.java +++ /dev/null @@ -1,376 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.sound; - - -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.settings.ISettingsListener; -import net.sf.robocode.settings.ISettingsManager; -import robocode.control.events.BattleAdaptor; -import robocode.control.events.BattleFinishedEvent; -import robocode.control.events.BattleStartedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IBulletSnapshot; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.control.snapshot.RobotState; - -import javax.sound.sampled.AudioSystem; -import javax.sound.sampled.Clip; -import javax.sound.sampled.FloatControl; -import javax.sound.sampled.Mixer; - - -/** - * The sound manager is responsible of keeping a table of sound effects and - * play the appropriate sound for each bullet or robot event that is supposed - * to make any noise. - * - * @author Luis Crespo (original) - * @author Flemming N. Larsen (contributor) - * @author Titus Chen (contributor) - */ -public class SoundManager implements ISoundManager { - - // Cache containing sound clips - private SoundCache sounds; - - // Access to properties - private final ISettingsManager properties; - private final IBattleManager battleManager; - private boolean isSoundEnabled = true; - BattleObserver observer; - - public SoundManager(final ISettingsManager properties, IBattleManager battleManager) { - this.battleManager = battleManager; - this.properties = properties; - if (isSoundEnabled()) { - observer = new BattleObserver(); - battleManager.addListener(observer); - } - - properties.addPropertyListener(new ISettingsListener() { - public void settingChanged(String property) { - if (property.equals(ISettingsManager.OPTIONS_SOUND_ENABLESOUND)) { - updateListener(); - } - } - }); - - } - - /** - * Returns the current mixer selected from the Robocode properties. - * - * @return the current Mixer instance - */ - public Mixer getMixer() { - return findMixer(properties.getOptionsSoundMixer()); - } - - private boolean isSoundEnabled() { - return isSoundEnabled && properties.getOptionsSoundEnableSound(); - } - - public void setEnableSound(boolean enable) { - isSoundEnabled = enable; - updateListener(); - } - - private void updateListener() { - if (observer == null && isSoundEnabled()) { - observer = new BattleObserver(); - battleManager.addListener(observer); - } else if (observer != null && !isSoundEnabled()) { - battleManager.removeListener(observer); - observer = null; - } - } - - /** - * Returns the cache containing sound clips. - * - * @return a SoundCache instance - */ - private SoundCache getSounds() { - if (sounds == null) { - sounds = new SoundCache(getMixer()); - - // Sound effects - sounds.addSound("gunshot", properties.getFileGunshotSfx(), 5); - sounds.addSound("robot death", properties.getRobotDeathSfx(), 3); - sounds.addSound("bullet hits robot", properties.getBulletHitsRobotSfx(), 3); - sounds.addSound("bullet hits bullet", properties.getBulletHitsBulletSfx(), 2); - sounds.addSound("robot collision", properties.getRobotCollisionSfx(), 2); - sounds.addSound("wall collision", properties.getWallCollisionSfx(), 2); - - // Music - sounds.addSound("theme", properties.getFileThemeMusic(), 1); - sounds.addSound("background", properties.getFileBackgroundMusic(), 1); - sounds.addSound("endOfBattle", properties.getFileEndOfBattleMusic(), 1); - } - return sounds; - } - - /** - * Iterates over the available mixers, looking for the one that matches a given - * class name. - * - * @param mixerClassName the class name of the mixer to be used. - * @return the requested mixer, if found. Otherwise, it returns null. - */ - private Mixer findMixer(String mixerClassName) { - if (mixerClassName == null) { - return null; - } - for (Mixer.Info mi : AudioSystem.getMixerInfo()) { - Mixer m = AudioSystem.getMixer(mi); - - if (m.getClass().getSimpleName().equals(mixerClassName)) { - return m; - } - } - return null; - } - - /** - * Performs shutdown, by liberating the sound table - */ - public void dispose() { - if (sounds != null) { // Do not call getSounds()! - sounds.clear(); - } - } - - /** - * Plays a specific sound at a given volume, panning and loop count - * - * @param key the sound name, as stored in the sound table - * @param pan panning to be used (-1=left, 0=middle, +1=right) - * @param volume volume to be used, from 0 to 1 - * @param loop the number of times to loop the sound - */ - private void playSound(Object key, float pan, float volume, int loop) { - Clip c = getSounds().getSound(key); - - if (c == null) { - return; - } - - if (properties.getOptionsSoundEnableMixerPan() && c.isControlSupported(FloatControl.Type.PAN)) { - FloatControl panCtrl = (FloatControl) c.getControl(FloatControl.Type.PAN); - - panCtrl.setValue(pan); - } - if (properties.getOptionsSoundEnableMixerVolume() && c.isControlSupported(FloatControl.Type.MASTER_GAIN)) { - FloatControl volCtrl = (FloatControl) c.getControl(FloatControl.Type.MASTER_GAIN); - - float min = volCtrl.getMinimum() / 4; - - if (volume != 1) { - volCtrl.setValue(min * (1 - volume)); - } - } - c.loop(loop); - } - - /** - * Plays a specific sound at a given panning with max. volume and without looping. - * - * @param key the sound name, as stored in the sound table - * @param pan panning to be used (-1=left, 0=middle, +1=right) - */ - private void playSound(Object key, float pan) { - playSound(key, pan, 1, 0); - } - - /** - * Plays a specific piece of music with a given loop count with no panning and - * max. volume. - * - * @param key the sound name, as stored in the sound table - * @param loop the number of times to loop the music - */ - private void playMusic(Object key, int loop) { - playSound(key, 0, 1, loop); - } - - /** - * Plays a bullet sound depending on the bullet's state - * - * @param bp the bullet peer - * @param battleFieldWidth the width of the battle field used for panning. - */ - public void playBulletSound(IBulletSnapshot bp, int battleFieldWidth) { - float pan = 0; - - if (properties.getOptionsSoundEnableMixerPan()) { - pan = calcPan((float) bp.getPaintX(), battleFieldWidth); - } - switch (bp.getState()) { - case FIRED: - if (properties.getOptionsSoundEnableGunshot()) { - playSound("gunshot", pan, calcBulletVolume(bp), 0); - } - break; - - case HIT_VICTIM: - if (properties.getOptionsSoundEnableBulletHit()) { - playSound("bullet hits robot", pan); - } - break; - - case HIT_BULLET: - if (properties.getOptionsSoundEnableBulletHit()) { - playSound("bullet hits bullet", pan); - } - break; - - case HIT_WALL: - // Currently, no sound - break; - - case EXPLODED: - if (properties.getOptionsSoundEnableRobotDeath()) { - playSound("robot death", pan); - } - break; - - default: - } - } - - /** - * Plays a robot sound depending on the robot's state - * - * @param robotPeer the robot peer - * @param battleFieldWidth the battle field width used for panning - */ - public void playRobotSound(IRobotSnapshot robotPeer, int battleFieldWidth) { - float pan = 0; - - if (properties.getOptionsSoundEnableMixerPan()) { - pan = calcPan((float) robotPeer.getX(), battleFieldWidth); - } - switch (robotPeer.getState()) { - case HIT_ROBOT: - if (properties.getOptionsSoundEnableRobotCollision()) { - playSound("robot collision", pan); - } - break; - - case HIT_WALL: - if (properties.getOptionsSoundEnableWallCollision()) { - playSound("wall collision", pan); - } - break; - - default: - } - } - - /** - * Plays the theme music once. - */ - public void playThemeMusic() { - if (isSoundEnabled()) { - playMusic("theme", 0); - } - } - - /** - * Plays the background music, which is looping forever until stopped. - */ - public void playBackgroundMusic() { - playMusic("background", -1); - } - - /** - * Stops the background music. - */ - public void stopBackgroundMusic() { - Clip c = getSounds().getSound("background"); - - if (c != null) { - c.stop(); - } - } - - /** - * Plays the end of battle music once. - */ - public void playEndOfBattleMusic() { - playMusic("endOfBattle", 0); - } - - /** - * Determines pan based on the relative position to the battlefield's width - * - * @param x the bullet or robot position - * @param width the battlefield's width - * @return the panning value, ranging from -1 to +1 - */ - private float calcPan(float x, float width) { - float semiWidth = width / 2; - - return (x - semiWidth) / semiWidth; - } - - /** - * Determines volume based on the bullets's energy - * - * @param bp the bullet peer - * @return the volume value, ranging from 0 to 1 - */ - private float calcBulletVolume(IBulletSnapshot bp) { - return (float) (bp.getPower() / robocode.Rules.MAX_BULLET_POWER); - } - - private class BattleObserver extends BattleAdaptor { - @Override - public void onBattleStarted(BattleStartedEvent event) { - if (isSoundEnabled()) { - playBackgroundMusic(); - } - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - stopBackgroundMusic(); - if (isSoundEnabled()) { - playEndOfBattleMusic(); - } - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - if (isSoundEnabled()) { - int battleFieldWidth = battleManager.getBattleProperties().getBattlefieldWidth(); - - for (IBulletSnapshot bp : event.getTurnSnapshot().getBullets()) { - if (bp.getFrame() == 0) { - playBulletSound(bp, battleFieldWidth); - } - } - - boolean playedRobotHitRobot = false; - - for (IRobotSnapshot rp : event.getTurnSnapshot().getRobots()) { - // Make sure that robot-hit-robot events do not play twice (one per colliding robot) - if (rp.getState() == RobotState.HIT_ROBOT) { - if (playedRobotHitRobot) { - continue; - } - playedRobotHitRobot = true; - } - - playRobotSound(rp, battleFieldWidth); - } - } - } - } -} diff --git a/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/13831_adcbicycle_22.wav b/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/13831_adcbicycle_22.wav deleted file mode 100644 index a721580..0000000 Binary files a/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/13831_adcbicycle_22.wav and /dev/null differ diff --git a/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/explode.wav b/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/explode.wav deleted file mode 100644 index a3e5a78..0000000 Binary files a/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/explode.wav and /dev/null differ diff --git a/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/shellhit.wav b/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/shellhit.wav deleted file mode 100644 index c077a22..0000000 Binary files a/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/shellhit.wav and /dev/null differ diff --git a/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/zap.wav b/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/zap.wav deleted file mode 100644 index da7406c..0000000 Binary files a/workspace_robo/robocode.sound/src/main/resources/net/sf/robocode/sound/sounds/zap.wav and /dev/null differ diff --git a/workspace_robo/robocode.tests.robots/.classpath b/workspace_robo/robocode.tests.robots/.classpath deleted file mode 100644 index fa51e61..0000000 --- a/workspace_robo/robocode.tests.robots/.classpath +++ /dev/null @@ -1,9 +0,0 @@ - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.tests.robots/.project b/workspace_robo/robocode.tests.robots/.project deleted file mode 100644 index e9d65ce..0000000 --- a/workspace_robo/robocode.tests.robots/.project +++ /dev/null @@ -1,17 +0,0 @@ - - - robocode.tests.robots - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.api - robocode.samples - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.tests.robots/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.tests.robots/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.tests.robots/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.tests.robots/pom.xml b/workspace_robo/robocode.tests.robots/pom.xml deleted file mode 100644 index 4c61b0f..0000000 --- a/workspace_robo/robocode.tests.robots/pom.xml +++ /dev/null @@ -1,45 +0,0 @@ - - - 4.0.0 - robocode.tests.robots - Robocode Tested Robots - - robocode - net.sf.robocode - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - net.sf.robocode - robocode.samples - ${project.version} - - - - - - org.apache.maven.plugins - maven-dependency-plugin - - - unpack-dependencies - test - - unpack-dependencies - - - sample*/** - ${project.build.directory}/classes - - - - - - - diff --git a/workspace_robo/robocode.tests.robots/robocode.tests.robots.iml b/workspace_robo/robocode.tests.robots/robocode.tests.robots.iml deleted file mode 100644 index d39c655..0000000 --- a/workspace_robo/robocode.tests.robots/robocode.tests.robots.iml +++ /dev/null @@ -1,70 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.tests.robots/src/main/java/NoPackageButReallyLongNameIWouldSayTooLongMaybeEventLonger.java b/workspace_robo/robocode.tests.robots/src/main/java/NoPackageButReallyLongNameIWouldSayTooLongMaybeEventLonger.java deleted file mode 100644 index 002d5f8..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/NoPackageButReallyLongNameIWouldSayTooLongMaybeEventLonger.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -import robocode.Robot; - - -/** - * @author Pavel Savara (original) - */ -public class NoPackageButReallyLongNameIWouldSayTooLongMaybeEventLonger extends Robot { - @Override - public void run() { - while (true) { - ahead(1); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(1); // Move back 100 - turnGunRight(360); // Spin gun around - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/NoPackageShortName.java b/workspace_robo/robocode.tests.robots/src/main/java/NoPackageShortName.java deleted file mode 100644 index ccc98f9..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/NoPackageShortName.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -import robocode.Robot; - - -/** - * @author Pavel Savara (original) - */ -public class NoPackageShortName extends Robot { - @Override - public void run() { - while (true) { - ahead(1); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(1); // Move back 100 - turnGunRight(360); // Spin gun around - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/robocode/BadNamespace.java b/workspace_robo/robocode.tests.robots/src/main/java/robocode/BadNamespace.java deleted file mode 100644 index d18c589..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/robocode/BadNamespace.java +++ /dev/null @@ -1,24 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package robocode; - - -/** - * @author Pavel Savara (original) - */ -public class BadNamespace extends Robot { - @Override - public void run() { - while (true) { - ahead(1); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(1); // Move back 100 - turnGunRight(360); // Spin gun around - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/Ahead.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/Ahead.java deleted file mode 100644 index 67d4bd8..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/Ahead.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; - - -/** - * @author Pavel Savara (original) - */ -public class Ahead extends AdvancedRobot { - - @Override - public void run() { - ahead(100); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/AwtAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/AwtAttack.java deleted file mode 100644 index 35c4ff8..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/AwtAttack.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import robocode.ScannedRobotEvent; - -import javax.swing.*; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - - -/** - * @author Pavel Savara (original) - */ -public class AwtAttack extends AdvancedRobot { - - @Override - public void run() { - // noinspection InfiniteLoopStatement - for (;;) { - turnLeft(100); - ahead(10); - turnLeft(100); - back(10); - } - } - - @Override - public void onScannedRobot(ScannedRobotEvent event) { - awtAttack(); - } - - private void awtAttack() { - try { - Runnable doHack = new Runnable() { - public void run() { - writeAttack(); - - JFrame frame; - - frame = new JFrame(); - frame.setName("Hack"); - frame.setVisible(true); - - } - }; - - javax.swing.SwingUtilities.invokeLater(doHack); - } catch (Throwable e) { - // swalow security exception - e.printStackTrace(out); - } - } - - private void writeAttack() { - FileOutputStream fs; - - try { - fs = new FileOutputStream("C:\\Robocode.attack"); - fs.write(0xBA); - fs.write(0xDF); - fs.write(0x00); - fs.write(0xD0); - fs.close(); - out.println("Hacked!!!"); - } catch (FileNotFoundException e) { - e.printStackTrace(out); - } catch (IOException e) { - e.printStackTrace(out); - } catch (Throwable e) { - // swalow security exception - e.printStackTrace(out); - } - } - -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BadFirePower.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BadFirePower.java deleted file mode 100644 index 7bdd393..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BadFirePower.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import robocode.Bullet; - - -/** - * From Bug 2410856 - * @author Pavel Savara (original) - */ -public class BadFirePower extends AdvancedRobot { - - public void run() { - while (true) { - Bullet bullet = setFireBullet(getTime() - 12.0); - - if (bullet != null) { - out.println(getTime() + " Bullet power: " + bullet.getPower()); - } else { - out.println(getTime() + " No bullet"); - } - execute(); - } - } - -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BattleLost.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BattleLost.java deleted file mode 100644 index 35226d9..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BattleLost.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.BattleEndedEvent; -import robocode.DeathEvent; -import robocode.Robot; -import robocode.WinEvent; - - -/** - * @author Pavel Savara (original) - */ -public class BattleLost extends Robot { - @Override - public void run() { - while (true) { - ahead(1); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(1); // Move back 100 - turnGunRight(360); // Spin gun around - } - } - - @Override - public void onWin(WinEvent e) { - out.println("Win!"); - } - - @Override - public void onDeath(DeathEvent e) { - out.println("Death!"); - } - - @Override - public void onBattleEnded(BattleEndedEvent event) { - out.println("BattleEnded!"); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BattleWin.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BattleWin.java deleted file mode 100644 index b37d4c1..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BattleWin.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.*; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class BattleWin extends Robot { - - @Override - public void run() { - while (true) { - ahead(100); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(100); // Move back 100 - turnGunRight(360); // Spin gun around - } - } - - @Override - public void onScannedRobot(ScannedRobotEvent e) { - fire(1); - } - - @Override - public void onHitByBullet(HitByBulletEvent e) { - turnLeft(90 - e.getBearing()); - } - - @Override - public void onWin(WinEvent e) { - out.println("Win!"); - } - - @Override - public void onDeath(DeathEvent e) { - out.println("Death!"); - } - - @Override - public void onRoundEnded(RoundEndedEvent event) { - out.println("RoundEnded!"); - } - - @Override - public void onBattleEnded(BattleEndedEvent event) { - out.println("BattleEnded!"); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BodyTurnRate.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BodyTurnRate.java deleted file mode 100644 index 7bed86e..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/BodyTurnRate.java +++ /dev/null @@ -1,75 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -/** - * @author Flemming N. Larsen (original) - */ -public class BodyTurnRate extends robocode.AdvancedRobot { - - public void run() { - // Test turn rate at all speed moving ahead and turning left - - setAhead(1000); - setTurnLeft(360); - executeAndDumpTurnRate9turns(); - - stopMoving(); - - // Test turn rate at all speed moving ahead and turning right - - setAhead(1000); - setTurnRight(360); - executeAndDumpTurnRate9turns(); - - stopMoving(); - - // Test turn rate at all speed moving back and turning right - - setBack(1000); - setTurnRight(360); - executeAndDumpTurnRate9turns(); - - stopMoving(); - - // Test turn rate at all speed moving back and turning left - - setBack(1000); - setTurnLeft(360); - executeAndDumpTurnRate9turns(); - - stopMoving(); - } - - private void executeAndDumpTurnRate9turns() { - for (int i = 0; i < 9; i++) { - executeAndDumpTurnRate(); - } - } - - private void executeAndDumpTurnRate() { - double lastHeading = getHeading(); - double lastVelocity = getVelocity(); - - execute(); - - double turnRate = robocode.util.Utils.normalRelativeAngleDegrees(getHeading() - lastHeading); - - out.println(getTime() + ": " + lastVelocity + ", " + turnRate); - } - - private void stopMoving() { - setAhead(0); - setTurnLeft(0); - - for (int i = 0; i < 6; i++) { - executeAndDumpTurnRate(); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorAwtAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorAwtAttack.java deleted file mode 100644 index 97bc321..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorAwtAttack.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import javax.swing.*; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - - -/** - * @author Flemming N. Larsen (original) - */ -public class ConstructorAwtAttack extends robocode.AdvancedRobot { - - public ConstructorAwtAttack() { - awtAttack(); - } - - private void awtAttack() { - try { - Runnable doHack = new Runnable() { - public void run() { - writeAttack(); - - JFrame frame; - - frame = new JFrame(); - frame.setName("Hack"); - frame.setVisible(true); - - } - }; - - javax.swing.SwingUtilities.invokeLater(doHack); - } catch (Throwable e) { - // swallow security exception - e.printStackTrace(out); - } - } - - private void writeAttack() { - FileOutputStream fs; - - try { - fs = new FileOutputStream("C:\\Robocode.attack"); - fs.write(0xBA); - fs.write(0xDF); - fs.write(0x00); - fs.write(0xD0); - fs.close(); - out.println("Hacked!!!"); - } catch (FileNotFoundException e) { - e.printStackTrace(out); - } catch (IOException e) { - e.printStackTrace(out); - } catch (Throwable e) { - // swallow security exception - e.printStackTrace(out); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorHttpAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorHttpAttack.java deleted file mode 100644 index c124fea..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorHttpAttack.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; - - -/** - * @author Flemming N. Larsen (original) - */ -public class ConstructorHttpAttack extends AdvancedRobot { - - static final String HTTP_ADDR = "http://robocode.sourceforge.net/"; - - public ConstructorHttpAttack() { - try { - URL url = new URL(HTTP_ADDR); - - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - - if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { - InputStream is = conn.getInputStream(); - - is.read(); - } - } catch (IOException e) { - e.printStackTrace(out); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorReflectionAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorReflectionAttack.java deleted file mode 100644 index c884f07..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorReflectionAttack.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import java.io.ByteArrayOutputStream; -import java.io.PrintStream; -import java.lang.reflect.*; - - -/** - * @author Flemming N. Larsen (original) - */ -public class ConstructorReflectionAttack extends robocode.AdvancedRobot { - - static ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - static { - try { - Field field = System.class.getField("out"); - - field.setAccessible(true); - Object obj = field.get(null); - Method method = obj.getClass().getMethod("print", new Class[] { String.class }); - - method.setAccessible(true); - method.invoke(obj, new Object[] { "Hello World" }); - - } catch (Exception e) { - // The stack trace from the exception is redirected to a temporary buffer, - // which is read and written out to the robot's output in the run() method. - - PrintStream ps = new PrintStream(baos); - - e.printStackTrace(ps); - ps.flush(); - } - } - - public void run() { - // Write out the buffered output - out.append(baos.toString()); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorSocketAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorSocketAttack.java deleted file mode 100644 index a509dae..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorSocketAttack.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import java.io.*; -import java.net.*; - - -/** - * @author Flemming N. Larsen (original) - */ -public class ConstructorSocketAttack extends AdvancedRobot { - - static ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - static { - ServerSocket server = null; - Socket client = null; - - try { - server = new ServerSocket(9999); - client = server.accept(); - - InputStream is = new DataInputStream(client.getInputStream()); - OutputStream os = new PrintStream(client.getOutputStream()); - - os.write(1); - is.read(); - } catch (IOException e) { - // The stack trace from the exception is redirected to a temporary buffer, - // which is read and written out to the robot's output in the run() method. - - PrintStream ps = new PrintStream(baos); - - e.printStackTrace(ps); - ps.flush(); - } finally { - if (server != null) { - try { - server.close(); - } catch (IOException e) {} - } - if (client != null) { - try { - client.close(); - } catch (IOException e) {} - } - } - } - - public void run() { - // Write out the buffered output - out.append(baos.toString()); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorThreadAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorThreadAttack.java deleted file mode 100644 index a0c1e4a..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ConstructorThreadAttack.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -/** - * @author Flemming N. Larsen (original) - */ -public class ConstructorThreadAttack extends robocode.AdvancedRobot { - - public ConstructorThreadAttack() { - runAttack(); - runAttack2(); - } - - private void runAttack() { - try { - Attacker a = new Attacker(); - Thread t = new Thread(a); - - t.start(); - } catch (Throwable e) { - // swallow security exception - e.printStackTrace(out); - } - } - - private void runAttack2() { - try { - Attacker a = new Attacker(); - ThreadGroup tg = new ThreadGroup("MyAttack"); - - tg.setMaxPriority(10); - Thread t = new Thread(tg, a); - - t.start(); - } catch (Throwable e) { - // swallow security exception - e.printStackTrace(out); - } - } - - private class Attacker implements Runnable { - - public synchronized void run() { - if (Thread.currentThread().getPriority() > 4) { - out.println("Priority attack"); - } - runAttack2(); - - try { - this.wait(); - } catch (InterruptedException e) {} - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/CustomEvents.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/CustomEvents.java deleted file mode 100644 index 7cc0415..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/CustomEvents.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import robocode.Condition; -import robocode.CustomEvent; -import robocode.ScannedRobotEvent; - - -/** - * @author Pavel Savara (original) - */ -public class CustomEvents extends AdvancedRobot { - @Override - public void run() { - - addCustomEvent(new Condition("onTick99", 99) { - public boolean test() { - return true; - } - }); - - addCustomEvent(new Condition("onTick30", 30) { - public boolean test() { - return true; - } - }); - - addCustomEvent(new Condition("onLowEnergy98", 98) { - public boolean test() { - return getEnergy() < 20; - } - }); - while (true) { - ahead(100); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(100); // Move back 100 - turnGunRight(360); // Spin gun around - } - } - - public void onCustomEvent(CustomEvent e) { - out.println(getTime() + " " + e.getCondition().getName()); - } - - public void onScannedRobot(ScannedRobotEvent e) { - out.println(getTime() + " onScannedRobot10"); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DecelerationCaveat1.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DecelerationCaveat1.java deleted file mode 100644 index 77ef9cc..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DecelerationCaveat1.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; - - -/** - * This test robot is based on Eric Simonton's 3 caveats on the RoboWiki - * where Robocode did not work as expected when updating the robot movements - * with deceleration. - * - * @author Flemming N. Larsen (original) - */ -public class DecelerationCaveat1 extends AdvancedRobot { - - @Override - public void run() { - setAhead(100); - for (int i = 1; i <= 8; i++) { - execute(); - } - - setAhead(22.8); - for (int i = 1; i <= 5; i++) { - execute(); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DecelerationCaveat2.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DecelerationCaveat2.java deleted file mode 100644 index 72beece..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DecelerationCaveat2.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; - - -/** - * This test robot is based on Eric Simonton's 3 caveats on the RoboWiki - * where Robocode did not work as expected when updating the robot movements - * with deceleration. - * - * @author Flemming N. Larsen (original) - */ -public class DecelerationCaveat2 extends AdvancedRobot { - - @Override - public void run() { - setAhead(100); - for (int i = 1; i <= 8; i++) { - execute(); - } - - setAhead(22.5); - for (int i = 1; i <= 6; i++) { - execute(); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DecelerationCaveat3.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DecelerationCaveat3.java deleted file mode 100644 index 3fa6a50..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DecelerationCaveat3.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; - - -/** - * This test robot is based on Eric Simonton's 3 caveats on the RoboWiki - * where Robocode did not work as expected when updating the robot movements - * with deceleration. - * - * @author Flemming N. Larsen (original) - */ -public class DecelerationCaveat3 extends AdvancedRobot { - - @Override - public void run() { - setAhead(100); - for (int i = 1; i <= 8; i++) { - execute(); - } - - setAhead(-200); - setMaxVelocity(7); - execute(); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DieFast.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DieFast.java deleted file mode 100644 index 580309c..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/DieFast.java +++ /dev/null @@ -1,22 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.Robot; -import robocode.exception.RobotException; - - -/** - * @author Pavel Savara (original) - */ -public class DieFast extends Robot { - public void run() { - throw new RobotException(); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/EnvAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/EnvAttack.java deleted file mode 100644 index d662243..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/EnvAttack.java +++ /dev/null @@ -1,32 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; - - -/** - * @author Pavel Savara (original) - */ -public class EnvAttack extends AdvancedRobot { - @Override - public void run() { - - // attack - System.setProperty("NOSECURITY", "true"); - - // noinspection InfiniteLoopStatement - for (;;) { - turnLeft(100); - ahead(10); - turnLeft(100); - back(10); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/EventPriorityFilter.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/EventPriorityFilter.java deleted file mode 100644 index 5e7ab7a..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/EventPriorityFilter.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import robocode.HitWallEvent; -import robocode.ScannedRobotEvent; - - -/** - * @author Pavel Savara (original) - */ -public class EventPriorityFilter extends AdvancedRobot { - - @Override - public void run() { - // noinspection InfiniteLoopStatement - for (;;) { - ahead(10); // make sure we eventually hits a wall to receive onHitWall - } - } - - @Override - public void onScannedRobot(ScannedRobotEvent event) { - out.println("Scanned!!!"); // a robot was scanned -> problem! - } - - @Override - public void onHitWall(HitWallEvent e) { - // when the radar is turned here, at least another robot should be scanned - // but event should not be dispatched because we are in handler with higher priority - turnRadarRight(360); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FairPlay.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FairPlay.java deleted file mode 100644 index 1de6b99..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FairPlay.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.*; - - -/** - * @author Nat Pavasant (original) - */ -public class FairPlay extends AdvancedRobot { - public void run() { - setTurnRadarRightRadians(1d / 0d); - } - - public void onScannedRobot(ScannedRobotEvent e) { - setTurnRadarLeft(getRadarTurnRemaining()); - setTurnGunRightRadians( - robocode.util.Utils.normalRelativeAngle(e.getBearingRadians() + getHeadingRadians() - getGunHeadingRadians())); - setFire(3); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FileAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FileAttack.java deleted file mode 100644 index 3a35cec..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FileAttack.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import robocode.ScannedRobotEvent; - -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - - -/** - * @author Pavel Savara (original) - */ -public class FileAttack extends AdvancedRobot { - - @Override - public void run() { - // noinspection InfiniteLoopStatement - for (;;) { - turnLeft(100); - ahead(10); - turnLeft(100); - back(10); - } - } - - @Override - public void onScannedRobot(ScannedRobotEvent event) { - readAttack(); - writeAttack(); - } - - private void readAttack() { - try { - FileInputStream fs = new FileInputStream("C:\\MSDOS.SYS"); - - System.out.print(fs.read()); - System.out.print(fs.read()); - System.out.print(fs.read()); - System.out.print(fs.read()); - fs.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(out); - } catch (IOException e) { - e.printStackTrace(out); - } catch (Throwable e) { - // swalow security exception - e.printStackTrace(out); - } - } - - private void writeAttack() { - FileOutputStream fs; - - try { - fs = new FileOutputStream("C:\\Robocode.attack"); - fs.write(0xBA); - fs.write(0xDF); - fs.write(0x00); - fs.write(0xD0); - fs.close(); - } catch (FileNotFoundException e) { - e.printStackTrace(out); - } catch (IOException e) { - e.printStackTrace(out); - } catch (Throwable e) { - // swalow security exception - e.printStackTrace(out); - } - } - -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FileOutputStreamAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FileOutputStreamAttack.java deleted file mode 100644 index 689f1ae..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FileOutputStreamAttack.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; - - -/** - * @author Flemming N. Larsen (original) - */ -public class FileOutputStreamAttack extends AdvancedRobot { - - public void run() { - File file = null; - FileOutputStream fis = null; - try { - file = getDataFile("test"); - fis = new FileOutputStream(file); - fis.write(1); - } catch (IOException e) { - e.printStackTrace(out); - } finally { - if (fis != null) { - try { - fis.close(); - } catch (IOException ignore) {} - } - if (file != null) { - file.delete(); - } - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FileWriteSize.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FileWriteSize.java deleted file mode 100644 index ed89564..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/FileWriteSize.java +++ /dev/null @@ -1,58 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import robocode.RobocodeFileOutputStream; -import java.io.File; -import java.io.IOException; - - -/** - * @author Flemming N. Larsen (original) - */ -public class FileWriteSize extends AdvancedRobot { - - public void run() { - out.println("Data directory: " + getDataDirectory()); - out.println("Data quota: " + getDataQuotaAvailable()); - - byte[] buf = new byte[100000]; - - File file = null; - RobocodeFileOutputStream rfos = null; - - try { - file = getDataFile("test"); - out.println("Data file: " + file.getCanonicalPath()); - file.delete(); - - rfos = new RobocodeFileOutputStream(file); - - for (int i = 0; i < 3; i++) { - rfos.write(buf); - } - } catch (IOException e) { - e.printStackTrace(out); - } finally { - if (rfos != null) { - try { - rfos.close(); - } catch (IOException e) { - e.printStackTrace(out); - } - } - if (file != null) { - if (!file.delete()) { - out.println("Could not delete the file: " + file); - } - } - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/GunHeat.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/GunHeat.java deleted file mode 100644 index 06ce045..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/GunHeat.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; - - -/** - * @author Pavel Savara (original) - * From bug 2405844 - */ -public class GunHeat extends AdvancedRobot { - - public void run() { - while (true) { - setFireBullet(3.0); - out.println(getTime() + " gunHeat after fire: " + getGunHeat()); - execute(); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/GunTurnRate.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/GunTurnRate.java deleted file mode 100644 index 3b265aa..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/GunTurnRate.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -/** - * @author Flemming N. Larsen (original) - */ -public class GunTurnRate extends robocode.AdvancedRobot { - public void run() { - setMaxTurnRate(5); - - setTurnGunLeft(Double.POSITIVE_INFINITY); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - setTurnGunRight(Double.POSITIVE_INFINITY); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - setTurnLeft(Double.POSITIVE_INFINITY); - setTurnGunLeft(Double.POSITIVE_INFINITY); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - setTurnRight(Double.POSITIVE_INFINITY); - setTurnGunRight(Double.POSITIVE_INFINITY); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - setMaxTurnRate(20); - - setTurnLeft(Double.POSITIVE_INFINITY); - setTurnGunLeft(Double.POSITIVE_INFINITY); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - setTurnRight(Double.POSITIVE_INFINITY); - setTurnGunRight(Double.POSITIVE_INFINITY); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - setAdjustGunForRobotTurn(false); - - setTurnRight(Double.POSITIVE_INFINITY); - setTurnGunLeft(Double.POSITIVE_INFINITY); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - - setTurnLeft(Double.POSITIVE_INFINITY); - setTurnGunRight(Double.POSITIVE_INFINITY); - executeAndDumpTurnRate(); - executeAndDumpTurnRate(); - } - - private void executeAndDumpTurnRate() { - double lastHeading = getGunHeading(); - - execute(); - - double turnRate = robocode.util.Utils.normalRelativeAngleDegrees(getGunHeading() - lastHeading); - - out.println(getTime() + ": " + turnRate); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/HttpAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/HttpAttack.java deleted file mode 100644 index ea0c97c..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/HttpAttack.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import java.io.IOException; -import java.io.InputStream; -import java.net.HttpURLConnection; -import java.net.URL; - - -/** - * @author Flemming N. Larsen (original) - */ -public class HttpAttack extends AdvancedRobot { - - static final String HTTP_ADDR = "http://robocode.sourceforge.net/"; - - public void run() { - try { - URL url = new URL(HTTP_ADDR); - - HttpURLConnection conn = (HttpURLConnection) url.openConnection(); - - if (conn.getResponseCode() == HttpURLConnection.HTTP_OK) { - InputStream is = conn.getInputStream(); - - is.read(); - } - } catch (IOException e) { - e.printStackTrace(out); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/IncludeNamespaceAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/IncludeNamespaceAttack.java deleted file mode 100644 index d2cb8e1..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/IncludeNamespaceAttack.java +++ /dev/null @@ -1,45 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import net.sf.robocode.security.HiddenAccess; -import robocode.AdvancedRobot; -import robocode.ScannedRobotEvent; - - -/** - * @author Pavel Savara (original) - */ -public class IncludeNamespaceAttack extends AdvancedRobot { - - @Override - public void run() { - // noinspection InfiniteLoopStatement - for (;;) { - turnLeft(100); - ahead(10); - turnLeft(100); - back(10); - } - } - - @Override - public void onScannedRobot(ScannedRobotEvent event) { - namespaceAttack(); - } - - private void namespaceAttack() { - try { - HiddenAccess.createRules(10, 10, 10, 10, 1, false, 100); - } catch (Throwable e) { - // Swallow security exception - e.printStackTrace(out); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/InteruptibleEvent.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/InteruptibleEvent.java deleted file mode 100644 index d3a306f..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/InteruptibleEvent.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import robocode.HitWallEvent; -import robocode.ScannedRobotEvent; - - -/** - * Based on bug 2212289. - * - * Robot provided for the test named TestScanForRobotsWhenHitWall, which tests if onScannedRobot() - * is called when the radar is turned from within a onHitWall() event. - * - * @author Flemming N. Larsen (original) - */ -public class InteruptibleEvent extends AdvancedRobot { - - @Override - public void run() { - setEventPriority("HitWallEvent", getEventPriority("ScannedRobotEvent")); // make same as scan - - // noinspection InfiniteLoopStatement - for (;;) { - ahead(10); // make sure we eventually hits a wall to receive onHitWall - } - } - - @Override - public void onScannedRobot(ScannedRobotEvent event) { - out.println("Scanned!!!"); // a robot was scanned -> success! - } - - @Override - public void onHitWall(HitWallEvent e) { - setInterruptible(true); // make sure that the event handler can be interrupted and restarted - turnRadarRight(360); // when the radar is turned here, at least another robot should be scanned - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/JuniorEvents.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/JuniorEvents.java deleted file mode 100644 index cd126f8..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/JuniorEvents.java +++ /dev/null @@ -1,135 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.*; -import robocode.Event; -import robocode.robotinterfaces.IBasicEvents; -import robocode.robotinterfaces.IJuniorRobot; -import robocode.robotinterfaces.peer.IBasicRobotPeer; -import robocode.util.Utils; - -import java.awt.*; -import java.io.PrintStream; -import java.util.HashMap; -import java.util.Map; - - -/** - * @author Pavel Savara (original) - */ -public class JuniorEvents implements IJuniorRobot, IBasicEvents, Runnable { - - IBasicRobotPeer peer; - PrintStream out; - final Map counts = new HashMap(); - Bullet bullet; - - public void run() { - // noinspection InfiniteLoopStatement - while (true) { - peer.move(100); // Move ahead 100 - peer.turnGun(Math.PI * 2); // Spin gun around - peer.move(-100); // Move back 100 - peer.turnGun(Math.PI * 2); // Spin gun around - } - } - - public Runnable getRobotRunnable() { - return this; - } - - public IBasicEvents getBasicEventListener() { - return this; - } - - public void setPeer(IBasicRobotPeer peer) { - this.peer = peer; - } - - public void setOut(PrintStream out) { - this.out = out; - } - - public void onStatus(StatusEvent event) { - count(event); - final Graphics2D g = peer.getGraphics(); - - g.setColor(Color.orange); - g.drawOval((int) (peer.getX() - 55), (int) (peer.getY() - 55), 110, 110); - } - - public void onBulletHit(BulletHitEvent event) { - count(event); - } - - public void onBulletHitBullet(BulletHitBulletEvent event) { - count(event); - } - - public void onBulletMissed(BulletMissedEvent event) { - count(event); - } - - public void onDeath(DeathEvent event) { - count(event); - } - - public void onHitByBullet(HitByBulletEvent event) { - count(event); - } - - public void onHitRobot(HitRobotEvent event) { - count(event); - } - - public void onHitWall(HitWallEvent event) { - count(event); - } - - public void onRobotDeath(RobotDeathEvent event) { - count(event); - } - - public void onWin(WinEvent event) { - count(event); - - // this is tested output - for (Map.Entry s : counts.entrySet()) { - out.println(s.getKey() + " " + s.getValue()); - } - out.println("last bullet heading " + bullet.getHeadingRadians()); - } - - public void onScannedRobot(ScannedRobotEvent event) { - count(event); - - // Turn gun to point at the scanned robot - peer.turnGun(Utils.normalAbsoluteAngle(peer.getBodyHeading() + event.getBearingRadians() - peer.getGunHeading())); // - - // Fire! - double power = 1; - - Bullet firedBullet = peer.fire(power); - - if (firedBullet != null) { - this.bullet = firedBullet; - } - } - - private void count(Event event) { - final String name = event.getClass().getName(); - Integer curr = counts.get(name); - - if (curr == null) { - curr = 0; - } - counts.put(name, curr + 1); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/MaxTurnRate.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/MaxTurnRate.java deleted file mode 100644 index 858e625..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/MaxTurnRate.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -/** - * @author Flemming N. Larsen (original) - */ -public class MaxTurnRate extends robocode.AdvancedRobot { - public void run() { - - setTurnLeft(Double.POSITIVE_INFINITY); - - for (int i = 0; i < 13; i++) { - setMaxTurnRate(i); - executeAndDumpTurnRate(); - } - - setTurnRight(Double.POSITIVE_INFINITY); - - for (int i = 0; i < 13; i++) { - setMaxTurnRate(i); - executeAndDumpTurnRate(); - } - } - - private void executeAndDumpTurnRate() { - double lastHeading = getHeading(); - - execute(); - - double turnRate = robocode.util.Utils.normalRelativeAngleDegrees(getHeading() - lastHeading); - - out.println(getTime() + ": " + getVelocity() + ", " + turnRate); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/MaxVelocity.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/MaxVelocity.java deleted file mode 100644 index fec7a11..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/MaxVelocity.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -/** - * @author Flemming N. Larsen (original) - */ -public class MaxVelocity extends robocode.AdvancedRobot { - - public void run() { - for (;;) { - int time = (int) getTime(); - - if (time < 200) { - out.println(time + ": " + getVelocity()); - } - - switch (time) { - case 1: - setAhead(1000); - break; - - case 20: - setBack(1000); - break; - - case 40: - setMaxVelocity(4.2); - setAhead(1000); - break; - - case 60: - setBack(1000); - break; - - case 80: - setMaxVelocity(100); - setAhead(1000); - break; - - case 100: - setBack(1000); - break; - - case 120: - setMaxVelocity(-2); - setAhead(1000); - break; - - case 140: - setBack(1000); - break; - - case 160: - setMaxVelocity(0); - setAhead(1000); - break; - - case 180: - setBack(1000); - break; - } - execute(); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/PrivateConstructor.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/PrivateConstructor.java deleted file mode 100644 index 505eb51..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/PrivateConstructor.java +++ /dev/null @@ -1,20 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.Robot; - - -/** - * @author Pavel Savara (original) - */ -public class PrivateConstructor extends Robot { - private PrivateConstructor() {// private - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/RadarTurnRateAndSetAdjust.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/RadarTurnRateAndSetAdjust.java deleted file mode 100644 index 6e9ddf1..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/RadarTurnRateAndSetAdjust.java +++ /dev/null @@ -1,134 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -/** - * @author Flemming N. Larsen (original) - */ -public class RadarTurnRateAndSetAdjust extends robocode.AdvancedRobot { - public void run() { - // -- Turn 1 -- - setTurnRadarRight(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. radar turn rate = 45 - - // -- Turn 2 -- - setTurnGunRight(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. gun + radar turn rate = 20 + 45 = 65 - - // -- Turn 3 -- - setTurnRight(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. robot + gun + radar turn rate = 10 + 20 + 45 = 75 - - // -- Turn 4 -- - setTurnRadarLeft(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. robot + gun - radar turn rate = 10 + 20 - 45 = -15 - - // -- Turn 5 -- - setTurnGunLeft(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. robot + gun - radar turn rate = 10 - 20 - 45 = -55 - - // -- Turn 6 -- - setTurnLeft(1000); - executeAndDumpTurnRate(); - // Expected turn rate: max. robot + gun - radar turn rate = -10 - 20 - 45 = -75 - - // -- Turn 7 -- - setAdjustRadarForGunTurn(false); - setTurnRight(14); - setTurnGunRight(15); - setTurnRadarRight(7); - executeAndDumpTurnRate(); - // Expected turn rate: robot + gun + radar turn rate = 14 + 15 + 7 = 32 - - // -- Turn 8 -- - setAdjustGunForRobotTurn(false); - setAdjustRadarForRobotTurn(false); - setAdjustRadarForGunTurn(true); - setTurnRight(14); - setTurnGunLeft(15); - setTurnRadarRight(7); - executeAndDumpTurnRate(); - // Expected turn rate: robot (max) + radar turn rate (ignoring gun turn rate, but not robot turn rate) = 10 + 7 = 17 - - // -- Turn 9 -- - setAdjustGunForRobotTurn(false); - setAdjustRadarForRobotTurn(true); - setAdjustRadarForGunTurn(true); - setTurnRight(14); - setTurnGunLeft(15); - setTurnRadarRight(35); - executeAndDumpTurnRate(); - // Expected turn rate: robot turn rate (ignoring both gun and body turn rate) = 35 - - // -- Turn 10 -- - setAdjustGunForRobotTurn(false); - setAdjustRadarForRobotTurn(false); - setAdjustRadarForGunTurn(true); - setTurnRight(14); - setTurnGunLeft(15); - setTurnRadarLeft(7); - executeAndDumpTurnRate(); - // Expected turn rate: robot (max) + radar turn rate (ignoring gun turn rate, but not robot turn rate) = 10 - 7 = 3 - - // -- Turn 11 -- - setAdjustGunForRobotTurn(false); - setAdjustRadarForRobotTurn(true); - setAdjustRadarForGunTurn(true); - setTurnRight(4); - setTurnGunRight(60); - setTurnRadarLeft(100); - executeAndDumpTurnRate(); - // Expected turn rate: robot (max) turn rate (ignoring both gun and body turn rate) = -20 - - // -- Turn 12 -- - setAdjustGunForRobotTurn(false); - setAdjustRadarForRobotTurn(false); - setAdjustRadarForGunTurn(true); - setTurnRight(Double.POSITIVE_INFINITY); - setTurnGunRight(Double.POSITIVE_INFINITY); - setTurnRadarRight(Double.POSITIVE_INFINITY); - executeAndDumpTurnRate(); - // Expected turn rate: setAdjusts are all ignored, max. robot + gun + radar turn rate = 10 + 20 + 45 = 75 - - // -- Turn 13 -- - setAdjustGunForRobotTurn(true); - setAdjustRadarForRobotTurn(false); - setAdjustRadarForGunTurn(true); - setTurnRight(Double.NEGATIVE_INFINITY); - setTurnGunRight(Double.NEGATIVE_INFINITY); - setTurnRadarRight(Double.NEGATIVE_INFINITY); - executeAndDumpTurnRate(); - // Expected turn rate: setAdjusts are all ignored, max. robot + gun + radar turn rate = -10 - 20 - 45 = -75 - - // -- Turn 14 -- - setAdjustGunForRobotTurn(true); - setAdjustRadarForRobotTurn(true); - setAdjustRadarForGunTurn(true); - setTurnLeft(Double.NEGATIVE_INFINITY); - setTurnGunLeft(Double.NEGATIVE_INFINITY); - setTurnRadarLeft(Double.POSITIVE_INFINITY); - executeAndDumpTurnRate(); - // Expected turn rate: setAdjusts are all ignored, max. robot + gun + radar turn rate = -(-10) - (-20) - 45 = -15 - } - - private void executeAndDumpTurnRate() { - double lastHeading = getRadarHeading(); - - execute(); - - double turnRate = robocode.util.Utils.normalRelativeAngleDegrees(getRadarHeading() - lastHeading); - - out.println(getTime() + ": " + turnRate); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/Random.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/Random.java deleted file mode 100644 index c9415b5..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/Random.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.Robot; - - -/** - * @author Pavel Savara (original) - */ -public class Random extends Robot { - - @Override - public void run() { - - while (true) { - ahead(100 * Math.random()); - turnRight(180 * Math.random()); - back(100 * Math.random()); - turnLeft(360 * Math.random()); - } - } -} - diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/RateControl.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/RateControl.java deleted file mode 100644 index bf97c6f..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/RateControl.java +++ /dev/null @@ -1,46 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.RateControlRobot; - - -/** - * @author Joshua Galecki (original) - */ -public class RateControl extends RateControlRobot { - @Override - public void run() { - for (int turnNumber = 0; turnNumber < 80; turnNumber++) { - if (turnNumber == 0) { - setTurnRate(4.5); - } else if (turnNumber == 10) { - setTurnRate(-9); - } else if (turnNumber == 20) { - setTurnRate(0); - setVelocityRate(2); - } else if (turnNumber == 25) { - setVelocityRate(-8); - } else if (turnNumber == 35) { - setVelocityRate(0); - setGunRotationRate(9); - } else if (turnNumber == 45) { - setGunRotationRate(-4.5); - } else if (turnNumber == 55) { - setGunRotationRate(0); - setRadarRotationRate(9); - } else if (turnNumber == 65) { - setRadarRotationRate(-4.5); - } else if (turnNumber == 75) { - setRadarRotationRate(0); - } - execute(); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ReflectionAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ReflectionAttack.java deleted file mode 100644 index 37355c0..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ReflectionAttack.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import java.lang.reflect.*; - - -/** - * @author Flemming N. Larsen (original) - */ -public class ReflectionAttack extends robocode.AdvancedRobot { - - public void run() { - try { - Field field = System.class.getField("out"); - - field.setAccessible(true); - Object obj = field.get(null); - Method method = obj.getClass().getMethod("print", new Class[] { String.class }); - - method.setAccessible(true); - method.invoke(obj, new Object[] { "Hello World" }); - - } catch (Exception e) { - e.printStackTrace(out); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ReverseDirection.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ReverseDirection.java deleted file mode 100644 index de7cc0b..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ReverseDirection.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -/** - * @author Flemming N. Larsen (original) - */ -public class ReverseDirection extends robocode.AdvancedRobot { - public void run() { - setAhead(Double.POSITIVE_INFINITY); - setMaxVelocity(1.0); - execute(); - // robot has a positive velocity of 1.0 - - out.println(getVelocity()); - - setMaxVelocity(0.5); - setAhead(Double.NEGATIVE_INFINITY); - execute(); - // robot should have a negative velocity of -0.5 - - out.println(getVelocity()); - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/RobotDeathEvents.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/RobotDeathEvents.java deleted file mode 100644 index d057416..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/RobotDeathEvents.java +++ /dev/null @@ -1,40 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.DeathEvent; -import robocode.RobotDeathEvent; -import robocode.AdvancedRobot; - - -/** - * @author Flemming N. Larsen (original) - */ -public class RobotDeathEvents extends AdvancedRobot { - private boolean dead; - private long enemyCount; - - public void run() { - enemyCount = getOthers(); - while (!dead) { - if (enemyCount != getOthers()) { - throw new RuntimeException("enemyCount != getOthers()"); - } - execute(); - } - } - - public void onRobotDeath(RobotDeathEvent e) { - enemyCount--; - } - - public void onDeath(DeathEvent e) { - dead = true; - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/SkipTurns.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/SkipTurns.java deleted file mode 100644 index 09b562e..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/SkipTurns.java +++ /dev/null @@ -1,80 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import robocode.SkippedTurnEvent; -import robocode.StatusEvent; - - -/** - * @author Pavel Savara (original) - */ -public class SkipTurns extends AdvancedRobot { - private volatile int skipped = 0; - - static final int LIMIT = 5; - - @Override - public void run() { - // noinspection InfiniteLoopStatement - for (;;) { - if (skipped > LIMIT) { - throw new Error("satisfied, end battle please"); - } - turnLeft(10); - if (skipped > LIMIT) { - // satisfied, end battle please - throw new Error(); - } - ahead(1); - if (skipped > LIMIT) { - // satisfied, end battle please - throw new Error(); - } - turnLeft(10); - if (skipped > LIMIT) { - // satisfied, end battle please - throw new Error(); - } - back(1); - } - } - - @Override - public void onStatus(StatusEvent e) { - out.println("live"); - slowResponse(); - } - - @Override - public void onSkippedTurn(SkippedTurnEvent event) { - out.println("Skipped!!!"); - - skipped++; - } - - private final Object w = new Object(); - - private void slowResponse() { - - synchronized (w) { - try { - if (skipped > 3) { - w.wait(3000); - } else { - w.wait(130); - } - } catch (InterruptedException e) { - // eat interrupt - e.printStackTrace(out); - } - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/SocketAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/SocketAttack.java deleted file mode 100644 index 5109c10..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/SocketAttack.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import java.io.*; -import java.net.*; - - -/** - * @author Flemming N. Larsen (original) - */ -public class SocketAttack extends AdvancedRobot { - - public void run() { - ServerSocket server = null; - Socket client = null; - - try { - server = new ServerSocket(9999); - client = server.accept(); - - InputStream is = new DataInputStream(client.getInputStream()); - OutputStream os = new PrintStream(client.getOutputStream()); - - os.write(1); - is.read(); - } catch (IOException e) { - e.printStackTrace(out); - } finally { - if (server != null) { - try { - server.close(); - } catch (IOException e) {} - } - if (client != null) { - try { - client.close(); - } catch (IOException e) {} - } - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ThreadAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ThreadAttack.java deleted file mode 100644 index 84cd88f..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ThreadAttack.java +++ /dev/null @@ -1,87 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; -import robocode.ScannedRobotEvent; - -import java.util.concurrent.atomic.AtomicInteger; - - -/** - * @author Pavel Savara (original) - */ -public class ThreadAttack extends AdvancedRobot { - - @Override - public void run() { - // noinspection InfiniteLoopStatement - for (;;) { - turnLeft(100); - ahead(10); - turnLeft(100); - back(10); - } - } - - @Override - public void onScannedRobot(ScannedRobotEvent event) { - runAttack(); - runAttack2(); - } - - private void runAttack() { - try { - Attacker a = new Attacker(); - Thread t = new Thread(a); - - t.start(); - } catch (Throwable e) { - // swallow security exception - e.printStackTrace(out); - } - } - - private void runAttack2() { - try { - Attacker a = new Attacker(); - ThreadGroup tg = new ThreadGroup("MyAttack"); - - tg.setMaxPriority(10); - Thread t = new Thread(tg, a); - - t.start(); - } catch (Throwable e) { - // swallow security exception - e.printStackTrace(out); - } - } - - private AtomicInteger counter = new AtomicInteger(); - - private class Attacker implements Runnable { - - public synchronized void run() { - final int id = counter.incrementAndGet(); - - out.println("Running id:" + id); - - if (Thread.currentThread().getPriority() > 4) { - out.println("Priority attack"); - } - runAttack2(); - - try { - this.wait(); - } catch (InterruptedException e) { - out.println("Interrupted id:" + id); - } - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ThreadGroupAttack.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ThreadGroupAttack.java deleted file mode 100644 index dbf59ec..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/ThreadGroupAttack.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.*; - - -/** - * This nasty robot tries to interrupt the thread of each opponent robot that it scans. - * It enumerates the threads recursively of thread group that is a parent of its own - * thread group to find out, which threads that are active. These threads are all robot - * threads. - * - * This robot is inspired by the hacker.Destroyer 1.3, which proved a security breach in - * Robocode 1.7.2.1 Beta. The security breach was reported with: - * Bug [3021140] Possible for robot to kill other robot threads. - * - * The security manager of Robocode must make sure that unsafe (robot) threads cannot - * access thread groups other than its own thread group within checkAccess(Thread). - * - * @author Flemming N. Larsen (original) - */ -public class ThreadGroupAttack extends Robot { - private Thread[] threads = new Thread[100]; - - public void run() { - runAttack(); - - while (true) { - turnGunLeft(30); - } - } - - private void runAttack() { - try { - new Thread(new Runnable() { - public void run() { - ThreadGroup parentGroup = Thread.currentThread().getThreadGroup().getParent(); - - while (true) { - parentGroup.enumerate(threads, true); - try { - Thread.sleep(0); - } catch (InterruptedException ignore) {} - } - } - }).start(); - } catch (Throwable t) { - t.printStackTrace(out); - } - } - - public void onScannedRobot(ScannedRobotEvent e) { - attackRobotThread(e.getName()); - } - - private void attackRobotThread(String robotName) { - for (Thread t : threads) { - if (t != null && robotName.equals(t.getName())) { - t.interrupt(); - out.println("Interrupted: " + robotName); - } - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/TooLongNameThisIsReallyTooLongName.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/TooLongNameThisIsReallyTooLongName.java deleted file mode 100644 index 77cb808..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/TooLongNameThisIsReallyTooLongName.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.Robot; - - -/** - * @author Pavel Savara (original) - */ -public class TooLongNameThisIsReallyTooLongName extends Robot { - @Override - public void run() { - while (true) { - ahead(1); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(1); // Move back 100 - turnGunRight(360); // Spin gun around - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/UndeadThread.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/UndeadThread.java deleted file mode 100644 index 94b042c..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/UndeadThread.java +++ /dev/null @@ -1,44 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.AdvancedRobot; - - -/** - * @author Pavel Savara (original) - */ -public class UndeadThread extends AdvancedRobot { - - @Override - public void run() { - out.println("I will live forever!"); - // noinspection InfiniteLoopStatement - while (true) { - try { - body(); - } catch (Throwable t) { - // spamming the console - out.println("Swalowed it, HA HA HA HA HAAAAA !!!!!"); - out.println(t); - } - } - } - - private void body() { - // noinspection InfiniteLoopStatement - for (;;) { - turnLeft(100); - ahead(10); - turnLeft(100); - back(10); - } - } - -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/WatchBullets.java b/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/WatchBullets.java deleted file mode 100644 index 16bcee8..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tested/robots/WatchBullets.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tested.robots; - - -import robocode.*; -import static robocode.util.Utils.normalRelativeAngle; - - -/** - * @author Pavel Savara (original) - */ -public class WatchBullets extends AdvancedRobot { - public void run() { - while (true) { - ahead(100); - turnGunRight(360); - back(100); - turnGunRight(360); - } - } - - Bullet bullet; - - public void onStatus(StatusEvent event) { - dump(); - } - - @Override - public void onScannedRobot(ScannedRobotEvent e) { - // Calculate exact location of the robot - double absoluteBearing = getHeading() + e.getBearing(); - double bearingFromGun = normalRelativeAngle(absoluteBearing - getGunHeading()); - - // If it's close enough, fire! - if (Math.abs(bearingFromGun) <= 3) { - turnGunRight(bearingFromGun); - // We check gun heat here, because calling fire() - // uses a turn, which could cause us to lose track - // of the other robot. - if (getGunHeat() == 0 && bullet == null) { - final Bullet lbullet = fireBullet(Math.min(3 - Math.abs(bearingFromGun), getEnergy() - .1)); - - bullet = lbullet; - } - } // otherwise just set the gun to turn. - // Note: This will have no effect until we call scan() - else { - turnGunRight(bearingFromGun); - } - // Generates another scan event if we see a robot. - // We only need to call this if the gun (and therefore radar) - // are not turning. Otherwise, scan is called automatically. - if (bearingFromGun == 0) { - scan(); - } - } - - private void dump() { - if (bullet != null) { - out.println( - getTime() + " " + bullet.getX() + " " + bullet.getY() + " " + bullet.getHeading() + " " - + bullet.isActive()); - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/java/tooLongNamespaceThisIsReallyTooLongNamespace/TooLongNamespace.java b/workspace_robo/robocode.tests.robots/src/main/java/tooLongNamespaceThisIsReallyTooLongNamespace/TooLongNamespace.java deleted file mode 100644 index 0fc2fb2..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/java/tooLongNamespaceThisIsReallyTooLongNamespace/TooLongNamespace.java +++ /dev/null @@ -1,27 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package tooLongNamespaceThisIsReallyTooLongNamespace; - - -import robocode.Robot; - - -/** - * @author Pavel Savara (original) - */ -public class TooLongNamespace extends Robot { - @Override - public void run() { - while (true) { - ahead(1); // Move ahead 100 - turnGunRight(360); // Spin gun around - back(1); // Move back 100 - turnGunRight(360); // Spin gun around - } - } -} diff --git a/workspace_robo/robocode.tests.robots/src/main/resources/tested/robots/TestTeam.team b/workspace_robo/robocode.tests.robots/src/main/resources/tested/robots/TestTeam.team deleted file mode 100644 index fd3a223..0000000 --- a/workspace_robo/robocode.tests.robots/src/main/resources/tested/robots/TestTeam.team +++ /dev/null @@ -1,7 +0,0 @@ -#Robocode robot team -#Sat Oct 25 22:23:58 CEST 2008 -team.members=sampleteam.MyFirstLeader,sampleteam.MyFirstDroid,sample.Fire -team.author.name= -robocode.version=unknown -uuid=8abd63e8-1156-4fb4-a81f-eb10fca9596d -team.description=testteam diff --git a/workspace_robo/robocode.tests/.classpath b/workspace_robo/robocode.tests/.classpath deleted file mode 100644 index 54fd109..0000000 --- a/workspace_robo/robocode.tests/.classpath +++ /dev/null @@ -1,18 +0,0 @@ - - - - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.tests/.project b/workspace_robo/robocode.tests/.project deleted file mode 100644 index 96f238f..0000000 --- a/workspace_robo/robocode.tests/.project +++ /dev/null @@ -1,22 +0,0 @@ - - - robocode.tests - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.api - robocode.tests.robots - robocode.samples - robocode.core - robocode.host - robocode.battle - robocode.repository - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.tests/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.tests/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.tests/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.tests/config/robocode.properties b/workspace_robo/robocode.tests/config/robocode.properties deleted file mode 100644 index ad5840f..0000000 --- a/workspace_robo/robocode.tests/config/robocode.properties +++ /dev/null @@ -1,3 +0,0 @@ -#Robocode Properties -#Thu Mar 12 00:15:08 CET 2009 -robocode.cpu.constant=9994115 diff --git a/workspace_robo/robocode.tests/pom.xml b/workspace_robo/robocode.tests/pom.xml deleted file mode 100644 index d84174f..0000000 --- a/workspace_robo/robocode.tests/pom.xml +++ /dev/null @@ -1,59 +0,0 @@ - - - 4.0.0 - robocode.tests - Robocode Tests - - net.sf.robocode - robocode - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - net.sf.robocode - robocode.tests.robots - ${project.version} - - - junit - junit - 4.11 - - - net.sf.robocode - robocode.core - ${project.version} - test - - - net.sf.robocode - robocode.samples - ${project.version} - test - - - net.sf.robocode - robocode.host - ${project.version} - test - - - net.sf.robocode - robocode.battle - ${project.version} - test - - - net.sf.robocode - robocode.repository - ${project.version} - test - - - \ No newline at end of file diff --git a/workspace_robo/robocode.tests/robocode.tests.iml b/workspace_robo/robocode.tests/robocode.tests.iml deleted file mode 100644 index 7cffb25..0000000 --- a/workspace_robo/robocode.tests/robocode.tests.iml +++ /dev/null @@ -1,103 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.tests/src/main/java/net/sf/robocode/test/helpers/Assert.java b/workspace_robo/robocode.tests/src/main/java/net/sf/robocode/test/helpers/Assert.java deleted file mode 100644 index 6f5fded..0000000 --- a/workspace_robo/robocode.tests/src/main/java/net/sf/robocode/test/helpers/Assert.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.helpers; - - -import robocode.util.Utils; - - -/** - * @author Pavel Savara (original) - */ -public class Assert extends org.junit.Assert { - public static void assertNear(double v1, double v2) { - org.junit.Assert.assertEquals(v1, v2, Utils.NEAR_DELTA); - } - - public static void allAssertNear(double v1, double v2) { - try { - assertNear(v1, v2); - } catch (Throwable ex) { - ex.printStackTrace(System.err); - } - } - - public static void allAssertThat(T t, org.hamcrest.Matcher tMatcher) { - try { - org.junit.Assert.assertThat(t, tMatcher); - } catch (Throwable ex) { - ex.printStackTrace(System.err); - } - } - -} diff --git a/workspace_robo/robocode.tests/src/main/java/net/sf/robocode/test/helpers/RobocodeTestBed.java b/workspace_robo/robocode.tests/src/main/java/net/sf/robocode/test/helpers/RobocodeTestBed.java deleted file mode 100644 index ad034fb..0000000 --- a/workspace_robo/robocode.tests/src/main/java/net/sf/robocode/test/helpers/RobocodeTestBed.java +++ /dev/null @@ -1,209 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.helpers; - - -import net.sf.robocode.io.Logger; - -import org.junit.After; -import org.junit.Before; -import org.junit.Test; -import robocode.control.*; -import robocode.control.events.*; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.util.Utils; - -import java.io.File; -import java.io.IOException; -import java.util.Random; - - -/** - * @author Pavel Savara (original) - */ -public abstract class RobocodeTestBed extends BattleAdaptor { - protected static final IRobocodeEngine engine; - protected final BattlefieldSpecification battleFieldSpec = new BattlefieldSpecification(); - protected static int errors = 0; - protected static StringBuilder errorText = new StringBuilder(); - protected static int messages = 0; - protected static String robotsPath; - - public static boolean isDumpingPositions = false; - public static boolean isDumpingTurns = false; - public static boolean isDumpingOutput = true; - public static boolean isDumpingErrors = true; - public static boolean isDumpingMessages = true; - public static boolean hasJavaNetURLPermission = isClassAvailable("java.net.URLPermission"); - - private static boolean isClassAvailable(String name) { - try { - return Class.forName(name) != null; - } catch (ClassNotFoundException e) { - return false; - } - } - - static { - System.setProperty("EXPERIMENTAL", "true"); - System.setProperty("TESTING", "true"); - System.setProperty("WORKINGDIRECTORY", "target/test-classes"); - try { - String currentDirAbsolutePath = new File("").getAbsolutePath(); - if (currentDirAbsolutePath.endsWith("robocode.tests")) { - robotsPath = new File("../robocode.tests.robots").getCanonicalPath(); - } else if (currentDirAbsolutePath.endsWith("robocode.dotnet.tests")) { - robotsPath = new File("../../../robocode.tests.robots").getCanonicalPath(); - } else if (new File("robocode.tests.robots").isDirectory()) { - robotsPath = new File("robocode.tests.robots").getCanonicalPath(); - } else { - throw new Error("Unknown directory: " + currentDirAbsolutePath); - } - } catch (IOException e) { - e.printStackTrace(Logger.realErr); - } - System.setProperty("ROBOTPATH", robotsPath + "/target/classes"); - - engine = new RobocodeEngine(new BattleAdaptor() { - public void onBattleMessage(BattleMessageEvent event) { - if (isDumpingMessages) { - Logger.realOut.println(event.getMessage()); - } - messages++; - } - - public void onBattleError(BattleErrorEvent event) { - if (isDumpingErrors) { - Logger.realErr.println(event.getError()); - } - errorText.append("----------err #"); - errorText.append(errors); - errorText.append("--------------------------------------------------\n"); - errorText.append(event.getError()); - errorText.append("\n"); - errors++; - } - }); - } - - public RobocodeTestBed() { - // silent when running in maven - if (System.getProperty("surefire.test.class.path", null) != null) { - isDumpingOutput = false; - isDumpingErrors = false; - isDumpingMessages = false; - } - errors = 0; - messages = 0; - } - - public void onTurnEnded(TurnEndedEvent event) { - if (isDumpingTurns) { - Logger.realOut.println("turn " + event.getTurnSnapshot().getTurn()); - } - for (IRobotSnapshot robot : event.getTurnSnapshot().getRobots()) { - if (isDumpingPositions) { - Logger.realOut.print(robot.getVeryShortName()); - Logger.realOut.print(" X:"); - Logger.realOut.print(robot.getX()); - Logger.realOut.print(" Y:"); - Logger.realOut.print(robot.getY()); - Logger.realOut.print(" V:"); - Logger.realOut.print(robot.getVelocity()); - Logger.realOut.println(); - } - if (isDumpingOutput) { - Logger.realOut.print(robot.getOutputStreamSnapshot()); - } - } - } - - public void onBattleStarted(BattleStartedEvent event) { - if (isDeterministic() && isCheckOnBattleStart()) { - final Random random = Utils.getRandom(); - - if (event.getRobotsCount() == 2) { - Assert.assertNear(0.98484154, random.nextDouble()); - } - } - } - - public abstract String getRobotNames(); - - public int getNumRounds() { - return 1; - } - - public String getInitialPositions() { - return null; - } - - public int getExpectedRobotCount(String robotList) { - return robotList.split("[\\s,;]+").length; - } - - public boolean isDeterministic() { - return true; - } - - public boolean isCheckOnBattleStart() { - return false; - } - - @Before - public void setup() { - engine.addBattleListener(this); - if (isDeterministic()) { - RandomFactory.resetDeterministic(0); - if (isCheckOnBattleStart()) { - Assert.assertNear(0.730967, RandomFactory.getRandom().nextDouble()); - } - } - errors = 0; - errorText = new StringBuilder(); - messages = 0; - } - - @After - public void tearDown() { - engine.removeBattleListener(this); - } - - @Test - public void run() { - runSetup(); - runBattle(getRobotNames(), getNumRounds(), getInitialPositions()); - runTeardown(); - final int expectedErrors = getExpectedErrors(); - - if (errors != expectedErrors) { - throw new AssertionError( - "Number of errors " + errors + " is different than expected " + expectedErrors + "\n" + errorText - + "======================================================================"); - } - } - - protected int getExpectedErrors() { - return 0; - } - - protected void runSetup() {} - - protected void runTeardown() {} - - protected void runBattle(String robotList, int numRounds, String initialPositions) { - final RobotSpecification[] robotSpecifications = engine.getLocalRepository(robotList); - - if (getExpectedRobotCount(robotList) > 0) { - Assert.assertNotNull("Robot were not loaded", robotSpecifications); - Assert.assertEquals("Robot were not loaded", getExpectedRobotCount(robotList), robotSpecifications.length); - engine.runBattle(new BattleSpecification(numRounds, battleFieldSpec, robotSpecifications), initialPositions, - true); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/core/util/AlphanumericComparatorTest.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/core/util/AlphanumericComparatorTest.java deleted file mode 100644 index 255fbd2..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/core/util/AlphanumericComparatorTest.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.core.util; - - -import java.util.Arrays; - -import net.sf.robocode.util.AlphanumericComparator; - -import org.junit.Assert; -import org.junit.Test; - - -/** - * @author Flemming N. Larsen (original) - */ -public class AlphanumericComparatorTest { - @Test - public void correctSorting() { - - // Our unsorted strings that must be sorted - final String[] unsortedStrings = { - null, "", " ", "alpha2", "alpha1", "bEtA", "BeTa", "alpha", "Alpha2", "Alpha1", "Alpha", "1.2", "1.22", - "1.22A", "1.3", "2.10a.1", "2.1.1", "2.10", "2.1a", "2.10.2", "1c", "1h", "1p", "alpha", "beta", "alPHA", - "beTA", "ALpha", "BEta", "ALPHA", "BETA" - }; - - // The expected result, when the unsorted strings have been sorted correctly - final String[] correctlySortedStrings = { - "1.2", "1.3", "1.22A", "1.22", "1c", "1h", "1p", "2.1.1", "2.1a", "2.10.2", "2.10a.1", "2.10", " ", "ALPHA", - "ALpha", "Alpha1", "Alpha2", "Alpha", "alPHA", "alpha1", "alpha2", "alpha", "alpha", "BETA", "BEta", "BeTa", - "bEtA", "beTA", "beta", "", null - }; - - // Make sure the input and expected output string arrays have the same length - Assert.assertEquals(unsortedStrings.length, correctlySortedStrings.length); - - // Sort the unsorted strings - Arrays.sort(unsortedStrings, new AlphanumericComparator()); - - // Check the result against our expected result - boolean sortedCorrectly = true; - - for (int i = 0; i < unsortedStrings.length; i++) { - String str1 = unsortedStrings[i]; - String str2 = correctlySortedStrings[i]; - - if (!(str1 == null && str2 == null) && !str1.equals(str2)) { - sortedCorrectly = false; - break; - } - } - Assert.assertTrue(sortedCorrectly); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/host/security/RobotClassLoaderTest.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/host/security/RobotClassLoaderTest.java deleted file mode 100644 index 13cd254..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/host/security/RobotClassLoaderTest.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.host.security; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.core.EngineClassLoader; -import net.sf.robocode.host.security.RobotClassLoader; -import net.sf.robocode.security.HiddenAccess; -import org.junit.Assert; -import org.junit.BeforeClass; -import org.junit.Test; - -import java.io.File; -import java.io.IOException; -import java.net.URL; - - -/** - * @author Pavel Savara (original) - */ -public class RobotClassLoaderTest { - static URL classPath; - final String badRobot = "tested.robots.IncludeNamespaceAttack"; - final String goodRobot = "tested.robots.Ahead"; - - @BeforeClass - public static void init() throws IOException { - HiddenAccess.initContainer(); - classPath = new File("../robocode.tests.robots/target/classes").getCanonicalFile().toURI().toURL(); - } - - @Test - public void engineAllowed() throws ClassNotFoundException { - final ClassLoader engineLoader = new EngineClassLoader(ClassLoader.getSystemClassLoader()); - - engineLoader.loadClass("net.sf.robocode.host.proxies.BasicRobotProxy"); - final Class c = engineLoader.loadClass("net.sf.robocode.host.proxies.BasicRobotProxy"); - - Assert.assertEquals(engineLoader, c.getClassLoader()); - } - - @Test - public void robotAllowed() throws ClassNotFoundException { - RobotClassLoader cl = new RobotClassLoader(classPath, goodRobot); - final Class c = cl.loadClass("robocode.Robot", true); - - Assert.assertEquals(Container.systemLoader, c.getClassLoader()); - } - - @Test - public void robotAllowedMain() throws ClassNotFoundException { - RobotClassLoader cl = new RobotClassLoader(classPath, goodRobot); - final Class c = cl.loadRobotMainClass(true); - - Assert.assertEquals(cl, c.getClassLoader()); - } - - @Test(expected = ClassNotFoundException.class) - public void robotBlockedBad() throws ClassNotFoundException { - RobotClassLoader cl = new RobotClassLoader(classPath, badRobot); - - cl.loadRobotMainClass(true); - } - - @Test(expected = ClassNotFoundException.class) - public void robotBlockedRobocode() throws ClassNotFoundException { - RobotClassLoader cl = new RobotClassLoader(classPath, goodRobot); - - cl.loadClass("net.sf.robocode.host.proxies.BasicRobotProxy"); - } - - @Test(expected = ClassNotFoundException.class) - public void robotBlockedControl() throws ClassNotFoundException { - RobotClassLoader cl = new RobotClassLoader(classPath, goodRobot); - - cl.loadClass("robocode.control.RobocodeEngine"); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestAcceleration.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestAcceleration.java deleted file mode 100644 index 4afd20c..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestAcceleration.java +++ /dev/null @@ -1,197 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; - -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class TestAcceleration extends RobocodeTestBed { - - private double[] startX = new double[3]; - private double[] startY = new double[3]; - - @Test - public void run() { - super.run(); - } - - @Override - public String getRobotNames() { - return "tested.robots.DecelerationCaveat1,tested.robots.DecelerationCaveat2,tested.robots.DecelerationCaveat3"; - } - - @Override - public String getInitialPositions() { - return "(50,50,0), (100,50,0), (150,50,0)"; // Make sure the robots do not collide! - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - IRobotSnapshot caveat1 = event.getTurnSnapshot().getRobots()[0]; - IRobotSnapshot caveat2 = event.getTurnSnapshot().getRobots()[1]; - IRobotSnapshot caveat3 = event.getTurnSnapshot().getRobots()[2]; - - switch (event.getTurnSnapshot().getTurn()) { - case 1: - resetStartPositions(event.getTurnSnapshot()); - - Assert.assertNear(1, caveat1.getVelocity()); - Assert.assertNear(1, caveat2.getVelocity()); - Assert.assertNear(1, caveat3.getVelocity()); - - Assert.assertNear(1 - 1, distance(0, caveat1)); - Assert.assertNear(1 - 1, distance(1, caveat2)); - Assert.assertNear(1 - 1, distance(2, caveat3)); - break; - - case 2: - Assert.assertNear(2, caveat1.getVelocity()); - Assert.assertNear(2, caveat2.getVelocity()); - Assert.assertNear(2, caveat3.getVelocity()); - - Assert.assertNear(3 - 1, distance(0, caveat1)); - Assert.assertNear(3 - 1, distance(1, caveat2)); - Assert.assertNear(3 - 1, distance(2, caveat3)); - break; - - case 3: - Assert.assertNear(3, caveat1.getVelocity()); - Assert.assertNear(3, caveat2.getVelocity()); - Assert.assertNear(3, caveat3.getVelocity()); - - Assert.assertNear(6 - 1, distance(0, caveat1)); - Assert.assertNear(6 - 1, distance(1, caveat2)); - Assert.assertNear(6 - 1, distance(2, caveat3)); - break; - - case 4: - Assert.assertNear(4, caveat1.getVelocity()); - Assert.assertNear(4, caveat2.getVelocity()); - Assert.assertNear(4, caveat3.getVelocity()); - - Assert.assertNear(10 - 1, distance(0, caveat1)); - Assert.assertNear(10 - 1, distance(1, caveat2)); - Assert.assertNear(10 - 1, distance(2, caveat3)); - break; - - case 5: - Assert.assertNear(5, caveat1.getVelocity()); - Assert.assertNear(5, caveat2.getVelocity()); - Assert.assertNear(5, caveat3.getVelocity()); - - Assert.assertNear(15 - 1, distance(0, caveat1)); - Assert.assertNear(15 - 1, distance(1, caveat2)); - Assert.assertNear(15 - 1, distance(2, caveat3)); - break; - - case 6: - Assert.assertNear(6, caveat1.getVelocity()); - Assert.assertNear(6, caveat2.getVelocity()); - Assert.assertNear(6, caveat3.getVelocity()); - - Assert.assertNear(21 - 1, distance(0, caveat1)); - Assert.assertNear(21 - 1, distance(1, caveat2)); - Assert.assertNear(21 - 1, distance(2, caveat3)); - break; - - case 7: - Assert.assertNear(7, caveat1.getVelocity()); - Assert.assertNear(7, caveat2.getVelocity()); - Assert.assertNear(7, caveat3.getVelocity()); - - Assert.assertNear(28 - 1, distance(0, caveat1)); - Assert.assertNear(28 - 1, distance(1, caveat2)); - Assert.assertNear(28 - 1, distance(2, caveat3)); - break; - - case 8: - Assert.assertNear(8, caveat1.getVelocity()); - Assert.assertNear(8, caveat2.getVelocity()); - Assert.assertNear(8, caveat3.getVelocity()); - - Assert.assertNear(36 - 1, distance(0, caveat1)); - Assert.assertNear(36 - 1, distance(1, caveat2)); - Assert.assertNear(36 - 1, distance(2, caveat3)); - - resetStartPositions(event.getTurnSnapshot()); - break; - - case 9: - Assert.assertNear(8, caveat1.getVelocity()); - Assert.assertNear(8, caveat2.getVelocity()); - - Assert.assertNear(6, caveat3.getVelocity()); // Caveat 3 (max. speed is set to 6) - - Assert.assertNear(8, distance(0, caveat1)); - Assert.assertNear(8, distance(1, caveat2)); - - resetStartPositions(event.getTurnSnapshot()); - break; - - case 10: - Assert.assertNear(caveat1.getVelocity(), distance(0, caveat1)); - Assert.assertNear(caveat2.getVelocity(), distance(1, caveat2)); - - resetStartPositions(event.getTurnSnapshot()); - break; - - case 11: - Assert.assertNear(caveat1.getVelocity(), distance(0, caveat1)); - Assert.assertNear(caveat2.getVelocity(), distance(1, caveat2)); - - resetStartPositions(event.getTurnSnapshot()); - break; - - case 12: - Assert.assertNear(caveat1.getVelocity(), distance(0, caveat1)); - Assert.assertNear(caveat2.getVelocity(), distance(1, caveat2)); - - resetStartPositions(event.getTurnSnapshot()); - break; - - case 13: - Assert.assertNear(caveat1.getVelocity(), distance(0, caveat1)); // Caveat 1 (distance should be = velocity) - Assert.assertNear(caveat2.getVelocity(), distance(1, caveat2)); - - resetStartPositions(event.getTurnSnapshot()); - break; - - case 14: - Assert.assertNear(0, caveat1.getVelocity()); - Assert.assertNear(0, caveat2.getVelocity()); - - Assert.assertNear(0, distance(1, caveat2)); // Caveat 2 (distance should be 0) - break; - } - } - - private void resetStartPositions(ITurnSnapshot turnSnapshot) { - for (int i = 0; i < 3; i++) { - IRobotSnapshot robot = turnSnapshot.getRobots()[i]; - - startX[i] = robot.getX(); - startY[i] = robot.getY(); - } - } - - private double distance(int index, IRobotSnapshot robotSnapshot) { - return Math.hypot(robotSnapshot.getX() - startX[index], robotSnapshot.getY() - startY[index]); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestAwtAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestAwtAttack.java deleted file mode 100644 index a53be8b..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestAwtAttack.java +++ /dev/null @@ -1,82 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; - -import javax.swing.*; - - -/** - * @author Pavel Savara (original) - */ -public class TestAwtAttack extends RobocodeTestBed { - // in case: boolean messagedAttack; - boolean messagedBreakthru; - - @Test - public void run() { - super.run(); - } - - /* in case that we don't block JFrame by classloader - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("Hacked!!!")) { - messagedBreakthru = true; - } - if (out.contains("Robots are not allowed to reference javax.swing package")) { - messagedAttack = true; - } - } */ - - @Override - public String getRobotNames() { - return "tested.robots.BattleLost,tested.robots.AwtAttack"; - } - - JFrame frame; - - @Override - protected void runSetup() { - frame = new JFrame(); - frame.setVisible(true); - } - - @Override - protected int getExpectedErrors() { - return 2; - } - - @Override - public int getExpectedRobotCount(String list) { - return 1; - } - - @Override - protected void runTeardown() { - - Runnable doCheck = new Runnable() { - public void run() { - Logger.logMessage("works still!!!"); - } - }; - - javax.swing.SwingUtilities.invokeLater(doCheck); - - frame.setVisible(false); - Assert.assertFalse(messagedBreakthru); - // in case: Assert.assertTrue(messagedAttack); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestBodyTurnRate.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestBodyTurnRate.java deleted file mode 100644 index 5ec9dc7..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestBodyTurnRate.java +++ /dev/null @@ -1,128 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestBodyTurnRate extends RobocodeTestBed { - - StringBuffer buf = new StringBuffer(); - - @Override - public String getRobotNames() { - return "tested.robots.BodyTurnRate,sample.Target"; - } - - @Override - public String getInitialPositions() { - return "(600,200,0), (50,50,0)"; // Make sure the robots do not collide! - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - buf.append(event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot()); - - if (event.getTurnSnapshot().getTurn() == 60) { - final String out = buf.toString(); - - Assert.assertTrue(out.contains("1: 0.0, -10.0") | out.contains("1: 0.0, -9.9999999999")); - Assert.assertTrue(out.contains("2: 1.0, -9.25") | out.contains("2: 1.0, -9.2499999999")); - Assert.assertTrue(out.contains("3: 2.0, -8.5") | out.contains("3: 2.0, -8.4999999999")); - Assert.assertTrue(out.contains("4: 3.0, -7.75") | out.contains("4: 3.0, -7.7499999999")); - Assert.assertTrue(out.contains("5: 4.0, -7.0") | out.contains("5: 4.0, -6.9999999999")); - Assert.assertTrue(out.contains("6: 5.0, -6.25") | out.contains("6: 5.0, -6.2499999999")); - Assert.assertTrue(out.contains("7: 6.0, -5.5") | out.contains("7: 6.0, -5.4999999999")); - Assert.assertTrue(out.contains("8: 7.0, -4.75") | out.contains("8: 7.0, -4.7499999999")); - Assert.assertTrue(out.contains("9: 8.0, -4.0") | out.contains("9: 8.0, -3.9999999999")); - - Assert.assertTrue(out.contains("10: 8.0, 0.0") | out.contains("10: 8.0, -0.0")); - Assert.assertTrue(out.contains("11: 6.0, 0.0") | out.contains("11: 6.0, -0.0")); - Assert.assertTrue(out.contains("12: 4.0, 0.0") | out.contains("12: 4.0, -0.0")); - Assert.assertTrue(out.contains("13: 2.0, 0.0") | out.contains("13: 2.0, -0.0")); - Assert.assertTrue( - out.contains("14: 0.0, 0.0") | out.contains("14: 0.0, -0.0") | out.contains("14: -0.0, 0.0") - | out.contains("14: -0.0, -0.0")); - Assert.assertTrue( - out.contains("15: 0.0, 0.0") | out.contains("15: 0.0, -0.0") | out.contains("15: -0.0, 0.0") - | out.contains("15: -0.0, -0.0")); - - Assert.assertTrue(out.contains("16: 0.0, 10.0") | out.contains("16: 0.0, 9.9999999999")); - Assert.assertTrue(out.contains("17: 1.0, 9.25") | out.contains("17: 1.0, 9.2499999999")); - Assert.assertTrue(out.contains("18: 2.0, 8.5") | out.contains("18: 2.0, 8.4999999999")); - Assert.assertTrue(out.contains("19: 3.0, 7.75") | out.contains("19: 3.0, 7.7499999999")); - Assert.assertTrue(out.contains("20: 4.0, 7.0") | out.contains("20: 4.0, 6.9999999999")); - Assert.assertTrue(out.contains("21: 5.0, 6.25") | out.contains("21: 5.0, 6.2499999999")); - Assert.assertTrue(out.contains("22: 6.0, 5.5") | out.contains("22: 6.0, 5.4999999999")); - Assert.assertTrue(out.contains("23: 7.0, 4.75") | out.contains("23: 7.0, 4.7499999999")); - Assert.assertTrue(out.contains("24: 8.0, 4.0") | out.contains("24: 8.0, 3.9999999999")); - - Assert.assertTrue(out.contains("25: 8.0, 0.0") | out.contains("25: 8.0, -0.0")); - Assert.assertTrue(out.contains("26: 6.0, 0.0") | out.contains("26: 6.0, -0.0")); - Assert.assertTrue(out.contains("27: 4.0, 0.0") | out.contains("27: 4.0, -0.0")); - Assert.assertTrue(out.contains("28: 2.0, 0.0") | out.contains("28: 2.0, -0.0")); - Assert.assertTrue( - out.contains("29: 0.0, 0.0") | out.contains("29: 0.0, -0.0") | out.contains("29: -0.0, 0.0") - | out.contains("29: -0.0, -0.0")); - Assert.assertTrue( - out.contains("30: 0.0, 0.0") | out.contains("30: 0.0, -0.0") | out.contains("30: -0.0, 0.0") - | out.contains("30: -0.0, -0.0")); - - Assert.assertTrue(out.contains("31: 0.0, 10.0") | out.contains("31: 0.0, 9.9999999999")); - Assert.assertTrue(out.contains("32: -1.0, 9.25") | out.contains("32: -1.0, 9.2499999999")); - Assert.assertTrue(out.contains("33: -2.0, 8.5") | out.contains("33: -2.0, 8.4999999999")); - Assert.assertTrue(out.contains("34: -3.0, 7.75") | out.contains("34: -3.0, 7.7499999999")); - Assert.assertTrue(out.contains("35: -4.0, 7.0") | out.contains("35: -4.0, 6.9999999999")); - Assert.assertTrue(out.contains("36: -5.0, 6.25") | out.contains("36: -5.0, 6.2499999999")); - Assert.assertTrue(out.contains("37: -6.0, 5.5") | out.contains("37: -6.0, 5.4999999999")); - Assert.assertTrue(out.contains("38: -7.0, 4.75") | out.contains("38: -7.0, 4.7499999999")); - Assert.assertTrue(out.contains("39: -8.0, 4.0") | out.contains("39: -8.0, 3.9999999999")); - - Assert.assertTrue(out.contains("40: -8.0, 0.0") | out.contains("40: -8.0, -0.0")); - Assert.assertTrue(out.contains("41: -6.0, 0.0") | out.contains("41: -6.0, -0.0")); - Assert.assertTrue(out.contains("42: -4.0, 0.0") | out.contains("42: -4.0, -0.0")); - Assert.assertTrue(out.contains("43: -2.0, 0.0") | out.contains("43: -2.0, -0.0")); - Assert.assertTrue( - out.contains("44: -0.0, 0.0") | out.contains("44: -0.0, -0.0") | out.contains("44: 0.0, 0.0") - | out.contains("44: 0.0, -0.0")); - Assert.assertTrue( - out.contains("45: -0.0, 0.0") | out.contains("45: -0.0, -0.0") | out.contains("45: 0.0, 0.0") - | out.contains("45: 0.0, -0.0")); - - Assert.assertTrue(out.contains("46: 0.0, -10.0") | out.contains("46: 0.0, -9.9999999999")); - Assert.assertTrue(out.contains("47: -1.0, -9.25") | out.contains("47: -1.0, -9.2499999999")); - Assert.assertTrue(out.contains("48: -2.0, -8.5") | out.contains("48: -2.0, -8.4999999999")); - Assert.assertTrue(out.contains("49: -3.0, -7.75") | out.contains("49: -3.0, -7.7499999999")); - Assert.assertTrue(out.contains("50: -4.0, -7.0") | out.contains("50: -4.0, -6.9999999999")); - Assert.assertTrue(out.contains("51: -5.0, -6.25") | out.contains("51: -5.0, -6.2499999999")); - Assert.assertTrue(out.contains("52: -6.0, -5.5") | out.contains("52: -6.0, -5.4999999999")); - Assert.assertTrue(out.contains("53: -7.0, -4.75") | out.contains("53: -7.0, -4.7499999999")); - Assert.assertTrue(out.contains("54: -8.0, -4.0") | out.contains("54: -8.0, -3.9999999999")); - - Assert.assertTrue(out.contains("55: -8.0, 0.0") | out.contains("55: -8.0, -0.0")); - Assert.assertTrue(out.contains("56: -6.0, 0.0") | out.contains("56: -6.0, -0.0")); - Assert.assertTrue(out.contains("57: -4.0, 0.0") | out.contains("57: -4.0, -0.0")); - Assert.assertTrue(out.contains("58: -2.0, 0.0") | out.contains("58: -2.0, -0.0")); - Assert.assertTrue( - out.contains("59: -0.0, 0.0") | out.contains("59: -0.0, -0.0") | out.contains("59: 0.0, 0.0") - | out.contains("59: 0.0, -0.0")); - Assert.assertTrue( - out.contains("60: -0.0, 0.0") | out.contains("60: -0.0, -0.0") | out.contains("60: 0.0, 0.0") - | out.contains("60: 0.0, -0.0")); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestBulletPower.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestBulletPower.java deleted file mode 100644 index b37b24f..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestBulletPower.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestBulletPower extends RobocodeTestBed { - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "sample.Target,tested.robots.BadFirePower"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - IRobotSnapshot bp = event.getTurnSnapshot().getRobots()[1]; - - final int time = event.getTurnSnapshot().getTurn(); - - switch (time) { - case 30: - case 46: - case 62: - case 78: - case 94: - case 110: - test(bp, "Bullet power: 3.0"); - break; - - default: - if (time > 1 && time < 115) { - test(bp, "No bullet"); - } - break; - } - } - - private void test(IRobotSnapshot gh, String s) { - Assert.assertTrue(gh.getOutputStreamSnapshot() + " expected " + s, gh.getOutputStreamSnapshot().contains(s)); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorAwtAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorAwtAttack.java deleted file mode 100644 index be70e57..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorAwtAttack.java +++ /dev/null @@ -1,76 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import javax.swing.*; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestConstructorAwtAttack extends RobocodeTestBed { - // in case: boolean messagedAttack; - boolean messagedBreakthru; - - JFrame frame; - - @Override - public String getRobotNames() { - return "tested.robots.ConstructorAwtAttack,tested.robots.BattleLost"; - } - - /* in case that we don't block JFrame by classloader - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("Hacked!!!")) { - messagedBreakthru = true; - } - if (out.contains("Robots are not allowed to reference javax.swing package")) { - messagedAttack = true; - } - } */ - - @Override - protected void runSetup() { - frame = new JFrame(); - frame.setVisible(true); - } - - @Override - protected int getExpectedErrors() { - return 2; - } - - @Override - public int getExpectedRobotCount(String list) { - return 1; - } - - @Override - protected void runTeardown() { - Runnable doCheck = new Runnable() { - public void run() { - Logger.logMessage("works still!!!"); - } - }; - - javax.swing.SwingUtilities.invokeLater(doCheck); - - frame.setVisible(false); - Assert.assertFalse(messagedBreakthru); - // in case: Assert.assertTrue(messagedAttack); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorHttpAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorHttpAttack.java deleted file mode 100644 index 8a613fa..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorHttpAttack.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestConstructorHttpAttack extends RobocodeTestBed { - - private boolean messagedInitialization; - private boolean messagedAccessDenied; - - @Override - public String getRobotNames() { - return "tested.robots.ConstructorHttpAttack,sample.Target"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("An error occurred during initialization")) { - messagedInitialization = true; - } - - if (out.contains("access denied (java.net.SocketPermission") - || out.contains("access denied (\"java.net.SocketPermission\"")) { - messagedAccessDenied = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("Error during initialization", messagedInitialization); - Assert.assertTrue("HTTP connection is not allowed", messagedAccessDenied); - } - - @Override - protected int getExpectedErrors() { - return hasJavaNetURLPermission ? 3 : 2; // Security error must be reported as an error - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorReflectionAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorReflectionAttack.java deleted file mode 100644 index 9dd6718..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorReflectionAttack.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestConstructorReflectionAttack extends RobocodeTestBed { - - private boolean messagedAccessDenied; - - @Override - public String getRobotNames() { - return "tested.robots.ConstructorReflectionAttack,sample.Target"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("access denied (java.lang.reflect.ReflectPermission") - || out.contains("access denied (\"java.lang.reflect.ReflectPermission\"")) { - messagedAccessDenied = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("Reflection is not allowed", messagedAccessDenied); - } - - @Override - protected int getExpectedErrors() { - return 1; // Security error must be reported as an error - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorSocketAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorSocketAttack.java deleted file mode 100644 index 74ced61..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorSocketAttack.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestConstructorSocketAttack extends RobocodeTestBed { - - private boolean messagedInitialization; - private boolean messagedAccessDenied; - - @Override - public String getRobotNames() { - return "tested.robots.ConstructorSocketAttack,sample.Target"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("An error occurred during initialization")) { - messagedInitialization = true; - } - - if (out.contains("access denied (java.net.SocketPermission") - || out.contains("access denied (\"java.net.SocketPermission\"")) { - messagedAccessDenied = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("Error during initialization", messagedInitialization); - Assert.assertTrue("Socket connection is not allowed", messagedAccessDenied); - } - - @Override - protected int getExpectedErrors() { - return 2; // Security error must be reported as an error - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorThreadAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorThreadAttack.java deleted file mode 100644 index 48bae71..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestConstructorThreadAttack.java +++ /dev/null @@ -1,41 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestConstructorThreadAttack extends RobocodeTestBed { - boolean messagedUnknown; - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("Preventing Thread-") && out.contains("from access to MyAttack")) { - messagedUnknown = true; - } - } - - @Override - public String getRobotNames() { - return "tested.robots.ConstructorThreadAttack,sample.Target"; - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedUnknown); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestCustomEvents.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestCustomEvents.java deleted file mode 100644 index 8446b86..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestCustomEvents.java +++ /dev/null @@ -1,56 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import org.junit.Test; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import net.sf.robocode.test.helpers.Assert; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestCustomEvents extends RobocodeTestBed { - - @Test - public void run() { - super.run(); - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - IRobotSnapshot gh = event.getTurnSnapshot().getRobots()[1]; - - switch (event.getTurnSnapshot().getTurn()) { - case 130: - test(gh, "130 onTick99\n130 onTick30"); - break; - - case 1451: - test(gh, "1451 onTick99\n1451 onLowEnergy98\n1451 onTick30\n1451 onScannedRobot10"); - break; - - default: - break; - } - } - - private void test(IRobotSnapshot gh, String s) { - Assert.assertTrue("got: " + gh.getOutputStreamSnapshot() + ", expected: " + s, - gh.getOutputStreamSnapshot().contains(s)); - } - - @Override - public String getRobotNames() { - return "sample.Target,tested.robots.CustomEvents"; - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestDuplicatesAndScore.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestDuplicatesAndScore.java deleted file mode 100644 index 0ce124d..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestDuplicatesAndScore.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import static org.hamcrest.CoreMatchers.is; -import org.junit.Assert; -import org.junit.Test; -import robocode.BattleResults; -import robocode.control.events.BattleCompletedEvent; -import robocode.control.events.BattleFinishedEvent; -import robocode.control.events.RoundStartedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestDuplicatesAndScore extends RobocodeTestBed { - private IRobotSnapshot[] robots; - private BattleResults[] results; - private int lastTurn; - - @Test - public void run() { - super.run(); - } - - @Override - public int getExpectedRobotCount(String list) { - return 8; - } - - @Override - public String getRobotNames() { - return "sample.Fire,tested.robots.TestTeam,tested.robots.TestTeam,sample.Crazy"; - } - - @Override - public void onRoundStarted(final RoundStartedEvent event) { - super.onRoundStarted(event); - if (event.getRound() == 0) { - robots = event.getStartSnapshot().getRobots(); - Assert.assertEquals(8, robots.length); - - net.sf.robocode.test.helpers.Assert.assertNear(568.1445492, robots[0].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(436.7181397, robots[1].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(316.4177265, robots[2].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(721.2294027, robots[3].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(142.7260067, robots[4].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(738.1464346, robots[5].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(335.0596303, robots[6].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(390.7055126, robots[7].getX()); - - net.sf.robocode.test.helpers.Assert.assertNear(100.000, robots[0].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(200.000, robots[1].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(120.000, robots[2].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(100.000, robots[3].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(200.000, robots[4].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(120.000, robots[5].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(100.000, robots[6].getEnergy()); - net.sf.robocode.test.helpers.Assert.assertNear(100.000, robots[7].getEnergy()); - } - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - lastTurn = event.getTurnSnapshot().getTurn(); - robots = event.getTurnSnapshot().getRobots(); - - if (lastTurn == 1) { - net.sf.robocode.test.helpers.Assert.assertNear(568.1445492, robots[0].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(437.5845260, robots[1].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(316.4177265, robots[2].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(721.2294027, robots[3].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(142.4365354, robots[4].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(738.1464346, robots[5].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(335.0596303, robots[6].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(389.7078698, robots[7].getX()); - } - - if (lastTurn == 1365) { - net.sf.robocode.test.helpers.Assert.assertNear(468.5942997, robots[0].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(415.4262123, robots[1].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(317.3362130, robots[2].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(671.1937618, robots[3].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(365.6640401, robots[4].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(734.4305396, robots[5].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(368.6778268, robots[6].getX()); - net.sf.robocode.test.helpers.Assert.assertNear(112.8133694, robots[7].getX()); - } - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - if (event.isAborted()) { - results = null; - } - } - - @Override - public void onBattleCompleted(BattleCompletedEvent event) { - results = event.getSortedResults(); - } - - @Override - protected void runTeardown() { - Assert.assertNotNull(results); - Assert.assertNotNull(robots); - Assert.assertThat(robots[0].getName(), is("sample.Fire (1)")); - Assert.assertThat(robots[1].getName(), is("sampleteam.MyFirstLeader (1)")); - Assert.assertThat(robots[2].getName(), is("sampleteam.MyFirstDroid (1)")); - Assert.assertThat(robots[3].getName(), is("sample.Fire (2)")); - Assert.assertThat(robots[4].getName(), is("sampleteam.MyFirstLeader (2)")); - Assert.assertThat(robots[5].getName(), is("sampleteam.MyFirstDroid (2)")); - Assert.assertThat(robots[6].getName(), is("sample.Fire (3)")); - Assert.assertThat(robots[7].getName(), is("sample.Crazy")); - - Assert.assertThat(results[0].getTeamLeaderName(), is("tested.robots.TestTeam (2)")); - Assert.assertThat(results[1].getTeamLeaderName(), is("tested.robots.TestTeam (1)")); - Assert.assertThat(results[2].getTeamLeaderName(), is("sample.Fire (1)")); - Assert.assertThat(results[3].getTeamLeaderName(), is("sample.Crazy")); - - Assert.assertThat(results[0].getLastSurvivorBonus(), is(100)); - Assert.assertThat(results[1].getLastSurvivorBonus(), is(0)); - Assert.assertThat(results[2].getLastSurvivorBonus(), is(0)); - Assert.assertThat(results[3].getLastSurvivorBonus(), is(0)); - - Assert.assertThat(results[0].getRamDamage(), is(0)); - Assert.assertThat(results[1].getRamDamage(), is(2)); - Assert.assertThat(results[2].getRamDamage(), is(2)); - Assert.assertThat(results[3].getRamDamage(), is(10)); - - Assert.assertThat(results[0].getBulletDamageBonus(), is(93)); - Assert.assertThat(results[1].getBulletDamageBonus(), is(18)); - Assert.assertThat(results[2].getBulletDamageBonus(), is(0)); - Assert.assertThat(results[3].getBulletDamageBonus(), is(0)); - - Assert.assertThat(results[0].getBulletDamage(), is(513)); - Assert.assertThat(results[1].getBulletDamage(), is(280)); - Assert.assertThat(results[2].getBulletDamage(), is(89)); - Assert.assertThat(results[3].getBulletDamage(), is(48)); - - Assert.assertThat(results[0].getScore(), is(1206)); - Assert.assertThat(results[1].getScore(), is(650)); - Assert.assertThat(results[2].getScore(), is(242)); - Assert.assertThat(results[3].getScore(), is(158)); - - Assert.assertThat(lastTurn, is(893)); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestEnvAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestEnvAttack.java deleted file mode 100644 index f1c05ed..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestEnvAttack.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Pavel Savara (original) - */ -public class TestEnvAttack extends RobocodeTestBed { - boolean messagedAttack; - - @Test - public void run() { - super.run(); - } - - @Override - public String getRobotNames() { - return "tested.robots.BattleLost,tested.robots.EnvAttack"; - } - - @Override - protected int getExpectedErrors() { - return 1; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("AccessControlException: access denied")) { - messagedAttack = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedAttack); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestEventPriorityFilter.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestEventPriorityFilter.java deleted file mode 100644 index 4800756..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestEventPriorityFilter.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Pavel Savara (original) - */ -public class TestEventPriorityFilter extends RobocodeTestBed { - boolean messagedScanned; - - @Test - public void run() { - super.run(); - } - - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("Scanned!!!")) { - messagedScanned = true; - } - } - - @Override - public String getRobotNames() { - return "tested.robots.EventPriorityFilter,tested.robots.EventPriorityFilter"; - } - - @Override - protected void runTeardown() { - Assert.assertFalse(messagedScanned); - } -} - diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFairPlay.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFairPlay.java deleted file mode 100644 index 39769a6..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFairPlay.java +++ /dev/null @@ -1,66 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import org.junit.Assert; -import org.junit.Test; - -import robocode.control.events.BattleFinishedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IScoreSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestFairPlay extends RobocodeTestBed { - - ITurnSnapshot lastTurnSnapshot; - - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "tested.robots.FairPlay,tested.robots.FairPlay"; - } - - @Override - public int getNumRounds() { - return 200; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - lastTurnSnapshot = event.getTurnSnapshot(); - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - final IScoreSnapshot[] scores = lastTurnSnapshot.getSortedTeamScores(); - final IScoreSnapshot score1 = scores[0]; - final IScoreSnapshot score2 = scores[1]; - - double minTotal = Math.min(score1.getTotalScore(), score2.getTotalScore()); - double maxTotal = Math.max(score1.getTotalScore(), score2.getTotalScore()); - - Assert.assertTrue("The total scores should be almost the same", maxTotal / minTotal <= 1.05); - - double minFirsts = Math.min(score1.getTotalFirsts(), score2.getTotalFirsts()); - double maxFirsts = Math.max(score1.getTotalFirsts(), score2.getTotalFirsts()); - - Assert.assertTrue("The total firsts should be almost the same", maxFirsts / minFirsts <= 1.05); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileAttack.java deleted file mode 100644 index a7085d0..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileAttack.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; - -import java.io.File; - - -/** - * @author Pavel Savara (original) - */ -public class TestFileAttack extends RobocodeTestBed { - boolean messagedWrite; - boolean messagedRead; - - @Test - public void run() { - super.run(); - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("Preventing tested.robots.FileAttack from access: (java.io.FilePermission C:\\MSDOS.SYS read)") - || out.contains( - "Preventing tested.robots.FileAttack from access: (\"java.io.FilePermission\" \"C:\\MSDOS.SYS\" \"read\")")) { - messagedRead = true; - } - if (out.contains( - "Preventing tested.robots.FileAttack from access: (java.io.FilePermission C:\\Robocode.attack write)") - || out.contains( - "Preventing tested.robots.FileAttack from access: (\"java.io.FilePermission\" \"C:\\Robocode.attack\" \"write\")")) { - messagedWrite = true; - } - } - - @Override - public String getRobotNames() { - return "sample.Fire,tested.robots.FileAttack"; - } - - @Override - protected void runSetup() { - File attack = new File("C:\\Robocode.attack"); - - if (attack.exists()) { - Assert.assertTrue(attack.delete()); - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("Didn't seen preventing read", messagedRead); - Assert.assertTrue("Didn't seen preventing write", messagedWrite); - Assert.assertFalse("Found attack file", new File("C:\\Robocode.attack").exists()); - } - - @Override - protected int getExpectedErrors() { - return 2; // Security error must be reported as an error - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileOutputStreamAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileOutputStreamAttack.java deleted file mode 100644 index cc64e98..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileOutputStreamAttack.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestFileOutputStreamAttack extends RobocodeTestBed { - - private boolean messagedAccessDenied; - - @Override - public String getRobotNames() { - return "tested.robots.FileOutputStreamAttack,sample.Target"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("access denied (java.io.FilePermission") - || out.contains("access denied (\"java.io.FilePermission\"")) { - messagedAccessDenied = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("FileOutputStream is not allowed", messagedAccessDenied); - } - - @Override - protected int getExpectedErrors() { - return 1; // Security error must be reported as an error - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileWrite.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileWrite.java deleted file mode 100644 index d59c722..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileWrite.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import org.junit.Test; - -import java.io.File; - - -/** - * @author Pavel Savara (original) - */ -public class TestFileWrite extends RobocodeTestBed { - - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "sample.Walls,sample.SittingDuck"; - } - - File file = new File(robotsPath, "/target/classes/sample/SittingDuck.data/count.dat"); - - @Override - protected void runSetup() { - if (file.exists()) { - if (!file.delete()) { - Logger.logError("Can't delete" + file); - } - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue(file.exists()); - if (!file.delete()) { - Logger.logError("Can't delete" + file); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileWriteSize.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileWriteSize.java deleted file mode 100644 index 12dac22..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestFileWriteSize.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import java.io.File; - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestFileWriteSize extends RobocodeTestBed { - - boolean messagedDataQuota; - boolean messagedDataDirectory; - boolean messagedDataFile; - boolean messageQuotaReached; - boolean robotTerminated; - - @Override - public String getRobotNames() { - return "tested.robots.FileWriteSize,sample.Target"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - String path = robotsPath; - - if (File.separatorChar == '\\') { - out = out.replaceAll("[\\\\]", "/"); - path = path.replaceAll("[\\\\]", "/"); - } - if (out.contains("Data quota: 200000\n")) { - messagedDataQuota = true; - } - if (out.contains("Data directory: " + path + "/target/classes/tested/robots/FileWriteSize.data")) { - messagedDataDirectory = true; - } - if (out.contains("Data file: " + path + "/target/classes/tested/robots/FileWriteSize.data/test")) { - messagedDataFile = true; - } - if (out.contains("You have reached your filesystem quota of: 200000 bytes")) { - messageQuotaReached = true; - } - if (event.getTurnSnapshot().getRobots()[0].getEnergy() == 0) { - robotTerminated = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("Data quota must be 200000", messagedDataQuota); - Assert.assertTrue("Data directory path is wrong", messagedDataDirectory); - Assert.assertTrue("Data file path is wrong", messagedDataFile); - Assert.assertTrue("Error must be output that file quota has been exceeded", messageQuotaReached); - Assert.assertTrue("Game must terminate the robot", robotTerminated); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestGunHeat.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestGunHeat.java deleted file mode 100644 index f19ea6d..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestGunHeat.java +++ /dev/null @@ -1,90 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestGunHeat extends RobocodeTestBed { - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "sample.Target,tested.robots.GunHeat"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - IRobotSnapshot gh = event.getTurnSnapshot().getRobots()[1]; - - switch (event.getTurnSnapshot().getTurn()) { - case 1: - test(gh, "3.0"); - break; - - case 2: - test(gh, "2.8"); - break; - - case 3: - test(gh, "2.699999"); - break; - - case 4: - test(gh, "2.599999"); - break; - - case 9: - test(gh, "2.09999999"); - break; - - case 20: - test(gh, "0.9999999"); - break; - - case 28: - test(gh, "0.19999999"); - break; - - case 29: - test(gh, "0.09999999"); - break; - - case 30: - test(gh, "1.6"); - break; - - case 570: - test(gh, "2.77555"); - break; - - case 571: - test(gh, "0.0"); - break; - - default: - break; - } - } - - private void test(IRobotSnapshot gh, String s) { - Assert.assertTrue(gh.getOutputStreamSnapshot() + " expected " + s, - gh.getOutputStreamSnapshot().contains("after fire: " + s)); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestGunTurnRate.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestGunTurnRate.java deleted file mode 100644 index c19543e..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestGunTurnRate.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestGunTurnRate extends RobocodeTestBed { - - StringBuffer buf = new StringBuffer(); - - @Override - public String getRobotNames() { - return "tested.robots.GunTurnRate,sample.Target"; - } - - @Override - public String getInitialPositions() { - return "(50,50,0), (150,50,0)"; // Make sure the robots do not collide! - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - buf.append(event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot()); - - if (event.getTurnSnapshot().getTurn() == 16) { - final String out = buf.toString(); - - Assert.assertTrue(out.contains("1: -20.0") | out.contains("1: -19.9999999999")); - Assert.assertTrue(out.contains("2: -20.0") | out.contains("2: -19.9999999999")); - Assert.assertTrue(out.contains("3: 20.0") | out.contains("3: 19.9999999999")); - Assert.assertTrue(out.contains("4: 20.0") | out.contains("4: 19.9999999999")); - Assert.assertTrue(out.contains("5: -25.0") | out.contains("5: -24.9999999999")); - Assert.assertTrue(out.contains("6: -25.0") | out.contains("6: -24.9999999999")); - Assert.assertTrue(out.contains("7: 25.0") | out.contains("7: 24.9999999999")); - Assert.assertTrue(out.contains("8: 25.0") | out.contains("8: 24.9999999999")); - Assert.assertTrue(out.contains("9: -30.0") | out.contains("9: -29.9999999999")); - Assert.assertTrue(out.contains("10: -30.0") | out.contains("10: -29.9999999999")); - Assert.assertTrue(out.contains("11: 30.0") | out.contains("11: 29.9999999999")); - Assert.assertTrue(out.contains("12: 30.0") | out.contains("12: 29.9999999999")); - Assert.assertTrue(out.contains("13: -10.0") | out.contains("13: -9.9999999999")); - Assert.assertTrue(out.contains("14: -10.0") | out.contains("14: -9.9999999999")); - Assert.assertTrue(out.contains("15: 10.0") | out.contains("15: 9.9999999999")); - Assert.assertTrue(out.contains("16: 10.0") | out.contains("16: 9.9999999999")); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestHttpAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestHttpAttack.java deleted file mode 100644 index bd097be..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestHttpAttack.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestHttpAttack extends RobocodeTestBed { - - private boolean messagedAccessDenied; - - @Override - public String getRobotNames() { - return "tested.robots.HttpAttack,sample.Target"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("access denied (java.net.SocketPermission") - || out.contains("access denied (\"java.net.SocketPermission\"")) { - messagedAccessDenied = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("HTTP connection is not allowed", messagedAccessDenied); - } - - @Override - protected int getExpectedErrors() { - return hasJavaNetURLPermission ? 2 : 1; // Security error must be reported as an error. Java 8 reports two errors. - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestIncludeNamespaceAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestIncludeNamespaceAttack.java deleted file mode 100644 index 200d715..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestIncludeNamespaceAttack.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; - - -/** - * @author Pavel Savara (original) - */ -public class TestIncludeNamespaceAttack extends RobocodeTestBed { - @Test - public void run() { - super.run(); - } - - @Override - protected int getExpectedErrors() { - return 2; - } - - @Override - public int getExpectedRobotCount(String list) { - return 1; - } - - @Override - public String getRobotNames() { - return "tested.robots.DieFast,tested.robots.IncludeNamespaceAttack"; - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestInteruptibleEvent.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestInteruptibleEvent.java deleted file mode 100644 index 8faacad..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestInteruptibleEvent.java +++ /dev/null @@ -1,48 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; - - -/** - * Test if onScannedRobot() is called when the radar is turned from within a onHitWall() event. - * - * @author Flemming N. Larsen (original) - */ -public class TestInteruptibleEvent extends RobocodeTestBed { - boolean messagedScanned; - - @Test - public void run() { - super.run(); - } - - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("Scanned!!!")) { - messagedScanned = true; - } - } - - @Override - public String getRobotNames() { - return "tested.robots.InteruptibleEvent,tested.robots.InteruptibleEvent"; - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedScanned); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestJunior.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestJunior.java deleted file mode 100644 index 3d8d21c..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestJunior.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import org.junit.Assert; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestJunior extends RobocodeTestBed { - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "tested.robots.JuniorEvents,sample.SittingDuck"; - } - - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[0]; - - if (event.getTurnSnapshot().getTurn() == 590) { - String out = robot.getOutputStreamSnapshot(); - - test(out, "robocode.BulletMissedEvent 5"); - test(out, "robocode.ScannedRobotEvent 100"); - test(out, "robocode.BulletHitEvent 24"); - test(out, "robocode.StatusEvent 590"); - test(out, "robocode.WinEvent 1"); - test(out, "last bullet heading 6.06794172"); - } - } - - private void test(String out, String in) { - Assert.assertTrue(in, out.contains(in)); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestLost.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestLost.java deleted file mode 100644 index cb49cbb..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestLost.java +++ /dev/null @@ -1,61 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import static org.hamcrest.CoreMatchers.is; -import org.junit.Assert; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestLost extends RobocodeTestBed { - private int lost = 0; - private int end = 0; - - @Test - public void run() { - super.run(); - } - - @Override - public int getNumRounds() { - return 5; - } - - @Override - public String getRobotNames() { - return "sample.Fire,tested.robots.BattleLost"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1]; - final String streamSnapshot = robot.getOutputStreamSnapshot(); - - if (streamSnapshot.contains("Death!")) { - lost++; - } - if (streamSnapshot.contains("BattleEnded!")) { - end++; - } - } - - @Override - protected void runTeardown() { - Assert.assertThat("always should loose", lost, is(getNumRounds())); - Assert.assertThat("should get BattleEnded event", end, is(1)); - } - -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestMaxTurnRate.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestMaxTurnRate.java deleted file mode 100644 index b139c08..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestMaxTurnRate.java +++ /dev/null @@ -1,72 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestMaxTurnRate extends RobocodeTestBed { - - StringBuffer buf = new StringBuffer(); - - @Override - public String getRobotNames() { - return "tested.robots.MaxTurnRate,sample.Target"; - } - - @Override - public String getInitialPositions() { - return "(50,50,0), (150,50,0)"; // Make sure the robots do not collide! - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - buf.append(event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot()); - - if (event.getTurnSnapshot().getTurn() == 26) { - final String out = buf.toString(); - - Assert.assertTrue(out.contains("1: 0.0, 0.0") | out.contains("1: 0.0, -0.0")); - Assert.assertTrue(out.contains("2: 0.0, -1.0") | out.contains("2: 0.0, -0.999999999")); - Assert.assertTrue(out.contains("3: 0.0, -2.0") | out.contains("3: 0.0, -1.999999999")); - Assert.assertTrue(out.contains("4: 0.0, -3.0") | out.contains("4: 0.0, -2.999999999")); - Assert.assertTrue(out.contains("5: 0.0, -4.0") | out.contains("5: 0.0, -3.999999999")); - Assert.assertTrue(out.contains("6: 0.0, -5.0") | out.contains("6: 0.0, -4.999999999")); - Assert.assertTrue(out.contains("7: 0.0, -6.0") | out.contains("7: 0.0, -5.999999999")); - Assert.assertTrue(out.contains("8: 0.0, -7.0") | out.contains("8: 0.0, -6.999999999")); - Assert.assertTrue(out.contains("9: 0.0, -8.0") | out.contains("9: 0.0, -7.999999999")); - Assert.assertTrue(out.contains("10: 0.0, -9.0") | out.contains("10: 0.0, -8.999999999")); - Assert.assertTrue(out.contains("11: 0.0, -10.0") | out.contains("11: 0.0, -9.999999999")); - Assert.assertTrue(out.contains("12: 0.0, -10.0") | out.contains("12: 0.0, -9.999999999")); - Assert.assertTrue(out.contains("13: 0.0, -10.0") | out.contains("13: 0.0, -9.999999999")); - - Assert.assertTrue(out.contains("14: 0.0, 0.0") | out.contains("14: 0.0, -0.0")); - Assert.assertTrue(out.contains("15: 0.0, 1.0") | out.contains("15: 0.0, 0.999999999")); - Assert.assertTrue(out.contains("16: 0.0, 2.0") | out.contains("16: 0.0, 1.999999999")); - Assert.assertTrue(out.contains("17: 0.0, 3.0") | out.contains("17: 0.0, 2.999999999")); - Assert.assertTrue(out.contains("18: 0.0, 4.0") | out.contains("18: 0.0, 3.999999999")); - Assert.assertTrue(out.contains("19: 0.0, 5.0") | out.contains("19: 0.0, 4.999999999")); - Assert.assertTrue(out.contains("20: 0.0, 6.0") | out.contains("20: 0.0, 5.999999999")); - Assert.assertTrue(out.contains("21: 0.0, 7.0") | out.contains("21: 0.0, 6.999999999")); - Assert.assertTrue(out.contains("22: 0.0, 8.0") | out.contains("22: 0.0, 7.999999999")); - Assert.assertTrue(out.contains("23: 0.0, 9.0") | out.contains("23: 0.0, 8.999999999")); - Assert.assertTrue(out.contains("24: 0.0, 10.0") | out.contains("24: 0.0, 9.999999999")); - Assert.assertTrue(out.contains("25: 0.0, 10.0") | out.contains("25: 0.0, 9.999999999")); - Assert.assertTrue(out.contains("26: 0.0, 10.0") | out.contains("26: 0.0, 9.999999999")); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestMaxVelocity.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestMaxVelocity.java deleted file mode 100644 index ac28d8b..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestMaxVelocity.java +++ /dev/null @@ -1,81 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import robocode.control.events.TurnEndedEvent; -import robocode.util.Utils; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestMaxVelocity extends RobocodeTestBed { - - @Override - public String getRobotNames() { - return "tested.robots.MaxVelocity,sample.Target"; - } - - @Override - public String getInitialPositions() { - return "(50,50,0), (600,50,0)"; // Make sure the robots do not collide! - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final int time = (int) event.getTurnSnapshot().getTurn(); - final double velocity = event.getTurnSnapshot().getRobots()[0].getVelocity(); - - switch (time) { - case 10: - case 20: - case 100: - Assert.assertTrue(Utils.isNear(velocity, 8)); - break; - - case 32: - case 40: - case 120: - Assert.assertTrue(Utils.isNear(velocity, -8)); - break; - - case 50: - case 60: - Assert.assertTrue(Utils.isNear(velocity, 4.2)); - break; - - case 70: - case 80: - Assert.assertTrue(Utils.isNear(velocity, -4.2)); - break; - - case 130: - case 140: - Assert.assertTrue(Utils.isNear(velocity, 2)); - break; - - case 150: - case 160: - Assert.assertTrue(Utils.isNear(velocity, -2)); - break; - - case 170: - case 180: - case 190: - case 199: - Assert.assertTrue(Utils.isNear(velocity, 0)); - break; - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestNames.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestNames.java deleted file mode 100644 index 3eacb74..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestNames.java +++ /dev/null @@ -1,38 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; - - -/** - * @author Pavel Savara (original) - */ -public class TestNames extends RobocodeTestBed { - @Test - public void run() { - super.run(); - } - - @Override - protected int getExpectedErrors() { - return 4; - } - - @Override - public int getExpectedRobotCount(String list) { - return 2; - } - - @Override - public String getRobotNames() { - return "sample.Fire,robocode.BadNamespace,tested.robots.TooLongNameThisIsReallyTooLongName,tooLongNamespaceThisIsReallyTooLongNamespace.TooLongNamespace,NoPackageButReallyLongNameIWouldSayTooLongMaybeEventLonger,NoPackageShortName"; - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestPosition.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestPosition.java deleted file mode 100644 index b8055e2..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestPosition.java +++ /dev/null @@ -1,78 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import static org.hamcrest.CoreMatchers.is; -import org.junit.Test; -import robocode.control.events.RoundStartedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * Repeatable robot possition test - * - * @author Pavel Savara (original) - */ -public class TestPosition extends RobocodeTestBed { - int lastTurn; - - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "sample.Crazy,sample.Target"; - } - - @Override - public void onRoundStarted(final RoundStartedEvent event) { - super.onRoundStarted(event); - if (event.getRound() == 0) { - IRobotSnapshot crazy = event.getStartSnapshot().getRobots()[0]; - IRobotSnapshot target = event.getStartSnapshot().getRobots()[1]; - - Assert.assertNear(568.1445492, crazy.getX()); - Assert.assertNear(163.0032275, crazy.getY()); - Assert.assertNear(436.7181397, target.getX()); - Assert.assertNear(351.5039067, target.getY()); - } - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - lastTurn = event.getTurnSnapshot().getTurn(); - - IRobotSnapshot crazy = event.getTurnSnapshot().getRobots()[0]; - IRobotSnapshot target = event.getTurnSnapshot().getRobots()[1]; - - if (lastTurn == 1) { - Assert.assertNear(567.2831835, crazy.getX()); - Assert.assertNear(162.4952421, crazy.getY()); - Assert.assertNear(436.7181397, target.getX()); - Assert.assertNear(351.5039067, target.getY()); - } - - if (lastTurn == 1700) { - Assert.assertNear(373.9958377, crazy.getX()); - Assert.assertNear(196.1380677, crazy.getY()); - Assert.assertNear(340.3212984, target.getX()); - Assert.assertNear(456.5502002, target.getY()); - } - } - - @Override - protected void runTeardown() { - Assert.assertThat(lastTurn, is(2080)); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestPrivateConstructor.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestPrivateConstructor.java deleted file mode 100644 index 5c9b5c9..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestPrivateConstructor.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestPrivateConstructor extends RobocodeTestBed { - boolean messaged; - - @Test - public void run() { - super.run(); - } - - public void onTurnEnded(final TurnEndedEvent event) { - super.onTurnEnded(event); - final IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1]; - - if (robot.getOutputStreamSnapshot().contains("SYSTEM: Is your constructor marked public?")) { - messaged = true; - } - Assert.assertNear(0, robot.getEnergy()); - } - - @Override - public String getRobotNames() { - return "sample.Fire,tested.robots.PrivateConstructor"; - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messaged); - } - - @Override - protected int getExpectedErrors() { - return 1; // Security error must be reported as an error - } -} - diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRadarTurnRateAndSetAdjust.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRadarTurnRateAndSetAdjust.java deleted file mode 100644 index f5b28bc..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRadarTurnRateAndSetAdjust.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestRadarTurnRateAndSetAdjust extends RobocodeTestBed { - - StringBuffer buf = new StringBuffer(); - - @Override - public String getRobotNames() { - return "tested.robots.RadarTurnRateAndSetAdjust,sample.Target"; - } - - @Override - public String getInitialPositions() { - return "(50,50,0), (150,50,0)"; // Make sure the robots do not collide! - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - buf.append(event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot()); - - if (event.getTurnSnapshot().getTurn() == 14) { - final String out = buf.toString(); - - Assert.assertTrue(out.contains("1: 45.0") | out.contains("1: 44.999999999")); - Assert.assertTrue(out.contains("2: 65.0") | out.contains("2: 64.999999999")); - Assert.assertTrue(out.contains("3: 75.0") | out.contains("3: 74.999999999")); - Assert.assertTrue(out.contains("4: -15.0") | out.contains("4: -14.999999999")); - Assert.assertTrue(out.contains("5: -55.0") | out.contains("5: -54.999999999")); - Assert.assertTrue(out.contains("6: -75.0") | out.contains("6: -74.999999999")); - Assert.assertTrue(out.contains("7: 32.0") | out.contains("7: 31.999999999")); - Assert.assertTrue(out.contains("8: 17.0") | out.contains("8: 16.999999999")); - Assert.assertTrue(out.contains("9: 35.0") | out.contains("9: 34.999999999")); - Assert.assertTrue(out.contains("10: 3.0") | out.contains("10: 2.999999999")); - Assert.assertTrue(out.contains("11: -21.0") | out.contains("11: -20.999999999")); - Assert.assertTrue(out.contains("12: 75.0") | out.contains("12: 74.999999999")); - Assert.assertTrue(out.contains("13: -75.0") | out.contains("13: -74.999999999")); - Assert.assertTrue(out.contains("14: -15.0") | out.contains("14: -14.999999999")); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRandom.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRandom.java deleted file mode 100644 index f5d846a..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRandom.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * Repeatable random test - * - * @author Pavel Savara (original) - */ -public class TestRandom extends RobocodeTestBed { - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "sample.Fire,tested.robots.Random"; - } - - @Override - public boolean isCheckOnBattleStart() { - return true; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - Assert.assertTrue(event.getTurnSnapshot().getTurn() <= 1407); - IRobotSnapshot fire = event.getTurnSnapshot().getRobots()[0]; - IRobotSnapshot random = event.getTurnSnapshot().getRobots()[1]; - - if (event.getTurnSnapshot().getTurn() == 1241) { - Assert.assertNear(213.18621928, fire.getX()); - Assert.assertNear(371.45706118, fire.getY()); - Assert.assertNear(782.0, random.getX()); - Assert.assertNear(230.95479253, random.getY()); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRankingsWithTargetRobots.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRankingsWithTargetRobots.java deleted file mode 100644 index 3536f0f..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRankingsWithTargetRobots.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import static org.hamcrest.CoreMatchers.is; -import org.junit.Assert; -import robocode.control.events.BattleFinishedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IScoreSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - - -/** - * This test is used for checking the rankings of two sample.Target robots, i.e. - * robots that does not shot, but is just waiting for someone to shot them. As - * two sample.Targets robots are not fighting each other, the battles are - * expected to end fairly even, but not necessarily due to collisions between - * the robots and the wall. - * - * @author Flemming N. Larsen (original) - */ -public class TestRankingsWithTargetRobots extends RobocodeTestBed { - - ITurnSnapshot lastTurnSnapshot; - - @Override - public String getRobotNames() { - return "sample.Target,sample.Target"; - } - - @Override - public int getNumRounds() { - return 20; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - lastTurnSnapshot = event.getTurnSnapshot(); - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - final IScoreSnapshot[] scores = lastTurnSnapshot.getSortedTeamScores(); - final IScoreSnapshot score1 = scores[0]; - final IScoreSnapshot score2 = scores[1]; - - // 1sts + 2nds = number of rounds, e.g. 4 + 6 = 10 (where 4 is 1st places, and 6 is 2nd places) - Assert.assertThat("1st ranked robot's total 1st and 2nd places must be equal to the number of rounds", - score1.getTotalFirsts() + score1.getTotalSeconds(), is(getNumRounds())); - Assert.assertThat("2nd ranked robot's total 1st and 2nd places must be equal to the number of rounds", - score2.getTotalFirsts() + score2.getTotalSeconds(), is(getNumRounds())); - - // If 1st robot's 1sts = 6, 2nds = 4, then 2nd robot's 1sts = 4, 2nds = 6 - /* Assert.assertThat( - "1st ranked robot's number of 1st places must be equal to the 2nd ranked robot's number of 2nd places", - score1.getTotalFirsts(), is(score2.getTotalSeconds())); - Assert.assertThat( - "2nd ranked robot's number of 1st places must be equal to the 1st ranked robot's number of 2nd places", - score2.getTotalFirsts(), is(score1.getTotalSeconds()));*/ - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRateControl.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRateControl.java deleted file mode 100644 index efbd12d..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRateControl.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import static robocode.util.Utils.normalRelativeAngle; - -import org.junit.Test; - -import robocode.control.events.RoundStartedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - - -/** - * @author Joshua Galecki (original) - */ -public class TestRateControl extends RobocodeTestBed { - int turnNumber; - double originalHeading; - double originalX; - double originalGunHeading; - double originalRadarHeading; - - @Test - public void run() { - super.run(); - } - - @Override - public String getRobotNames() { - return "tested.robots.RateControl,sample.Target"; - } - - @Override - public String getInitialPositions() { - return "(320,220,0), (50,50,0)"; // Make sure the robot doesn't start too near to a wall - } - - @Override - public void onRoundStarted(final RoundStartedEvent event) { - super.onRoundStarted(event); - IRobotSnapshot rate = event.getStartSnapshot().getRobots()[0]; - - originalHeading = rate.getBodyHeading(); - originalX = rate.getX(); - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - turnNumber = event.getTurnSnapshot().getTurn(); - - IRobotSnapshot rate = event.getTurnSnapshot().getRobots()[0]; - - // Test turnRate - if (turnNumber == 10) { - Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getBodyHeading() - originalHeading)); - } - if (turnNumber == 20) { - Assert.assertNear(-Math.PI / 4, normalRelativeAngle(rate.getBodyHeading() - originalHeading)); - } - if (turnNumber == 25) { - // Test that turnRate was set to zero - Assert.assertNear(-Math.PI / 4, normalRelativeAngle(rate.getBodyHeading() - originalHeading)); - - // Test velocityRate - double theta = rate.getBodyHeading(); - double deltaX = rate.getX() - originalX; - double distanceTravelled = deltaX / Math.sin(theta); - - Assert.assertNear(9, distanceTravelled); - } - if (turnNumber == 35) { - double theta = rate.getBodyHeading(); - double deltaX = rate.getX() - originalX; - double distanceTravelled = deltaX / Math.sin(theta); - - Assert.assertNear(-35, distanceTravelled); - originalGunHeading = rate.getGunHeading(); - } - if (turnNumber == 45) { - // Test that velocityRate was set to zero - double theta = rate.getBodyHeading(); - double deltaX = rate.getX() - originalX; - double distanceTravelled = deltaX / Math.sin(theta); - - Assert.assertNear(-47, distanceTravelled); - - // test gunRotationRate - Assert.assertNear(Math.PI / 2, normalRelativeAngle(rate.getGunHeading() - originalGunHeading)); - } - if (turnNumber == 55) { - Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getGunHeading() - originalGunHeading)); - originalRadarHeading = rate.getRadarHeading(); - } - - if (turnNumber == 65) { - // test that gunRotationRate was set to zero - Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getGunHeading() - originalGunHeading)); - - // test radarRotationRate - Assert.assertNear(Math.PI / 2, normalRelativeAngle(rate.getRadarHeading() - originalRadarHeading)); - } - if (turnNumber == 75) { - Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getRadarHeading() - originalRadarHeading)); - } - if (turnNumber == 76) { - // test that radarRotationRate was set to zero - Assert.assertNear(Math.PI / 4, normalRelativeAngle(rate.getRadarHeading() - originalRadarHeading)); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestReflectionAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestReflectionAttack.java deleted file mode 100644 index 218f2de..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestReflectionAttack.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestReflectionAttack extends RobocodeTestBed { - - private boolean messagedAccessDenied; - - @Override - public String getRobotNames() { - return "tested.robots.ReflectionAttack,sample.Target"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("access denied (java.lang.reflect.ReflectPermission") - || out.contains("access denied (\"java.lang.reflect.ReflectPermission\"")) { - messagedAccessDenied = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("Reflection is not allowed", messagedAccessDenied); - } - - @Override - protected int getExpectedErrors() { - return 1; // Security error must be reported as an error - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestReverseDirection.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestReverseDirection.java deleted file mode 100644 index 2b0da8b..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestReverseDirection.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import robocode.control.events.TurnEndedEvent; -import robocode.util.Utils; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestReverseDirection extends RobocodeTestBed { - - @Override - public String getRobotNames() { - return "tested.robots.ReverseDirection,sample.Target"; - } - - @Override - public String getInitialPositions() { - return "(50,50,0), (600,50,0)"; // Make sure the robots do not collide! - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final int time = (int) event.getTurnSnapshot().getTurn(); - final double velocity = event.getTurnSnapshot().getRobots()[0].getVelocity(); - - switch (time) { - case 1: - Assert.assertTrue(Utils.isNear(velocity, 1.0)); - break; - - case 2: - Assert.assertTrue(Utils.isNear(velocity, -0.5)); - break; - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRobotDeathEvents.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRobotDeathEvents.java deleted file mode 100644 index 45b0781..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestRobotDeathEvents.java +++ /dev/null @@ -1,42 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestRobotDeathEvents extends RobocodeTestBed { - - @Override - public String getRobotNames() { - return "tested.robots.RobotDeathEvents,sample.Crazy,sample.Target,sample.Target,sample.Target"; - } - - @Override - public int getNumRounds() { - return 5; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("enemyCount != getOthers()")) { - Assert.fail("Robot is missing RobotDeathEvent"); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestScoring.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestScoring.java deleted file mode 100644 index 5fb08f3..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestScoring.java +++ /dev/null @@ -1,83 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import robocode.control.events.BattleFinishedEvent; -import robocode.control.events.RoundEndedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IScoreSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - - -/** - * This test is used for testing if the current scores and total scores are - * calculated correctly. Current scores are tested at each turn, and the total - * scores are tested per round and per battle. - * - * @author Flemming N. Larsen (original) - */ -public class TestScoring extends RobocodeTestBed { - - ITurnSnapshot lastTurnSnapshot; - - @Override - public String getRobotNames() { - return "sample.Corners,sample.Crazy,sample.Fire,sample.RamFire,sample.SittingDuck,sample.SpinBot,sample.Tracker,sample.TrackFire,sample.Walls"; - } - - @Override - public int getNumRounds() { - return 10; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - lastTurnSnapshot = event.getTurnSnapshot(); - - for (IScoreSnapshot score : lastTurnSnapshot.getSortedTeamScores()) { - // Notice that the is no such thing as a 'current total last - // survivor bonus' - double currentScore = score.getCurrentSurvivalScore() + score.getCurrentBulletDamageScore() - + score.getCurrentBulletKillBonus() + score.getCurrentRammingDamageScore() - + score.getCurrentRammingKillBonus() + score.getCurrentSurvivalBonus(); - - Assert.assertNear(currentScore, score.getCurrentScore()); - } - } - - @Override - public void onRoundEnded(RoundEndedEvent event) { - super.onRoundEnded(event); - - for (IScoreSnapshot score : lastTurnSnapshot.getSortedTeamScores()) { - - double totalScore = score.getTotalSurvivalScore() + score.getTotalLastSurvivorBonus() - + score.getTotalBulletDamageScore() + score.getTotalBulletKillBonus() + score.getTotalRammingDamageScore() - + score.getTotalRammingKillBonus(); - - Assert.assertNear(totalScore, score.getTotalScore()); - } - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - for (IScoreSnapshot score : lastTurnSnapshot.getSortedTeamScores()) { - - double totalScore = score.getTotalSurvivalScore() + score.getTotalLastSurvivorBonus() - + score.getTotalBulletDamageScore() + score.getTotalBulletKillBonus() + score.getTotalRammingDamageScore() - + score.getTotalRammingKillBonus(); - - Assert.assertNear(totalScore, score.getTotalScore()); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestSkippedTurns.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestSkippedTurns.java deleted file mode 100644 index c0f9959..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestSkippedTurns.java +++ /dev/null @@ -1,53 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import org.junit.Ignore; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Pavel Savara (original) - */ -@Ignore("is very timing sensitive test, so it usually fails on different machines, please run explicitly if you did something to security or timing") -public class TestSkippedTurns extends RobocodeTestBed { - boolean messagedBattle; - boolean messagedEvent; - - @Test - public void run() { - super.run(); - } - - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[1].getOutputStreamSnapshot(); - - if (out.contains("Skipped!!!")) { - messagedEvent = true; - } - if (out.contains("not performed any actions in a reasonable")) { - messagedBattle = true; - } - } - - @Override - public String getRobotNames() { - return "sample.TrackFire,tested.robots.SkipTurns"; - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedEvent); - Assert.assertTrue(messagedBattle); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestSocketAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestSocketAttack.java deleted file mode 100644 index da634ac..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestSocketAttack.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Assert; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Flemming N. Larsen (original) - */ -public class TestSocketAttack extends RobocodeTestBed { - - private boolean messagedAccessDenied; - - @Override - public String getRobotNames() { - return "tested.robots.SocketAttack,sample.Target"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("access denied (java.net.SocketPermission") - || out.contains("access denied (\"java.net.SocketPermission\"")) { - messagedAccessDenied = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue("Socket connection is not allowed", messagedAccessDenied); - } - - @Override - protected int getExpectedErrors() { - return 1; // Security error must be reported as an error - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestThreadAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestThreadAttack.java deleted file mode 100644 index e4233fa..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestThreadAttack.java +++ /dev/null @@ -1,55 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import org.junit.Ignore; - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import robocode.control.events.TurnEndedEvent; - - -/** - * @author Pavel Savara (original) - */ -@Ignore("Please run explicitly if you did something to security or timing") -public class TestThreadAttack extends RobocodeTestBed { - boolean messagedMax; - boolean messagedUnknown; - - @Override - public String getRobotNames() { - return "tested.robots.ThreadAttack,sample.SittingDuck"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("Robots are only allowed to create up to 5 threads!")) { - messagedMax = true; - } - - if (out.contains("Preventing Thread-") && out.contains("from access to MyAttack")) { - messagedUnknown = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedMax); - Assert.assertTrue(messagedUnknown); - } - - @Override - protected int getExpectedErrors() { - return 1; // Security error must be reported as an error - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestThreadGroupAttack.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestThreadGroupAttack.java deleted file mode 100644 index efd019d..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestThreadGroupAttack.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import robocode.control.events.TurnEndedEvent; - - -/** - * This test was made due to hacker.Destroyer 1.3, which proved a security breach in - * Robocode 1.7.2.1 Beta. The security breach was reported with: - * Bug [3021140] Possible for robot to kill other robot threads. - * - * The security manager of Robocode must make sure that unsafe (robot) threads cannot - * access thread groups other than its own thread group within checkAccess(Thread). - * - * @author Flemming N. Larsen (original) - */ -public class TestThreadGroupAttack extends RobocodeTestBed { - boolean messagedInterrupted; - boolean messagedPreventing; - - @Override - public String getRobotNames() { - return "tested.robots.ThreadGroupAttack,sample.SittingDuck"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final String out = event.getTurnSnapshot().getRobots()[0].getOutputStreamSnapshot(); - - if (out.contains("Interrupted: sample.SittingDuck")) { - messagedInterrupted = true; - } - - if (out.contains("Preventing tested.robots.ThreadGroupAttack from access to sample.SittingDuck")) { - messagedPreventing = true; - } - } - - @Override - protected void runTeardown() { - Assert.assertFalse(messagedInterrupted); - Assert.assertTrue(messagedPreventing); - } - - @Override - protected int getExpectedErrors() { - return 3; // Security error must be reported as an error - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestUndeadThread.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestUndeadThread.java deleted file mode 100644 index 5e76bad..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestUndeadThread.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.Assert; -import net.sf.robocode.test.helpers.RobocodeTestBed; -import org.junit.Test; -import org.junit.Ignore; -import robocode.control.events.BattleErrorEvent; - - -/** - * @author Pavel Savara (original) - */ -@Ignore("is very time consuming test, please run explicitly if you did something to security or timing") -public class TestUndeadThread extends RobocodeTestBed { - boolean messagedStop; - boolean messagedForcing; - - @Test - public void run() { - super.run(); - } - - public void onBattleError(BattleErrorEvent event) { - super.onBattleError(event); - final String error = event.getError(); - - if (error.contains("is not stopping. Forcing a stop.")) { - messagedForcing = true; - } - if (error.contains("Unable to stop thread")) { - messagedStop = true; - } - } - - @Override - protected int getExpectedErrors() { - return 3; - } - - @Override - public String getRobotNames() { - return "sample.SittingDuck,tested.robots.UndeadThread"; - } - - @Override - protected void runTeardown() { - Assert.assertTrue(messagedForcing); - Assert.assertTrue(messagedStop); - } - -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestWatchBullet.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestWatchBullet.java deleted file mode 100644 index 7f3cbe0..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestWatchBullet.java +++ /dev/null @@ -1,50 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; - -import org.junit.Assert; -import org.junit.Test; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - */ -public class TestWatchBullet extends RobocodeTestBed { - @Test - public void run() { - super.run(); - } - - public String getRobotNames() { - return "tested.robots.WatchBullets,sample.SittingDuck"; - } - - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - final IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[0]; - - final String out = robot.getOutputStreamSnapshot(); - final int time = event.getTurnSnapshot().getTurn(); - - test(out, time, 33, "33 487.438779505497 119.51131582855926 347.66745091446046 true"); - test(out, time, 45, "45 459.24550664858225 248.46533618316306 347.66745091446046 true"); - test(out, time, 52, "52 442.799430815382 323.6885147233484 347.66745091446046 true"); - test(out, time, 53, "53 440.4499914106391 334.43468308623204 347.66745091446046 false"); - } - - private void test(String out, int timecurr, int timeWatch, String in) { - if (timecurr == timeWatch) { - Assert.assertTrue("got: " + out + ", expected: " + in, out.contains(in)); - } - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestWin.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestWin.java deleted file mode 100644 index c16b99c..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/robots/TestWin.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.robots; - - -import net.sf.robocode.test.helpers.RobocodeTestBed; -import static org.hamcrest.CoreMatchers.is; -import org.junit.Assert; -import org.junit.Test; -import robocode.BattleResults; -import robocode.control.events.BattleCompletedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; - - -/** - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public class TestWin extends RobocodeTestBed { - private BattleResults[] results; - private StringBuffer outputBuf = new StringBuffer(); - - @Test - public void run() { - super.run(); - } - - @Override - public int getNumRounds() { - return 5; - } - - @Override - public String getRobotNames() { - return "sample.MyFirstRobot,tested.robots.BattleWin"; - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - super.onTurnEnded(event); - IRobotSnapshot robot = event.getTurnSnapshot().getRobots()[1]; - final String streamSnapshot = robot.getOutputStreamSnapshot(); - - outputBuf.append(streamSnapshot); - } - - public void onBattleCompleted(BattleCompletedEvent event) { - results = event.getSortedResults(); - } - - @Override - protected void runTeardown() { - String[] lines = outputBuf.toString().split("\\n"); - - Assert.assertThat(lines[1], is("Round 1 of 5")); - Assert.assertThat(lines[3], is("RoundEnded!")); - Assert.assertThat(lines[4], is("SYSTEM: tested.robots.BattleWin has died")); - Assert.assertThat(lines[5], is("Death!")); - Assert.assertThat(lines[7], is("Round 2 of 5")); - Assert.assertThat(lines[9], is("RoundEnded!")); - Assert.assertThat(lines[10], is("SYSTEM: tested.robots.BattleWin has died")); - Assert.assertThat(lines[11], is("Death!")); - Assert.assertThat(lines[13], is("Round 3 of 5")); - Assert.assertThat(lines[15], is("SYSTEM: Bonus for killing sample.MyFirstRobot: 1")); - Assert.assertThat(lines[16], is("SYSTEM: tested.robots.BattleWin wins the round.")); - Assert.assertThat(lines[17], is("RoundEnded!")); - Assert.assertThat(lines[18], is("Win!")); - Assert.assertThat(lines[20], is("Round 4 of 5")); - Assert.assertThat(lines[22], is("SYSTEM: Bonus for killing sample.MyFirstRobot: 3")); - Assert.assertThat(lines[23], is("SYSTEM: tested.robots.BattleWin wins the round.")); - Assert.assertThat(lines[24], is("RoundEnded!")); - Assert.assertThat(lines[25], is("Win!")); - Assert.assertThat(lines[27], is("Round 5 of 5")); - Assert.assertThat(lines[29], is("SYSTEM: tested.robots.BattleWin wins the round.")); - Assert.assertThat(lines[30], is("RoundEnded!")); - Assert.assertThat(lines[31], is("Win!")); - Assert.assertThat(lines[32], is("BattleEnded!")); - - Assert.assertThat("1st robot should get right score", results[0].getScore(), is(233)); - Assert.assertThat("2nd robot should get right score", results[1].getScore(), is(216)); - } -} diff --git a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/samples/RobocodeRunner.java b/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/samples/RobocodeRunner.java deleted file mode 100644 index 3bb11f0..0000000 --- a/workspace_robo/robocode.tests/src/test/java/net/sf/robocode/test/samples/RobocodeRunner.java +++ /dev/null @@ -1,91 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.test.samples; - - -import robocode.BattleResults; -import robocode.control.*; -import robocode.control.events.*; - - -/** - * Sample application that runs two sample robots in Robocode. - * - * @author Flemming N. Larsen (original) - */ -public class RobocodeRunner { - - public static void main(String[] args) { - - // Battle listener used for receiving battle events - BattleObserver battleListener = new BattleObserver(); - - // Create the RobocodeEngine - // IRobocodeEngine engine = new RobocodeEngine(new java.io.File("C:/Robocode")); // Run from C:/Robocode - RobocodeEngine engine = new RobocodeEngine(); // Run from current working directory - - // Add battle listener to our RobocodeEngine - engine.addBattleListener(battleListener); - - // Show the battles - engine.setVisible(true); - - // Setup the battle specification - - int numberOfRounds = 5; - BattlefieldSpecification battlefield = new BattlefieldSpecification(800, 600); // 800x600 - RobotSpecification[] selectedRobots = engine.getLocalRepository("sample.RamFire, sample.Corners"); - - BattleSpecification battleSpec = new BattleSpecification(numberOfRounds, battlefield, selectedRobots); - - // Run our specified battle and let it run till it's over - engine.runBattle(battleSpec, true/* wait till the battle is over */); - - // Cleanup our RobocodeEngine - engine.close(); - - // Make sure that the Java VM is shut down properly - System.exit(0); - } - - /** - * BattleListener for handling the battle event we are interested in. - */ - static class BattleObserver extends BattleAdaptor { - - public void onBattleStarted(BattleStartedEvent e) { - System.out.println("-- Battle was started --"); - } - - public void onBattleFinished(BattleFinishedEvent e) { - if (e.isAborted()) { - System.out.println("-- Battle was aborted --"); - } else { - System.out.println("-- Battle was finished succesfully --"); - } - } - - public void onBattleCompleted(BattleCompletedEvent e) { - System.out.println("-- Battle has completed --"); - - // Print out the sorted results with the robot names - System.out.println("\n-- Battle results --"); - for (BattleResults result : e.getSortedResults()) { - System.out.println(" " + result.getTeamLeaderName() + ": " + result.getScore()); - } - } - - public void onBattleMessage(BattleMessageEvent e) { - System.out.println("Msg> " + e.getMessage()); - } - - public void onBattleError(BattleErrorEvent e) { - System.out.println("Err> " + e.getError()); - } - } -} diff --git a/workspace_robo/robocode.ui.editor/.classpath b/workspace_robo/robocode.ui.editor/.classpath deleted file mode 100644 index b053438..0000000 --- a/workspace_robo/robocode.ui.editor/.classpath +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.ui.editor/.project b/workspace_robo/robocode.ui.editor/.project deleted file mode 100644 index 10502cc..0000000 --- a/workspace_robo/robocode.ui.editor/.project +++ /dev/null @@ -1,22 +0,0 @@ - - - robocode.ui.editor - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.ui - robocode.api - robocode.core - robocode.battle - robocode.host - robocode.repository - robocode.sound - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.ui.editor/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.ui.editor/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.ui.editor/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.ui.editor/pom.xml b/workspace_robo/robocode.ui.editor/pom.xml deleted file mode 100644 index 1554dfa..0000000 --- a/workspace_robo/robocode.ui.editor/pom.xml +++ /dev/null @@ -1,19 +0,0 @@ - - - 4.0.0 - robocode.ui.editor - Robocode UI Robot editor - - robocode - net.sf.robocode - ${robocode.version} - - - - net.sf.robocode - robocode.ui - ${project.version} - - - diff --git a/workspace_robo/robocode.ui.editor/robocode.ui.editor.iml b/workspace_robo/robocode.ui.editor/robocode.ui.editor.iml deleted file mode 100644 index 45f9610..0000000 --- a/workspace_robo/robocode.ui.editor/robocode.ui.editor.iml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/CompilerPreferencesDialog.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/CompilerPreferencesDialog.java deleted file mode 100644 index 3286733..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/CompilerPreferencesDialog.java +++ /dev/null @@ -1,171 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.FileOutputStream; -import java.io.IOException; - - -/** - * @author Mathew A. Nelson (original) - * @author Matthew Reeder (contributor) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class CompilerPreferencesDialog extends JDialog { - - private JButton cancelButton; - private JTextField compilerBinaryField; - private JTextField compilerClasspathField; - private JTextField compilerOptionsField; - private JPanel compilerPreferencesContentPane; - private CompilerProperties compilerProperties; - private JButton okButton; - - private final EventHandler eventHandler = new EventHandler(); - - private class EventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - if (e.getSource().equals(getOkButton())) { - if (compilerProperties == null) { - compilerProperties = new CompilerProperties(); - } - compilerProperties.setCompilerBinary(getCompilerBinaryField().getText()); - compilerProperties.setCompilerOptions(getCompilerOptionsField().getText()); - compilerProperties.setCompilerClasspath(getCompilerClasspathField().getText()); - saveCompilerProperties(); - dispose(); - } - if (e.getSource().equals(getCancelButton())) { - dispose(); - } - } - } - - public CompilerPreferencesDialog(JFrame owner) { - super(owner, true); - this.compilerProperties = net.sf.robocode.core.Container.getComponent(RobocodeCompilerFactory.class).getCompilerProperties(); - initialize(); - } - - private void initialize() { - setTitle("Compiler Preferences"); - setContentPane(getCompilerPreferencesContentPane()); - } - - public JButton getCancelButton() { - if (cancelButton == null) { - cancelButton = new JButton("Cancel"); - cancelButton.setMnemonic('C'); - cancelButton.addActionListener(eventHandler); - } - return cancelButton; - } - - public JTextField getCompilerBinaryField() { - if (compilerBinaryField == null) { - compilerBinaryField = new JTextField(40); - compilerBinaryField.setText(compilerProperties.getCompilerBinary()); - } - return compilerBinaryField; - } - - public JTextField getCompilerClasspathField() { - if (compilerClasspathField == null) { - compilerClasspathField = new JTextField(40); - compilerClasspathField.setText(compilerProperties.getCompilerClasspath()); - } - return compilerClasspathField; - } - - public JTextField getCompilerOptionsField() { - if (compilerOptionsField == null) { - compilerOptionsField = new JTextField(40); - compilerOptionsField.setText(compilerProperties.getCompilerOptions()); - } - return compilerOptionsField; - } - - private JPanel getCompilerPreferencesContentPane() { - if (compilerPreferencesContentPane == null) { - compilerPreferencesContentPane = new JPanel(); - compilerPreferencesContentPane.setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - compilerPreferencesContentPane.setLayout(new BoxLayout(compilerPreferencesContentPane, BoxLayout.Y_AXIS)); - JLabel label = new JLabel("Compiler Binary:"); - - label.setAlignmentX(Component.LEFT_ALIGNMENT); - compilerPreferencesContentPane.add(label); - - getCompilerBinaryField().setAlignmentX(Component.LEFT_ALIGNMENT); - compilerPreferencesContentPane.add(getCompilerBinaryField()); - - label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - compilerPreferencesContentPane.add(label); - label = new JLabel("Compiler Options:"); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - compilerPreferencesContentPane.add(label); - getCompilerOptionsField().setAlignmentX(Component.LEFT_ALIGNMENT); - compilerPreferencesContentPane.add(getCompilerOptionsField()); - label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - compilerPreferencesContentPane.add(label); - label = new JLabel("Compiler Classpath:"); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - compilerPreferencesContentPane.add(label); - getCompilerClasspathField().setAlignmentX(Component.LEFT_ALIGNMENT); - compilerPreferencesContentPane.add(getCompilerClasspathField()); - JPanel panel = new JPanel(); - - panel.setAlignmentX(Component.LEFT_ALIGNMENT); - panel.add(getOkButton()); - panel.add(getCancelButton()); - compilerPreferencesContentPane.add(panel); - } - return compilerPreferencesContentPane; - } - - public JButton getOkButton() { - if (okButton == null) { - okButton = new JButton("OK"); - okButton.setMnemonic('O'); - okButton.addActionListener(eventHandler); - } - return okButton; - } - - public void saveCompilerProperties() { - if (compilerProperties == null) { - Logger.logError("Cannot save null compiler properties"); - return; - } - FileOutputStream out = null; - - try { - out = new FileOutputStream(FileUtil.getCompilerConfigFile()); - - compilerProperties.store(out, "Robocode Compiler Properties"); - } catch (IOException e) { - Logger.logError(e); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException ignored) {} - } - } - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/CompilerProperties.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/CompilerProperties.java deleted file mode 100644 index d105f54..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/CompilerProperties.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Properties; - - -/** - * @author Mathew A. Nelson (original) - */ -public class CompilerProperties { - public final static String COMPILER_BINARY = "compiler.binary"; - public final static String COMPILER_OPTIONS = "compiler.options"; - public final static String COMPILER_CLASSPATH = "compiler.classpath"; - public final static String ROBOCODE_VERSION = "robocode.version"; - - private String compilerBinary; - private String compilerOptions; - private String compilerClasspath; - private String robocodeVersion; - - private final Properties props = new Properties(); - - public CompilerProperties() { - super(); - } - - /** - * Returns the compilerBinary. - * - * @return String - */ - public String getCompilerBinary() { - if (compilerBinary == null) { - setCompilerBinary(""); - } - return compilerBinary; - } - - /** - * Returns the compilerClasspath. - * - * @return String - */ - public String getCompilerClasspath() { - if (compilerClasspath == null) { - setCompilerClasspath(""); - } - return compilerClasspath; - } - - /** - * Returns the compilerOptions. - * - * @return String - */ - public String getCompilerOptions() { - if (compilerOptions == null) { - setCompilerOptions(""); - } - return compilerOptions; - } - - /** - * Returns the robocodeVersion. - * - * @return String - */ - public String getRobocodeVersion() { - return robocodeVersion; - } - - public void resetCompiler() { - this.compilerBinary = null; - props.remove(COMPILER_BINARY); - } - - /** - * Sets the compilerBinary. - * - * @param compilerBinary The compilerBinary to set - */ - public void setCompilerBinary(String compilerBinary) { - this.compilerBinary = compilerBinary; - props.setProperty(COMPILER_BINARY, compilerBinary); - } - - /** - * Sets the compilerClasspath. - * - * @param compilerClasspath The compilerClasspath to set - */ - public void setCompilerClasspath(String compilerClasspath) { - this.compilerClasspath = compilerClasspath; - props.setProperty(COMPILER_CLASSPATH, compilerClasspath); - } - - /** - * Sets the compilerOptions. - * - * @param compilerOptions The compilerOptions to set - */ - public void setCompilerOptions(String compilerOptions) { - this.compilerOptions = compilerOptions; - props.setProperty(COMPILER_OPTIONS, compilerOptions); - } - - /** - * Sets the robocodeVersion. - * - * @param robocodeVersion The robocodeVersion to set - */ - public void setRobocodeVersion(String robocodeVersion) { - this.robocodeVersion = robocodeVersion; - props.setProperty(ROBOCODE_VERSION, robocodeVersion); - } - - public void load(InputStream is) throws IOException { - props.load(is); - this.compilerBinary = props.getProperty(COMPILER_BINARY); - this.compilerOptions = props.getProperty(COMPILER_OPTIONS); - this.compilerClasspath = props.getProperty(COMPILER_CLASSPATH); - this.robocodeVersion = props.getProperty(ROBOCODE_VERSION); - } - - public void store(OutputStream os, String header) throws IOException { - props.store(os, header); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/CompoundUndoManager.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/CompoundUndoManager.java deleted file mode 100644 index efa4ebf..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/CompoundUndoManager.java +++ /dev/null @@ -1,147 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import javax.swing.event.UndoableEditEvent; -import javax.swing.event.DocumentEvent.EventType; -import javax.swing.text.AbstractDocument.DefaultDocumentEvent; -import javax.swing.text.BadLocationException; -import javax.swing.undo.CannotUndoException; -import javax.swing.undo.CompoundEdit; -import javax.swing.undo.UndoableEdit; - - -/** - * Undo manager that compounds undo and redo edits. - * - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class CompoundUndoManager extends UndoManagerWithActions { - - private CompoundEdit currentCompoundEdit; - private EventType lastEventType; - private boolean isCompoundMarkStart; - - public CompoundUndoManager() { - super(); - reset(); - } - - @Override - public void undoableEditHappened(UndoableEditEvent undoableEditEvent) { - UndoableEdit edit = undoableEditEvent.getEdit(); - - // Make sure this event is a document event - if (edit instanceof DefaultDocumentEvent) { - // Get the event type - DefaultDocumentEvent event = (DefaultDocumentEvent) edit; - EventType eventType = event.getType(); - - // Check if the event type is not a change on character attributes, but instead an insertion or removal of - // text. - if (eventType != EventType.CHANGE) { - boolean isEndCompoundEdit = false; - - // Check if current compound edit must be ended as it contains at least one new line - if (eventType == EventType.INSERT) { - try { - // Check if the inserted text contains a new line character - String insertedText = event.getDocument().getText(event.getOffset(), event.getLength()); - isEndCompoundEdit = insertedText.contains("\n"); - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - - // Make sure we are not in an explicit marked compound edit - if (!isCompoundMarkStart) { - // Check if current compound edit must be ended due to change between insertion or removal change - isEndCompoundEdit |= (eventType != lastEventType); - - // Check if the current compound edit should be ended and a new one started - if (isEndCompoundEdit) { - endCurrentCompoundEdit(); - } - // Save the last event type - lastEventType = eventType; - } - - // Create new compound edit if the current one has been ended or does not exist - if (currentCompoundEdit == null) { - newCurrentCompoundEdit(); - } - } - // Added event edit to the current compound edit - if (currentCompoundEdit != null) { - currentCompoundEdit.addEdit(edit); - } - } - // Update the state of the actions - updateUndoRedoState(); - } - - @Override - public void discardAllEdits() { - super.discardAllEdits(); - reset(); - } - - /** - * Ends the current compound edit, and mark the start for combining the next insertions or removals of text to be - * put into the same compound edit so that these combined operations acts like as one single edit. - * - * @see #markCompoundEnd() - */ - public void markCompoundStart() { - endCurrentCompoundEdit(); - isCompoundMarkStart = true; - } - - /** - * Ends the current compound edit so that previous edits acts like a single edit. - * - * @see #markCompoundStart() - */ - public void markCompoundEnd() { - endCurrentCompoundEdit(); - isCompoundMarkStart = false; - } - - private void reset() { - currentCompoundEdit = null; - lastEventType = EventType.INSERT; // important - } - - private void endCurrentCompoundEdit() { - if (currentCompoundEdit != null) { - currentCompoundEdit.end(); - currentCompoundEdit = null; - } - } - - private void newCurrentCompoundEdit() { - // Set current compound edit to a new one - currentCompoundEdit = new CompoundEdit() { - // Make sure canUndo() and canRedo() works - @Override - public boolean isInProgress() { - return false; - } - - @Override - public void undo() throws CannotUndoException { - endCurrentCompoundEdit(); - super.undo(); - } - }; - // Add the current compound edit to the internal edits - addEdit(currentCompoundEdit); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditWindow.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditWindow.java deleted file mode 100644 index 4986b8b..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditWindow.java +++ /dev/null @@ -1,485 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.IRepositoryManager; -import net.sf.robocode.ui.editor.theme.EditorThemeProperties; -import net.sf.robocode.ui.editor.theme.EditorThemePropertiesManager; -import net.sf.robocode.ui.editor.theme.EditorThemePropertyChangeAdapter; - -import javax.swing.*; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.event.InternalFrameAdapter; -import javax.swing.event.InternalFrameEvent; -import javax.swing.filechooser.FileFilter; - -import java.awt.Font; -import java.io.BufferedWriter; -import java.io.File; -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.OutputStreamWriter; -import java.util.StringTokenizer; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Matthew Reeder (contributor) - */ -@SuppressWarnings("serial") -public class EditWindow extends JInternalFrame { - - private String fileName; - private String robotName; - public boolean modified; - private final RobocodeEditor editor; - private final IRepositoryManager repositoryManager; - private final File robotsDirectory; - private EditorPanel editorPanel; - private EditorPane editorPane; - - public EditWindow(IRepositoryManager repositoryManager, RobocodeEditor editor, File robotsDirectory) { - super("Edit Window", true, true, true, true); - this.editor = editor; - this.robotsDirectory = robotsDirectory; - this.repositoryManager = repositoryManager; - initialize(); - } - - public EditorPane getEditorPane() { - if (editorPane == null) { - editorPane = editorPanel.getEditorPane(); - InputMap im = editorPane.getInputMap(); - - // FIXME: Replace hack with better solution than using 'ctrl H' - im.put(KeyStroke.getKeyStroke("ctrl H"), editor.getReplaceAction()); - } - return editorPane; - } - - public String getFileName() { - return fileName; - } - - public String getRobotName() { - return robotName; - } - - private void initialize() { - try { - addInternalFrameListener(new InternalFrameAdapter() { - @Override - public void internalFrameClosing(InternalFrameEvent e) { - if (!modified || fileSave(true)) { - editor.setLineStatus(-1); - dispose(); - } - editor.removeFromWindowMenu(EditWindow.this); - } - - @Override - public void internalFrameDeactivated(InternalFrameEvent e) { - editor.setLineStatus(-1); - } - - @Override - public void internalFrameIconified(InternalFrameEvent e) { - editor.setLineStatus(-1); - } - }); - setFrameIcon(new ImageIcon(EditWindow.class.getResource("/net/sf/robocode/ui/icons/robocode-icon.png"))); - setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); - - setSize(750, 500); - - editor.addToWindowMenu(this); - - editorPanel = new EditorPanel(); - setContentPane(editorPanel); - - EditorThemeProperties currentThemeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - Font font = currentThemeProps.getFont(); - editorPanel.setFont(font); - - // Make sure the source editor window gets focus with a blinking cursor - SwingUtilities.invokeLater(new Runnable() { - @Override - public void run() { - editorPanel.getEditorPane().requestFocus(); - } - }); - - EditorThemePropertiesManager.addListener(new EditorThemePropertyChangeAdapter() { - @Override - public void onFontChanged(Font newFont) { - editorPanel.setFont(newFont); - } - }); - - final JavaDocument document = (JavaDocument) editorPanel.getEditorPane().getDocument(); - - document.addDocumentListener(new DocumentListener() { - public void removeUpdate(DocumentEvent e) { - updateModificationState(); - } - - public void insertUpdate(DocumentEvent e) { - updateModificationState(); - } - - public void changedUpdate(DocumentEvent e) { - updateModificationState(); - } - - // Bug-361 Problem in the text editor related with the .java file modification - private void updateModificationState() { - setModified(editorPanel.getEditorPane().isModified()); - } - }); - } catch (Throwable e) { - Logger.logError(e); - } - } - - public void setFileName(String newFileName) { - fileName = newFileName; - updateTitle(); - } - - public void setRobotName(String newRobotName) { - robotName = newRobotName; - updateTitle(); - } - - private void updateTitle() { - StringBuffer titleBuf = new StringBuffer("Editing"); - if (fileName != null) { - titleBuf.append(" - ").append(fileName); - } else if (robotName != null) { - titleBuf.append(" - ").append(robotName); - } - if (modified) { - titleBuf.append(" *"); - } - setTitle(titleBuf.toString()); - } - - private void setModified(boolean modified) { - boolean updated = (modified != this.modified); - if (updated) { - this.modified = modified; - updateTitle(); - editor.setSaveFileMenuItemsEnabled(modified); - } - } - - public void compile() { - if (!fileSave(true, true)) { - error("You must save before compiling."); - return; - } - if (editor.getCompiler() != null) { - // The compiler + refresh of the repository is done in a thread in order to avoid the compiler - // window hanging while compiling. The SwingUtilities.invokeLater() does not do a good job here - // (window is still hanging). Hence, a real thread running beside the EDT is used, which does a - // great job, where each each new print from the compiler is written out as soon as it is ready - // in the output stream. - new Thread(new Runnable() { - public void run() { - if (fileName == null) { - error("You must save before compiling."); - return; - } - editor.getCompiler().compile(getRobotDir(), fileName); - repositoryManager.refresh(fileName); - } - }).start(); - } else { - JOptionPane.showMessageDialog(editor, "No compiler installed.", "Error", JOptionPane.ERROR_MESSAGE); - } - } - - private void error(String msg) { - Object[] options = { - "OK" - }; - - JOptionPane.showOptionDialog(this, msg, "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, - options, options[0]); - } - - public boolean fileSave(boolean confirm) { - return fileSave(confirm, false); - } - - private boolean fileSave(boolean confirm, boolean mustSave) { - if (confirm) { - if (!modified) { - return true; - } - String s = fileName; - - if (s == null) { - s = robotName; - } - if (s == null) { - s = "This file"; - } - int ok = JOptionPane.showConfirmDialog(this, s + " has been modified. Do you wish to save it?", - "Modified file", JOptionPane.YES_NO_CANCEL_OPTION); - - if (ok == JOptionPane.NO_OPTION) { - return !mustSave; - } - if (ok == JOptionPane.CANCEL_OPTION) { - return false; - } - } - String fileName = getFileName(); - - if (fileName == null) { - return fileSaveAs(); - } - - String reasonableFilename = getReasonableFilename(); - - if (reasonableFilename != null) { - try { - String a = new File(reasonableFilename).getCanonicalPath(); - String b = new File(fileName).getCanonicalPath(); - - if (!a.equals(b)) { - int ok = JOptionPane.showConfirmDialog(this, - fileName + " should be saved in: \n" + reasonableFilename - + "\n Would you like to save it there instead?", - "Name has changed", - JOptionPane.YES_NO_CANCEL_OPTION); - - if (ok == JOptionPane.CANCEL_OPTION) { - return false; - } - if (ok == JOptionPane.YES_OPTION) { - return fileSaveAs(); - } - } - } catch (IOException e) { - Logger.logError("Unable to check reasonable filename: ", e); - } - } - - BufferedWriter bufferedWriter = null; - OutputStreamWriter outputStreamWriter = null; - FileOutputStream fileOutputStream = null; - - try { - fileOutputStream = new FileOutputStream(fileName); - outputStreamWriter = new OutputStreamWriter(fileOutputStream, "UTF8"); - bufferedWriter = new BufferedWriter(outputStreamWriter); - - getEditorPane().write(bufferedWriter); - setModified(false); - } catch (IOException e) { - error("Cannot write file: " + e); - return false; - } finally { - FileUtil.cleanupStream(bufferedWriter); - } - return true; - } - - private String getRobotDir() { - String saveDir = robotsDirectory.getPath() + File.separatorChar; - - String text = getEditorPane().getText(); - int pIndex = text.indexOf("package "); - - if (pIndex >= 0) { - int pEIndex = text.indexOf(";", pIndex); - - if (pEIndex > 0) { - String packageTree = text.substring(pIndex + 8, pEIndex) + File.separatorChar; - - packageTree = packageTree.replace('.', File.separatorChar); - - saveDir += packageTree; - } - } - return saveDir; - } - - public boolean fileSaveAs() { - String javaFileName = null; - String saveDir = getRobotDir(); - - String text = getEditorPane().getText(); - - int pIndex = text.indexOf("public class "); - - if (pIndex >= 0) { - int pEIndex = text.indexOf(" ", pIndex + 13); - - if (pEIndex > 0) { - int pEIndex2 = text.indexOf("\n", pIndex + 13); - - if (pEIndex2 > 0 && pEIndex2 < pEIndex) { - pEIndex = pEIndex2; - } - javaFileName = text.substring(pIndex + 13, pEIndex).trim() + ".java"; - } else { - pEIndex = text.indexOf("\n", pIndex + 13); - if (pEIndex > 0) { - javaFileName = text.substring(pIndex + 13, pEIndex).trim() + ".java"; - } - } - } - - File f = new File(saveDir); - - if (!f.exists()) { - int ok = JOptionPane.showConfirmDialog(this, - "Your robot should be saved in the directory: " + saveDir - + "\nThis directory does not exist, would you like to create it?", - "Create Directory", - JOptionPane.YES_NO_CANCEL_OPTION); - - if (ok == JOptionPane.YES_OPTION) { - if (!f.exists() && !f.mkdirs()) { - Logger.logError("Cannot create: " + f); - } - f = new File(saveDir); - } - if (ok == JOptionPane.CANCEL_OPTION) { - return false; - } - } - - JFileChooser chooser; - - chooser = new JFileChooser(f); - chooser.setCurrentDirectory(f); - - FileFilter filter = new FileFilter() { - @Override - public boolean accept(File pathname) { - if (pathname.isDirectory()) { - return true; - } - String fn = pathname.getName(); - int idx = fn.lastIndexOf('.'); - String extension = ""; - - if (idx >= 0) { - extension = fn.substring(idx); - } - return extension.equalsIgnoreCase(".java"); - } - - @Override - public String getDescription() { - return "Robots"; - } - }; - - chooser.setFileFilter(filter); - - boolean done = false; - - while (!done) { - done = true; - if (javaFileName != null) { - chooser.setSelectedFile(new File(f, javaFileName)); - } - int rv = chooser.showSaveDialog(this); - String robotFileName; - - if (rv == JFileChooser.APPROVE_OPTION) { - robotFileName = chooser.getSelectedFile().getPath(); - File outFile = new File(robotFileName); - - if (outFile.exists()) { - int ok = JOptionPane.showConfirmDialog(this, - robotFileName + " already exists. Are you sure you want to replace it?", "Warning", - JOptionPane.YES_NO_CANCEL_OPTION); - - if (ok == JOptionPane.NO_OPTION) { - done = false; - continue; - } - if (ok == JOptionPane.CANCEL_OPTION) { - return false; - } - } - setFileName(robotFileName); - fileSave(false); - } else { - return false; - } - } - - return true; - } - - public String getPackage() { - String text = getEditorPane().getText(); - int pIndex = text.indexOf("package "); - - if (pIndex >= 0) { - int pEIndex = text.indexOf(";", pIndex); - - if (pEIndex > 0) { - return text.substring(pIndex + 8, pEIndex); - } - } - return ""; - } - - private String getReasonableFilename() { - StringBuffer fileName = new StringBuffer(robotsDirectory.getPath()).append(File.separatorChar); - String javaFileName; - String packageTree = null; - - String text = getEditorPane().getText(); - StringTokenizer tokenizer = new StringTokenizer(text, " \t\r\n;"); - String token; - boolean inComment = false; - - while (tokenizer.hasMoreTokens()) { - token = tokenizer.nextToken(); - if (!inComment && (token.equals("/*") || token.equals("/**"))) { - inComment = true; - } - if (inComment && (token.equals("*/") || token.equals("**/"))) { - inComment = false; - } - if (inComment) { - continue; - } - - if (packageTree == null && token.equals("package")) { - packageTree = tokenizer.nextToken(); - if (packageTree == null || packageTree.length() == 0) { - return null; - } - packageTree = packageTree.replace('.', File.separatorChar); - packageTree += File.separator; - fileName.append(packageTree); - } - if (token.equals("class")) { - javaFileName = tokenizer.nextToken() + ".java"; - fileName.append(javaFileName); - return fileName.toString(); - } - } - return null; - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditorPane.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditorPane.java deleted file mode 100644 index ec856d2..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditorPane.java +++ /dev/null @@ -1,374 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import java.awt.Event; -import java.awt.FontMetrics; -import java.awt.event.KeyAdapter; -import java.awt.event.KeyEvent; -import java.beans.PropertyChangeEvent; -import java.beans.PropertyChangeListener; -import java.io.IOException; -import java.io.Reader; - -import javax.swing.InputMap; -import javax.swing.JTextPane; -import javax.swing.JViewport; -import javax.swing.KeyStroke; -import javax.swing.SwingUtilities; -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.DefaultCaret; -import javax.swing.text.DefaultEditorKit; -import javax.swing.text.Document; -import javax.swing.text.EditorKit; -import javax.swing.text.SimpleAttributeSet; -import javax.swing.text.StyleConstants; -import javax.swing.text.StyledEditorKit; -import javax.swing.text.TabSet; -import javax.swing.text.TabStop; - - -/** - * Editor pane used for editing source code. - * - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class EditorPane extends JTextPane { - - private int tabSize = 4; // Default - - // Key bindings - private static final KeyStroke CUT_KEYSTROKE = KeyStroke.getKeyStroke(KeyEvent.VK_X, Event.CTRL_MASK); - private static final KeyStroke COPY_KEYSTROKE = KeyStroke.getKeyStroke(KeyEvent.VK_C, Event.CTRL_MASK); - private static final KeyStroke PASTE_KEYSTROKE = KeyStroke.getKeyStroke(KeyEvent.VK_V, Event.CTRL_MASK); - private static final KeyStroke UNDO_KEYSTROKE = KeyStroke.getKeyStroke(KeyEvent.VK_Z, Event.CTRL_MASK); - private static final KeyStroke REDO_KEYSTROKE = KeyStroke.getKeyStroke(KeyEvent.VK_Y, Event.CTRL_MASK); - - private final JavaDocument document; - - private final CompoundUndoManager undoManager = new CompoundUndoManager(); - - private final TextTool textTool = new TextTool(); - - private JViewport viewport; - - public EditorPane(JViewport viewport) { - super(); - this.viewport = viewport; - document = new JavaDocument(this); - - DefaultCaret caret = (DefaultCaret) getCaret(); - caret.setUpdatePolicy(DefaultCaret.NEVER_UPDATE); - - new LineNumberArea(this); - - LineHighlighter.install(this); - - EditorKit editorKit = new StyledEditorKit() { - @Override - public Document createDefaultDocument() { - return document; - } - }; - - setEditorKitForContentType("text/java", editorKit); - setContentType("text/java"); - - addPropertyChangeListener("font", new FontHandler()); - addKeyListener(new KeyHandler()); - - setKeyBindings(); - setActionBindings(); - - getDocument().addUndoableEditListener(undoManager); - } - - public JViewport getViewport() { - return viewport; - } - - // No line wrapping! - @Override - public boolean getScrollableTracksViewportWidth() { - return getUI().getPreferredSize(this).width <= getParent().getSize().width; - } - - // Don't enforce height -> Avoid line height changes - @Override - public boolean getScrollableTracksViewportHeight() { - return false; - } - - // Make sure to discard all undo/redo edits when text completely replaced - @Override - public void setText(final String text) { - // Adding this call to the EDT prevents problems with deleting text that eats text before the deletion - SwingUtilities.invokeLater(new Runnable() { - public void run() { - JavaDocument javaDocument = (JavaDocument) getDocument(); - - // Bug-357: Tab characters are inserted in the last line of a robot source file when opening it. - // This bug was fixed by disabling auto-indentation while reading the file. - javaDocument.setReplacingText(true); - EditorPane.super.setText(text); - javaDocument.setReplacingText(false); - - resetCaretPosition(); - - undoManager.discardAllEdits(); - } - }); - } - - // Make sure to discard all undo/redo edits when text is read as one block - @Override - public void read(Reader in, Object desc) throws IOException { - JavaDocument javaDocument = (JavaDocument) getDocument(); - - // Bug-357: Tab characters are inserted in the last line of a robot source file when opening it. - // This bug was fixed by disabling auto-indentation while reading the file. - javaDocument.setReplacingText(true); - super.read(in, desc); - javaDocument.setReplacingText(false); - - resetCaretPosition(); - - undoManager.discardAllEdits(); - } - - public boolean isModified() { - return undoManager.canUndo(); - } - - public void undo() { - if (undoManager.canUndo()) { - undoManager.undo(); - } - } - - public void redo() { - if (undoManager.canRedo()) { - undoManager.redo(); - } - } - - private void setKeyBindings() { - InputMap inputMap = this.getInputMap(); - - inputMap.put(CUT_KEYSTROKE, DefaultEditorKit.cutAction); - inputMap.put(COPY_KEYSTROKE, DefaultEditorKit.copyAction); - inputMap.put(PASTE_KEYSTROKE, DefaultEditorKit.pasteAction); - inputMap.put(UNDO_KEYSTROKE, undoManager.getUndoAction()); - inputMap.put(REDO_KEYSTROKE, undoManager.getRedoAction()); - } - - private void setActionBindings() { - getActionMap().put("undo-keystroke", undoManager.getUndoAction()); - getActionMap().put("redo-keystroke", undoManager.getRedoAction()); - } - - private void setTabSize(int tabSize) { - document.setTabSize(tabSize); - - FontMetrics fm = getFontMetrics(getFont()); - - int charWidth = fm.charWidth('#'); - int tabWidth = charWidth * tabSize; - - TabStop[] tabs = new TabStop[100]; - for (int j = 0; j < tabs.length; j++) { - tabs[j] = new TabStop((j + 1) * tabWidth); - } - - SimpleAttributeSet attributes = new SimpleAttributeSet(); - - StyleConstants.setTabSet(attributes, new TabSet(tabs)); - - getDocument().removeUndoableEditListener(undoManager); // Avoid this change to be undone - getStyledDocument().setParagraphAttributes(0, getDocument().getLength(), attributes, false); - getDocument().addUndoableEditListener(undoManager); - } - - private void resetCaretPosition() { - // Make sure to put this request on the EDT or the caret position might not be reset after all. - SwingUtilities.invokeLater(new Runnable() { - public void run() { - setCaretPosition(0); - } - }); - } - - private void onTabCharPressed(boolean isUnindent) { - - int selectionStart = getSelectionStart(); - int selectionEnd = getSelectionEnd(); - - if (selectionStart == selectionEnd) { - // No selection -> Handle normal tab indentation - - if (isUnindent) { - textTool.removeLastTab(getCaretPosition()); - } else { - textTool.insertString(getCaretPosition(), "\t"); - } - } else { - // Start block indentation - - // Make sure that the start selection is lesser than the end selection - if (selectionStart > selectionEnd) { - // Swap selection start and selection end - int tmp = selectionStart; - - selectionStart = selectionEnd; - selectionEnd = tmp; - } - - StringBuilder newText = new StringBuilder(); - int count = 0; - boolean stopUnindent = false; - - // Handle each line - - String selectedText = textTool.getSelectedText(); - - selectedText = selectedText.replaceAll("\\s*$", ""); - - String[] lines = selectedText.split(String.valueOf('\n')); - - // iterate lines, rebuilding tabs and newlines - for (int i = 0; i < lines.length; i++) { - String line = lines[i]; - - if (isUnindent) { - if (line.charAt(0) != '\t') { - stopUnindent = true; - break; - } else { - newText.append(line.substring(1, line.length())); - count++; - } - } else { - newText.append('\t').append(line); - count++; - } - if (i != lines.length - 1) { - newText.append('\n'); - } - } - - if (!stopUnindent) { - try { - // Replace the indented/unindented text in one single compound edit - undoManager.markCompoundStart(); - getDocument().remove(selectionStart, selectedText.length()); - textTool.insertString(selectionStart, newText.toString()); - undoManager.markCompoundStart(); - } catch (BadLocationException e) { - e.printStackTrace(); - } - - // Compute the new selection - int mod = isUnindent ? -1 : 1; - - // Make new selection using the EDT, as replacing the text above must run before a new selection can be made - - final int newSelectionStart = selectionStart; - final int newSelectionEnd = selectionStart + selectedText.length() + count * mod; - - SwingUtilities.invokeLater(new Runnable() { - public void run() { - setSelectionStart(newSelectionStart); - setSelectionEnd(newSelectionEnd); - } - }); - } - } - } - - private class FontHandler implements PropertyChangeListener { - public void propertyChange(PropertyChangeEvent e) { - setTabSize(tabSize); - } - } - - - private class KeyHandler extends KeyAdapter { - - @Override - public void keyPressed(KeyEvent e) { - switch (e.getKeyCode()) { - case KeyEvent.VK_TAB: - onTabCharPressed(e.isShiftDown()); - e.consume(); - break; - } - } - } - - - /** - * Handy text tool. - */ - private class TextTool { - - String getSelectedText() { - int start = getSelectionStart(); - int end = getSelectionEnd(); - - try { - return getDocument().getText(start, end - start); - } catch (BadLocationException e) { - e.printStackTrace(); - } - return null; - } - - void insertString(int offset, String str) { - insertString(offset, str, null); - } - - void insertString(final int offset, final String str, final AttributeSet a) { - try { - getDocument().insertString(offset, str, a); - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - - void removeLastTab(int offset) { - int pos = offset; - - while (--pos >= 0) { - try { - char ch = getDocument().getText(pos, 1).charAt(0); - - if (ch == '\t') { - remove(pos, 1); - return; - } - if (ch == '\n') { - return; - } - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - } - - void remove(final int offset, final int len) { - try { - getDocument().remove(offset, len); - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditorPanel.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditorPanel.java deleted file mode 100644 index 0ffd6c4..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditorPanel.java +++ /dev/null @@ -1,181 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import java.awt.BorderLayout; -import java.awt.Color; -import java.awt.Font; -import java.awt.FontMetrics; - -import javax.swing.BorderFactory; -import javax.swing.JPanel; -import javax.swing.JScrollPane; -import javax.swing.JTextField; -import javax.swing.SwingUtilities; -import javax.swing.border.Border; -import javax.swing.event.CaretEvent; -import javax.swing.event.CaretListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.JTextComponent; -import javax.swing.text.Utilities; - -import net.sf.robocode.ui.editor.theme.EditorThemeProperties; -import net.sf.robocode.ui.editor.theme.EditorThemePropertiesManager; -import net.sf.robocode.ui.editor.theme.EditorThemePropertyChangeAdapter; - - -/** - * Editor panel containing editor pane in a scroll pane, a line number area, and a statusTextField text field. - * - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class EditorPanel extends JPanel { - - private JTextField statusTextField; - private final JScrollPane scrollPane; - private final EditorPane editorPane; - private final LineNumberArea lineNumberArea; - - public EditorPanel() { - super(); - - setLayout(new BorderLayout()); - - statusTextField = new JTextField(); - statusTextField.setEditable(false); - - scrollPane = new JScrollPane(); - - editorPane = new EditorPane(scrollPane.getViewport()); - editorPane.addCaretListener(new CaretListener() { - public void caretUpdate(CaretEvent e) { - updateStatus(getRow(e.getDot(), editorPane), getColumn(e.getDot(), editorPane)); - } - }); - - scrollPane.setViewportView(editorPane); - - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - setBackgroundColor(themeProps.getBackgroundColor()); - setSelectionColor(themeProps.getSelectionColor()); - setSelectedTextColor(themeProps.getSelectedTextColor()); - - lineNumberArea = new LineNumberArea(editorPane); - scrollPane.setRowHeaderView(lineNumberArea); - - add(scrollPane, BorderLayout.CENTER); - add(statusTextField, BorderLayout.SOUTH); - - updateStatus(1, 1); - - EditorThemePropertiesManager.addListener(new EditorThemePropertyChangeAdapter() { - @Override - public void onBackgroundColorChanged(Color newColor) { - setBackgroundColor(newColor); - } - - @Override - public void onSelectionColorChanged(Color newColor) { - setSelectionColor(newColor); - } - - @Override - public void onSelectedTextColorChanged(Color newColor) { - setSelectedTextColor(newColor); - } - }); - } - - @Override - public void requestFocus() { - super.requestFocus(); - if (editorPane != null) { - editorPane.requestFocus(); - editorPane.requestFocusInWindow(); - } - } - - @Override - public void setFont(Font font) { - super.setFont(font); - if (editorPane != null) { - editorPane.setFont(font); - - Border border = BorderFactory.createEmptyBorder(3, 3, 3, 3); - editorPane.setBorder(border); - } - if (lineNumberArea != null) { - lineNumberArea.setFont(font); - - FontMetrics fm = getFontMetrics(font); - int delta = fm.getHeight() - fm.getDescent() - fm.getAscent(); - Border border = BorderFactory.createEmptyBorder(delta + 3, 3, 3, 3); - lineNumberArea.setBorder(border); - } - } - - public EditorPane getEditorPane() { - return editorPane; - } - - private void updateStatus(int linenumber, int columnnumber) { - statusTextField.setText("Line: " + linenumber + " Column: " + columnnumber); - } - - private static int getRow(int pos, JTextComponent editor) { - int rn = (pos == 0) ? 1 : 0; - - try { - int offs = pos; - - while (offs > 0) { - offs = Utilities.getRowStart(editor, offs) - 1; - rn++; - } - } catch (BadLocationException e) { - e.printStackTrace(); - } - return rn; - } - - private static int getColumn(int pos, JTextComponent editor) { - try { - return pos - Utilities.getRowStart(editor, pos) + 1; - } catch (BadLocationException e) { - e.printStackTrace(); - } - return -1; - } - - private void setBackgroundColor(final Color backgroundColor) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - scrollPane.getViewport().setBackground(backgroundColor); - editorPane.setBackground(backgroundColor); - } - }); - } - - private void setSelectionColor(final Color selectionColor) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - editorPane.setSelectionColor(selectionColor); - } - }); - } - - private void setSelectedTextColor(final Color selectedTextColor) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - editorPane.setSelectedTextColor(selectedTextColor); - } - }); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditorThemeConfigDialog.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditorThemeConfigDialog.java deleted file mode 100644 index a773203..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/EditorThemeConfigDialog.java +++ /dev/null @@ -1,978 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import javax.swing.*; -import javax.swing.filechooser.FileFilter; - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.ui.editor.theme.ColorAndStyle; -import net.sf.robocode.ui.editor.theme.ColorAndStyleAdapter; -import net.sf.robocode.ui.editor.theme.ComboBoxUtil; -import net.sf.robocode.ui.editor.theme.EditorPropertiesManager; -import net.sf.robocode.ui.editor.theme.EditorThemeProperties; -import net.sf.robocode.ui.editor.theme.EditorThemePropertiesManager; -import net.sf.robocode.ui.editor.theme.IEditorThemeProperties; - -import java.awt.Color; -import java.awt.Component; -import java.awt.Dimension; -import java.awt.Font; -import java.awt.FontMetrics; -import java.awt.GraphicsEnvironment; -import java.awt.GridBagConstraints; -import java.awt.GridBagLayout; -import java.awt.Insets; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.File; -import java.io.IOException; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collections; -import java.util.List; - - -/** - * @author Flemming N. Larsen (original) - * - * @since 1.8.3.0 - */ -@SuppressWarnings("serial") -public class EditorThemeConfigDialog extends JDialog { - - private static final boolean ONLY_MONOSPACED = true; - - private static final String[] FONT_SIZES = { - "8", "9", "10", "11", "12", "14", "16", "18", "20", "22", "24", "26", "28", "36", "48", "72" - }; - - private JButton saveButton; - private JButton closeButton; - - private JComboBox fontNameComboBox; - private JComboBox fontStyleComboBox; - private JComboBox fontSizeComboBox; - - private JLabel previewLabel; - - private JComboBox themeComboBox; - - private ColorAndStyle backgroundColorAndStyle; - private ColorAndStyle lineNumberBackgroundColorAndStyle; - private ColorAndStyle lineNumberTextColorAndStyle; - private ColorAndStyle highlightedLineColorAndStyle; - private ColorAndStyle selectionColorAndStyle; - private ColorAndStyle selectedTextColorAndStyle; - private ColorAndStyle normalTextColorAndStyle; - private ColorAndStyle quotedTextColorAndStyle; - private ColorAndStyle keywordTextColorAndStyle; - private ColorAndStyle literalTextColorAndStyle; - private ColorAndStyle annotationTextColorAndStyle; - private ColorAndStyle commentTextColorAndStyle; - - private final EventHandler eventHandler = new EventHandler(); - - public EditorThemeConfigDialog(JFrame owner) { - super(owner, true); - initialize(); - } - - private void initialize() { - setTitle("Editor Theme Configurator"); - setLayout(new GridBagLayout()); - setResizable(false); - - // Initialize the font and theme ---- - initializeFontAndTheme(); - - getSaveButton().setEnabled(false); - - // ---- General font settings ---- - - GridBagConstraints gbc = new GridBagConstraints(); - gbc.insets = new Insets(5, 5, 5, 5); - gbc.anchor = GridBagConstraints.WEST; - - int gridy = 0; - - gbc.gridx = 0; - gbc.gridy = gridy; - gbc.fill = GridBagConstraints.HORIZONTAL; - - gbc.weightx = 0.6; - add(getFontNamePanel(), gbc); - - gbc.gridx = 1; - gbc.weightx = 0.3; - add(getFontStylePanel(), gbc); - - gbc.gridx = 2; - gbc.weightx = 0.1; - add(getFontSizePanel(), gbc); - - gbc.gridx = 0; - gbc.gridy = ++gridy; - gbc.gridwidth = 3; - gbc.gridheight = 1; - - gbc.fill = GridBagConstraints.BOTH; - gbc.weightx = 1.0; - gbc.weighty = 1.0; - add(getPreviewPanel(), gbc); - - // ----- Theme settings ---- - - gbc.weightx = 0; - gbc.weighty = 0; - - gbc.gridx = 0; - gbc.gridy = ++gridy; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.gridwidth = 1; - add(getThemeComboBox(), gbc); - - // ---- Color buttons and font styles ---- - - gbc.gridwidth = 1; - - gbc.gridx = 0; - gbc.gridy = ++gridy; - gbc.gridwidth = 1; - - gbc.fill = GridBagConstraints.NONE; - - JPanel colorButtonsPanel = new JPanel(); - colorButtonsPanel.setLayout(new GridBagLayout()); - add(colorButtonsPanel, gbc); - - GridBagConstraints gbc2 = new GridBagConstraints(); - gbc2.insets = new Insets(5, 5, 5, 5); - gbc2.anchor = GridBagConstraints.WEST; - - int gridy2 = 0; - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getBackgroundColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getLineNumberBackgroundColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getLineNumberTextColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getHighlightedLineColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getSelectionColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getSelectedTextColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getNormalTextColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getCommentTextColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getQuotedTextColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getKeywordTextColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getLiteralTextColorAndStyle(), colorButtonsPanel, gbc2); - - gbc2.gridy = gridy2++; - addColoredButtonAndFontStyleToPanel(getAnnotationTextColorAndStyle(), colorButtonsPanel, gbc2); - - // ------ OK & Cancel buttons ---- - - JPanel okCancelPanel = new JPanel(); - okCancelPanel.add(getSaveButton()); - okCancelPanel.add(getCloseButton(), gbc); - - gbc.gridy = ++gridy; - add(okCancelPanel, gbc); - } - - private JButton getSaveButton() { - if (saveButton == null) { - saveButton = new JButton("Save & Close"); - saveButton.setMnemonic('S'); - saveButton.addActionListener(eventHandler); - } - return saveButton; - } - - private JButton getCloseButton() { - if (closeButton == null) { - closeButton = new JButton("Close"); - closeButton.setMnemonic('C'); - closeButton.addActionListener(eventHandler); - } - return closeButton; - } - - private JComboBox getFontNameComboBox() { - if (fontNameComboBox == null) { - String[] fontFamilyNames = GraphicsEnvironment.getLocalGraphicsEnvironment().getAvailableFontFamilyNames(); - List fontFamilyNameList = Arrays.asList(fontFamilyNames); - - List fontNameList = new ArrayList(); - - if (ONLY_MONOSPACED) { - for (String monospacedFontName : getMonospacedFontNames()) { - if (fontFamilyNameList.contains(monospacedFontName)) { - fontNameList.add(monospacedFontName); - } - } - } else { - fontNameList.addAll(fontFamilyNameList); - } - if (!fontNameList.contains("Monospaced")) { - fontNameList.add("Monospaced"); - } - Collections.sort(fontNameList); - - fontNameComboBox = new JComboBox(fontNameList.toArray()); - fontNameComboBox.setRenderer(new FontCellRenderer()); - - fontNameComboBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - - String oldFontName = themeProps.getFontName(); - String newFontName = ComboBoxUtil.getSelectedName(fontNameComboBox); - if (!newFontName.equals(oldFontName)) { - String oldThemeName = themeProps.getThemeName(); - String newThemeName = ComboBoxUtil.getSelectedName(getThemeComboBox()); - if (newThemeName.equals(oldThemeName)) { - themeProps.setFontName(newFontName); - updateSaveButton(); - } - } - } - }); - } - return fontNameComboBox; - } - - private JComboBox getFontStyleComboBox() { - if (fontStyleComboBox == null) { - fontStyleComboBox = ComboBoxUtil.createFontStyleComboBox(FontStyle.PLAIN); - - fontStyleComboBox.addActionListener( - new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - - FontStyle oldFontStyle = themeProps.getNormalTextStyle(); - FontStyle newFontStyle = ComboBoxUtil.getSelectedStyle(getFontStyleComboBox()); - if (newFontStyle != oldFontStyle) { - themeProps.setNormalTextStyle(newFontStyle); - - ComboBoxUtil.setSelected(getNormalTextColorAndStyle().getFontStyleComboBox(), - (String) getFontStyleComboBox().getSelectedItem()); - - updateSaveButton(); - } - } - }); - } - return fontStyleComboBox; - } - - private JComboBox getFontSizeComboBox() { - if (fontSizeComboBox == null) { - fontSizeComboBox = new JComboBox(FONT_SIZES); - fontSizeComboBox.setSelectedIndex(5); - - fontSizeComboBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - - int oldFontSize = themeProps.getFontSize(); - int newFontSize = Integer.parseInt((String) getFontSizeComboBox().getSelectedItem()); - if (newFontSize != oldFontSize) { - themeProps.setFontSize(newFontSize); - updateSaveButton(); - } - } - }); - } - return fontSizeComboBox; - } - - private JPanel getFontNamePanel() { - JPanel panel = new JPanel(); - JLabel label = new JLabel("Font Name"); - - panel.setLayout(new GridBagLayout()); - - GridBagConstraints gbc = new GridBagConstraints(); - - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.NORTHWEST; - panel.add(label, gbc); - - gbc.gridx = 0; - gbc.gridy = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weightx = 1.0; - panel.add(getFontNameComboBox(), gbc); - - return panel; - } - - private JPanel getFontStylePanel() { - JPanel panel = new JPanel(); - JLabel label = new JLabel("Style"); - - panel.setLayout(new GridBagLayout()); - - GridBagConstraints gbc = new GridBagConstraints(); - - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.NORTHWEST; - panel.add(label, gbc); - - gbc.gridx = 0; - gbc.gridy = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weightx = 1.0; - panel.add(getFontStyleComboBox(), gbc); - - return panel; - } - - private JPanel getFontSizePanel() { - JPanel panel = new JPanel(); - JLabel label = new JLabel("Size"); - - panel.setLayout(new GridBagLayout()); - - GridBagConstraints gbc = new GridBagConstraints(); - - gbc.gridx = 0; - gbc.gridy = 0; - gbc.anchor = GridBagConstraints.NORTHWEST; - panel.add(label, gbc); - - gbc.gridx = 0; - gbc.gridy = 1; - gbc.fill = GridBagConstraints.HORIZONTAL; - gbc.weightx = 1.0; - panel.add(getFontSizeComboBox(), gbc); - - return panel; - } - - private JLabel getPreviewLabel() { - if (previewLabel == null) { - previewLabel = new JLabel("AaBbYyZz"); - } - return previewLabel; - } - - private JPanel getPreviewPanel() { - final JPanel panel = new JPanel(); - panel.setLayout(new GridBagLayout()); - - panel.setBorder(BorderFactory.createEtchedBorder()); - panel.setBackground(Color.WHITE); - panel.setForeground(Color.BLACK); - panel.setPreferredSize(new Dimension(400, 120)); - - ActionListener actionListener = new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - setPreviewLabelFont(panel); - panel.repaint(); - } - }; - - getFontNameComboBox().addActionListener(actionListener); - getFontStyleComboBox().addActionListener(actionListener); - getFontSizeComboBox().addActionListener(actionListener); - - setPreviewLabelFont(panel); - panel.add(getPreviewLabel(), SwingConstants.CENTER); - - return panel; - } - - private ColorAndStyle getBackgroundColorAndStyle() { - if (backgroundColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - backgroundColorAndStyle = new ColorAndStyle("Background Color", props.getBackgroundColor(), null); - backgroundColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setBackgroundColor(newColor); - - updateSaveButton(); - } - }); - } - return backgroundColorAndStyle; - } - - private ColorAndStyle getLineNumberBackgroundColorAndStyle() { - if (lineNumberBackgroundColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - lineNumberBackgroundColorAndStyle = new ColorAndStyle("Line Number Background Color", - props.getLineNumberBackgroundColor(), null); - lineNumberBackgroundColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setLineNumberBackgroundColor(newColor); - - updateSaveButton(); - } - }); - } - return lineNumberBackgroundColorAndStyle; - } - - private ColorAndStyle getLineNumberTextColorAndStyle() { - if (lineNumberTextColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - lineNumberTextColorAndStyle = new ColorAndStyle("Line Number Text Color", props.getLineNumberTextColor(), - null); - lineNumberTextColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setLineNumberTextColor(newColor); - - updateSaveButton(); - } - }); - } - return lineNumberTextColorAndStyle; - } - - private ColorAndStyle getHighlightedLineColorAndStyle() { - if (highlightedLineColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - highlightedLineColorAndStyle = new ColorAndStyle("Highlighted Line Color", props.getHighlightedLineColor(), - null); - highlightedLineColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setHighlightedLineColor(newColor); - - updateSaveButton(); - } - }); - } - return highlightedLineColorAndStyle; - } - - private ColorAndStyle getSelectionColorAndStyle() { - if (selectionColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - selectionColorAndStyle = new ColorAndStyle("Selection Color", props.getSelectionColor(), null); - selectionColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setSelectionColor(newColor); - - updateSaveButton(); - } - }); - } - return selectionColorAndStyle; - } - - private ColorAndStyle getSelectedTextColorAndStyle() { - if (selectedTextColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - selectedTextColorAndStyle = new ColorAndStyle("Selected Text Color", props.getSelectedTextColor(), null); - selectedTextColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setSelectedTextColor(newColor); - } - }); - } - return selectedTextColorAndStyle; - } - - private ColorAndStyle getNormalTextColorAndStyle() { - if (normalTextColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - normalTextColorAndStyle = new ColorAndStyle("Normal Text Color", props.getNormalTextColor(), - props.getNormalTextStyle()); - normalTextColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setNormalTextColor(newColor); - - updateSaveButton(); - } - - @Override - public void styleChanged(FontStyle newStyle) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setNormalTextStyle(newStyle); - - updateSaveButton(); - - // Make sure to update the font style combo box - ComboBoxUtil.setSelected(getFontStyleComboBox(), newStyle); - } - }); - } - return normalTextColorAndStyle; - } - - private ColorAndStyle getQuotedTextColorAndStyle() { - if (quotedTextColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - quotedTextColorAndStyle = new ColorAndStyle("Quoted Text Color", props.getQuotedTextColor(), - props.getQuotedTextStyle()); - quotedTextColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setQuotedTextColor(newColor); - - updateSaveButton(); - } - - @Override - public void styleChanged(FontStyle newStyle) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setQuotedTextStyle(newStyle); - - updateSaveButton(); - } - }); - } - return quotedTextColorAndStyle; - } - - private ColorAndStyle getKeywordTextColorAndStyle() { - if (keywordTextColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - keywordTextColorAndStyle = new ColorAndStyle("Keyword Color", props.getKeywordTextColor(), - props.getKeywordTextStyle()); - keywordTextColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setKeywordTextColor(newColor); - - updateSaveButton(); - } - - @Override - public void styleChanged(FontStyle newStyle) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setKeywordTextStyle(newStyle); - - updateSaveButton(); - } - }); - } - return keywordTextColorAndStyle; - } - - private ColorAndStyle getLiteralTextColorAndStyle() { - if (literalTextColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - literalTextColorAndStyle = new ColorAndStyle("Literal Color", props.getLiteralTextColor(), - props.getLiteralTextStyle()); - literalTextColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setLiteralTextColor(newColor); - - updateSaveButton(); - } - - @Override - public void styleChanged(FontStyle newStyle) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setLiteralTextStyle(newStyle); - - updateSaveButton(); - } - }); - } - return literalTextColorAndStyle; - } - - private ColorAndStyle getAnnotationTextColorAndStyle() { - if (annotationTextColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - annotationTextColorAndStyle = new ColorAndStyle("Annotation Color", props.getAnnotationTextColor(), - props.getAnnotationTextStyle()); - annotationTextColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setAnnotationTextColor(newColor); - - updateSaveButton(); - } - - @Override - public void styleChanged(FontStyle newStyle) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setAnnotationTextStyle(newStyle); - - updateSaveButton(); - } - }); - } - return annotationTextColorAndStyle; - } - - private ColorAndStyle getCommentTextColorAndStyle() { - if (commentTextColorAndStyle == null) { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - commentTextColorAndStyle = new ColorAndStyle("Comment Color", props.getCommentTextColor(), - props.getCommentTextStyle()); - commentTextColorAndStyle.addListener(new ColorAndStyleAdapter() { - @Override - public void colorChanged(Color newColor) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setCommentTextColor(newColor); - - updateSaveButton(); - } - - @Override - public void styleChanged(FontStyle newStyle) { - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setCommentTextStyle(newStyle); - - updateSaveButton(); - } - }); - } - return commentTextColorAndStyle; - } - - private JComboBox getThemeComboBox() { - if (themeComboBox == null) { - final String fileExt = EditorThemePropertiesManager.getFileExt(); - - File[] themeFiles = FileUtil.getEditorThemeConfigDir().listFiles(new java.io.FileFilter() { - public boolean accept(File filepath) { - return filepath.getName().endsWith(fileExt); - } - }); - - List themeNames = new ArrayList(); - for (File file : themeFiles) { - String themeName = file.getName(); - themeName = themeName.substring(0, themeName.lastIndexOf(fileExt)); - themeNames.add(themeName); - } - - themeComboBox = new JComboBox(themeNames.toArray()); - themeComboBox.addActionListener(eventHandler); - } - return themeComboBox; - } - - private void setPreviewLabelFont(JPanel panel) { - String fontName = (String) getFontNameComboBox().getSelectedItem(); - int fontStyleFlags = FontStyle.fromName((String) getFontStyleComboBox().getSelectedItem()).getFontStyleFlags(); - int fontSize = Integer.parseInt((String) getFontSizeComboBox().getSelectedItem()); - - Font font = new Font(fontName, fontStyleFlags, fontSize); - - getPreviewLabel().setFont(font); - - FontMetrics fontMetrics = panel.getFontMetrics(font); - - int width = fontMetrics.stringWidth(getPreviewLabel().getText()); - int height = fontMetrics.getHeight(); - - getPreviewLabel().setPreferredSize(new Dimension(width, height)); - } - - private void initializeFontAndTheme() { - // Read the theme properties - IEditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - - // Set selected theme - ComboBoxUtil.setSelected(getThemeComboBox(), themeProps.getThemeName()); - - // Set selected font name - ComboBoxUtil.setSelected(getFontNameComboBox(), themeProps.getFontName()); - - // Set selected font style - ComboBoxUtil.setSelected(getFontStyleComboBox(), themeProps.getNormalTextStyle()); - - // Set selected font size - ComboBoxUtil.setSelected(getFontSizeComboBox(), "" + themeProps.getFontSize()); - } - - private class EventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - Object source = e.getSource(); - if (source.equals(getThemeComboBox())) { - performThemeComboBoxAction(); - } else if (e.getSource().equals(getSaveButton())) { - performSaveButtonAction(); - } else if (e.getSource().equals(getCloseButton())) { - dispose(); - } - } - } - - private List getMonospacedFontNames() { - List monospacedFontNames = new ArrayList(); - - Font[] allFonts = GraphicsEnvironment.getLocalGraphicsEnvironment().getAllFonts(); - for (Font font : allFonts) { - if (isMonospaced(font)) { - monospacedFontNames.add(font.getFontName()); - } - } - return monospacedFontNames; - } - - private boolean isMonospaced(Font font) { - FontMetrics fontMetrics = getFontMetrics(font); - - int lastCharWidth = -1; - - for (int charCode = 0; charCode < 128; charCode++) { - if (Character.isValidCodePoint(charCode) && (Character.isLetter(charCode) || Character.isDigit(charCode))) { - int charWidth = fontMetrics.charWidth((char) charCode); - if (lastCharWidth >= 0 && charWidth != lastCharWidth) { - return false; // font is not mono-spaced - } - lastCharWidth = charWidth; - } - } - return true; // font is mono-spaced - } - - private static void addColoredButtonAndFontStyleToPanel(ColorAndStyle group, JPanel panel, GridBagConstraints gbc) { - gbc.gridx = 0; - panel.add(group.getColoredButton(), gbc); - - gbc.gridx = 1; - panel.add(group.getLabel(), gbc); - - if (group.getFontStyleComboBox() != null) { - gbc.gridx = 2; - panel.add(group.getFontStyleComboBox(), gbc); - } - } - - private void udateComponentsTheme(final String themeName) { - SwingUtilities.invokeLater(new Runnable() { - public void run() { - // Store current theme name - EditorPropertiesManager.getEditorProperties().setThemeName(themeName); - EditorPropertiesManager.saveEditorProperties(); - - // Load theme properties - File filepath = EditorThemePropertiesManager.getFilepath(themeName); - EditorThemePropertiesManager.loadEditorThemeProperties(filepath); - - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - - ComboBoxUtil.setSelected(getFontNameComboBox(), themeProps.getFontName()); - ComboBoxUtil.setSelected(getFontSizeComboBox(), "" + themeProps.getFontSize()); - - getBackgroundColorAndStyle().setSelectedColor(themeProps.getBackgroundColor()); - - getLineNumberBackgroundColorAndStyle().setSelectedColor(themeProps.getLineNumberBackgroundColor()); - getLineNumberTextColorAndStyle().setSelectedColor(themeProps.getLineNumberTextColor()); - - getHighlightedLineColorAndStyle().setSelectedColor(themeProps.getHighlightedLineColor()); - - getSelectionColorAndStyle().setSelectedColor(themeProps.getSelectionColor()); - getSelectedTextColorAndStyle().setSelectedColor(themeProps.getSelectedTextColor()); - - getNormalTextColorAndStyle().setSelectedColor(themeProps.getNormalTextColor()); - getNormalTextColorAndStyle().setSelectedStyle(themeProps.getNormalTextStyle()); - - getCommentTextColorAndStyle().setSelectedColor(themeProps.getCommentTextColor()); - getCommentTextColorAndStyle().setSelectedStyle(themeProps.getCommentTextStyle()); - - getQuotedTextColorAndStyle().setSelectedColor(themeProps.getQuotedTextColor()); - getQuotedTextColorAndStyle().setSelectedStyle(themeProps.getQuotedTextStyle()); - - getKeywordTextColorAndStyle().setSelectedColor(themeProps.getKeywordTextColor()); - getKeywordTextColorAndStyle().setSelectedStyle(themeProps.getKeywordTextStyle()); - - getLiteralTextColorAndStyle().setSelectedColor(themeProps.getLiteralTextColor()); - getLiteralTextColorAndStyle().setSelectedStyle(themeProps.getLiteralTextStyle()); - - getAnnotationTextColorAndStyle().setSelectedColor(themeProps.getAnnotationTextColor()); - getAnnotationTextColorAndStyle().setSelectedStyle(themeProps.getAnnotationTextStyle()); - - updateSaveButton(); - } - }); - } - - private void updateSaveButton() { - EditorThemeProperties props = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - boolean enabled = props.isChanged(); - getSaveButton().setEnabled(enabled); - } - - private void performThemeComboBoxAction() { - EditorThemeProperties currentThemeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - - String oldThemeName = currentThemeProps.getThemeName(); - String newThemeName = (String) getThemeComboBox().getSelectedItem(); - if (!oldThemeName.equals(newThemeName)) { - if (currentThemeProps.isChanged()) { - Object[] options = { "Yes, save changes", "No, forget changes", "Cancel"}; - - int option = JOptionPane.showOptionDialog(null, - "Changes have been made to the theme:\n" + oldThemeName - + "\nDo you want save the changes to this theme?", - "Warning", - JOptionPane.YES_NO_CANCEL_OPTION, - JOptionPane.QUESTION_MESSAGE, - null, - options, - options[2]); - - if (option == JOptionPane.YES_OPTION) { - File filepath = EditorThemePropertiesManager.getFilepath(oldThemeName); - if (filepath != null && !filepath.exists()) { - try { - filepath.createNewFile(); - } catch (IOException e) { - Logger.logError(e); - return; - } - } - EditorThemePropertiesManager.saveEditorThemeProperties(filepath); - - } else if (option == JOptionPane.CANCEL_OPTION) { - ComboBoxUtil.setSelected(getThemeComboBox(), oldThemeName); - return; - } - } - // Switch to new theme - udateComponentsTheme(newThemeName); - } - } - - private void performSaveButtonAction() { - String themeName = "My theme"; - File file = EditorThemePropertiesManager.getFilepath(themeName); - - JFileChooser saveThemeDialog = new JFileChooser(FileUtil.getEditorThemeConfigDir()); - saveThemeDialog.setDialogTitle("Save Theme"); - saveThemeDialog.setSelectedFile(file); - - FileFilter fileFilter = new FileFilter() { - @Override - public boolean accept(File filepath) { - return filepath.getName().endsWith(EditorThemePropertiesManager.getFileExt()); - } - - @Override - public String getDescription() { - return "Robocode Editor Theme properties"; - } - }; - - saveThemeDialog.addChoosableFileFilter(fileFilter); - saveThemeDialog.setAcceptAllFileFilterUsed(false); - - int returnState = saveThemeDialog.showSaveDialog(this); - - file = saveThemeDialog.getSelectedFile(); - - if (!file.getName().endsWith(EditorThemePropertiesManager.getFileExt())) { - file = new File(file.getAbsolutePath() + EditorThemePropertiesManager.getFileExt()); - } - - if (!FileUtil.isFilenameValid(file.getName())) { - JOptionPane.showMessageDialog(this, "Not a valid file name:\n" + file.getName(), "Error", - JOptionPane.ERROR_MESSAGE); - - } else if (returnState == JFileChooser.APPROVE_OPTION) { - - if (file.exists()) { - Object[] options = { "Yes, overwrite", "No, do not overwrite"}; - - int option = JOptionPane.showOptionDialog(this, - "File already exists:\n" + file.getName() + "\nDo you want to overwrite this file?", "Warning", - JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, options, options[1]); - - if (option == JOptionPane.NO_OPTION) { - return; - } - } else { - try { - file.createNewFile(); // File must be created if it does not exist already - } catch (IOException e) { - Logger.logError(e); - return; - } - } - - ComboBoxUtil.setSelected(getThemeComboBox(), themeName); - EditorPropertiesManager.getEditorProperties().setThemeName(themeName); - EditorPropertiesManager.saveEditorProperties(); - - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - themeProps.setThemeName(themeName); - - themeProps.setFontName(ComboBoxUtil.getSelectedName(getFontNameComboBox())); - themeProps.setFontSize(Integer.parseInt(ComboBoxUtil.getSelectedName(getFontSizeComboBox()))); - - EditorThemePropertiesManager.saveEditorThemeProperties(file); - - dispose(); // Only when save was successful - - } else if (returnState == JFileChooser.ERROR_OPTION) { - JOptionPane.showMessageDialog(this, "The editor theme was not saved.", "Warning", - JOptionPane.WARNING_MESSAGE); - } - } - - private class FontCellRenderer extends DefaultListCellRenderer { - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - Font font = new Font((String) value, Font.PLAIN, 20); - if (font.canDisplayUpTo(label.getText()) == -1) { // -1 means, can display all of the string - label.setFont(font); - } - return label; - } - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/FindReplaceDialog.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/FindReplaceDialog.java deleted file mode 100644 index fedc9c9..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/FindReplaceDialog.java +++ /dev/null @@ -1,386 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import static javax.swing.GroupLayout.Alignment.*; -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.regex.Matcher; -import java.util.regex.Pattern; - - -/** - * @author Matthew Reeder (original) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class FindReplaceDialog extends JDialog implements ActionListener { - private JTextField findTextField; - private JTextField replaceTextField; - private JButton findNextButton; - private JButton replaceFindButton; - private JButton replaceButton; - private JButton replaceAllButton; - private JButton closeButton; - private JCheckBox caseSensitiveCheckBox; - private JCheckBox wholeWordCheckBox; - private JRadioButton regexButton; - private JRadioButton wildCardsButton; - private JRadioButton literalButton; - private JLabel findLabel; - private JLabel replaceLabel; - private boolean initLoc; - private final RobocodeEditor editor; - - public FindReplaceDialog(RobocodeEditor owner) { - super(owner, false); - editor = owner; - - GroupLayout layout = new GroupLayout(getContentPane()); - - getContentPane().setLayout(layout); - layout.setAutoCreateGaps(true); - layout.setAutoCreateContainerGaps(true); - - JPanel optionsPanel = new JPanel(); - - optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS)); - optionsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Options")); - optionsPanel.add(getCaseSensitiveCheckBox()); - optionsPanel.add(getWholeWordCheckBox()); - optionsPanel.setAlignmentY(TOP_ALIGNMENT); - - JPanel usePanel = new JPanel(); - - usePanel.setLayout(new BoxLayout(usePanel, BoxLayout.Y_AXIS)); - usePanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Use")); - usePanel.add(getLiteralButton()); - usePanel.add(getWildCardsButton()); - usePanel.add(getRegexButton()); - usePanel.setAlignmentY(TOP_ALIGNMENT); - - ButtonGroup buttonGroup = new ButtonGroup(); - - buttonGroup.add(getLiteralButton()); - buttonGroup.add(getWildCardsButton()); - buttonGroup.add(getRegexButton()); - - layout.setHorizontalGroup( - layout.createSequentialGroup().addGroup(layout.createParallelGroup(LEADING).addGroup(layout.createSequentialGroup().addComponent(getFindLabel()).addComponent(getFindTextField())).addGroup(layout.createSequentialGroup().addComponent(getReplaceLabel()).addComponent(getReplaceTextField())).addGroup(layout.createSequentialGroup().addComponent(optionsPanel).addComponent(usePanel))).addGroup( - layout.createParallelGroup(LEADING).addComponent(getFindNextButton()).addComponent(getReplaceFindButton()).addComponent(getReplaceButton()).addComponent(getReplaceAllButton()).addComponent( - getCloseButton()))); - - layout.linkSize(SwingConstants.HORIZONTAL, getFindLabel(), getReplaceLabel()); - layout.linkSize(SwingConstants.HORIZONTAL, getFindNextButton(), getReplaceFindButton(), getReplaceButton(), - getReplaceAllButton(), getCloseButton()); - - layout.setVerticalGroup( - layout.createSequentialGroup().addGroup(layout.createParallelGroup(BASELINE).addComponent(getFindLabel()).addComponent(getFindTextField()).addComponent(getFindNextButton())).addGroup(layout.createParallelGroup(BASELINE).addComponent(getReplaceLabel()).addComponent(getReplaceTextField()).addComponent(getReplaceButton())).addGroup( - layout.createParallelGroup(BASELINE).addComponent(optionsPanel).addComponent(usePanel).addGroup( - layout.createSequentialGroup().addComponent(getReplaceFindButton()).addComponent(getReplaceAllButton()).addComponent( - getCloseButton())))); - - pack(); - setResizable(false); - } - - public void showDialog(boolean showReplace) { - getReplaceLabel().setVisible(showReplace); - getReplaceTextField().setVisible(showReplace); - getReplaceButton().setVisible(showReplace); - getReplaceAllButton().setVisible(showReplace); - if (showReplace) { - setTitle("Replace"); - getRootPane().setDefaultButton(getReplaceButton()); - getReplaceFindButton().setText("Find..."); - getReplaceFindButton().setMnemonic('d'); - getReplaceFindButton().setDisplayedMnemonicIndex(3); - } else { - setTitle("Find"); - getRootPane().setDefaultButton(getFindNextButton()); - getReplaceFindButton().setText("Replace..."); - getReplaceFindButton().setMnemonic('R'); - getReplaceFindButton().setDisplayedMnemonicIndex(0); - } - - pack(); - - if (!initLoc && editor != null) { - Rectangle bounds = editor.getBounds(); - Dimension size = getSize(); - - setLocation((int) (bounds.getX() + (bounds.getWidth() - size.getWidth()) / 2), - (int) (bounds.getY() + (bounds.getHeight() - size.getHeight()) / 2)); - initLoc = true; - } - - // Bugfix [2664844] - Editor: Find (set cursor position) - getFindTextField().requestFocus(); - - setVisible(true); - } - - public JLabel getFindLabel() { - if (findLabel == null) { - findLabel = new JLabel(); - findLabel.setText("Find:"); - findLabel.setDisplayedMnemonicIndex(3); - } - return findLabel; - } - - public JLabel getReplaceLabel() { - if (replaceLabel == null) { - replaceLabel = new JLabel(); - replaceLabel.setText("Replace:"); - replaceLabel.setDisplayedMnemonicIndex(3); - } - return replaceLabel; - } - - public JTextField getFindTextField() { - if (findTextField == null) { - findTextField = new JTextField(); - findTextField.setFocusAccelerator('n'); - findTextField.addActionListener(this); - } - return findTextField; - } - - public JTextField getReplaceTextField() { - if (replaceTextField == null) { - replaceTextField = new JTextField(); - replaceTextField.setFocusAccelerator('p'); - replaceTextField.addActionListener(this); - } - return replaceTextField; - } - - public JButton getFindNextButton() { - if (findNextButton == null) { - findNextButton = new JButton(); - findNextButton.setText("Find Next"); - findNextButton.setMnemonic('F'); - findNextButton.setDefaultCapable(true); - findNextButton.addActionListener(this); - } - return findNextButton; - } - - public JButton getReplaceFindButton() { - if (replaceFindButton == null) { - replaceFindButton = new JButton("Replace..."); - replaceFindButton.setMnemonic('R'); - replaceFindButton.addActionListener(this); - } - return replaceFindButton; - } - - public JButton getReplaceButton() { - if (replaceButton == null) { - replaceButton = new JButton(); - replaceButton.setText("Replace"); - replaceButton.setMnemonic('R'); - replaceButton.setDefaultCapable(true); - replaceButton.addActionListener(this); - } - return replaceButton; - } - - public JButton getReplaceAllButton() { - if (replaceAllButton == null) { - replaceAllButton = new JButton(); - replaceAllButton.setText("Replace All"); - replaceAllButton.setMnemonic('A'); - replaceAllButton.setDisplayedMnemonicIndex(8); - replaceAllButton.addActionListener(this); - } - return replaceAllButton; - } - - public JButton getCloseButton() { - if (closeButton == null) { - closeButton = new JButton(); - closeButton.setText("Close"); - closeButton.setMnemonic('C'); - closeButton.addActionListener(this); - } - return closeButton; - } - - public JCheckBox getCaseSensitiveCheckBox() { - if (caseSensitiveCheckBox == null) { - caseSensitiveCheckBox = new JCheckBox(); - caseSensitiveCheckBox.setText("Case Sensitive"); - caseSensitiveCheckBox.setMnemonic('v'); - caseSensitiveCheckBox.setDisplayedMnemonicIndex(12); - caseSensitiveCheckBox.addActionListener(this); - } - return caseSensitiveCheckBox; - } - - public JCheckBox getWholeWordCheckBox() { - if (wholeWordCheckBox == null) { - wholeWordCheckBox = new JCheckBox(); - wholeWordCheckBox.setText("Whole Words Only"); - wholeWordCheckBox.setMnemonic('W'); - wholeWordCheckBox.addActionListener(this); - } - return wholeWordCheckBox; - } - - public JRadioButton getLiteralButton() { - if (literalButton == null) { - literalButton = new JRadioButton(); - literalButton.setText("Literal"); - literalButton.setMnemonic('L'); - literalButton.setSelected(true); - literalButton.addActionListener(this); - } - return literalButton; - } - - public JRadioButton getWildCardsButton() { - if (wildCardsButton == null) { - wildCardsButton = new JRadioButton(); - wildCardsButton.setText("Wild Cards"); - wildCardsButton.setMnemonic('i'); - wildCardsButton.setDisplayedMnemonicIndex(1); - wildCardsButton.addActionListener(this); - } - return wildCardsButton; - } - - public JRadioButton getRegexButton() { - if (regexButton == null) { - regexButton = new JRadioButton(); - regexButton.setText("Regular Expressions"); - regexButton.setMnemonic('x'); - regexButton.setDisplayedMnemonicIndex(9); - regexButton.addActionListener(this); - } - return regexButton; - } - - public void actionPerformed(ActionEvent e) { - Object source = e.getSource(); - - if (source == getFindNextButton()) { - findNext(); - } else if (source == getReplaceButton()) { - doReplacement(); - findNext(); - } else if (source == getReplaceAllButton()) { - doReplaceAll(); - } else if (source == getCloseButton()) { - setVisible(false); - } else if (source == getReplaceFindButton()) { - showDialog(!getReplaceButton().isVisible()); - } else if (source instanceof JTextField) { - getRootPane().getDefaultButton().doClick(); - } - } - - private Pattern getCurrentPattern() { - String pattern = getFindTextField().getText(); - int flags = Pattern.DOTALL; - - if (!getRegexButton().isSelected()) { - StringBuffer newpattern = new StringBuffer(); - - // 'quote' the pattern - for (int i = 0; i < pattern.length(); i++) { - if ("\\[]^$&|().*+?{}".indexOf(pattern.charAt(i)) >= 0) { - newpattern.append('\\'); - } - newpattern.append(pattern.charAt(i)); - } - pattern = newpattern.toString(); - - // make "*" .* and "?" . - if (getWildCardsButton().isSelected()) { - pattern = pattern.replaceAll("\\\\\\*", ".+?"); - pattern = pattern.replaceAll("\\\\\\?", "."); - } - } - if (!getCaseSensitiveCheckBox().isSelected()) { - flags |= Pattern.CASE_INSENSITIVE; - } - if (getWholeWordCheckBox().isSelected()) { - pattern = "\\b" + pattern + "\\b"; - } - return Pattern.compile(pattern, flags); - } - - public void findNext() { - EditWindow currentWindow = editor.getActiveWindow(); - - if (currentWindow == null || getFindTextField().getText().length() == 0) { - // launch error dialog? - return; - } - Pattern p = getCurrentPattern(); - JEditorPane editorPane = currentWindow.getEditorPane(); - - // for some reason, getText() trims off \r but the indexes in - // the editor pane don't. - String text = editorPane.getText().replaceAll("\\r", ""); - Matcher m = p.matcher(text); - int index = editorPane.getSelectionEnd(); - - if (!(m.find(index) || m.find())) { - return; - } - editorPane.setSelectionStart(m.start()); - editorPane.setSelectionEnd(m.end()); - } - - public void doReplacement() { - EditWindow currentWindow = editor.getActiveWindow(); - - if (currentWindow == null || getFindTextField().getText().length() == 0) { - // launch error dialog? - return; - } - JEditorPane editorPane = currentWindow.getEditorPane(); - String text = editorPane.getSelectedText(); - - if (text == null) { - // no selection - return; - } - Matcher m = getCurrentPattern().matcher(text); - - if (m.matches()) { - String replacement = getReplaceTextField().getText(); - - if (getRegexButton().isSelected()) { - replacement = m.replaceFirst(replacement); - } - editorPane.replaceSelection(replacement); - } - } - - public void doReplaceAll() { - EditWindow currentWindow = editor.getActiveWindow(); - - if (currentWindow == null || getFindTextField().getText().length() == 0) { - // launch error dialog? - return; - } - JEditorPane editorPane = currentWindow.getEditorPane(); - String text = editorPane.getText(); - - String replacement = getReplaceTextField().getText(); - - editorPane.setText(getCurrentPattern().matcher(text).replaceAll(replacement)); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/FontStyle.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/FontStyle.java deleted file mode 100644 index c593c2e..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/FontStyle.java +++ /dev/null @@ -1,68 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import java.awt.Font; - - -/** - * Font style enumeration type, which provides an abstraction over the style flags from - * the integer flags from the {@link Font#getStyle()} method. - * - * @author Flemming N. Larsen (original) - */ -public enum FontStyle { - - PLAIN(Font.PLAIN, "Plain"), - BOLD(Font.BOLD, "Bold"), - ITALIC(Font.ITALIC, "Italic"), - BOLD_ITALIC(Font.BOLD + Font.ITALIC, "Bold Italic"); - - private final int fontStyleFlags; - private final String name; - - private FontStyle(int fontStyleFlags, String name) { - this.fontStyleFlags = fontStyleFlags; - this.name = name; - } - - public static FontStyle fromName(String name) { - for (FontStyle value : values()) { - if (value.name.equalsIgnoreCase(name)) { - return value; - } - } - return null; - } - - public static FontStyle fromStyleFlags(int flags) { - for (FontStyle value : values()) { - if (value.fontStyleFlags == flags) { - return value; - } - } - return null; - } - - public int getFontStyleFlags() { - return fontStyleFlags; - } - - public String getName() { - return name; - } - - public boolean isBold() { - return this == BOLD || this == BOLD_ITALIC; - } - - public boolean isItalic() { - return this == ITALIC || this == BOLD_ITALIC; - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/IEditorProperties.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/IEditorProperties.java deleted file mode 100644 index 40f090d..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/IEditorProperties.java +++ /dev/null @@ -1,21 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -/** - * Interface for editor properties. - * - * @author Flemming N. Larsen (original) - * - * @since 1.8.3.0 - */ -public interface IEditorProperties { - - String getThemeName(); -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/JavaDocument.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/JavaDocument.java deleted file mode 100644 index 7497f42..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/JavaDocument.java +++ /dev/null @@ -1,1137 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.Point; -import java.awt.event.FocusEvent; -import java.awt.event.FocusListener; -import java.util.Arrays; -import java.util.HashSet; -import java.util.Set; - -import javax.swing.JViewport; -import javax.swing.SwingUtilities; -import javax.swing.event.ChangeListener; -import javax.swing.event.ChangeEvent; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.*; - -import net.sf.robocode.ui.editor.theme.EditorThemePropertiesManager; -import net.sf.robocode.ui.editor.theme.EditorThemePropertyChangeAdapter; -import net.sf.robocode.ui.editor.theme.IEditorThemeProperties; -import net.sf.robocode.util.StringUtil; - - -// FIXME: Column in status bar does not take tab size into account - -// TODO: Make it configurable to extend the Java keywords. -// TODO: Highlight methods from Robocode API? -// TODO: Highlight numbers? -// TODO: Method names and method invocations in bold? -// TODO: Trim trailing white-spaces from all lines? - -/** - * Represents a styled Java document used for syntax high-lightning. - * - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class JavaDocument extends StyledDocument { - - /** The text pane this document is used with necessary for setting the caret position when auto indenting */ - private final EditorPane textPane; - - /** Flag defining if the contained text is being loaded or replaced externally */ - private boolean isReplacingText; - - // Indentation // - - /** Flag defining if auto indentation is enabled */ - private boolean isAutoIndentEnabled = true; - - /** Flag defining if spaces must be used for indentation; otherwise tabulation characters are being used */ - private boolean useSpacesForIndentation = false; - - /** Tab size (column width) */ - private int tabSize = 4; // Default is every 4th column - - /** Java language quote delimiter characters represented in a string */ - private static final String QUOTE_DELIMITERS = "\"'"; - - /** Java keywords */ - private static final Set KEYWORDS = new HashSet( - Arrays.asList( - new String[] { - "abstract", "assert", "boolean", "break", "byte", "case", "catch", "char", "class", "const", "continue", - "default", "do", "double", "else", "enum", "extends", "final", "finally", "float", "for", "goto", "if", - "implements", "import", "instanceof", "int", "interface", "long", "native", "new", "package", "private", - "protected", "public", "return", "short", "static", "strictfp", "super", "switch", "synchronized", "this", - "throw", "throws", "transient", "try", "void", "volatile", "while" })); - - /** Predefined Java literals */ - private static final Set PREDEFINED_LITERALS = new HashSet( - Arrays.asList(new String[] { "false", "true", "null" })); - - /** Normal text attribute set */ - private final SimpleAttributeSet normalAttrSet = new SimpleAttributeSet(); - - /** Quoted text attribute set */ - private final SimpleAttributeSet quoteAttrSet = new SimpleAttributeSet(); - - /** Keyword attribute set */ - private final SimpleAttributeSet keywordAttrSet = new SimpleAttributeSet(); - - /** Predefined literal attribute set */ - private final SimpleAttributeSet literalAttrSet = new SimpleAttributeSet(); - - /** Annotation attribute set */ - private final SimpleAttributeSet annotationAttrSet = new SimpleAttributeSet(); - - /** Comment attribute set */ - private SimpleAttributeSet commentAttrSet = new SimpleAttributeSet(); - - /** String buffer holding only space characters for fast replacement of tabulator characters */ - private String spaceBuffer; - - /** Old start offset for syntax highlighting */ - private int lastSyntaxHighlightStartOffset; - - /** Old end offset for syntax highlighting */ - private int lastSyntaxHighlightEndOffset; - - private int autoIndentationCaretPos = -1; - - private boolean updateSyntaxHighlightingEDTidle = true; - - /** - * Constructor that creates a Java document. - * - * @param textPane - * is the text pane that this Java documents must apply to. - */ - public JavaDocument(EditorPane textPane) { - super(); - this.textPane = textPane; - - // Setup text colors and styles - setTextColorsAndStyles(null); - - // Setup document listener in order to update caret position and update syntax highlighting - addDocumentListener(new JavaDocumentListener()); - - // Setup editor properties change listener - EditorThemePropertiesManager.addListener(new EditorThemePropertyChangeAdapter() { - @Override - public void onNormalTextColorChanged(Color newColor) { - setNormalTextColor(newColor); - updateSyntaxHighlighting(true); - } - - @Override - public void onNormalTextStyleChanged(FontStyle newStyle) { - setNormalTextStyle(newStyle); - updateSyntaxHighlighting(true); - } - - @Override - public void onQuotedTextColorChanged(Color newColor) { - setQuotedTextColor(newColor); - updateSyntaxHighlighting(true); - } - - @Override - public void onQuotedTextStyleChanged(FontStyle newStyle) { - setQuotedTextStyle(newStyle); - updateSyntaxHighlighting(true); - } - - @Override - public void onKeywordTextColorChanged(Color newColor) { - setKeywordTextColor(newColor); - updateSyntaxHighlighting(true); - } - - @Override - public void onKeywordTextStyleChanged(FontStyle newStyle) { - setKeywordTextStyle(newStyle); - updateSyntaxHighlighting(true); - } - - @Override - public void onLiteralTextColorChanged(Color newColor) { - setLiteralTextColor(newColor); - updateSyntaxHighlighting(true); - } - - @Override - public void onLiteralTextStyleChanged(FontStyle newStyle) { - setLiteralTextStyle(newStyle); - updateSyntaxHighlighting(true); - } - - @Override - public void onAnnotationTextColorChanged(Color newColor) { - setAnnotationTextColor(newColor); - updateSyntaxHighlighting(true); - } - - @Override - public void onAnnotationTextStyleChanged(FontStyle newStyle) { - setAnnotationTextStyle(newStyle); - updateSyntaxHighlighting(true); - } - - @Override - public void onCommentTextColorChanged(Color newColor) { - setCommentTextColor(newColor); - updateSyntaxHighlighting(true); - } - - @Override - public void onCommentTextStyleChanged(FontStyle newStyle) { - setCommentTextStyle(newStyle); - updateSyntaxHighlighting(true); - } - }); - - // Setup change listener and focus listener on the viewport of the text pane - - JViewport viewport = textPane.getViewport(); - - viewport.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - updateSyntaxHighlighting(false); - } - }); - - viewport.addFocusListener(new FocusListener() { - public void focusGained(FocusEvent e) { - updateSyntaxHighlighting(false); - } - - public void focusLost(FocusEvent e) {} - }); - } - - /** - * Checks if auto indentation is enabled. - * - * @return true if auto indentation is enabled; false otherwise. - */ - public boolean isAutoIndentEnabled() { - return isReplacingText ? false : isAutoIndentEnabled; - } - - /** - * Enable or disable auto indentation. - * - * @param enable is set to true, if auto indentation must be enabled; false is auto indentation must be disabled. - */ - public void setAutoIndentEnabled(boolean enable) { - isAutoIndentEnabled = enable; - } - - /** - * Checks if the contained text is currently being replaced externally. - * - * @return true if the text is being replaced; false otherwise. - */ - public boolean isReplacingText() { - return isReplacingText; - } - - /** - * Sets the flag if the contained text is currently being replaced externally or not. - * - * @param isReplacingText is true if the text is currently being replaced; false otherwise. - */ - public void setReplacingText(boolean isReplacingText) { - this.isReplacingText = isReplacingText; - } - - @Override - public void insertString(int offset, String str, AttributeSet a) throws BadLocationException { - // Process auto indentation on inserted string - final Indentation indent = applyAutoIndentation(offset, str); - - // Replace indentation tabulation characters with spaces if spaces must be used instead of tabulation characters - str = replaceTabulatorCharacters(getEndOffset(getElementFromOffset(offset)), indent.text); - - // Set the new caret position on the text pane if the caret position has been set - autoIndentationCaretPos = indent.caretPos; - - // Insert the modified string using the original method for inserting string into this document - super.insertString(offset, str, a); - } - - /** - * Sets the tabulation column size. - * - * @param tabSize - * is the new tabulation column size, which must be >= 1. - */ - public void setTabSize(int tabSize) { - this.tabSize = tabSize; - } - - private void setTextColorsAndStyles(IEditorThemeProperties themeProps) { - if (themeProps == null) { - themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - } - setNormalTextColor(themeProps.getNormalTextColor()); - setNormalTextStyle(themeProps.getNormalTextStyle()); - setQuotedTextColor(themeProps.getQuotedTextColor()); - setQuotedTextStyle(themeProps.getQuotedTextStyle()); - setKeywordTextColor(themeProps.getKeywordTextColor()); - setKeywordTextStyle(themeProps.getKeywordTextStyle()); - setLiteralTextColor(themeProps.getLiteralTextColor()); - setLiteralTextStyle(themeProps.getLiteralTextStyle()); - setAnnotationTextColor(themeProps.getAnnotationTextColor()); - setAnnotationTextStyle(themeProps.getAnnotationTextStyle()); - setCommentTextColor(themeProps.getCommentTextColor()); - setCommentTextStyle(themeProps.getCommentTextStyle()); - } - - private void setNormalTextColor(Color newColor) { - StyleConstants.setForeground(normalAttrSet, newColor); - } - - private void setNormalTextStyle(FontStyle newStyle) { - StyleConstants.setBold(normalAttrSet, newStyle.isBold()); - StyleConstants.setItalic(normalAttrSet, newStyle.isItalic()); - } - - private void setQuotedTextColor(Color newColor) { - StyleConstants.setForeground(quoteAttrSet, newColor); - } - - private void setQuotedTextStyle(FontStyle newStyle) { - StyleConstants.setBold(quoteAttrSet, newStyle.isBold()); - StyleConstants.setItalic(quoteAttrSet, newStyle.isItalic()); - } - - private void setKeywordTextColor(Color newColor) { - StyleConstants.setForeground(keywordAttrSet, newColor); - } - - private void setKeywordTextStyle(FontStyle newStyle) { - StyleConstants.setBold(keywordAttrSet, newStyle.isBold()); - StyleConstants.setItalic(keywordAttrSet, newStyle.isItalic()); - } - - private void setLiteralTextColor(Color newColor) { - StyleConstants.setForeground(literalAttrSet, newColor); - } - - private void setLiteralTextStyle(FontStyle newStyle) { - StyleConstants.setBold(literalAttrSet, newStyle.isBold()); - StyleConstants.setItalic(literalAttrSet, newStyle.isItalic()); - } - - private void setAnnotationTextColor(Color newColor) { - StyleConstants.setForeground(annotationAttrSet, newColor); - } - - private void setAnnotationTextStyle(FontStyle newStyle) { - StyleConstants.setBold(annotationAttrSet, newStyle.isBold()); - StyleConstants.setItalic(annotationAttrSet, newStyle.isItalic()); - } - - private void setCommentTextColor(Color newColor) { - StyleConstants.setForeground(commentAttrSet, newColor); - } - - private void setCommentTextStyle(FontStyle newStyle) { - StyleConstants.setBold(commentAttrSet, newStyle.isBold()); - StyleConstants.setItalic(commentAttrSet, newStyle.isItalic()); - } - - /** - * Applies indentation for an inserted string at a given offset if auto indentation is enabled. - * - * @param offset - * is the offset of the inserted string. - * @param str - * is the inserted string. - * @return an Indentation container with indentation details. - * @throws BadLocationException - */ - private Indentation applyAutoIndentation(int offset, String str) throws BadLocationException { - // Prepare indentation container - Indentation indentation = new Indentation(); - - indentation.caretPos = -1; // Meaning that caret position is not changed - indentation.text = str; - - // Apply auto indentation if it is enabled, and the new line character has been entered - if (isAutoIndentEnabled() && str.equals("\n")) { - - // Save the current indentation for later, as it might change from here on - int currentIndentation = getIndentationLengthFromOffset(offset); - - // Read the line content from the offset - String line = getLineFromOffset(offset); - - // Calculate the end offset of the line - int lineEndOffset = getElementFromOffset(offset).getStartOffset() + line.length(); - - // Continue if the line has content and the offset is after the line end offset - if (line.length() > 0 && offset >= lineEndOffset) { - - // Check/compose and return a body start indentation a '{' is found - if (composeBodyStartIndentation(offset, line, indentation)) { - return indentation; - } - // Check/compose and return a multiline comment start indentation if a '/*' is found - if (composeMultilineCommentStartIndentation(offset, line, indentation)) { - return indentation; - } - // Check/compose and return a continued multiline comment if a '*' is found inside a multiline comment - if (composeMultilineCommentContinuedIndentation(offset, line, indentation)) { - return indentation; - } - // Check/compose and return a multiline comment end indentation if a '*/' is found - if (composeMultilineCommentEndIndentation(offset, line, indentation)) { - return indentation; - } - // Extend the current indentation text based on the current indentation - // Note: Will replace tabulator characters with spaces etc. if this must be done. - indentation.text += getStartIndentation(currentIndentation); // FIXME - } - } - return indentation; - } - - /** - * Returns a string where tabulator characters in the given string is replaced with spaces, but only if these must - * be replaced with spaces by configuration. - * - * @param startIndex - * is the start index of the string in a line used for determine the current tabulator column. - * @param str - * is the string containing tabulator characters that might need to be replaced with spaces. - * @return a string where tabulator characters might have been replaced with spaces. - */ - private String replaceTabulatorCharacters(int startIndex, String str) { - // Check if tabulator characters needs to be replaced with space characters - if (useSpacesForIndentation) { - // Prepare string buffer containing replaced text - StringBuilder sb = new StringBuilder(); - - int tabIndex; // Index of current tabulator character - - // Run loop as long as we find a tabulator character from the start index - while ((tabIndex = str.indexOf('\t', startIndex)) >= 0) { - // Put the current text (non tabulator characters) into the string buffer - sb.append(str.substring(startIndex, tabIndex)); - - // Calculate the number of spaces that remain before the next tabulator column - int numSpaces = tabSize - (sb.length() % tabSize); - - // Run loop while the follower character is a tabulator character - while (++tabIndex < str.length() && str.charAt(tabIndex) == '\t') { - // Increment the number of spaces that to use to replace tabulator characters with the tabulator - // column size. - numSpaces += tabSize; - } - // Append the calculated number of space characters to replace the tabulator characters - sb.append(getSpaces(numSpaces)); - - // The new start index is the current tabulator index - startIndex = tabIndex; - } - // Append the text that remain to the string buffer from the current start index - sb.append(str.substring(startIndex)); - - // Set the result to the build string from the string buffer - str = sb.toString(); - } - // Return the resulting string - return str; - } - - /** - * Returns a string containing a specific number of spaces only. - * - * @param count - * is the number of spaces the the string should contain. - * @return a string containing only the given number of space characters. - */ - private String getSpaces(int count) { - if (count == 0) { - return ""; - } - // Determine the current buffer size - int bufferSize = (spaceBuffer == null) ? 0 : spaceBuffer.length(); - - // Check if we need to reallocate the buffer to accommodate the given number of spaces - if (count > bufferSize) { - // Determine the new buffer size, which is set to twice the number of spaces, but minimum 100 characters - bufferSize = Math.max(2 * count, 100); - // Create a new string containing spaces with the new buffer size - char[] chars = new char[bufferSize]; - - Arrays.fill(chars, ' '); - spaceBuffer = new String(chars); - } - // Return a string containing the given number of spaces - return spaceBuffer.substring(0, count); - } - - /** - * Composes a body start indentation block starting with a '{' and ending with a '}' and update the caret position. - * - * @param offset - * is the offset of the inserted string. - * @param line - * is the line, where the indentation block must be appended to. - * @param indentation - * is containing the current indentation date. - * @return true if a body start indentation block should be inserted after the given line; false otherwise. - * @throws BadLocationException - */ - private boolean composeBodyStartIndentation(int offset, String line, Indentation indentation) - throws BadLocationException { - // Check if the given line ends with a body start character, i.e. '{' - if (line.endsWith("{")) { - // We only start a new body indentation if the number of body start characters in the first part of the - // text up to specified offset lesser than the number of body end characters in the last part of the text - String textFirstHalf = getText(0, offset); - String textLastHalf = getText(offset, getLength() - offset); - if (StringUtil.countChar(textLastHalf, '}') >= StringUtil.countChar(textFirstHalf, '{')) { - return false; - } - // Calculated current start indentation length from the given offset - int startIndentLen = getIndentationLengthFromOffset(offset); - // Calculate the start indentation string - String startIndent = getStartIndentation(startIndentLen); - // Prapare buffer for containing the indentation block - StringBuilder sb = new StringBuilder("\n"); - - // Append new indented line to the buffer, that is indented based on the start indentation - sb.append(getStartIndentation(startIndentLen + tabSize)).append('\n'); - // Update the caret position to be placed in the end of the new indented line - indentation.caretPos = offset + sb.toString().length() - 1; - // Append the body end character on a new line - sb.append(startIndent).append('}'); - // Set the indentation block text to the string containing from the buffer - indentation.text = sb.toString(); - // Indentation block was created - return true; - } - // Indentation block was not created - return false; - } - - /** - * Composes a multiline comment start indentation block. - * - * @param offset - * is the offset of the inserted string. - * @param line - * is the line, where the indentation block must be appended to. - * @param indentation - * is containing the current indentation date. - * @return true if a multiline comment start indentation block should be inserted after the given line; false - * otherwise. - * @throws BadLocationException - */ - private boolean composeMultilineCommentStartIndentation(int offset, String line, Indentation indentation) - throws BadLocationException { - - // Check if the given line contains a multiline start string, i.e. '/*' - if (line.trim().startsWith("/*")) { - // Calculated current start indentation length from the given offset - int startIndentLen = getIndentationLengthFromOffset(offset); - // Calculate the start indentation string - String startIndent = getStartIndentation(startIndentLen); - // Prepare buffer for containing the indentation block - StringBuilder sb = new StringBuilder("\n"); - - // Append new indented multiline comment line to the buffer, that is indented based on the start indentation - sb.append(startIndent).append(" * \n"); - // Update the caret position to be placed in the end of the new indented line - indentation.caretPos = offset + sb.toString().length() - 1; - // Append the multiline comment end character on a new line - sb.append(startIndent).append(" */"); - // Set the indentation block text to the string containing from the buffer - indentation.text = sb.toString(); - // Indentation block was created - return true; - } - // Indentation block was not created - return false; - } - - /** - * Composes a continued multiline comment indentation block. - * - * @param offset - * is the offset of the inserted string. - * @param line - * is the line, where the indentation block must be appended to. - * @param indentation - * is containing the current indentation date. - * @return true if a continued multiline comment indentation block should be inserted after the given line; false - * otherwise. - * @throws BadLocationException - */ - private boolean composeMultilineCommentContinuedIndentation(int offset, String line, Indentation indentation) - throws BadLocationException { - - // Check if the given line contains a '*' and is located inside of a multiline comment - if (line.trim().startsWith("*") && isInMultilineComment(offset)) { - // Calculated current start indentation length from the given offset - int startIndentLen = getIndentationLengthFromOffset(offset); - // Calculate the start indentation string - String startIndent = getStartIndentation(startIndentLen); - // Prepare buffer for containing the indentation block - StringBuilder sb = new StringBuilder("\n"); - - // Append new indented multiline comment line to the buffer, that is indented based on the start indentation - sb.append(startIndent).append("* "); - // Update the caret position to be placed in the end of the new indented line - indentation.caretPos = offset + sb.toString().length(); - // Set the indentation block text to the string containing from the buffer - indentation.text = sb.toString(); - // Indentation block was created - return true; - } - // Indentation block was not created - return false; - } - - /** - * Composes a multiline end start indentation block. - * - * @param offset - * is the offset of the inserted string. - * @param line - * is the line, where the indentation block must be appended to. - * @param indentation - * is containing the current indentation date. - * @return true if a multiline comment end indentation block should be inserted after the given line; false - * otherwise. - * @throws BadLocationException - */ - private boolean composeMultilineCommentEndIndentation(int offset, String line, Indentation indentation) - throws BadLocationException { - - // Check if the given line contains a multiline end string, i.e. '*/' - if (line.trim().endsWith("*/")) { - // Get the line index from the current offset - int lineIndex = getElementIndex(offset); - - // Run loop as long as the line index is still positive (till the start of the document text) - while (lineIndex >= 0) { - // Check if the current line line is not in a multiline comment - int lineOffset = getElement(lineIndex).getStartOffset(); - - if (!isInMultilineComment(lineOffset)) { - // Append indentation that matches the start offset of the current line - indentation.text += getStartIndentation(getIndentationLengthFromOffset(lineOffset)); - break; - } - // Move to previous line - lineIndex--; - } - // Indentation block was created - return true; - } - // Indentation block was not created - return false; - } - - /** - * Returns line from the specified offset where trailing white spaces are removed. Note: The white spaces in the - * beginning of the line is not removed as these serve to determine start indentation for inserted lines following - * this line. - * - * @param offset - * is the offset to retrieve the line from. - * @return the line at the given offset where trailing white spaces have been trimmed. - * @throws BadLocationException - */ - private String getLineFromOffset(int offset) throws BadLocationException { - // Get the start and end index of the line - Element element = getElementFromOffset(offset); - int start = element.getStartOffset(); - int end = getEndOffset(element); - - if (end == start) { - return ""; - } - - // Get the line content - String origLine = getText(start, end - start); - // Trim trailing white spaces - String trimmedLine = origLine.replaceAll("\\s*$", ""); - - // Return the trimmed line, but only if it did not contain only white spaces as we need the white spaces for - // indentation for lines inserted after this line. - return trimmedLine.length() > 0 ? trimmedLine : origLine; - } - - /** - * Calculates and returns the indentation length (number of space characters) of the line at the given offset. - * - * @param offset - * is the document offset of the line. - * @return the calculated indentation length of the line at the given offset. - * @throws BadLocationException - */ - private int getIndentationLengthFromOffset(int offset) throws BadLocationException { - // Gets the start offset of the line at the given offset - int startOffset = getElementFromOffset(offset).getStartOffset(); - - // Run loop while the next character is a space of tabulator character. - int length = 0; - - for (;;) { - // Get the next character - char ch = getText(startOffset++, 1).charAt(0); - - if (ch == ' ') { - // Increment the length by 1 if the character is a space - length++; - } else if (ch == '\t') { - // Increment the length by the number of spaces the remain in order to reach the next tabulator column, - // if the character is a tabulator character. - length = tabSize * (length / tabSize + 1); - } else { - // Otherwise, stop looping - break; - } - } - // Return the calculated indentation length - return length; - } - - /** - * Returns a start indentation string of the given length. - * - * @param length - * is the length of the indentation measured in number of spaces. - * @return a string to apply to the start of a line in order to indent the line. - */ - private String getStartIndentation(int length) { - if (length == 0) { - return ""; - } - - // Prepare string buffer for containing the indentation string - StringBuilder sb = new StringBuilder(); - - // Check if tabulator characters must be used for indentation - if (!useSpacesForIndentation) { - // Append as many tabulator characters to the indentation string that fits into the given length - for (int i = length / tabSize; i > 0; i--) { - sb.append('\t'); - } - // Set the length to the spaces remaining to reach the input length - length %= tabSize; - } - // Apply spaces to the string buffer (might be the spaces that remain to fit the given length) - sb.append(getSpaces(length)); - // Return the indentation string contained in the string buffer - return sb.toString(); - } - - /** - * Updates the syntax highlighting on the document using the EDT. - */ - private void updateSyntaxHighlighting(final boolean force) { - // Only invoke the EDT, if this operation is not already initiated - if (updateSyntaxHighlightingEDTidle) { - updateSyntaxHighlightingEDTidle = false; - - SwingUtilities.invokeLater(new Runnable() { - public void run() { - try { - // Apply syntax highlighting from the current offset - performSyntaxHighlighting(force); - updateSyntaxHighlightingEDTidle = true; - } catch (BadLocationException e) { - e.printStackTrace(); - } - } - }); - } - } - - /** - * Perform syntax highlighting on the document. This implementation only performs syntax highlighting on the current - * visible text in the view port of the text pane, and detects if the text has been changed before performing the - * syntax highlighting. - * - * @throws BadLocationException - */ - private void performSyntaxHighlighting(boolean force) throws BadLocationException { - // Return if there is nothing to highlight - if (getLength() == 0 && !force) { - return; - } - - // Get the start and end offset of the visible text - - JViewport viewport = textPane.getViewport(); - Point startPoint = viewport.getViewPosition(); - Dimension size = viewport.getExtentSize(); - Point endPoint = new Point(startPoint.x + size.width, startPoint.y + size.height); - - int startOffset = textPane.viewToModel(startPoint); - int endOffset = textPane.viewToModel(endPoint); - - // Return if the current start and end offset is equal to the last ones - if (!force && startOffset == lastSyntaxHighlightStartOffset && endOffset == lastSyntaxHighlightEndOffset) { - return; - } - - lastSyntaxHighlightStartOffset = startOffset; - lastSyntaxHighlightEndOffset = endOffset; - - setCharacterAttributes(startOffset, endOffset - startOffset, normalAttrSet, true); - - // Get start and end line - int startLine = getElementIndex(startOffset); - int endLine = getElementIndex(endOffset); - - // Process each changed line one by one from the start line to the end line - for (int line = startLine; line <= endLine; line++) { - processChangedLine(line); - } - } - - /** - * Process changed line by applying syntax highlighting on the entire line at the given index. - * - * @param lineIndex - * is the index of the line. - * @throws BadLocationException - */ - private void processChangedLine(int lineIndex) throws BadLocationException { - // Process the syntax tokens on the given line - Element element = getElement(lineIndex); - - processLineTokens(element.getStartOffset(), getEndOffset(element)); - } - - /** - * Process the syntax tokens contained in a line. - * - * @param startOffset - * is the document start offset of the line to process. - * @param endOffset - * is the document end offset of the line to process. - * @throws BadLocationException - */ - private void processLineTokens(int startOffset, int endOffset) throws BadLocationException { - // Calculate the length of the line based on the given start and end offset - int len = endOffset - startOffset; - - // Process tokens one by one - String textFragment = getText(startOffset, len); - int index = 0; - - while (index < len) { - index += processToken(textFragment.substring(index), startOffset + index); - } - } - - /** - * Process the syntax token contained in a text fragment. - * - * @param textFragment - * is the text fragment. - * @param startOffset - * is the start offset of the text fragment to process. - * @return the number of processed characters. - * @throws BadLocationException - */ - private int processToken(final String textFragment, final int startOffset) throws BadLocationException { - // Process quote token if the first character in the text fragment is a quote delimiter - if (isQuoteDelimiter(textFragment.charAt(0))) { - return processQuoteToken(textFragment, startOffset); - } - int len; - - // Check if the token is a single line comment - // Note: Single line comment has higher precedence than a multiline comment. - if (textFragment.startsWith("//")) { - len = textFragment.length(); - setCharacterAttributes(startOffset, len, commentAttrSet, true); - return len; - } - // Check if the token is a multiline comment - if (textFragment.startsWith("/*")) { - return processStartMultilineCommentToken(textFragment, startOffset); - } - // Check if the token is in the middle of a multiline comment - if (isInMultilineComment(startOffset)) { - // Check if the token contains the end mark of the multiline comment - int endCommentIndex = textFragment.indexOf("*/"); - - if (endCommentIndex >= 0) { - len = endCommentIndex + 2; // Limit length to the end mark - } else { - len = textFragment.length(); // Use the whole token - } - setCharacterAttributes(startOffset, len, commentAttrSet, true); - return len; - } - - // Skip delimiter characters - len = 1; - while (len < textFragment.length()) { - char ch = textFragment.charAt(len); - - if (!Character.isLetter(ch)) { - break; - } - len++; - } - - // Limit token to current length, e.g. if it contained delimiter characters - String token = textFragment.substring(0, len); - - // Check if the token is a keyword or an annotation - if (startOffset > 0 && !Character.isLetter(getText(startOffset - 1, 1).charAt(0)) || startOffset == 0) { - if (isKeyword(token)) { - setCharacterAttributes(startOffset, len, keywordAttrSet, true); - } else if (isPredefinedLiteral(token)) { - setCharacterAttributes(startOffset, len, literalAttrSet, true); - } else if (isAnnotation(token)) { - setCharacterAttributes(startOffset, len, annotationAttrSet, true); - } else { - len = 1; - } - } else { - len = 1; - } - // Return the number of processed characters - return len; - } - - /** - * Process a quote token. - * - * @param textFragment - * is the text fragment. - * @param startOffset - * is the start offset of the text fragment to process. - * @return the number of processed characters. - * @throws BadLocationException - */ - private int processQuoteToken(final String textFragment, final int startOffset) { - char quoteDelimiter = textFragment.charAt(0); - - // Find end quote if it exists. Ignore escaped quotes - int indexQuote = 1; - int quoteEndIndex = -1; - - for (;;) { - indexQuote = textFragment.indexOf(quoteDelimiter, indexQuote); - if (indexQuote <= 0 || indexQuote > textFragment.length()) { - break; - } - if (textFragment.charAt(indexQuote - 1) != '\\') { - quoteEndIndex = indexQuote; - break; - } - indexQuote++; - } - - // Set length of token, if end quote was found - int len = quoteEndIndex >= 0 ? quoteEndIndex + 1 : textFragment.length(); - - // Set quote attribute set - setCharacterAttributes(startOffset, len, quoteAttrSet, true); - - return len; - } - - /** - * Process a multiline comment token. - * - * @param textFragment - * is the text fragment. - * @param startOffset - * is the start offset of the text fragment to process. - * @return the number of processed characters. - * @throws BadLocationException - */ - private int processStartMultilineCommentToken(final String textFragment, final int startOffset) { - int endIndex = textFragment.indexOf("*/", 1); - int len = endIndex >= 0 ? endIndex + 2 : textFragment.length(); - - setCharacterAttributes(startOffset, len, commentAttrSet, true); - - return len; - } - - /** - * Checks if the current text offset is within a multiline comment. - * - * @param offset - * is the text offset. - * @return true if the given offset is within a multiline comment; false otherwise. - * @throws BadLocationException - */ - private boolean isInMultilineComment(final int offset) throws BadLocationException { - return isInMultilineComment(getElementIndex(offset), offset); - } - - /** - * Checks if the current text offset is within a multiline comment. - * - * @oaram lineIndex is the element index of a line. - * @param offset - * is the text offset. - * @return true if the given line element index and offset is within a multiline comment; false otherwise. - * @throws BadLocationException - */ - private boolean isInMultilineComment(final int lineIndex, final int offset) throws BadLocationException { - int startOffset = getElement(lineIndex).getStartOffset(); - String lineText = getLineFromOffset(startOffset); - int len = Math.min((offset - startOffset), lineText.length()); - - lineText = lineText.substring(0, len); - - int commentStart = lineText.lastIndexOf("/*"); - int commentEnd = lineText.lastIndexOf("*/"); - - if (commentStart >= 0) { - if (commentEnd >= 0) { - if (commentEnd > commentStart) { - return (len < commentEnd); - } - } else { - return true; - } - } - if (commentEnd >= 0) { - return false; - } - - int prevLine = lineIndex - 1; - - return (prevLine >= 0) ? isInMultilineComment(prevLine, offset) : false; - } - - /** - * Checks if a character is a quote delimiter character. - * - * @param ch - * is the character. - * @return true if the given character is a quote delimiter character; false otherwise. - */ - private static boolean isQuoteDelimiter(char ch) { - return QUOTE_DELIMITERS.indexOf(ch) >= 0; - } - - /** - * Checks if a token is a keyword. - * - * @param token - * is the token. - * @return true if the given token is a keyword; false otherwise. - */ - private static boolean isKeyword(String token) { - return KEYWORDS.contains(token); - } - - /** - * Checks if a token is a predefined literal. - * - * @param token - * is the token. - * @return true if the given token is a predefined literal; false otherwise. - */ - private static boolean isPredefinedLiteral(String token) { - return PREDEFINED_LITERALS.contains(token); - } - - /** - * Checks if a token is an annotation. - * - * @param token - * is the token. - * @return true if the given token is an annotation; false otherwise. - */ - private static boolean isAnnotation(String token) { - return token.matches("@\\w.*"); - } - - /** - * Class containing data for indentation. - */ - private class Indentation { - // Is the new caret position after the indentation has been made. -1 means no change. - int caretPos; - // Is the indentation text - String text; - } - - - /** - * This document listener is used for updating the caret position and update syntax highlighting when the contents - * of the document is changed. - */ - private class JavaDocumentListener implements DocumentListener { - - // Caret position updater - final CaretPositionUpdater caretPositionUpdater = new CaretPositionUpdater(); - - public void insertUpdate(final DocumentEvent e) { - int newCaretPosition; - - // Check if the caret position has been changed by auto indentation - if (autoIndentationCaretPos >= 0) { - // Set the new caret position to the one set for auto indentation - newCaretPosition = autoIndentationCaretPos; - // Signal that the caret position for auto indentation has been set - autoIndentationCaretPos = -1; - } else { - // Set the new caret position to the end of the inserted text - newCaretPosition = e.getOffset() + e.getLength(); - } - // Update the caret position to the new position - caretPositionUpdater.updateCaretPosition(newCaretPosition); - - // Apply syntax highlighting from the current offset - updateSyntaxHighlighting(false); - } - - public void removeUpdate(final DocumentEvent e) { - // Set the caret position where the text was removed. - caretPositionUpdater.updateCaretPosition(e.getOffset()); - - // Apply syntax highlighting from the current offset - updateSyntaxHighlighting(false); - } - - public void changedUpdate(DocumentEvent e) {} - - private final class CaretPositionUpdater { - - /** - * Updates the caret position via the EDT. - * - * @param newCaretPosition is the new caret position. - */ - public void updateCaretPosition(int newCaretPosition) { - // Set the caret position, and take care that it is not out of range - textPane.setCaretPosition(Math.min(newCaretPosition, getLength())); - } - } - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/LineHighlighter.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/LineHighlighter.java deleted file mode 100644 index 6f8a7e1..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/LineHighlighter.java +++ /dev/null @@ -1,141 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import java.awt.Color; -import java.awt.Graphics; -import java.awt.Rectangle; -import java.awt.Shape; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionAdapter; -import java.awt.event.MouseMotionListener; - -import javax.swing.event.CaretEvent; -import javax.swing.event.CaretListener; -import javax.swing.text.BadLocationException; -import javax.swing.text.Highlighter; -import javax.swing.text.JTextComponent; - -import net.sf.robocode.ui.editor.theme.EditorThemePropertiesManager; -import net.sf.robocode.ui.editor.theme.EditorThemePropertyChangeAdapter; - - -/** - * Class used for highlighting the current line for a JTextComponent. - * - * @author Santhosh Kumar T (original) - * @author Peter De Bruycker (contributor) - * @author Flemming N. Larsen (contributor) - */ -public final class LineHighlighter { - private static final String LINE_HIGHLIGHT = "line-highlight"; - private static final String PREVIOUS_CARET = "previous-caret"; - - private static Color color; // Color used for highlighting the line - - private LineHighlighter() {} - - /** - * Installs CurrentLineHilighter for the given JTextComponent. - * @param c is the text component - */ - public static void install(JTextComponent c) { - try { - Object obj = c.getHighlighter().addHighlight(0, 0, painter); - c.putClientProperty(LINE_HIGHLIGHT, obj); - c.putClientProperty(PREVIOUS_CARET, new Integer(c.getCaretPosition())); - c.addCaretListener(caretListener); - c.addMouseListener(mouseListener); - c.addMouseMotionListener(mouseMotionListener); - - color = EditorThemePropertiesManager.getCurrentEditorThemeProperties().getHighlightedLineColor(); - EditorThemePropertiesManager.addListener(editorThemePropertyChangeListener); - } catch (BadLocationException ex) {} - } - - /** - * Uninstalls CurrentLineHighligher for the given JTextComponent. - * @param c is the text component - */ - public static void uninstall(JTextComponent c) { - c.putClientProperty(LINE_HIGHLIGHT, null); - c.putClientProperty(PREVIOUS_CARET, null); - c.removeCaretListener(caretListener); - c.removeMouseListener(mouseListener); - c.removeMouseMotionListener(mouseMotionListener); - EditorThemePropertiesManager.removeListener(editorThemePropertyChangeListener); - } - - /** - * Fetches the previous caret location, stores the current caret location, - * If the caret is on another line, repaint the previous line and the current line - * @param c is the text component - */ - private static void caretUpdate(JTextComponent c) { - try { - int previousCaret = ((Integer) c.getClientProperty(PREVIOUS_CARET)).intValue(); - final int actualCaretPosition = c.getCaretPosition(); - c.putClientProperty(PREVIOUS_CARET, new Integer(actualCaretPosition)); - Rectangle prev = c.modelToView(previousCaret); - Rectangle r = c.modelToView(actualCaretPosition); - // c.putClientProperty(PREVIOUS_CARET, new Integer(actualCaretPosition)); - - if (prev != null && prev.y != r.y) { - c.repaint(0, prev.y, c.getWidth(), r.height); - c.repaint(0, r.y, c.getWidth(), r.height); - } - } catch (BadLocationException ignore) {} - } - - private static CaretListener caretListener = new CaretListener() { - @Override - public void caretUpdate(CaretEvent e) { - JTextComponent c = (JTextComponent) e.getSource(); - LineHighlighter.caretUpdate(c); - } - }; - - private static MouseListener mouseListener = new MouseAdapter() { - // highlight the line the user clicks on - @Override - public void mousePressed(MouseEvent e) { - JTextComponent c = (JTextComponent) e.getSource(); - caretUpdate(c); - } - }; - - private static MouseMotionListener mouseMotionListener = new MouseMotionAdapter() { - @Override - public void mouseDragged(MouseEvent e) { - JTextComponent c = (JTextComponent) e.getSource(); - caretUpdate(c); - } - }; - - private static EditorThemePropertyChangeAdapter editorThemePropertyChangeListener = new EditorThemePropertyChangeAdapter() { - public void onHighlightedLineColorChanged(Color newColor) { - if (!color.equals(newColor)) { - color = newColor; - } - } - }; - - private static Highlighter.HighlightPainter painter = new Highlighter.HighlightPainter() { - @Override - public void paint(Graphics g, int p0, int p1, Shape bounds, JTextComponent c) { - try { - Rectangle r = c.modelToView(c.getCaretPosition()); - g.setColor(color); - g.fillRect(0, r.y, c.getWidth(), r.height); - } catch (BadLocationException ignore) {} - } - }; -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/LineNumberArea.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/LineNumberArea.java deleted file mode 100644 index 675ea1f..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/LineNumberArea.java +++ /dev/null @@ -1,137 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import java.awt.Color; -import java.awt.Rectangle; - -import javax.swing.JTextArea; -import javax.swing.SwingUtilities; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.Document; -import javax.swing.text.JTextComponent; - -import net.sf.robocode.ui.editor.theme.EditorThemeProperties; -import net.sf.robocode.ui.editor.theme.EditorThemePropertiesManager; -import net.sf.robocode.ui.editor.theme.EditorThemePropertyChangeAdapter; - - -/** - * A text area containing line numbers for the editor pane and editor panel. - * - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class LineNumberArea extends JTextArea { - - private final DocumentListener documentListener = new TextDocumentListener(); - - public LineNumberArea(JTextComponent textComponent) { - super("1"); - - setEditable(false); - setLineWrap(false); - - EditorThemeProperties themeProps = EditorThemePropertiesManager.getCurrentEditorThemeProperties(); - setBackgroundColor(themeProps.getLineNumberBackgroundColor()); - setTextColor(themeProps.getLineNumberTextColor()); - - textComponent.getDocument().addDocumentListener(documentListener); - - EditorThemePropertiesManager.addListener(new EditorThemePropertyChangeAdapter() { - @Override - public void onLineNumberBackgroundColorChanged(Color newColor) { - setBackgroundColor(newColor); - } - - @Override - public void onLineNumberTextColorChanged(Color newColor) { - setTextColor(newColor); - } - }); - } - - private class TextDocumentListener implements DocumentListener { - int lastNumLines = 1; - - public void insertUpdate(DocumentEvent e) { - updateText(e.getDocument()); - } - - public void removeUpdate(DocumentEvent e) { - updateText(e.getDocument()); - } - - public void changedUpdate(DocumentEvent e) { - updateText(e.getDocument()); - } - - private void updateText(final Document doc) { - - final int numLines = getNumLines(doc); - - if (numLines == lastNumLines) { - return; - } - lastNumLines = numLines; - - SwingUtilities.invokeLater(new Runnable() { - public void run() { - final Rectangle visibleRect = getVisibleRect(); - - setIgnoreRepaint(true); // avoid flickering - setText(generateLinesText(numLines)); - - // Must be done this way to keep aligned with scroll bar! - SwingUtilities.invokeLater(new Runnable() { - public void run() { - scrollRectToVisible(visibleRect); - setIgnoreRepaint(false); // avoid flickering - } - }); - } - }); - } - - /** - * Returns a string containing text lines for all line numbers. - * Each line number is right-aligned and ended a space + a new-line character. - * - * @param numLines is the number of lines to create the line number text for. - * @return a string containing line numbers. - */ - private String generateLinesText(int numLines) { - String format = "%" + ("" + (numLines + 1)).length() + "s "; - - StringBuilder lines = new StringBuilder(); - int i = 1; - while (i <= numLines) { - String s = String.format(format, "" + i++); - lines.append(s).append('\n'); - } - lines.append(String.format(format, "" + i)); - return lines.toString(); - } - - private int getNumLines(Document doc) { - return doc.getDefaultRootElement().getElementIndex(doc.getLength()); - } - } - - private void setBackgroundColor(Color newBackgroundColor) { - setBackground(newBackgroundColor); - setSelectionColor(newBackgroundColor); - } - - private void setTextColor(Color newTextColor) { - setForeground(newTextColor); - setSelectedTextColor(newTextColor); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/Module.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/Module.java deleted file mode 100644 index 17a07cf..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/Module.java +++ /dev/null @@ -1,23 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import net.sf.robocode.core.BaseModule; -import net.sf.robocode.core.Container; - - -/** - * @author Pavel Savara (original) - */ -public class Module extends BaseModule { - static { - Container.cache.addComponent(RobocodeCompilerFactory.class); - Container.cache.addComponent(RobocodeEditor.class); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/MoreWindowsDialog.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/MoreWindowsDialog.java deleted file mode 100644 index 0154521..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/MoreWindowsDialog.java +++ /dev/null @@ -1,138 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.Vector; - - -/** - * @author Matthew Reeder (original) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class MoreWindowsDialog extends JDialog implements ActionListener, MouseListener { - private JButton activateButton; - private JButton cancelButton; - private JButton closeButton; - private JList windowList; - private final Vector windowListItems; - - public MoreWindowsDialog(RobocodeEditor window) { - super(window, "More Windows...", false); - windowListItems = new Vector(); - JPanel listPanel = new JPanel(new GridLayout(1, 1)); - - listPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Open Windows")); - listPanel.add(new JScrollPane(getWindowList())); - JPanel buttonPanel = new JPanel(); - - buttonPanel.setLayout(new BoxLayout(buttonPanel, BoxLayout.X_AXIS)); - buttonPanel.add(getActivateButton()); - buttonPanel.add(getCancelButton()); - buttonPanel.add(getCloseButton()); - getContentPane().setLayout(new BorderLayout()); - getContentPane().add(buttonPanel, BorderLayout.SOUTH); - getContentPane().add(listPanel); - setSize(400, 400); - } - - public void addWindowItem(WindowMenuItem item) { - windowListItems.add(item); - getWindowList().setListData(windowListItems); - } - - public void removeWindowItem(WindowMenuItem item) { - windowListItems.remove(item); - getWindowList().setListData(windowListItems); - } - - public JButton getActivateButton() { - if (activateButton == null) { - activateButton = new JButton(); - activateButton.setText("Activate"); - activateButton.setMnemonic('A'); - activateButton.setDefaultCapable(true); - activateButton.addActionListener(this); - } - return activateButton; - } - - public JButton getCancelButton() { - if (cancelButton == null) { - cancelButton = new JButton(); - cancelButton.setText("Cancel"); - cancelButton.setMnemonic('C'); - cancelButton.addActionListener(this); - } - return cancelButton; - } - - public JButton getCloseButton() { - if (closeButton == null) { - closeButton = new JButton(); - closeButton.setText("Close"); - closeButton.setMnemonic('l'); - closeButton.setDisplayedMnemonicIndex(1); - closeButton.addActionListener(this); - } - return closeButton; - } - - public JList getWindowList() { - if (windowList == null) { - windowList = new JList(); - windowList.addMouseListener(this); - windowList.setSelectionMode(ListSelectionModel.SINGLE_SELECTION); - } - return windowList; - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == closeButton) { - WindowMenuItem item = (WindowMenuItem) windowList.getSelectedValue(); - - if (item != null && item.getEditWindow() != null) { - item.getEditWindow().doDefaultCloseAction(); - } - } else { - if (e.getSource() == activateButton) { - WindowMenuItem item = (WindowMenuItem) windowList.getSelectedValue(); - - if (item != null) { - item.actionPerformed(null); - } - } - setVisible(false); - } - } - - public void mouseClicked(MouseEvent e) { - if (e.getSource() == getWindowList() && e.getClickCount() == 2) { - WindowMenuItem item = windowListItems.get(windowList.locationToIndex(e.getPoint())); - - item.actionPerformed(null); // Good thing WindowMenuItem doesn't - // reference the ActionEvent? - setVisible(false); - } - } - - public void mousePressed(MouseEvent e) {} - - public void mouseReleased(MouseEvent e) {} - - public void mouseEntered(MouseEvent e) {} - - public void mouseExited(MouseEvent e) {} -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeCompiler.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeCompiler.java deleted file mode 100644 index 2a4f649..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeCompiler.java +++ /dev/null @@ -1,112 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.CodeSizeCalculator; -import net.sf.robocode.ui.dialog.ConsoleDialog; -import net.sf.robocode.ui.dialog.WindowUtil; - -import java.io.File; -import java.io.IOException; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class RobocodeCompiler { - - private final String compilerBinary; - private final RobocodeEditor editor; - private final String compilerOptions; - private final String compilerClassPath; - - protected RobocodeCompiler(RobocodeEditor editor, String binary, String options, String classPath) { - super(); - this.compilerBinary = binary; - this.compilerOptions = options; - this.compilerClassPath = classPath; - this.editor = editor; - } - - public void compile(String directory, String fileName) { - fileName = FileUtil.quoteFileName(fileName); - - ConsoleDialog console; - - if (editor != null) { - console = new ConsoleDialog(editor, "Compiling", false); - } else { - console = new ConsoleDialog(); - } - console.setSize(500, 400); - console.setText("Compiling...\n"); - WindowUtil.centerShow(editor, console); - - try { - StringBuffer command = new StringBuffer(compilerBinary).append(' ').append(compilerOptions).append(' ').append(compilerClassPath).append(' ').append( - fileName); - - Logger.logMessage("Compile command: " + command); - - ProcessBuilder pb = new ProcessBuilder(command.toString().split(" ")); - - pb.redirectErrorStream(true); - pb.directory(FileUtil.getCwd()); - Process p = pb.start(); - - // The waitFor() must done after reading the input and error stream of the process - console.processStream(p.getInputStream()); - p.waitFor(); - - if (p.exitValue() == 0) { - console.append("Compiled successfully.\n"); - console.setTitle("Compiled successfully."); - } else { - console.append("Compile Failed (" + p.exitValue() + ")\n"); - console.setTitle("Compile failed."); - } - } catch (IOException e) { - console.append("Unable to compile!\n"); - console.append("Exception was: " + e.toString() + "\n"); - console.append("Does " + compilerBinary + " exist?\n"); - console.setTitle("Exception while compiling"); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - - console.append("Compile interrupted.\n"); - console.setTitle("Compile interrupted."); - } - - Integer codesize = CodeSizeCalculator.getDirectoryCodeSize(new File(directory)); - if (codesize != null) { - String weightClass = null; - - if (codesize >= 1500) { - weightClass = "MegaBot (codesize >= 1500 bytes)"; - } else if (codesize > 750) { - weightClass = "MiniBot (codesize < 1500 bytes)"; - } else if (codesize > 250) { - weightClass = "MicroBot (codesize < 750 bytes)"; - } else { - weightClass = "NanoBot (codesize < 250 bytes)"; - } - StringBuilder sb = new StringBuilder(); - - sb.append("\n\n---- Codesize ----\n"); - sb.append("Codesize: ").append(codesize).append(" bytes\n"); - sb.append("Robot weight class: ").append(weightClass).append('\n'); - - console.append(sb.toString()); - } - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeCompilerFactory.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeCompilerFactory.java deleted file mode 100644 index 2d515ee..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeCompilerFactory.java +++ /dev/null @@ -1,219 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import net.sf.robocode.core.ContainerBase; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.manager.IVersionManagerBase; -import static net.sf.robocode.io.Logger.logError; -import static net.sf.robocode.io.Logger.logMessage; -import net.sf.robocode.ui.dialog.ConsoleDialog; -import net.sf.robocode.ui.dialog.WindowUtil; - -import javax.swing.*; -import java.io.*; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class RobocodeCompilerFactory { - - private static final String COMPILER_CLASSPATH = "-classpath " + getJavaLib() + File.pathSeparator + "libs" - + File.separator + "robocode.jar" + File.pathSeparator - + FileUtil.quoteFileName(FileUtil.getRobotsDir().toString()); - - private CompilerProperties compilerProperties; - - public RobocodeCompiler createCompiler(RobocodeEditor editor) { - compilerProperties = null; - if (getCompilerProperties().getCompilerBinary() == null - || getCompilerProperties().getCompilerBinary().length() == 0) { - if (configureCompiler(editor)) { - return new RobocodeCompiler(editor, getCompilerProperties().getCompilerBinary(), - getCompilerProperties().getCompilerOptions(), getCompilerProperties().getCompilerClasspath()); - } - logError("Unable to create compiler."); - return null; - } - return new RobocodeCompiler(editor, getCompilerProperties().getCompilerBinary(), - getCompilerProperties().getCompilerOptions(), getCompilerProperties().getCompilerClasspath()); - } - - public CompilerProperties getCompilerProperties() { - if (compilerProperties == null) { - compilerProperties = new CompilerProperties(); - - FileInputStream in = null; - File file = null; - - try { - file = FileUtil.getCompilerConfigFile(); - in = new FileInputStream(file); - compilerProperties.load(in); - if (compilerProperties.getRobocodeVersion() == null) { - logMessage("Setting up new compiler."); - compilerProperties.setCompilerBinary(""); - } - } catch (FileNotFoundException e) { - logMessage("Compiler configuration file was not found. A new one will be created."); - } catch (IOException e) { - logError("Error while reading " + file, e); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException ignored) {} - } - } - } - return compilerProperties; - } - - private static String getJavaLib() { - String javahome = System.getProperty("java.home"); - String javalib; - if (System.getProperty("os.name").indexOf("Mac") == 0) { - javalib = new File(javahome).getParentFile().getPath() + "/Classes/classes.jar"; - } else { - javalib = javahome + "/lib/rt.jar"; - } - - return FileUtil.quoteFileName(javalib); - } - - public boolean configureCompiler(RobocodeEditor editor) { - ConsoleDialog console = new ConsoleDialog(editor, "Setting up compiler", false); - - console.setSize(500, 400); - console.getOkButton().setEnabled(false); - console.setText("Please wait while Robocode sets up a compiler for you...\n\n"); - WindowUtil.centerShow(editor, console); - - console.append("Setting up compiler\n"); - console.append("Java home is " + System.getProperty("java.home") + "\n\n"); - - String compilerName = "Java Compiler (javac)"; - String compilerBinary = "javac"; - String compilerOptions = "-deprecation -g -source 1.6 -encoding UTF-8"; - - boolean javacOK = testCompiler(compilerName, compilerBinary, console); - boolean ecjOK = false; - - if (javacOK) { - int rc = JOptionPane.showConfirmDialog(editor, - "Robocode has found a working javac (Java Compiler) on this system.\nWould you like to use it?\n" - + "(If you click No, Robocode will use the build-in Eclipse Compiler for Java (ECJ))", - "Confirm javac", - JOptionPane.YES_NO_OPTION, - JOptionPane.QUESTION_MESSAGE); - - if (rc == JOptionPane.NO_OPTION) { - javacOK = false; - } - } - - if (!javacOK) { - compilerName = "Eclipse Compiler for Java (ECJ)"; - compilerBinary = "java -cp compilers/ecj.jar org.eclipse.jdt.internal.compiler.batch.Main"; - - ecjOK = testCompiler("Eclipse Compiler for Java (ECJ)", compilerBinary, console); - } - - boolean compilerOK = javacOK || ecjOK; - - if (compilerOK) { - console.append("\nCompiler has been set up successfully.\nClick OK to continue.\n"); - - } else { - final String errorText = "Could not set up a working compiler for Robocode.\n" - + "Please consult the console window for errors.\n\n" - + "For help with this, please post to Help forum here:\n" - + "http://sourceforge.net/projects/robocode/forums/forum/116459"; - - console.append("\nUnable to set up a working compiler for Robocode.\n"); - - JOptionPane.showMessageDialog(editor, errorText, "Error", JOptionPane.ERROR_MESSAGE); - - compilerBinary = ""; - compilerOptions = ""; - } - - getCompilerProperties().setRobocodeVersion(ContainerBase.getComponent(IVersionManagerBase.class).getVersion()); - getCompilerProperties().setCompilerBinary(compilerBinary); - getCompilerProperties().setCompilerOptions(compilerOptions); - getCompilerProperties().setCompilerClasspath(COMPILER_CLASSPATH); - saveCompilerProperties(); - - console.scrollToBottom(); - console.getOkButton().setEnabled(true); - - return compilerOK; - } - - public void saveCompilerProperties() { - FileOutputStream out = null; - - try { - out = new FileOutputStream(FileUtil.getCompilerConfigFile()); - - getCompilerProperties().store(out, "Robocode Compiler Properties"); - } catch (IOException e) { - Logger.logError(e); - } finally { - FileUtil.cleanupStream(out); - } - } - - /** - * Tests a compiler by trying to let it compile the CompilerTest.java file. - * - * @param friendlyName friendly name of the compiler to test. - * @param filepath the file path of the compiler. - * @param console the console which outputs the result. - * @return true if the compiler was found and did compile the test file; false otherwise. - */ - private static boolean testCompiler(String friendlyName, String filepath, ConsoleDialog console) { - console.append("Testing compile with " + friendlyName + "\n"); - - boolean result = false; - - try { - String cmdAndArgs = filepath + " compilers/CompilerTest.java"; - - // Must be split command and arguments individually - ProcessBuilder pb = new ProcessBuilder(cmdAndArgs.split(" ")); - - pb.directory(FileUtil.getCwd()); - pb.redirectErrorStream(true); // we can use p.getInputStream() - Process p = pb.start(); - - // The waitFor() must done after reading the input and error stream of the process - console.processStream(p.getInputStream()); - p.waitFor(); - - result = (p.exitValue() == 0); - - } catch (IOException e) { - logError(e); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - } - - if (result) { - console.append(friendlyName + " was found and is working.\n"); - } else { - console.append(friendlyName + " does not exists or cannot compile.\n"); - } - return result; - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeEditor.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeEditor.java deleted file mode 100644 index 2a13525..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeEditor.java +++ /dev/null @@ -1,664 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.IRepositoryManager; -import net.sf.robocode.ui.BrowserManager; -import net.sf.robocode.ui.IWindowManager; -import net.sf.robocode.ui.IWindowManagerExt; -import net.sf.robocode.ui.gfx.ImageUtil; - -import javax.swing.*; -import javax.swing.filechooser.FileFilter; -import java.awt.*; -import java.awt.event.*; -import java.beans.PropertyVetoException; -import java.io.*; - - -/** - * The source code editor window containing all components. - * - * @author Mathew A. Nelson (original) - * @author Matthew Reeder (contributor) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class RobocodeEditor extends JFrame implements Runnable, IRobocodeEditor { - private static final int MAX_PACKAGE_NAME_LENGTH = 16; - private static final int MAX_ROBOT_NAME_LENGTH = 32; - - private JPanel robocodeEditorContentPane; - - private RobocodeEditorMenuBar robocodeEditorMenuBar; - private JDesktopPane desktopPane; - - private final Point origin = new Point(); - private final File robotsDirectory; - - private JToolBar statusBar; - private JLabel lineLabel; - - private File editorDirectory; - private final IRepositoryManager repositoryManager; - private final IWindowManagerExt windowManager; - - private FindReplaceDialog findReplaceDialog; - private ReplaceAction replaceAction; - - final EventHandler eventHandler = new EventHandler(); - - class EventHandler implements ComponentListener { - public void componentMoved(ComponentEvent e) {} - - public void componentHidden(ComponentEvent e) {} - - public void componentShown(ComponentEvent e) { - new Thread(RobocodeEditor.this).start(); - } - - public void componentResized(ComponentEvent e) {} - } - - - /** - * Action that launches the Replace dialog. - *

- * The reason this is needed (and the menubar isn't sufficient) is that - * ctrl+H is bound in JTextComponents at a lower level to backspace and in - * order to override this, I need to rebind it to an Action when the - * JEditorPane is created. - */ - class ReplaceAction extends AbstractAction { - public void actionPerformed(ActionEvent e) { - replaceDialog(); - } - } - - public RobocodeEditor(IRepositoryManager repositoryManager, IWindowManager windowManager) { - super(); - this.windowManager = (IWindowManagerExt) windowManager; - this.repositoryManager = repositoryManager; - robotsDirectory = FileUtil.getRobotsDir(); - initialize(); - } - - public void addPlaceShowFocus(JInternalFrame internalFrame) { - getDesktopPane().add(internalFrame); - - // Center a window - Dimension screenSize = getDesktopPane().getSize(); - Dimension size = internalFrame.getSize(); - - if (size.height > screenSize.height) { - size.height = screenSize.height; - } - if (size.width > screenSize.width) { - size.width = screenSize.width; - } - - if (origin.x + size.width > screenSize.width) { - origin.x = 0; - } - if (origin.y + size.height > screenSize.height) { - origin.y = 0; - } - internalFrame.setLocation(origin); - origin.x += 10; - origin.y += 10; - - internalFrame.setVisible(true); - getDesktopPane().moveToFront(internalFrame); - if (internalFrame instanceof EditWindow) { - ((EditWindow) internalFrame).getEditorPane().requestFocus(); - } else { - internalFrame.requestFocus(); - } - - // Make sure the internal frame is being maximized to fit the window when it is opened - try { - internalFrame.setMaximum(true); - } catch (PropertyVetoException e) { - Logger.logError(e); - } - } - - public boolean close() { - JInternalFrame[] frames = getDesktopPane().getAllFrames(); - if (frames != null) { - for (JInternalFrame frame : frames) { - if (frame != null) { - frame.moveToFront(); - if ((frame instanceof EditWindow) && !((EditWindow) frame).fileSave(true)) { - return false; - } - } - } - } - dispose(); - return true; - } - - public void createNewJavaFile() { - String packageName = null; - - if (getActiveWindow() != null) { - packageName = getActiveWindow().getPackage(); - } - if (packageName == null) { - packageName = "mypackage"; - } - - EditWindow editWindow = new EditWindow(repositoryManager, this, robotsDirectory); - - String templateName = "templates" + File.separatorChar + "newjavafile.tpt"; - - String template = ""; - - File f = new File(FileUtil.getCwd(), templateName); - int size = (int) (f.length()); - byte buff[] = new byte[size]; - - FileInputStream fis = null; - DataInputStream dis = null; - - try { - fis = new FileInputStream(f); - dis = new DataInputStream(fis); - - dis.readFully(buff); - template = new String(buff); - } catch (IOException e) { - template = "Unable to read template file: " + FileUtil.getCwd() + File.separatorChar + templateName; - } finally { - FileUtil.cleanupStream(fis); - FileUtil.cleanupStream(dis); - } - - String name = "MyClass"; - - int index = template.indexOf("$"); - - while (index >= 0) { - if (template.substring(index, index + 10).equals("$CLASSNAME")) { - template = template.substring(0, index) + name + template.substring(index + 10); - index += name.length(); - } else if (template.substring(index, index + 8).equals("$PACKAGE")) { - template = template.substring(0, index) + packageName + template.substring(index + 8); - index += packageName.length(); - } else { - index++; - } - index = template.indexOf("$", index); - } - - EditorPane editorPane = editWindow.getEditorPane(); - - editorPane.setText(template); - editorPane.setCaretPosition(0); - - addPlaceShowFocus(editWindow); - } - - public void createNewRobot() { - createNewRobot("Robot"); - } - - public void createNewJuniorRobot() { - createNewRobot("JuniorRobot"); - } - - private void createNewRobot(final String robotType) { - String message = "Enter the name of your new robot.\nExample: MyFirst" + robotType - + "\nNote that the name cannot contain spaces."; - String name = ""; - - boolean done = false; - - while (!done) { - name = (String) JOptionPane.showInputDialog(this, message, "New " + robotType, JOptionPane.PLAIN_MESSAGE, - null, null, name); - name = (name == null) ? "" : name.trim(); - if (name.length() == 0) { - return; - } - if (name.length() > MAX_ROBOT_NAME_LENGTH) { - name = name.substring(0, MAX_ROBOT_NAME_LENGTH); - message = "Please choose a shorter name (up to " + MAX_ROBOT_NAME_LENGTH + " characters)"; - continue; - } - - done = true; - - char firstLetter = name.charAt(0); - - if (firstLetter == '$' || firstLetter == '_') { - name = name.substring(1); - done = false; - } - int firstLetterCodePoint = name.codePointAt(0); // used for supporting Unicode methods - - if (!Character.isJavaIdentifierStart(firstLetterCodePoint) || Character.isLowerCase(firstLetterCodePoint)) { - name = (char) Character.toUpperCase(firstLetterCodePoint) + name.substring(1); - done = false; - } - if (!done) { - message = "Please start your robot name with a big letter,\n" - + "as should the first letter of every word in the name.\nExample: MyFirstRobot"; - continue; - } - - char ch = 0; - - for (int i = 1; i < name.length(); i++) { - ch = name.charAt(i); - int codePoint = name.codePointAt(i); - - if (!Character.isJavaIdentifierPart(codePoint) || ch == '$') { - done = false; - break; - } - } - if (!done) { - message = "Your robot name contains an invalid character: '" + ch - + "'\nPlease use only letters and digits."; - continue; - } - } - - message = "Enter a short package name for your new robot and without spaces (lower-case letters are prefered).\n" - + "Your initials will work well here.\n" - + "Your robot will be put into this package to avoid name conflict with other robots.\n" - + "The package name is used to identify your robot(s) in the game, especially if you\n" - + "want to let your robot(s) participate in competitions like e.g. RoboRumble@Home.\n" - + "Hence, you should enter the same package name for all of your robots."; - - String packageName = ""; - - done = false; - while (!done) { - packageName = (String) JOptionPane.showInputDialog(this, message, "Package name for " + name, - JOptionPane.PLAIN_MESSAGE, null, null, packageName); - packageName = (packageName == null) ? "" : packageName.trim(); - if (packageName.length() == 0) { - return; - } - if (packageName.length() > MAX_PACKAGE_NAME_LENGTH) { - packageName = packageName.substring(0, MAX_PACKAGE_NAME_LENGTH); - message = "Please choose a shorter name (up to " + MAX_PACKAGE_NAME_LENGTH + " characters)"; - continue; - } - - done = true; - - char firstLetter = packageName.charAt(0); - - if (firstLetter == '$' || firstLetter == '_') { - packageName = packageName.substring(1); - done = false; - } - int firstLetterCodePoint = packageName.codePointAt(0); // used for supporting Unicode methods - - if (!Character.isJavaIdentifierStart(firstLetterCodePoint)) { - done = false; - } - if (!done) { - message = "Please start the package name with a small letter.\n" - + "The entire package name should be written in lower-case letters\n" - + "(Java convention), although Robocode will accept big case letters as well."; - continue; - } - - char ch = 0; - - for (int i = 1; i < packageName.length(); i++) { - ch = packageName.charAt(i); - int codePoint = packageName.codePointAt(i); - - if (!(Character.isJavaIdentifierPart(codePoint) || ch == '.') || ch == '$') { - done = false; - break; - } - } - if (!done) { - message = "Your package name contains an invalid character: '" + ch - + "'\nPlease use only small letters and digits."; - continue; - } - - if (packageName.charAt(packageName.length() - 1) == '.') { - message = "The package name cannot end with a dot"; - done = false; - continue; - } - - boolean wrong_dot_combination = false; - int lastDotIndex = -1; - - for (int i = 0; i < packageName.length(); i++) { - if (packageName.charAt(i) == '.') { - if (i - lastDotIndex == 1) { - wrong_dot_combination = true; - break; - } - lastDotIndex = i; - } - } - if (wrong_dot_combination) { - message = "The package name contain two dots next to each other"; - done = false; - continue; - } - - if (repositoryManager != null) { - done = repositoryManager.verifyRobotName(packageName + "." + name, name); - } - if (!done) { - message = "The package name is reserved:\n" + packageName + "\nPlease enter a different package name."; - continue; - } - } - - EditWindow editWindow = new EditWindow(repositoryManager, this, robotsDirectory); - editWindow.setRobotName(name); - - String templateName = "templates" + File.separatorChar + "new" + robotType.toLowerCase() + ".tpt"; - - String template = ""; - - File f = new File(FileUtil.getCwd(), templateName); - int size = (int) (f.length()); - byte buff[] = new byte[size]; - FileInputStream fis = null; - DataInputStream dis = null; - - try { - fis = new FileInputStream(f); - dis = new DataInputStream(fis); - dis.readFully(buff); - template = new String(buff); - } catch (IOException e) { - template = "Unable to read template file: " + FileUtil.getCwd() + File.separatorChar + templateName; - } finally { - FileUtil.cleanupStream(fis); - FileUtil.cleanupStream(dis); - } - - int index = template.indexOf("$"); - - while (index >= 0) { - if (template.substring(index, index + 10).equals("$CLASSNAME")) { - template = template.substring(0, index) + name + template.substring(index + 10); - index += name.length(); - } else if (template.substring(index, index + 8).equals("$PACKAGE")) { - template = template.substring(0, index) + packageName + template.substring(index + 8); - index += packageName.length(); - } else { - index++; - } - index = template.indexOf("$", index); - } - - EditorPane editorPane = editWindow.getEditorPane(); - editorPane.setText(template); - editorPane.setCaretPosition(0); - - addPlaceShowFocus(editWindow); - if (repositoryManager != null) { - repositoryManager.refresh(); - } - } - - public void findDialog() { - getFindReplaceDialog().showDialog(false); - } - - public void replaceDialog() { - getFindReplaceDialog().showDialog(true); - } - - public EditWindow getActiveWindow() { - JInternalFrame[] frames = getDesktopPane().getAllFrames(); - EditWindow editWindow = null; - - if (frames != null) { - for (JInternalFrame frame : frames) { - if (frame.isSelected()) { - if (frame instanceof EditWindow) { - editWindow = (EditWindow) frame; - } - break; - } - } - } - return editWindow; - } - - public RobocodeCompiler getCompiler() { - return Container.getComponent(RobocodeCompilerFactory.class).createCompiler(this); - } - - public JDesktopPane getDesktopPane() { - if (desktopPane == null) { - desktopPane = new JDesktopPane(); - desktopPane.setBackground(Color.GRAY); - desktopPane.setPreferredSize(new Dimension(750, 550)); - } - return desktopPane; - } - - private JLabel getLineLabel() { - if (lineLabel == null) { - lineLabel = new JLabel(); - } - return lineLabel; - } - - private JPanel getRobocodeEditorContentPane() { - if (robocodeEditorContentPane == null) { - robocodeEditorContentPane = new JPanel(); - robocodeEditorContentPane.setLayout(new BorderLayout()); - robocodeEditorContentPane.add(getDesktopPane(), "Center"); - robocodeEditorContentPane.add(getStatusBar(), "South"); - } - return robocodeEditorContentPane; - } - - private RobocodeEditorMenuBar getRobocodeEditorMenuBar() { - if (robocodeEditorMenuBar == null) { - robocodeEditorMenuBar = new RobocodeEditorMenuBar(this); - } - return robocodeEditorMenuBar; - } - - private JToolBar getStatusBar() { - if (statusBar == null) { - statusBar = new JToolBar(); - statusBar.setLayout(new BorderLayout()); - statusBar.add(getLineLabel(), BorderLayout.WEST); - } - return statusBar; - } - - public FindReplaceDialog getFindReplaceDialog() { - if (findReplaceDialog == null) { - findReplaceDialog = new FindReplaceDialog(this); - } - return findReplaceDialog; - } - - public Action getReplaceAction() { - if (replaceAction == null) { - replaceAction = new ReplaceAction(); - } - return replaceAction; - } - - public void addToWindowMenu(EditWindow window) { - WindowMenuItem item = new WindowMenuItem(window, getRobocodeEditorMenuBar().getWindowMenu()); - - getRobocodeEditorMenuBar().getMoreWindowsDialog().addWindowItem(item); - } - - public void removeFromWindowMenu(EditWindow window) { - for (Component c : getRobocodeEditorMenuBar().getWindowMenu().getMenuComponents()) { - if (c instanceof WindowMenuItem) { - WindowMenuItem item = (WindowMenuItem) c; - - if (item.getEditWindow() == window) { - getRobocodeEditorMenuBar().getWindowMenu().remove(item); - getRobocodeEditorMenuBar().getMoreWindowsDialog().removeWindowItem(item); - break; - } - } - } - } - - private void initialize() { - addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - close(); - } - }); - setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); - setIconImage(ImageUtil.getImage("/net/sf/robocode/ui/icons/robocode-icon.png")); - setTitle("Robot Editor"); - setJMenuBar(getRobocodeEditorMenuBar()); - setContentPane(getRobocodeEditorContentPane()); - addComponentListener(eventHandler); - } - - public void openRobot() { - if (editorDirectory == null) { - editorDirectory = robotsDirectory; - } - JFileChooser chooser; - - chooser = new JFileChooser(editorDirectory); - FileFilter filter = new FileFilter() { - @Override - public boolean accept(File pathname) { - if (pathname.isHidden()) { - return false; - } - if (pathname.isDirectory()) { - return true; - } - String fn = pathname.getName(); - int idx = fn.lastIndexOf('.'); - String extension = ""; - - if (idx >= 0) { - extension = fn.substring(idx); - } - return extension.equalsIgnoreCase(".java"); - } - - @Override - public String getDescription() { - return "Robots"; - } - }; - - chooser.setFileFilter(filter); - int rv = chooser.showOpenDialog(this); - - if (rv == JFileChooser.APPROVE_OPTION) { - String robotFilename = chooser.getSelectedFile().getPath(); - - editorDirectory = chooser.getSelectedFile().getParentFile(); - - BufferedReader bufferedReader = null; - InputStreamReader inputStreamReader = null; - FileInputStream fileInputStream = null; - - try { - fileInputStream = new FileInputStream(robotFilename); - inputStreamReader = new InputStreamReader(fileInputStream, "UTF8"); - bufferedReader = new BufferedReader(inputStreamReader); - - EditWindow editWindow = new EditWindow(repositoryManager, this, robotsDirectory); - - EditorPane editorPane = editWindow.getEditorPane(); - - editorPane.read(bufferedReader, new File(robotFilename)); - - editWindow.setFileName(robotFilename); - - addPlaceShowFocus(editWindow); - } catch (Exception e) { - JOptionPane.showMessageDialog(this, e.toString()); - Logger.logError(e); - } finally { - FileUtil.cleanupStream(bufferedReader); - } - } - } - - public void extractRobot() { - windowManager.showRobotExtractor(this); - } - - public void run() { - getCompiler(); - } - - public void saveAsRobot() { - EditWindow editWindow = getActiveWindow(); - - if (editWindow != null) { - editWindow.fileSaveAs(); - } - } - - public void resetCompilerProperties() { - CompilerProperties props = Container.getComponent(RobocodeCompilerFactory.class).getCompilerProperties(); - - props.resetCompiler(); - Container.getComponent(RobocodeCompilerFactory.class).saveCompilerProperties(); - getCompiler(); - } - - public void saveRobot() { - EditWindow editWindow = getActiveWindow(); - - if (editWindow != null) { - editWindow.fileSave(false); - } - } - - public void setLineStatus(int line) { - if (line >= 0) { - getLineLabel().setText("Line: " + (line + 1)); - } else { - getLineLabel().setText(""); - } - } - - public void showHelpApi() { - String helpurl = "file:" + new File(FileUtil.getCwd(), "").getAbsoluteFile() + File.separator + "javadoc" - + File.separator + "index.html"; - - try { - BrowserManager.openURL(helpurl); - } catch (IOException e) { - JOptionPane.showMessageDialog(this, e.getMessage(), "Unable to open browser!", - JOptionPane.INFORMATION_MESSAGE); - } - } - - public void setSaveFileMenuItemsEnabled(boolean enabled) { - robocodeEditorMenuBar.getFileSaveAsMenuItem().setEnabled(enabled); - robocodeEditorMenuBar.getFileSaveMenuItem().setEnabled(enabled); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeEditorMenuBar.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeEditorMenuBar.java deleted file mode 100644 index e3bde6a..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/RobocodeEditorMenuBar.java +++ /dev/null @@ -1,722 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import net.sf.robocode.ui.dialog.WindowUtil; -import static net.sf.robocode.ui.util.ShortcutUtil.MENU_SHORTCUT_KEY_MASK; - -import javax.swing.*; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; - - -/** - * Menu bar for the Robocode source code editor. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Matthew Reeder (contributor) - */ -@SuppressWarnings("serial") -public class RobocodeEditorMenuBar extends JMenuBar { - - private final RobocodeEditor editor; - private final EventHandler eventHandler = new EventHandler(); - - private class EventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - final Object source = e.getSource(); - - if (source == RobocodeEditorMenuBar.this.getFileNewRobotMenuItem()) { - fileNewRobotActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getFileNewJuniorRobotMenuItem()) { - fileNewJuniorRobotActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getFileNewJavaFileMenuItem()) { - fileNewJavaFileActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getFileOpenMenuItem()) { - fileOpenActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getFileExtractMenuItem()) { - fileExtractActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getFileSaveMenuItem()) { - fileSaveActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getFileSaveAsMenuItem()) { - fileSaveAsActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getFileExitMenuItem()) { - fileExitActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getCompilerCompileMenuItem()) { - compilerCompileActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getCompilerOptionsPreferencesMenuItem()) { - compilerOptionsPreferencesActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getCompilerOptionsResetCompilerMenuItem()) { - compilerOptionsResetCompilerActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getHelpRobocodeApiMenuItem()) { - helpRobocodeApiActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getEditUndoMenuItem()) { - editUndoActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getEditRedoMenuItem()) { - editRedoActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getEditCutMenuItem()) { - editCutActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getEditCopyMenuItem()) { - editCopyActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getEditPasteMenuItem()) { - editPasteActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getEditDeleteMenuItem()) { - editDeleteActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getEditSelectAllMenuItem()) { - editSelectAllActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getEditFindMenuItem()) { - editFindActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getEditFindNextMenuItem()) { - editFindNextActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getEditReplaceMenuItem()) { - editReplaceActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getWindowCloseMenuItem()) { - windowCloseActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getWindowCloseAllMenuItem()) { - windowCloseAllActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getWindowWindowsDialogMenuItem()) { - windowMoreWindowsActionPerformed(); - } else if (source == RobocodeEditorMenuBar.this.getViewEditorThemeConfigDialogMenuItem()) { - viewEditorThemeConfigDialogActionPerformed(); - } - } - } - - // File menu - private JMenu fileMenu; - private JMenuItem fileOpenMenuItem; - private JMenuItem fileExtractMenuItem; - private JMenuItem fileSaveMenuItem; - private JMenuItem fileSaveAsMenuItem; - private JMenuItem fileExitMenuItem; - private JMenuItem fileNewJavaFileMenuItem; - private JMenu fileNewMenu; - private JMenuItem fileNewRobotMenuItem; - private JMenuItem fileNewJuniorRobotMenuItem; - - // Compiler menu - private JMenuItem compilerCompileMenuItem; - private JMenu compilerMenu; - private JMenu compilerOptionsMenu; - private JMenuItem compilerOptionsPreferencesMenuItem; - private JMenuItem compilerOptionsResetCompilerMenuItem; - - // Edit menu - private JMenu editMenu; - private JMenuItem editUndoMenuItem; - private JMenuItem editRedoMenuItem; - private JMenuItem editCutMenuItem; - private JMenuItem editCopyMenuItem; - private JMenuItem editPasteMenuItem; - private JMenuItem editDeleteMenuItem; - private JMenuItem editFindMenuItem; - private JMenuItem editFindNextMenuItem; - private JMenuItem editReplaceMenuItem; - private JMenuItem editSelectAllMenuItem; - - // View menu - private JMenu viewMenu; - private JMenuItem viewEditorThemeConfigDialogMenuItem; - - // Window menu - private JMenu windowMenu; - private JMenuItem windowCloseMenuItem; - private JMenuItem windowCloseAllMenuItem; - private JMenuItem windowWindowsDialogMenuItem; - private MoreWindowsDialog moreWindowsDialog; - - // Help menu - private JMenu helpMenu; - private JMenuItem helpRobocodeApiMenuItem; - - public RobocodeEditorMenuBar(RobocodeEditor editor) { - super(); - this.editor = editor; - initialize(); - } - - private void initialize() { - add(getFileMenu()); - add(getEditMenu()); - add(getViewMenu()); - add(getCompilerMenu()); - add(getWindowMenu()); - add(getHelpMenu()); - } - - private void compilerCompileActionPerformed() { - EditWindow editWindow = editor.getActiveWindow(); - if (editWindow != null) { - editWindow.compile(); - } - } - - private void compilerOptionsPreferencesActionPerformed() { - CompilerPreferencesDialog dialog = new CompilerPreferencesDialog(editor); - WindowUtil.packCenterShow(editor, dialog); - } - - private void compilerOptionsResetCompilerActionPerformed() { - if (JOptionPane.showConfirmDialog(editor, - "You are about to reset the compiler preferences. Do you wish to proceed?", "Reset Compiler Preferences", - JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) - == JOptionPane.NO_OPTION) { - return; - } - - new Thread(new Runnable() { - public void run() { - editor.resetCompilerProperties(); - } - }).start(); - } - - private void fileExitActionPerformed() { - editor.dispose(); - } - - private void fileNewJavaFileActionPerformed() { - editor.createNewJavaFile(); - - getFileSaveMenuItem().setEnabled(true); - getFileSaveAsMenuItem().setEnabled(true); - } - - private void fileNewRobotActionPerformed() { - editor.createNewRobot(); - - getFileSaveMenuItem().setEnabled(true); - getFileSaveAsMenuItem().setEnabled(true); - } - - private void fileNewJuniorRobotActionPerformed() { - editor.createNewJuniorRobot(); - - getFileSaveMenuItem().setEnabled(true); - getFileSaveAsMenuItem().setEnabled(true); - } - - private void fileOpenActionPerformed() { - editor.openRobot(); - } - - private void fileExtractActionPerformed() { - editor.extractRobot(); - } - - private void fileSaveActionPerformed() { - editor.saveRobot(); - } - - private void fileSaveAsActionPerformed() { - editor.saveAsRobot(); - } - - private void editUndoActionPerformed() { - EditWindow editWindow = editor.getActiveWindow(); - if (editWindow != null) { - editWindow.getEditorPane().undo(); - } - } - - private void editRedoActionPerformed() { - EditWindow editWindow = editor.getActiveWindow(); - if (editWindow != null) { - editWindow.getEditorPane().redo(); - } - } - - private void editCutActionPerformed() { - EditWindow editWindow = editor.getActiveWindow(); - - if (editWindow != null) { - editWindow.getEditorPane().cut(); - } - } - - private void editCopyActionPerformed() { - EditWindow editWindow = editor.getActiveWindow(); - if (editWindow != null) { - editWindow.getEditorPane().copy(); - } - } - - private void editPasteActionPerformed() { - EditWindow editWindow = editor.getActiveWindow(); - if (editWindow != null) { - editWindow.getEditorPane().paste(); - } - } - - private void editDeleteActionPerformed() { - EditWindow editWindow = editor.getActiveWindow(); - if (editWindow != null) { - editWindow.getEditorPane().replaceSelection(null); - } - } - - private void editSelectAllActionPerformed() { - EditWindow editWindow = editor.getActiveWindow(); - if (editWindow != null) { - editWindow.getEditorPane().selectAll(); - } - } - - private void editFindActionPerformed() { - editor.findDialog(); - } - - private void editReplaceActionPerformed() { - editor.replaceDialog(); - } - - private void editFindNextActionPerformed() { - editor.getFindReplaceDialog().findNext(); - } - - private void windowCloseActionPerformed() { - EditWindow editWindow = editor.getActiveWindow(); - if (editWindow != null) { - editWindow.doDefaultCloseAction(); - } - } - - private void windowCloseAllActionPerformed() { - JInternalFrame[] frames = editor.getDesktopPane().getAllFrames(); - if (frames != null) { - for (JInternalFrame frame : frames) { - frame.doDefaultCloseAction(); - } - } - } - - private void windowMoreWindowsActionPerformed() { - getMoreWindowsDialog().setVisible(true); - } - - private void viewEditorThemeConfigDialogActionPerformed() { - EditorThemeConfigDialog dialog = new EditorThemeConfigDialog(editor); - WindowUtil.packCenterShow(dialog); - } - - private JMenuItem getCompilerCompileMenuItem() { - if (compilerCompileMenuItem == null) { - compilerCompileMenuItem = new JMenuItem(); - compilerCompileMenuItem.setText("Compile"); - compilerCompileMenuItem.setMnemonic('m'); - compilerCompileMenuItem.setDisplayedMnemonicIndex(2); - compilerCompileMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_B, MENU_SHORTCUT_KEY_MASK)); - compilerCompileMenuItem.addActionListener(eventHandler); - } - return compilerCompileMenuItem; - } - - private JMenu getCompilerMenu() { - if (compilerMenu == null) { - compilerMenu = new JMenu(); - compilerMenu.setText("Compiler"); - compilerMenu.setMnemonic('C'); - compilerMenu.add(getCompilerCompileMenuItem()); - compilerMenu.add(getCompilerOptionsMenu()); - } - return compilerMenu; - } - - private JMenu getCompilerOptionsMenu() { - if (compilerOptionsMenu == null) { - compilerOptionsMenu = new JMenu(); - compilerOptionsMenu.setText("Options"); - compilerOptionsMenu.setMnemonic('O'); - compilerOptionsMenu.add(getCompilerOptionsPreferencesMenuItem()); - compilerOptionsMenu.add(getCompilerOptionsResetCompilerMenuItem()); - } - return compilerOptionsMenu; - } - - private JMenuItem getCompilerOptionsPreferencesMenuItem() { - if (compilerOptionsPreferencesMenuItem == null) { - compilerOptionsPreferencesMenuItem = new JMenuItem(); - compilerOptionsPreferencesMenuItem.setText("Preferences"); - compilerOptionsPreferencesMenuItem.setMnemonic('P'); - compilerOptionsPreferencesMenuItem.addActionListener(eventHandler); - } - return compilerOptionsPreferencesMenuItem; - } - - private JMenuItem getCompilerOptionsResetCompilerMenuItem() { - if (compilerOptionsResetCompilerMenuItem == null) { - compilerOptionsResetCompilerMenuItem = new JMenuItem(); - compilerOptionsResetCompilerMenuItem.setText("Reset Compiler"); - compilerOptionsResetCompilerMenuItem.setMnemonic('R'); - compilerOptionsResetCompilerMenuItem.addActionListener(eventHandler); - } - return compilerOptionsResetCompilerMenuItem; - } - - private JMenuItem getFileExitMenuItem() { - if (fileExitMenuItem == null) { - fileExitMenuItem = new JMenuItem(); - fileExitMenuItem.setText("Exit"); - fileExitMenuItem.setMnemonic('x'); - fileExitMenuItem.setDisplayedMnemonicIndex(1); - fileExitMenuItem.addActionListener(eventHandler); - } - return fileExitMenuItem; - } - - private JMenu getFileMenu() { - if (fileMenu == null) { - fileMenu = new JMenu(); - fileMenu.setText("File"); - fileMenu.setMnemonic('F'); - fileMenu.add(getFileNewMenu()); - fileMenu.add(getFileOpenMenuItem()); - fileMenu.add(getFileExtractMenuItem()); - fileMenu.add(getFileSaveMenuItem()); - fileMenu.add(getFileSaveAsMenuItem()); - fileMenu.add(new JSeparator()); - fileMenu.add(getFileExitMenuItem()); - } - return fileMenu; - } - - private JMenuItem getFileNewJavaFileMenuItem() { - if (fileNewJavaFileMenuItem == null) { - fileNewJavaFileMenuItem = new JMenuItem(); - fileNewJavaFileMenuItem.setText("Java File"); - fileNewJavaFileMenuItem.setMnemonic('J'); - fileNewJavaFileMenuItem.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_N, MENU_SHORTCUT_KEY_MASK | Event.SHIFT_MASK)); - fileNewJavaFileMenuItem.addActionListener(eventHandler); - } - return fileNewJavaFileMenuItem; - } - - private JMenu getFileNewMenu() { - if (fileNewMenu == null) { - fileNewMenu = new JMenu(); - fileNewMenu.setText("New"); - fileNewMenu.setMnemonic('N'); - fileNewMenu.add(getFileNewRobotMenuItem()); - fileNewMenu.add(getFileNewJuniorRobotMenuItem()); - fileNewMenu.add(getFileNewJavaFileMenuItem()); - } - return fileNewMenu; - } - - private JMenuItem getFileNewRobotMenuItem() { - if (fileNewRobotMenuItem == null) { - fileNewRobotMenuItem = new JMenuItem(); - fileNewRobotMenuItem.setText("Robot"); - fileNewRobotMenuItem.setMnemonic('R'); - fileNewRobotMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, MENU_SHORTCUT_KEY_MASK)); - fileNewRobotMenuItem.addActionListener(eventHandler); - } - return fileNewRobotMenuItem; - } - - private JMenuItem getFileNewJuniorRobotMenuItem() { - if (fileNewJuniorRobotMenuItem == null) { - fileNewJuniorRobotMenuItem = new JMenuItem(); - fileNewJuniorRobotMenuItem.setText("JuniorRobot"); - fileNewJuniorRobotMenuItem.setMnemonic('J'); - fileNewJuniorRobotMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_J, MENU_SHORTCUT_KEY_MASK)); - fileNewJuniorRobotMenuItem.addActionListener(eventHandler); - } - return fileNewJuniorRobotMenuItem; - } - - private JMenuItem getFileOpenMenuItem() { - if (fileOpenMenuItem == null) { - fileOpenMenuItem = new JMenuItem(); - fileOpenMenuItem.setText("Open"); - fileOpenMenuItem.setMnemonic('O'); - fileOpenMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MENU_SHORTCUT_KEY_MASK)); - fileOpenMenuItem.addActionListener(eventHandler); - } - return fileOpenMenuItem; - } - - private JMenuItem getFileExtractMenuItem() { - if (fileExtractMenuItem == null) { - fileExtractMenuItem = new JMenuItem(); - fileExtractMenuItem.setText("Extract downloaded robot for editing"); - fileExtractMenuItem.setMnemonic('t'); - fileExtractMenuItem.setDisplayedMnemonicIndex(2); - fileExtractMenuItem.addActionListener(eventHandler); - } - return fileExtractMenuItem; - } - - public JMenuItem getFileSaveAsMenuItem() { - if (fileSaveAsMenuItem == null) { - fileSaveAsMenuItem = new JMenuItem(); - fileSaveAsMenuItem.setText("Save As"); - fileSaveAsMenuItem.setMnemonic('A'); - fileSaveAsMenuItem.setDisplayedMnemonicIndex(5); - fileSaveAsMenuItem.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_SHORTCUT_KEY_MASK | Event.SHIFT_MASK)); - fileSaveAsMenuItem.addActionListener(eventHandler); - fileSaveAsMenuItem.setEnabled(false); - } - return fileSaveAsMenuItem; - } - - public JMenuItem getFileSaveMenuItem() { - if (fileSaveMenuItem == null) { - fileSaveMenuItem = new JMenuItem(); - fileSaveMenuItem.setText("Save"); - fileSaveMenuItem.setMnemonic('S'); - fileSaveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_SHORTCUT_KEY_MASK)); - fileSaveMenuItem.addActionListener(eventHandler); - fileSaveMenuItem.setEnabled(false); - } - return fileSaveMenuItem; - } - - @Override - public JMenu getHelpMenu() { - if (helpMenu == null) { - helpMenu = new JMenu(); - helpMenu.setText("Help"); - helpMenu.setMnemonic('H'); - helpMenu.add(getHelpRobocodeApiMenuItem()); - } - return helpMenu; - } - - private JMenuItem getHelpRobocodeApiMenuItem() { - if (helpRobocodeApiMenuItem == null) { - helpRobocodeApiMenuItem = new JMenuItem(); - helpRobocodeApiMenuItem.setText("Robocode API"); - helpRobocodeApiMenuItem.setMnemonic('A'); - helpRobocodeApiMenuItem.setDisplayedMnemonicIndex(9); - helpRobocodeApiMenuItem.addActionListener(eventHandler); - } - return helpRobocodeApiMenuItem; - } - - private JMenu getEditMenu() { - if (editMenu == null) { - editMenu = new JMenu(); - editMenu.setText("Edit"); - editMenu.setMnemonic('E'); - editMenu.add(getEditUndoMenuItem()); - editMenu.add(getEditRedoMenuItem()); - editMenu.addSeparator(); - editMenu.add(getEditCutMenuItem()); - editMenu.add(getEditCopyMenuItem()); - editMenu.add(getEditPasteMenuItem()); - editMenu.add(getEditDeleteMenuItem()); - editMenu.addSeparator(); - editMenu.add(getEditFindMenuItem()); - editMenu.add(getEditFindNextMenuItem()); - editMenu.add(getEditReplaceMenuItem()); - editMenu.addSeparator(); - editMenu.add(getEditSelectAllMenuItem()); - } - return editMenu; - } - - private JMenuItem getEditUndoMenuItem() { - if (editUndoMenuItem == null) { - editUndoMenuItem = new JMenuItem(); - editUndoMenuItem.setText("Undo"); - editUndoMenuItem.setMnemonic('U'); - editUndoMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Z, MENU_SHORTCUT_KEY_MASK)); - editUndoMenuItem.addActionListener(eventHandler); - } - return editUndoMenuItem; - } - - private JMenuItem getEditRedoMenuItem() { - if (editRedoMenuItem == null) { - editRedoMenuItem = new JMenuItem(); - editRedoMenuItem.setText("Redo"); - editRedoMenuItem.setMnemonic('R'); - editRedoMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_Y, MENU_SHORTCUT_KEY_MASK)); - editRedoMenuItem.addActionListener(eventHandler); - } - return editRedoMenuItem; - } - - private JMenuItem getEditCutMenuItem() { - if (editCutMenuItem == null) { - editCutMenuItem = new JMenuItem(); - editCutMenuItem.setText("Cut"); - editCutMenuItem.setMnemonic('t'); - editCutMenuItem.setDisplayedMnemonicIndex(2); - editCutMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_X, MENU_SHORTCUT_KEY_MASK)); - editCutMenuItem.addActionListener(eventHandler); - } - return editCutMenuItem; - } - - private JMenuItem getEditCopyMenuItem() { - if (editCopyMenuItem == null) { - editCopyMenuItem = new JMenuItem(); - editCopyMenuItem.setText("Copy"); - editCopyMenuItem.setMnemonic('C'); - editCopyMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_C, MENU_SHORTCUT_KEY_MASK)); - editCopyMenuItem.addActionListener(eventHandler); - } - return editCopyMenuItem; - } - - private JMenuItem getEditPasteMenuItem() { - if (editPasteMenuItem == null) { - editPasteMenuItem = new JMenuItem(); - editPasteMenuItem.setText("Paste"); - editPasteMenuItem.setMnemonic('P'); - editPasteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_V, MENU_SHORTCUT_KEY_MASK)); - editPasteMenuItem.addActionListener(eventHandler); - } - return editPasteMenuItem; - } - - private JMenuItem getEditDeleteMenuItem() { - if (editDeleteMenuItem == null) { - editDeleteMenuItem = new JMenuItem(); - editDeleteMenuItem.setText("Delete"); - editDeleteMenuItem.setMnemonic('l'); - editDeleteMenuItem.setDisplayedMnemonicIndex(2); - editDeleteMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_DELETE, 0)); - editDeleteMenuItem.addActionListener(eventHandler); - } - return editDeleteMenuItem; - } - - private JMenuItem getEditFindMenuItem() { - if (editFindMenuItem == null) { - editFindMenuItem = new JMenuItem(); - editFindMenuItem.setText("Find..."); - editFindMenuItem.setMnemonic('F'); - editFindMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_F, MENU_SHORTCUT_KEY_MASK)); - editFindMenuItem.addActionListener(eventHandler); - } - return editFindMenuItem; - } - - private JMenuItem getEditFindNextMenuItem() { - if (editFindNextMenuItem == null) { - editFindNextMenuItem = new JMenuItem(); - editFindNextMenuItem.setText("Find Next"); - editFindNextMenuItem.setMnemonic('N'); - editFindNextMenuItem.setDisplayedMnemonicIndex(5); - editFindNextMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_G, MENU_SHORTCUT_KEY_MASK)); - editFindNextMenuItem.addActionListener(eventHandler); - } - return editFindNextMenuItem; - } - - private JMenuItem getEditReplaceMenuItem() { - if (editReplaceMenuItem == null) { - editReplaceMenuItem = new JMenuItem(); - editReplaceMenuItem.setText("Replace..."); - editReplaceMenuItem.setMnemonic('R'); - editReplaceMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_H, MENU_SHORTCUT_KEY_MASK)); - editReplaceMenuItem.addActionListener(eventHandler); - } - return editReplaceMenuItem; - } - - private JMenuItem getEditSelectAllMenuItem() { - if (editSelectAllMenuItem == null) { - editSelectAllMenuItem = new JMenuItem(); - editSelectAllMenuItem.setText("Select All"); - editSelectAllMenuItem.setMnemonic('A'); - editSelectAllMenuItem.setDisplayedMnemonicIndex(7); - editSelectAllMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_A, MENU_SHORTCUT_KEY_MASK)); - editSelectAllMenuItem.addActionListener(eventHandler); - } - return editSelectAllMenuItem; - } - - public JMenu getWindowMenu() { - if (windowMenu == null) { - windowMenu = new JMenu(); - windowMenu.setText("Window"); - windowMenu.setMnemonic('W'); - // If you add more items to this menu, you need to update the - // constants in WindowMenuItem, too, or the dynamic part of the - // window menu won't operate correctly. - windowMenu.add(getWindowCloseMenuItem()); - windowMenu.add(getWindowCloseAllMenuItem()); - windowMenu.addSeparator(); - // stuff will be inserted here... - windowMenu.add(getWindowWindowsDialogMenuItem()); - } - return windowMenu; - } - - private JMenuItem getWindowCloseMenuItem() { - if (windowCloseMenuItem == null) { - windowCloseMenuItem = new JMenuItem(); - windowCloseMenuItem.setText("Close"); - windowCloseMenuItem.setMnemonic('C'); - windowCloseMenuItem.addActionListener(eventHandler); - } - return windowCloseMenuItem; - } - - private JMenuItem getWindowCloseAllMenuItem() { - if (windowCloseAllMenuItem == null) { - windowCloseAllMenuItem = new JMenuItem(); - windowCloseAllMenuItem.setText("Close All"); - windowCloseAllMenuItem.setMnemonic('A'); - windowCloseAllMenuItem.setDisplayedMnemonicIndex(6); - windowCloseAllMenuItem.addActionListener(eventHandler); - } - return windowCloseAllMenuItem; - } - - private JMenuItem getWindowWindowsDialogMenuItem() { - if (windowWindowsDialogMenuItem == null) { - windowWindowsDialogMenuItem = new WindowMenuItem(); - windowWindowsDialogMenuItem.addActionListener(eventHandler); - } - return windowWindowsDialogMenuItem; - } - - public MoreWindowsDialog getMoreWindowsDialog() { - if (moreWindowsDialog == null) { - moreWindowsDialog = new MoreWindowsDialog(editor); - } - return moreWindowsDialog; - } - - private void helpRobocodeApiActionPerformed() { - editor.showHelpApi(); - } - - private JMenu getViewMenu() { - if (viewMenu == null) { - viewMenu = new JMenu(); - viewMenu.setText("View"); - viewMenu.setMnemonic('V'); - - viewMenu.add(getViewEditorThemeConfigDialogMenuItem()); - } - return viewMenu; - } - - private JMenuItem getViewEditorThemeConfigDialogMenuItem() { - if (viewEditorThemeConfigDialogMenuItem == null) { - viewEditorThemeConfigDialogMenuItem = new JMenuItem(); - viewEditorThemeConfigDialogMenuItem.setText("Change Editor Theme"); - viewEditorThemeConfigDialogMenuItem.setMnemonic('T'); - viewEditorThemeConfigDialogMenuItem.addActionListener(eventHandler); - } - return viewEditorThemeConfigDialogMenuItem; - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/StyledDocument.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/StyledDocument.java deleted file mode 100644 index 9a66fbf..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/StyledDocument.java +++ /dev/null @@ -1,64 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import javax.swing.text.DefaultStyledDocument; -import javax.swing.text.Element; - - -/** - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class StyledDocument extends DefaultStyledDocument { - - /** - * Returns the element index from an offset. - * - * @param offset - * is the offset to retrieve the element index from. - * @return the element index >= 0. - */ - protected int getElementIndex(int offset) { - return getDefaultRootElement().getElementIndex(offset); - } - - /** - * Returns the end offset of an element. - * Notice, that the end offset is off-by-one, and hence this method wraps the Element.getEndOffset() - * - * @param element is the element to get the end offset from. - * @return the end offset of the element. - */ - protected int getEndOffset(Element element) { - return Math.min(getLength(), element.getEndOffset()); - } - - /** - * Returns the child element at the given element index. - * - * @param index - * is the element index. - * @return the child element. - */ - protected Element getElement(int index) { - return getDefaultRootElement().getElement(index); - } - - /** - * Returns the child element at the given document offset. - * - * @param offset - * is the document offset. - * @return the child element. - */ - protected Element getElementFromOffset(int offset) { - return getElement(getElementIndex(offset)); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/UndoManagerWithActions.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/UndoManagerWithActions.java deleted file mode 100644 index 4293351..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/UndoManagerWithActions.java +++ /dev/null @@ -1,96 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import java.awt.Toolkit; -import java.awt.event.ActionEvent; -import javax.swing.AbstractAction; -import javax.swing.Action; -import javax.swing.event.UndoableEditEvent; -import javax.swing.undo.CannotUndoException; -import javax.swing.undo.CannotRedoException; -import javax.swing.undo.UndoManager; - - -/** - * Undo manager containing actions for performing undo and redo edits. - * - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class UndoManagerWithActions extends UndoManager { - - private Action undoAction = new UndoAction(); - private Action redoAction = new RedoAction(); - - public UndoManagerWithActions() { - super(); - updateUndoRedoState(); - } - - @Override - public synchronized void undo() throws CannotUndoException { - super.undo(); - updateUndoRedoState(); - } - - @Override - public synchronized void redo() throws CannotRedoException { - super.redo(); - updateUndoRedoState(); - } - - @Override - public void undoableEditHappened(UndoableEditEvent undoableEditEvent) { - super.undoableEditHappened(undoableEditEvent); - updateUndoRedoState(); - } - - public Action getUndoAction() { - return undoAction; - } - - public Action getRedoAction() { - return redoAction; - } - - protected void updateUndoRedoState() { - undoAction.setEnabled(canUndo()); - redoAction.setEnabled(canRedo()); - } - - private class UndoAction extends AbstractAction { - public UndoAction() { - super("Undo"); - } - - public void actionPerformed(ActionEvent ae) { - try { - undo(); - } catch (CannotUndoException e) { - Toolkit.getDefaultToolkit().beep(); - } - } - } - - - private class RedoAction extends AbstractAction { - public RedoAction() { - super("Redo"); - } - - public void actionPerformed(ActionEvent ae) { - try { - redo(); - } catch (CannotRedoException e) { - Toolkit.getDefaultToolkit().beep(); - } - } - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/WindowMenuItem.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/WindowMenuItem.java deleted file mode 100644 index 1baec07..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/WindowMenuItem.java +++ /dev/null @@ -1,291 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.io.File; - - -/** - * Customized JMenuItem where each item is bound to a specific JInternalFrame, - * so we can have a dynamic menu of open windows. - * - * @author Matthew Reeder (original) - */ -@SuppressWarnings("serial") -public class WindowMenuItem extends JCheckBoxMenuItem implements ActionListener { - - // Maximum number of windows that will be shown on the menu (to get the rest, you'll - // have to open the dialog). The number 9 is also the number of most recently used - // files that normally show up in other applications. The reason is so that you can - // give them dynamic hotkeys from 1 to 9. Otherwise, there's no reason (besides - // avoiding taking up way too much space) to limit the size of the menu. - public static final int WINDOW_MENU_MAX_SIZE = 9; - // Number of static menu items before the dynamic menu (including seperators) - public static final int PRECEDING_WINDOW_MENU_ITEMS = 3; - // Number of static menu items after the dynamic menu (including seperators - // and the More Windows... menu item) - public static final int SUBSEQUENT_WINDOW_MENU_ITEMS = 1; - // Normal max length of a window name - public static final int MAX_WINDOW_NAME_LENGTH = 30; - // I make one "special" menu item that isn't tied to a window. Since it has - // similar needs for enabling/visibility and labeling, I made it the same class. - public static final int REGULAR_WINDOW = 0, SPECIAL_MORE = 2; - private EditWindow window; - private JMenu parentMenu; - private final int type; - - public WindowMenuItem(EditWindow window, JMenu parentMenu) { - super(); - this.window = window; - this.parentMenu = parentMenu; - type = REGULAR_WINDOW; - parentMenu.add(this, parentMenu.getMenuComponentCount() - SUBSEQUENT_WINDOW_MENU_ITEMS); - addActionListener(this); - } - - /** - * WindowMenuItem Constructor for "More Windows..." menu. - */ - public WindowMenuItem() { - type = SPECIAL_MORE; - } - - /** - * Event handler for the menu item - *

- * Brings the window to the front. This should be called for the "More - * Windows..." Item, because it doesn't make itself its own ActionListener. - *

- * Note that e can be null, and this menu item might not be showing (if this - * is called from the "More Windows" dialog). - */ - public void actionPerformed(ActionEvent e) { - if (window.isIcon()) { - try { - window.setIcon(false); - } catch (Throwable ignored) {} - } - if (window.getDesktopPane() != null) { - window.getDesktopPane().setSelectedFrame(window); - } - window.toFront(); - window.grabFocus(); - try { - window.setSelected(true); - } catch (Throwable ignored) {} - } - - /** - * Returns the label that should be used. If the menu item is supposed to be - * hidden, this may not be a real valid label. - */ - @Override - public String getText() { - if (type == SPECIAL_MORE) { - Container parent = getParent(); - - if (parent == null) { - return ""; - } - - int numWindows = parent.getComponentCount() - PRECEDING_WINDOW_MENU_ITEMS - SUBSEQUENT_WINDOW_MENU_ITEMS; - - if (numWindows <= 0) { - return "No Windows Open"; - } - - return "More Windows..."; - } - if (window == null || parentMenu == null) { - return ""; - } - String text = (getIndex() + 1) + " " + getFileName(); - - if (window.modified) { - text += " *"; - } - return text; - } - - protected String getFileName() { - if (window.getFileName() == null) { - return "Untitled " + (getPrecedingNewFiles() + 1); - } - - String name = window.getFileName(); - - if (name.length() < MAX_WINDOW_NAME_LENGTH) { - return name; - } - if (name.indexOf(File.separatorChar) < 0) { - return name; - } // If there are no separators, I can't really intelligently truncate. - int startLength = name.indexOf(File.separatorChar, 1) + 1; - int endLength = name.length() - name.lastIndexOf(File.separatorChar); - - if (endLength + startLength + 3 > name.length()) { - return name; - } // return name anyways, since we're not getting it any shorter. - - boolean change; - - do { - change = false; - int newEndLength = name.length() - name.lastIndexOf(File.separatorChar, name.length() - endLength - 1); - - if (newEndLength + startLength + 3 <= MAX_WINDOW_NAME_LENGTH) { - endLength = newEndLength; - change = true; - } - int newStartLength = name.indexOf(File.separatorChar, startLength + 1) + 1; - - if (endLength + startLength + 3 <= MAX_WINDOW_NAME_LENGTH) { - startLength = newStartLength; - change = true; - } - } while (change); - - return name.substring(0, startLength) + "..." + name.substring(name.length() - endLength); - } - - /** - * @return how many nameless windows occur before this one in the parent. - */ - protected int getPrecedingNewFiles() { - int count = 0; - - for (int i = 0; i < WINDOW_MENU_MAX_SIZE - && i < parentMenu.getMenuComponentCount() - PRECEDING_WINDOW_MENU_ITEMS - SUBSEQUENT_WINDOW_MENU_ITEMS - && parentMenu.getMenuComponent(i + PRECEDING_WINDOW_MENU_ITEMS) != this; i++) { - if (parentMenu.getMenuComponent(i + PRECEDING_WINDOW_MENU_ITEMS) instanceof WindowMenuItem - && ((WindowMenuItem) parentMenu.getMenuComponent(i + PRECEDING_WINDOW_MENU_ITEMS)).window.getFileName() - == null) { - count++; - } - } - return count; - } - - /** - * Figures out what index (from 0 to WINDOW_MENU_MAX_SIZE-1) this item is in - * the window menu. - *

- * @return -1 if this item isn't showing. - */ - protected int getIndex() { - for (int i = 0; i < WINDOW_MENU_MAX_SIZE - && i < parentMenu.getMenuComponentCount() - PRECEDING_WINDOW_MENU_ITEMS - SUBSEQUENT_WINDOW_MENU_ITEMS; i++) { - if (this == parentMenu.getMenuComponent(i + PRECEDING_WINDOW_MENU_ITEMS)) { - return i; - } - } - return -1; - } - - /** - * Returns the index of the character in the label that should be underlined - */ - @Override - public int getDisplayedMnemonicIndex() { - return (type == SPECIAL_MORE) ? 11 : 0; - } - - /** - * Returns the keyboard mnemonic for this item, which is the virtual key - * code for its 1-based index. - */ - @Override - public int getMnemonic() { - return (type == SPECIAL_MORE) ? KeyEvent.VK_S : KeyEvent.VK_1 + getIndex(); - } - - /** - * Returns true if this item should be showing. - *

- * Returns false if there are more than WINDOW_MENU_MAX_SIZE items before it - * in the menu. - */ - @Override - public boolean isVisible() { - if (type == SPECIAL_MORE) { - Container parent = getParent(); - - if (parent == null) { - return true; - } - int numWindows = parent.getComponentCount() - PRECEDING_WINDOW_MENU_ITEMS - SUBSEQUENT_WINDOW_MENU_ITEMS; - - updateSelection(); - return (numWindows <= 0) || (numWindows > WINDOW_MENU_MAX_SIZE); - } - updateSelection(); - return getIndex() >= 0; - } - - /** - * Returns true if this item should be enabled (selectable). - *

- * Returns false if it is a More Windows... item and there are no windows. - */ - @Override - public boolean isEnabled() { - if (type == SPECIAL_MORE) { - Container parent = getParent(); - - if (parent == null) { - return true; - } - int numWindows = parent.getComponentCount() - PRECEDING_WINDOW_MENU_ITEMS - SUBSEQUENT_WINDOW_MENU_ITEMS; - - return (numWindows > 0); - } - return true; - } - - /** - * Determines if this menu item should currently show as "selected". - *

- * The item should be seleced if the window it's tied to has focus. - */ - @Override - public boolean isSelected() { - return (type != SPECIAL_MORE) && (window != null && window.getDesktopPane() != null) - && window.getDesktopPane().getSelectedFrame() == window; - } - - /** - * Makes sure the underlying menu item knows if we're selected. - */ - public void updateSelection() { - setSelected(isSelected()); // Sort of a silly thing to do... - setEnabled(isEnabled()); - } - - /** - * @return the EditWindow that this menu item is tied to. - */ - public EditWindow getEditWindow() { - return window; - } - - /** - * Creates a string representation of this object. - *

- * Handy for repurposing the menu items as list items :-) - */ - @Override - public String toString() { - return (type == SPECIAL_MORE) ? "" : getFileName(); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/ColorAndStyle.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/ColorAndStyle.java deleted file mode 100644 index bbdedc1..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/ColorAndStyle.java +++ /dev/null @@ -1,159 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import java.awt.Color; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.BorderFactory; -import javax.swing.JButton; -import javax.swing.JColorChooser; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.border.BevelBorder; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import net.sf.robocode.ui.editor.FontStyle; - - -/** - * Class that is used for maintaining a text color and font style for an editor. - * - * @author Flemming N. Larsen (original) - * @since 1.8.3.0 - */ -public class ColorAndStyle { - private final JLabel label; - private final JButton coloredButton; - private final JComboBox fontStyleComboBox; - private final List listeners = new ArrayList(); - - private Color oldColor; - private FontStyle oldStyle; - - public ColorAndStyle(String label, final Color color, final FontStyle fontStyle) { - this.label = new JLabel(label); - - coloredButton = createColoredButton(color); - if (coloredButton != null) { - coloredButton.addChangeListener(new ChangeListener() { - @Override - public void stateChanged(ChangeEvent e) { - if (!coloredButton.getBackground().equals(color)) { - notifyColorChanged(coloredButton.getBackground()); - } - } - }); - } - - fontStyleComboBox = fontStyle == null ? null : ComboBoxUtil.createFontStyleComboBox(fontStyle); - if (fontStyleComboBox != null) { - fontStyleComboBox.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - FontStyle newStyle = ComboBoxUtil.getSelectedStyle(fontStyleComboBox); - if (oldStyle != newStyle) { - notifyStyleChanged(newStyle); - oldStyle = newStyle; - } - } - }); - } - } - - public JLabel getLabel() { - return label; - } - - public JButton getColoredButton() { - return coloredButton; - } - - public JComboBox getFontStyleComboBox() { - return fontStyleComboBox; - } - - public void addListener(IColorAndStyleListener listener) { - listeners.add(listener); - } - - public void removeListener(IColorAndStyleListener listener) { - listeners.remove(listener); - } - - public Color getSelectedColor() { - return (coloredButton == null) ? null : coloredButton.getBackground(); - } - - public void setSelectedColor(Color newColor) { - if (coloredButton != null) { - coloredButton.setBackground(newColor); - } - notifyColorChanged(newColor); - } - - public FontStyle getSelectedStyle() { - return (fontStyleComboBox == null) ? null : ComboBoxUtil.getSelectedStyle(fontStyleComboBox); - } - - public void setSelectedStyle(FontStyle newStyle) { - if (fontStyleComboBox != null) { - ComboBoxUtil.setSelected(fontStyleComboBox, newStyle); - } - notifyStyleChanged(newStyle); - } - - private void notifyColorChanged(Color newColor) { - if (newColor == null || !newColor.equals(oldColor)) { - for (IColorAndStyleListener listener : listeners) { - listener.colorChanged(newColor); - } - oldColor = newColor; - } - } - - private void notifyStyleChanged(FontStyle newStyle) { - if (newStyle == null || !newStyle.equals(oldStyle)) { - for (IColorAndStyleListener listener : listeners) { - listener.styleChanged(newStyle); - } - oldStyle = newStyle; - } - } - - private static JButton createColoredButton(Color color) { - final JButton button = new JButton(); - button.setBackground(color); - button.setContentAreaFilled(false); - button.setOpaque(true); - Dimension size = new Dimension(24, 24); - button.setPreferredSize(size); - button.setSize(size); - button.setMaximumSize(size); - button.setMinimumSize(size); - button.setBorder(BorderFactory.createBevelBorder(BevelBorder.RAISED)); - - button.addActionListener(new ActionListener() { - @Override - public void actionPerformed(ActionEvent e) { - Color selectedColor = JColorChooser.showDialog(null, "Pick a color", button.getBackground()); - if (selectedColor != null) { - button.setBackground(selectedColor); - } - } - }); - - return button; - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/ColorAndStyleAdapter.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/ColorAndStyleAdapter.java deleted file mode 100644 index 270f58c..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/ColorAndStyleAdapter.java +++ /dev/null @@ -1,28 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import java.awt.Color; - -import net.sf.robocode.ui.editor.FontStyle; - - -/** - * Adapter class for the {@link IColorAndStyleListener} interface. - * - * @author Flemming N. Larsen (original) - * @since 1.8.3.0 - */ -public abstract class ColorAndStyleAdapter implements IColorAndStyleListener { - @Override - public void colorChanged(Color newColor) {} - - @Override - public void styleChanged(FontStyle newStyle) {} -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/ComboBoxUtil.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/ComboBoxUtil.java deleted file mode 100644 index 853df84..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/ComboBoxUtil.java +++ /dev/null @@ -1,92 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import java.awt.Component; -import java.awt.Font; -import java.util.ArrayList; -import java.util.List; - -import javax.swing.ComboBoxModel; -import javax.swing.DefaultListCellRenderer; -import javax.swing.JComboBox; -import javax.swing.JLabel; -import javax.swing.JList; - -import net.sf.robocode.ui.editor.FontStyle; - - -/** - * Class for utilizing JComboBoxes. - * - * @author Flemming N. Larsen (original) - * @since 1.8.3.0 - */ -public class ComboBoxUtil { - - public static void setSelected(JComboBox comboBox, String name) { - ComboBoxModel model = comboBox.getModel(); - for (int i = 0; i < model.getSize(); i++) { - String itemName = (String) model.getElementAt(i); - if (itemName.equalsIgnoreCase(name)) { - model.setSelectedItem(itemName); - break; - } - } - } - - public static void setSelected(JComboBox comboBox, FontStyle fontStyle) { - ComboBoxModel model = comboBox.getModel(); - for (int i = 0; i < model.getSize(); i++) { - String name = (String) model.getElementAt(i); - FontStyle style = FontStyle.fromName(name); - if (style != null && style == fontStyle) { - model.setSelectedItem(name); - break; - } - } - } - - public static String getSelectedName(JComboBox comboBox) { - return (String) comboBox.getSelectedItem(); - } - - public static JComboBox createFontStyleComboBox(FontStyle fontStyle) { - List fontStyles = new ArrayList(); - for (FontStyle style : FontStyle.values()) { - fontStyles.add(style.getName()); - } - JComboBox comboBox = new JComboBox(fontStyles.toArray()); - comboBox.setRenderer(new FontStyleCellRenderer()); - - ComboBoxUtil.setSelected(comboBox, fontStyle); - - return comboBox; - } - - public static FontStyle getSelectedStyle(JComboBox comboBox) { - return FontStyle.fromName((String) comboBox.getSelectedItem()); - } - - private static class FontStyleCellRenderer extends DefaultListCellRenderer { - private static final long serialVersionUID = 1L; - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - JLabel label = (JLabel) super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - FontStyle fontStyle = FontStyle.fromName((String) value); - int styleFlags = (fontStyle == null) ? Font.PLAIN : fontStyle.getFontStyleFlags(); - - Font font = new Font((String) value, styleFlags, 12); - label.setFont(font); - return label; - } - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorProperties.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorProperties.java deleted file mode 100644 index 8843551..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorProperties.java +++ /dev/null @@ -1,70 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import java.io.File; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Properties; - -import net.sf.robocode.ui.editor.IEditorProperties; - - -/** - * Handles the editor properties. - * - * @author Flemming N. Larsen (original) - * - * @since 1.8.3.0 - */ -public class EditorProperties implements IEditorProperties { - - private static final String DEFAULT_THEME_NAME = "Robocode White Theme"; - - private static final String THEME_NAME = "editor.theme"; - - private String themeName; - - private final Properties props = new Properties(); - - @Override - public String getThemeName() { - String themeName = this.themeName; - if (themeName == null) { - themeName = props.getProperty(THEME_NAME); - } - if (themeName == null) { - themeName = DEFAULT_THEME_NAME; - } else { - File file = EditorThemePropertiesManager.getFilepath(themeName); - if (!file.exists()) { - themeName = DEFAULT_THEME_NAME; - } - } - this.themeName = themeName; - return themeName; - } - - public void setThemeName(String themeName) { - this.themeName = themeName; - } - - public void load(InputStream is) throws IOException { - props.load(is); - - themeName = props.getProperty(THEME_NAME); - } - - public void store(OutputStream os, String header) throws IOException { - props.setProperty(THEME_NAME, themeName); - - props.store(os, header); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorPropertiesManager.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorPropertiesManager.java deleted file mode 100644 index 0b5add2..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorPropertiesManager.java +++ /dev/null @@ -1,74 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import static net.sf.robocode.io.Logger.logError; -import static net.sf.robocode.io.Logger.logMessage; - -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; - - -/** - * Manages the editor property file. - * - * @author Flemming N. Larsen (original) - * - * @since 1.8.3.0 - */ -public class EditorPropertiesManager { - - private static EditorProperties editorProperties; - - public static EditorProperties getEditorProperties() { - if (editorProperties == null) { - editorProperties = new EditorProperties(); - - FileInputStream in = null; - File file = null; - try { - in = new FileInputStream(FileUtil.getEditorConfigFile()); - getEditorProperties().load(in); - } catch (FileNotFoundException e) { - logMessage("Editor properties file was not found. A new one will be created."); - } catch (IOException e) { - logError("Error while reading file: " + file, e); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException ignored) {} - } - } - } - return editorProperties; - } - - public static void saveEditorProperties() { - FileOutputStream out = null; - try { - out = new FileOutputStream(FileUtil.getEditorConfigFile()); - getEditorProperties().store(out, "Robocode Editor Properties"); - } catch (IOException e) { - Logger.logError(e); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException ignored) {} - } - } - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorThemeProperties.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorThemeProperties.java deleted file mode 100644 index b1ac011..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorThemeProperties.java +++ /dev/null @@ -1,541 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import java.awt.Color; -import java.awt.Font; -import java.io.IOException; -import java.io.InputStream; -import java.io.OutputStream; -import java.util.Properties; - -import net.sf.robocode.ui.editor.FontStyle; - - -/** - * Handles the editor theme properties. - * - * @author Flemming N. Larsen (original) - * - * @since 1.8.3.0 - */ -public class EditorThemeProperties implements IEditorThemeProperties { - - // ---- Default Colors and Styles ---- - - private static final String DEFAULT_THEME_NAME = EditorPropertiesManager.getEditorProperties().getThemeName(); - - private static final String DEFAULT_FONT_NAME = "Monospaced"; - private static final int DEFAULT_FONT_SIZE = 14; - - private static final Color DEFAULT_BACKGROUND_COLOR = Color.WHITE; - - private static final Color DEFAULT_LINE_NUMBER_BACKGROUND_COLOR = new Color(0xDD, 0xDD, 0xDD); - private static final Color DEFAULT_LINE_NUMBER_TEXT_COLOR = Color.BLACK; - - private static final Color DEFAULT_HIGHLIGHTED_LINE_COLOR = new Color(0xFF, 0xFF, 0x7F); - private static final Color DEFAULT_SELECTION_COLOR = new Color(0x33, 0x99, 0xFF); - private static final Color DEFAULT_SELECTED_TEXT_COLOR = Color.WHITE; - - private static final Color DEFAULT_NORMAL_TEXT_COLOR = Color.BLACK; - private static final FontStyle DEFAULT_NORMAL_TEXT_STYLE = FontStyle.PLAIN; - - private static final Color DEFAULT_COMMENT_TEXT_COLOR = new Color(0x00, 0xAF, 0x00); - private static final FontStyle DEFAULT_COMMENT_TEXT_STYLE = FontStyle.PLAIN; - - private static final Color DEFAULT_QUOTED_TEXT_COLOR = new Color(0x7f, 0x00, 0x00); - private static final FontStyle DEFAULT_QUOTED_TEXT_STYLE = FontStyle.PLAIN; - - private static final Color DEFAULT_KEYWORD_TEXT_COLOR = new Color(0x00, 0x00, 0xAF); - private static final FontStyle DEFAULT_KEYWORD_TEXT_STYLE = FontStyle.BOLD; - - private static final Color DEFAULT_LITERAL_TEXT_COLOR = new Color(0x00, 0x00, 0xAF); - private static final FontStyle DEFAULT_LITERAL_TEXT_STYLE = FontStyle.BOLD; - - private static final Color DEFAULT_ANNOTATION_TEXT_COLOR = new Color(0x7F, 0x7F, 0x7F); - private static final FontStyle DEFAULT_ANNOTATION_TEXT_STYLE = FontStyle.BOLD; - - // ---- Property Names ---- - - private static final String THEME_NAME = "editor.theme"; - - private static final String FONT_NAME = "editor.font.name"; - private static final String FONT_SIZE = "editor.font.size"; - - private static final String BACKGROUND_COLOR = "editor.background.color"; - - private static final String LINE_NUMBER_BACKGROUND_COLOR = "editor.lineNumber.background.color"; - private static final String LINE_NUMBER_TEXT_COLOR = "editor.lineNumber.text.color"; - - private static final String HIGHLIGHTED_LINE_COLOR = "editor.highlighted.line.color"; - - private static final String SELECTION_COLOR = "editor.selected.background.color"; - private static final String SELECTED_TEXT_COLOR = "editor.selected.text.color"; - - private static final String NORMAL_TEXT_COLOR = "editor.text.color.normal"; - private static final String NORMAL_TEXT_STYLE = "editor.text.style.normal"; - - private static final String COMMENT_TEXT_COLOR = "editor.text.color.comment"; - private static final String COMMENT_TEXT_STYLE = "editor.text.style.comment"; - - private static final String QUOTED_TEXT_COLOR = "editor.text.color.quoted"; - private static final String QUOTED_TEXT_STYLE = "editor.text.style.quoted"; - - private static final String KEYWORD_TEXT_COLOR = "editor.text.color.keyword"; - private static final String KEYWORD_TEXT_STYLE = "editor.text.style.keyword"; - - private static final String LITERAL_TEXT_COLOR = "editor.text.color.literal"; - private static final String LITERAL_TEXT_STYLE = "editor.text.style.literal"; - - private static final String ANNOTATION_TEXT_COLOR = "editor.text.color.annotation"; - private static final String ANNOTATION_TEXT_STYLE = "editor.text.style.annotation"; - - private String themeName; - - private String fontName; - private Integer fontSize; - - private ColorPropertyStrategy backgroundColor = new ColorPropertyStrategy(BACKGROUND_COLOR, DEFAULT_BACKGROUND_COLOR); - private ColorPropertyStrategy lineNumberBackgroundColor = new ColorPropertyStrategy(LINE_NUMBER_BACKGROUND_COLOR, - DEFAULT_LINE_NUMBER_BACKGROUND_COLOR); - private ColorPropertyStrategy lineNumberTextColor = new ColorPropertyStrategy(LINE_NUMBER_TEXT_COLOR, - DEFAULT_LINE_NUMBER_TEXT_COLOR); - private ColorPropertyStrategy highlightedLineColor = new ColorPropertyStrategy(HIGHLIGHTED_LINE_COLOR, - DEFAULT_HIGHLIGHTED_LINE_COLOR); - private ColorPropertyStrategy selectionColor = new ColorPropertyStrategy(SELECTION_COLOR, DEFAULT_SELECTION_COLOR); - private ColorPropertyStrategy selectedTextColor = new ColorPropertyStrategy(SELECTED_TEXT_COLOR, - DEFAULT_SELECTED_TEXT_COLOR); - private ColorPropertyStrategy normalTextColor = new ColorPropertyStrategy(NORMAL_TEXT_COLOR, - DEFAULT_NORMAL_TEXT_COLOR); - private FontStylePropertyStrategy normalTextStyle = new FontStylePropertyStrategy(NORMAL_TEXT_STYLE, - DEFAULT_NORMAL_TEXT_STYLE); - private ColorPropertyStrategy commentTextColor = new ColorPropertyStrategy(COMMENT_TEXT_COLOR, - DEFAULT_COMMENT_TEXT_COLOR); - private FontStylePropertyStrategy commentTextStyle = new FontStylePropertyStrategy(COMMENT_TEXT_STYLE, - DEFAULT_COMMENT_TEXT_STYLE); - private ColorPropertyStrategy quotedTextColor = new ColorPropertyStrategy(QUOTED_TEXT_COLOR, - DEFAULT_QUOTED_TEXT_COLOR); - private FontStylePropertyStrategy quotedTextStyle = new FontStylePropertyStrategy(QUOTED_TEXT_STYLE, - DEFAULT_QUOTED_TEXT_STYLE); - private ColorPropertyStrategy keywordTextColor = new ColorPropertyStrategy(KEYWORD_TEXT_COLOR, - DEFAULT_KEYWORD_TEXT_COLOR); - private FontStylePropertyStrategy keywordTextStyle = new FontStylePropertyStrategy(KEYWORD_TEXT_STYLE, - DEFAULT_KEYWORD_TEXT_STYLE); - private ColorPropertyStrategy literalTextColor = new ColorPropertyStrategy(LITERAL_TEXT_COLOR, - DEFAULT_LITERAL_TEXT_COLOR); - private FontStylePropertyStrategy literalTextStyle = new FontStylePropertyStrategy(LITERAL_TEXT_STYLE, - DEFAULT_LITERAL_TEXT_STYLE); - private ColorPropertyStrategy annotationTextColor = new ColorPropertyStrategy(ANNOTATION_TEXT_COLOR, - DEFAULT_ANNOTATION_TEXT_COLOR); - private FontStylePropertyStrategy annotationTextStyle = new FontStylePropertyStrategy(ANNOTATION_TEXT_STYLE, - DEFAULT_ANNOTATION_TEXT_STYLE); - - private IPropertyStrategy[] colorAndStyleProps = new IPropertyStrategy[] { - backgroundColor, lineNumberBackgroundColor, lineNumberTextColor, highlightedLineColor, selectionColor, - selectedTextColor, normalTextColor, normalTextStyle, commentTextColor, commentTextStyle, quotedTextColor, - quotedTextStyle, keywordTextColor, keywordTextStyle, literalTextColor, literalTextStyle, annotationTextColor, - annotationTextStyle - }; - - private final Properties props = new Properties(); - - private boolean isChanged; - - public String getThemeName() { - String themeName = this.themeName; - if (themeName == null) { - themeName = props.getProperty(THEME_NAME); - } - if (themeName == null) { - themeName = DEFAULT_THEME_NAME; - } - this.themeName = themeName; - return themeName; - } - - public void setThemeName(String newName) { - this.themeName = newName; - EditorThemePropertiesManager.notifyThemeNameChanged(newName); - } - - public Font getFont() { - return new Font(getFontName(), getNormalTextStyle().getFontStyleFlags(), getFontSize()); - } - - public void setFontName(String newName) { - this.fontName = newName; - EditorThemePropertiesManager.notifyFontNameChanged(newName); - isChanged = true; - } - - @Override - public String getFontName() { - String fontName = this.fontName; - if (fontName == null) { - fontName = props.getProperty(FONT_NAME); - } - if (fontName == null) { - fontName = DEFAULT_FONT_NAME; - } - this.fontName = fontName; - return fontName; - } - - public void setFontSize(int newSize) { - this.fontSize = newSize; - EditorThemePropertiesManager.notifyFontSizeChanged(newSize); - isChanged = true; - } - - @Override - public int getFontSize() { - Integer fontSize = this.fontSize; - if (fontSize == null) { - String value = props.getProperty(FONT_SIZE); - try { - fontSize = Integer.parseInt(value); - } catch (NumberFormatException ignore) {} - } - if (fontSize == null) { - fontSize = DEFAULT_FONT_SIZE; - } - this.fontSize = fontSize; - return fontSize; - } - - public void setBackgroundColor(Color newColor) { - backgroundColor.set(newColor); - EditorThemePropertiesManager.notifyBackgroundColorChanged(newColor); - } - - @Override - public Color getBackgroundColor() { - return backgroundColor.get(); - } - - public void setLineNumberBackgroundColor(Color newColor) { - lineNumberBackgroundColor.set(newColor); - EditorThemePropertiesManager.notifyLineNumberBackgroundColorChanged(newColor); - } - - @Override - public Color getLineNumberBackgroundColor() { - return lineNumberBackgroundColor.get(); - } - - public void setLineNumberTextColor(Color newColor) { - lineNumberTextColor.set(newColor); - EditorThemePropertiesManager.notifyLineNumberTextColorChanged(newColor); - } - - @Override - public Color getLineNumberTextColor() { - return lineNumberTextColor.get(); - } - - public void setHighlightedLineColor(Color newColor) { - highlightedLineColor.set(newColor); - EditorThemePropertiesManager.notifyHighlightedLineColorChanged(newColor); - } - - @Override - public Color getHighlightedLineColor() { - return highlightedLineColor.get(); - } - - public void setSelectionColor(Color newColor) { - selectionColor.set(newColor); - EditorThemePropertiesManager.notifySelectionColorChanged(newColor); - } - - @Override - public Color getSelectionColor() { - return selectionColor.get(); - } - - public void setSelectedTextColor(Color newColor) { - selectedTextColor.set(newColor); - EditorThemePropertiesManager.notifySelectedTextColorChanged(newColor); - } - - @Override - public Color getSelectedTextColor() { - return selectedTextColor.get(); - } - - public void setNormalTextColor(Color newColor) { - normalTextColor.set(newColor); - EditorThemePropertiesManager.notifyNormalTextColorChanged(newColor); - } - - @Override - public Color getNormalTextColor() { - return normalTextColor.get(); - } - - public void setNormalTextStyle(FontStyle newStyle) { - normalTextStyle.set(newStyle); - EditorThemePropertiesManager.notifyNormalTextStyleChanged(newStyle); - } - - @Override - public FontStyle getNormalTextStyle() { - return normalTextStyle.get(); - } - - public void setCommentTextColor(Color newColor) { - commentTextColor.set(newColor); - EditorThemePropertiesManager.notifyCommentTextColorChanged(newColor); - } - - @Override - public Color getCommentTextColor() { - return commentTextColor.get(); - } - - public void setCommentTextStyle(FontStyle newStyle) { - commentTextStyle.set(newStyle); - EditorThemePropertiesManager.notifyCommentTextStyleChanged(newStyle); - } - - @Override - public FontStyle getCommentTextStyle() { - return commentTextStyle.get(); - } - - public void setQuotedTextColor(Color newColor) { - quotedTextColor.set(newColor); - EditorThemePropertiesManager.notifyQuotedTextColorChanged(newColor); - } - - @Override - public Color getQuotedTextColor() { - return quotedTextColor.get(); - } - - public void setQuotedTextStyle(FontStyle newStyle) { - quotedTextStyle.set(newStyle); - EditorThemePropertiesManager.notifyQuotedTextStyleChanged(newStyle); - } - - @Override - public FontStyle getQuotedTextStyle() { - return quotedTextStyle.get(); - } - - public void setKeywordTextColor(Color newColor) { - keywordTextColor.set(newColor); - EditorThemePropertiesManager.notifyKeywordTextColorChanged(newColor); - } - - @Override - public Color getKeywordTextColor() { - return keywordTextColor.get(); - } - - public void setKeywordTextStyle(FontStyle newStyle) { - keywordTextStyle.set(newStyle); - EditorThemePropertiesManager.notifyKeywordTextStyleChanged(newStyle); - } - - @Override - public FontStyle getKeywordTextStyle() { - return keywordTextStyle.get(); - } - - public void setLiteralTextColor(Color newColor) { - literalTextColor.set(newColor); - EditorThemePropertiesManager.notifyLiteralTextColorChanged(newColor); - } - - @Override - public Color getLiteralTextColor() { - return literalTextColor.get(); - } - - public void setLiteralTextStyle(FontStyle newStyle) { - literalTextStyle.set(newStyle); - EditorThemePropertiesManager.notifyLiteralTextStyleChanged(newStyle); - } - - @Override - public FontStyle getLiteralTextStyle() { - return literalTextStyle.get(); - } - - public void setAnnotationTextColor(Color newColor) { - annotationTextColor.set(newColor); - EditorThemePropertiesManager.notifyAnnotationTextColorChanged(newColor); - } - - @Override - public Color getAnnotationTextColor() { - return annotationTextColor.get(); - } - - public void setAnnotationTextStyle(FontStyle newStyle) { - annotationTextStyle.set(newStyle); - EditorThemePropertiesManager.notifyAnnotationTextStyleChanged(newStyle); - } - - @Override - public FontStyle getAnnotationTextStyle() { - return annotationTextStyle.get(); - } - - public void load(InputStream is) throws IOException { - // Reset (clean) the property values before loading them - for (IPropertyStrategy propertyStrategy : colorAndStyleProps) { - propertyStrategy.set(null); // clean value - propertyStrategy.save(); // store cleaned value in property - } - - props.load(is); - - themeName = props.getProperty(THEME_NAME, DEFAULT_THEME_NAME); - fontName = props.getProperty(FONT_NAME, DEFAULT_FONT_NAME); - try { - fontSize = Integer.parseInt(props.getProperty(FONT_SIZE, "" + DEFAULT_FONT_SIZE)); - } catch (NumberFormatException e) { - fontSize = DEFAULT_FONT_SIZE; - } - - for (IPropertyStrategy propertyStrategy : colorAndStyleProps) { - propertyStrategy.load(); - } - - // Reset 'changed' flag - isChanged = false; - } - - public void store(OutputStream os, String header) throws IOException { - props.setProperty(THEME_NAME, themeName); - props.setProperty(FONT_NAME, fontName); - props.setProperty(FONT_SIZE, "" + fontSize); - - for (IPropertyStrategy propertyStrategy : colorAndStyleProps) { - propertyStrategy.save(); - } - - props.store(os, header); - - // Reset 'changed' flag - isChanged = false; - } - - public boolean isChanged() { - return isChanged; - } - - interface IPropertyStrategy { - V get(); - void set(V value); - void load(); - void save(); - } - - - class ColorPropertyStrategy implements IPropertyStrategy { - - final String propertyName; - final Color defaultColor; - Color color; - - ColorPropertyStrategy(String propertyName, Color defaultColor) { - this.propertyName = propertyName; - this.defaultColor = defaultColor; - this.color = defaultColor; - } - - @Override - public Color get() { - return color == null ? defaultColor : color; - } - - @Override - public void set(Color color) { - if ((color == null && this.color == null) || (color != null && color.equals(this.color))) { - return; - } - this.color = color; - isChanged = true; - } - - @Override - public void load() { - color = fromPropertyToColor(propertyName); - } - - @Override - public void save() { - props.setProperty(propertyName, toHexString(get())); - } - - private Color fromPropertyToColor(String propertyName) { - String hexValue = props.getProperty(propertyName); - if (hexValue != null) { - try { - // Yes, we need to use a Long instead of an Integer here + - // we mask out the alpha channel - int rgb = (int) Long.parseLong(hexValue, 16) & 0x00FFFFFF; - return new Color(rgb); - } catch (NumberFormatException ignore) {} - } - return null; - } - } - - - class FontStylePropertyStrategy implements IPropertyStrategy { - - final String propertyName; - final FontStyle defaultStyle; - FontStyle style; - - FontStylePropertyStrategy(String propertyName, FontStyle defaultStyle) { - this.propertyName = propertyName; - this.defaultStyle = defaultStyle; - this.style = defaultStyle; - } - - @Override - public FontStyle get() { - return style == null ? defaultStyle : style; - } - - @Override - public void set(FontStyle style) { - if ((style == null && this.style == null) || (style != null && style.equals(this.style))) { - return; - } - this.style = style; - isChanged = true; - } - - @Override - public void load() { - style = fromPropertyToFontStyle(propertyName); - } - - @Override - public void save() { - props.setProperty(propertyName, "" + get().getName()); - } - - private FontStyle fromPropertyToFontStyle(String propertyName) { - String styleName = props.getProperty(propertyName); - return (styleName == null) ? null : FontStyle.fromName(styleName); - } - } - - private static String toHexString(Color color) { - // We mask out the alpha channel and format as RRGGBB - return String.format("%06X", color.getRGB() & 0x00FFFFFF); - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorThemePropertiesManager.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorThemePropertiesManager.java deleted file mode 100644 index d696438..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorThemePropertiesManager.java +++ /dev/null @@ -1,248 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import static net.sf.robocode.io.Logger.logError; - -import java.awt.Color; -import java.awt.Font; -import java.io.File; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.ui.editor.FontStyle; - - -/** - * Manages the editor theme property files. - * - * @author Flemming N. Larsen (original) - * - * @since 1.8.3.0 - */ -public class EditorThemePropertiesManager { - - private static final String EDITOR_THEME_PROPERTIES_FILE_EXT = ".properties"; - - private static final List listeners = new ArrayList(); - - private static EditorThemeProperties editorThemeProperties; - - public static void addListener(IEditorThemePropertyChangeListener listener) { - if (!listeners.contains(listener)) { - listeners.add(listener); - } - } - - public static void removeListener(IEditorThemePropertyChangeListener listener) { - listeners.remove(listener); - } - - public static void notifyThemeNameChanged(String newThemeName) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onThemeNameChanged(newThemeName); - } - } - - public static void notifyFontChanged(Font newFont) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onFontChanged(newFont); - } - } - - public static void notifyFontNameChanged(String newFontName) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onFontNameChanged(newFontName); - } - } - - public static void notifyFontSizeChanged(int newFontSize) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onFontSizeChanged(newFontSize); - } - } - - public static void notifyBackgroundColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onBackgroundColorChanged(newColor); - } - } - - public static void notifyLineNumberBackgroundColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onLineNumberBackgroundColorChanged(newColor); - } - } - - public static void notifyLineNumberTextColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onLineNumberTextColorChanged(newColor); - } - } - - public static void notifyHighlightedLineColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onHighlightedLineColorChanged(newColor); - } - } - - public static void notifySelectionColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onSelectionColorChanged(newColor); - } - } - - public static void notifySelectedTextColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onSelectedTextColorChanged(newColor); - } - } - - public static void notifyNormalTextColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onNormalTextColorChanged(newColor); - } - } - - public static void notifyNormalTextStyleChanged(FontStyle newStyle) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onNormalTextStyleChanged(newStyle); - } - } - - public static void notifyQuotedTextColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onQuotedTextColorChanged(newColor); - } - } - - public static void notifyQuotedTextStyleChanged(FontStyle newStyle) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onQuotedTextStyleChanged(newStyle); - } - } - - public static void notifyKeywordTextColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onKeywordTextColorChanged(newColor); - } - } - - public static void notifyKeywordTextStyleChanged(FontStyle newStyle) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onKeywordTextStyleChanged(newStyle); - } - } - - public static void notifyLiteralTextColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onLiteralTextColorChanged(newColor); - } - } - - public static void notifyLiteralTextStyleChanged(FontStyle newStyle) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onLiteralTextStyleChanged(newStyle); - } - } - - public static void notifyAnnotationTextColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onAnnotationTextColorChanged(newColor); - } - } - - public static void notifyAnnotationTextStyleChanged(FontStyle newStyle) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onAnnotationTextStyleChanged(newStyle); - } - } - - public static void notifyCommentTextColorChanged(Color newColor) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onCommentTextColorChanged(newColor); - } - } - - public static void notifyCommentTextStyleChanged(FontStyle newStyle) { - for (IEditorThemePropertyChangeListener listener : listeners) { - listener.onCommentTextStyleChanged(newStyle); - } - } - - public static EditorThemeProperties getCurrentEditorThemeProperties() { - if (editorThemeProperties == null) { - editorThemeProperties = new EditorThemeProperties(); - - String themeName = EditorPropertiesManager.getEditorProperties().getThemeName(); - File filepath = EditorThemePropertiesManager.getFilepath(themeName); - - loadEditorThemeProperties(filepath); - } - return editorThemeProperties; - } - - public static void loadEditorThemeProperties(File filepath) { - if (filepath != null) { - FileInputStream in = null; - File file = null; - try { - in = new FileInputStream(filepath); - getCurrentEditorThemeProperties().load(in); - } catch (FileNotFoundException e) { - logError("Could not find file: " + file, e); - } catch (IOException e) { - logError("Error while reading file: " + file, e); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException ignored) {} - } - } - } - } - - public static void saveEditorThemeProperties(File filepath) { - FileOutputStream out = null; - try { - out = new FileOutputStream(filepath); - getCurrentEditorThemeProperties().store(out, "Robocode Editor Theme Properties"); - } catch (IOException e) { - Logger.logError(e); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException ignored) {} - } - } - } - - public static File getFilepath(String themeName) { - if (themeName == null) { - return null; - } - File configDirPath = FileUtil.getEditorThemeConfigDir(); - - String themeFileName = themeName + EDITOR_THEME_PROPERTIES_FILE_EXT; - - return new File(configDirPath, themeFileName); - } - - public static String getFileExt() { - return EDITOR_THEME_PROPERTIES_FILE_EXT; - } -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorThemePropertyChangeAdapter.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorThemePropertyChangeAdapter.java deleted file mode 100644 index fa8f21c..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/EditorThemePropertyChangeAdapter.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import java.awt.Color; -import java.awt.Font; - -import net.sf.robocode.ui.editor.FontStyle; - - -public class EditorThemePropertyChangeAdapter implements IEditorThemePropertyChangeListener { - - public void onThemeNameChanged(String newThemeName) {} - - public void onFontChanged(Font newFont) {} - - public void onFontNameChanged(String newFontName) {} - - public void onFontSizeChanged(int newFontSize) {} - - public void onBackgroundColorChanged(Color newColor) {} - - public void onLineNumberBackgroundColorChanged(Color newColor) {} - - public void onLineNumberTextColorChanged(Color newColor) {} - - public void onHighlightedLineColorChanged(Color newColor) {} - - public void onSelectionColorChanged(Color newColor) {} - - public void onSelectedTextColorChanged(Color newColor) {} - - public void onNormalTextColorChanged(Color newColor) {} - - public void onNormalTextStyleChanged(FontStyle newStyle) {} - - public void onQuotedTextColorChanged(Color newColor) {} - - public void onQuotedTextStyleChanged(FontStyle newStyle) {} - - public void onKeywordTextColorChanged(Color newColor) {} - - public void onKeywordTextStyleChanged(FontStyle newStyle) {} - - public void onLiteralTextColorChanged(Color newColor) {} - - public void onLiteralTextStyleChanged(FontStyle newStyle) {} - - public void onAnnotationTextColorChanged(Color newColor) {} - - public void onAnnotationTextStyleChanged(FontStyle newStyle) {} - - public void onCommentTextColorChanged(Color newColor) {} - - public void onCommentTextStyleChanged(FontStyle newStyle) {} -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/IColorAndStyleListener.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/IColorAndStyleListener.java deleted file mode 100644 index 21b7721..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/IColorAndStyleListener.java +++ /dev/null @@ -1,25 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import java.awt.Color; - -import net.sf.robocode.ui.editor.FontStyle; - - -/** - * Listener interface for the {@link ColorAndStyle} class. - * - * @author Flemming N. Larsen (original) - * @since 1.8.3.0 - */ -public interface IColorAndStyleListener { - void colorChanged(Color newColor); - void styleChanged(FontStyle newStyle); -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/IEditorThemeProperties.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/IEditorThemeProperties.java deleted file mode 100644 index 785ff89..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/IEditorThemeProperties.java +++ /dev/null @@ -1,59 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import java.awt.Color; -import java.awt.Font; - -import net.sf.robocode.ui.editor.FontStyle; - - -/** - * Interface for editor theme properties. - * - * @author Flemming N. Larsen (original) - * - * @since 1.8.3.0 - */ -public interface IEditorThemeProperties { - - String getThemeName(); - - Font getFont(); - String getFontName(); - int getFontSize(); - - Color getBackgroundColor(); - - Color getLineNumberBackgroundColor(); - Color getLineNumberTextColor(); - - Color getHighlightedLineColor(); - - Color getSelectionColor(); - Color getSelectedTextColor(); - - Color getNormalTextColor(); - FontStyle getNormalTextStyle(); - - Color getQuotedTextColor(); - FontStyle getQuotedTextStyle(); - - Color getKeywordTextColor(); - FontStyle getKeywordTextStyle(); - - Color getLiteralTextColor(); - FontStyle getLiteralTextStyle(); - - Color getAnnotationTextColor(); - FontStyle getAnnotationTextStyle(); - - Color getCommentTextColor(); - FontStyle getCommentTextStyle(); -} diff --git a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/IEditorThemePropertyChangeListener.java b/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/IEditorThemePropertyChangeListener.java deleted file mode 100644 index fd650c3..0000000 --- a/workspace_robo/robocode.ui.editor/src/main/java/net/sf/robocode/ui/editor/theme/IEditorThemePropertyChangeListener.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor.theme; - - -import java.awt.Color; -import java.awt.Font; - -import net.sf.robocode.ui.editor.FontStyle; - - -public interface IEditorThemePropertyChangeListener { - - void onThemeNameChanged(String newThemeName); - - void onFontChanged(Font newFont); - void onFontNameChanged(String newFontName); - void onFontSizeChanged(int newFontSize); - - void onBackgroundColorChanged(Color newColor); - - void onLineNumberBackgroundColorChanged(Color newColor); - void onLineNumberTextColorChanged(Color newColor); - - void onHighlightedLineColorChanged(Color newColor); - - void onSelectionColorChanged(Color newColor); - void onSelectedTextColorChanged(Color newColor); - - void onNormalTextColorChanged(Color newColor); - void onNormalTextStyleChanged(FontStyle newStyle); - - void onQuotedTextColorChanged(Color newColor); - void onQuotedTextStyleChanged(FontStyle newStyle); - - void onKeywordTextColorChanged(Color newColor); - void onKeywordTextStyleChanged(FontStyle newStyle); - - void onLiteralTextColorChanged(Color newColor); - void onLiteralTextStyleChanged(FontStyle newStyle); - - void onAnnotationTextColorChanged(Color newColor); - void onAnnotationTextStyleChanged(FontStyle newStyle); - - void onCommentTextColorChanged(Color newColor); - void onCommentTextStyleChanged(FontStyle newStyle); -} diff --git a/workspace_robo/robocode.ui/.classpath b/workspace_robo/robocode.ui/.classpath deleted file mode 100644 index aab3303..0000000 --- a/workspace_robo/robocode.ui/.classpath +++ /dev/null @@ -1,15 +0,0 @@ - - - - - - - - - - - - - - - \ No newline at end of file diff --git a/workspace_robo/robocode.ui/.project b/workspace_robo/robocode.ui/.project deleted file mode 100644 index c5e1c83..0000000 --- a/workspace_robo/robocode.ui/.project +++ /dev/null @@ -1,21 +0,0 @@ - - - robocode.ui - NO_M2ECLIPSE_SUPPORT: Project files created with the maven-eclipse-plugin are not supported in M2Eclipse. - - robocode.api - robocode.core - robocode.battle - robocode.host - robocode.repository - robocode.sound - - - - org.eclipse.jdt.core.javabuilder - - - - org.eclipse.jdt.core.javanature - - \ No newline at end of file diff --git a/workspace_robo/robocode.ui/.settings/org.eclipse.jdt.core.prefs b/workspace_robo/robocode.ui/.settings/org.eclipse.jdt.core.prefs deleted file mode 100644 index b12a989..0000000 --- a/workspace_robo/robocode.ui/.settings/org.eclipse.jdt.core.prefs +++ /dev/null @@ -1,9 +0,0 @@ -#Tue Nov 27 22:12:09 CET 2012 -org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.6 -eclipse.preferences.version=1 -encoding/src/main/java=8859_1 -org.eclipse.jdt.core.compiler.source=1.6 -encoding/src/test/resources=8859_1 -encoding/src/main/resources=8859_1 -encoding/src/test/java=8859_1 -org.eclipse.jdt.core.compiler.compliance=1.6 diff --git a/workspace_robo/robocode.ui/pom.xml b/workspace_robo/robocode.ui/pom.xml deleted file mode 100644 index 3355ac3..0000000 --- a/workspace_robo/robocode.ui/pom.xml +++ /dev/null @@ -1,35 +0,0 @@ - - - 4.0.0 - robocode.ui - Robocode UI - - robocode - net.sf.robocode - ${robocode.version} - - - - net.sf.robocode - robocode.api - ${project.version} - - - net.sf.robocode - robocode.core - ${project.version} - - - net.sf.robocode - robocode.battle - ${project.version} - - - net.sf.robocode - robocode.sound - ${project.version} - runtime - - - diff --git a/workspace_robo/robocode.ui/robocode.ui.iml b/workspace_robo/robocode.ui/robocode.ui.iml deleted file mode 100644 index 1e3dce7..0000000 --- a/workspace_robo/robocode.ui/robocode.ui.iml +++ /dev/null @@ -1,88 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/BrowserManager.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/BrowserManager.java deleted file mode 100644 index c5671dc..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/BrowserManager.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; - -import java.awt.Desktop; -import java.io.IOException; -import java.net.URI; -import java.net.URISyntaxException; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (original) - */ -public class BrowserManager { - - public static void openURL(String url) throws IOException { - - // Plan A: try to open the URL using the Java 6 Desktop class - if (Desktop.isDesktopSupported()) { - Desktop desktop = Desktop.getDesktop(); - if (desktop.isSupported(Desktop.Action.BROWSE)) { - try { - desktop.browse(new URI(url)); - return; // success - } catch (URISyntaxException e) { - Logger.logError(e); - } - } - // Fall thru to plan B - } - - // Plan B: try to open URL by calling a command-line tool for the specific OS - url = FileUtil.quoteFileName(url); - - Runtime rt = Runtime.getRuntime(); - String os = System.getProperty("os.name").toLowerCase(); - - if (os.startsWith("windows")) { - rt.exec("rundll32 url.dll, FileProtocolHandler " + url); - - } else if (os.startsWith("mac")) { - rt.exec("open " + url); - - } else if (os.indexOf("nix") >= 0 || os.indexOf("nux") >= 0) { - // Do a best guess on Unix until we get a platform independent way. - // Build a list of browsers to try, in this order. - final String[] browsers = { - "epiphany", "firefox", "mozilla", "konqueror", "galeon", "netscape", "opera", "links", "lynx" }; - - // Build a command string which looks like - // "browser1 "url" || browser2 "url" || ..." - StringBuffer cmd = new StringBuffer(); - - for (int i = 0; i < browsers.length; i++) { - cmd.append((i == 0 ? "" : " || ") + browsers[i] + " \"" + url + "\" "); - } - - rt.exec(new String[] { "sh", "-c", cmd.toString() }); - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/CheckList.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/CheckList.java deleted file mode 100644 index 114079b..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/CheckList.java +++ /dev/null @@ -1,220 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui; - - -import java.awt.Component; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.util.Arrays; -import java.util.Collection; -import java.util.HashSet; - -import javax.swing.DefaultListModel; -import javax.swing.JCheckBox; -import javax.swing.JList; -import javax.swing.ListCellRenderer; - -import net.sf.robocode.util.AlphanumericComparator; - - -/** - * A JList containing JCheckBox items. - * - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class CheckList extends JList { - - private DefaultListModel model; - - public CheckList() { - super(); - - initialize(); - } - - private void initialize() { - model = new DefaultListModel(); - setModel(model); - - // Use a CheckListRenderer (see below) to renderer list cells - setCellRenderer(new CheckListRenderer()); - - // Add a mouse listener to handle changing selection - addMouseListener(new MouseAdapter() { - public void mouseClicked(MouseEvent event) { - JList list = (JList) event.getSource(); - - // Get index of item clicked - int index = list.locationToIndex(event.getPoint()); - - if (index >= 0) { - if (event.getClickCount() == 2) { - CheckListItem item = (CheckListItem) model.getElementAt(index); - - // Toggle selected state - item.setSelected(!item.isSelected()); - - // Repaint cell - list.repaint(list.getCellBounds(index, index)); - } - } - } - }); - } - - public void clear() { - model.clear(); - } - - public int getLength() { - return model.getSize(); - } - - public String get(int index) { - return ((CheckListItem) model.getElementAt(index)).toString(); - } - - public void add(String label) { - model.addElement(new CheckListItem(label)); - } - - public void remove(int index) { - model.remove(index); - } - - public boolean contains(String label) { - if (label == null) { - return false; - } - for (int i = 0; i < model.getSize(); i++) { - CheckListItem item = (CheckListItem) model.getElementAt(i); - - if (label.equals(item.toString())) { - return true; - } - } - return false; - } - - public void sort() { - int size = model.getSize(); - - if (size > 0) { - CheckListItem[] items = new CheckListItem[size]; - - model.copyInto(items); - Arrays.sort(items); - - for (int i = 0; i < items.length; i++) { - model.setElementAt(items[i], i); - } - } - } - - public void setChecked(String label, boolean isChecked) { - if (label != null) { - for (int i = 0; i < model.getSize(); i++) { - CheckListItem item = (CheckListItem) model.getElementAt(i); - - if (label.equals(item.toString())) { - item.setSelected(isChecked); - break; - } - } - } - } - - public Collection getUnchecked() { - Collection unchecked = new HashSet(); - - for (int i = 0; i < model.getSize(); i++) { - CheckListItem item = (CheckListItem) model.getElementAt(i); - - if (!item.isSelected()) { - unchecked.add(item.toString()); - } - } - return unchecked; - } - - public Collection getAll() { - Collection all = new HashSet(); - - for (int i = 0; i < model.getSize(); i++) { - CheckListItem item = (CheckListItem) model.getElementAt(i); - - all.add(item.toString()); - } - return all; - } -} - - -/** - * Represents items in the list that can be selected. - */ -class CheckListItem implements Cloneable, Comparable { - private String label; - private boolean isSelected = true; - - public CheckListItem(String label) { - this.label = label; - } - - private CheckListItem(CheckListItem item) { - label = item.label; - isSelected = item.isSelected; - } - - public boolean isSelected() { - return isSelected; - } - - public void setSelected(boolean isSelected) { - this.isSelected = isSelected; - } - - // Must be here - public String toString() { - return label; - } - - // Must be here (for sorting) - public Object clone() { - return new CheckListItem(this); - } - - // Must be here (for sorting) - public int compareTo(CheckListItem item) { - return new AlphanumericComparator().compare(label, item.label); - } -} - - -/** - * CheckListRenderer handles rendering cells in the list using a check box. - */ -@SuppressWarnings("serial") -class CheckListRenderer extends JCheckBox implements ListCellRenderer { - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean hasFocus) { - setEnabled(list.isEnabled()); - setSelected(((CheckListItem) value).isSelected()); - setFont(list.getFont()); - if (isSelected) { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); - } else { - setBackground(list.getBackground()); - setForeground(list.getForeground()); - } - setText(value.toString()); - return this; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/IImageManager.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/IImageManager.java deleted file mode 100644 index 9272c68..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/IImageManager.java +++ /dev/null @@ -1,33 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui; - - -import net.sf.robocode.ui.gfx.RenderImage; - -import java.awt.*; - - -/** - * @author Pavel Savara (original) - */ -public interface IImageManager { - void initialize(); - - Image getGroundTileImage(int index); - - RenderImage getExplosionRenderImage(int which, int frame); - - RenderImage getExplosionDebriseRenderImage(); - - RenderImage getColoredBodyRenderImage(Integer color); - - RenderImage getColoredGunRenderImage(Integer color); - - RenderImage getColoredRadarRenderImage(Integer color); -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/IRobotDialogManager.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/IRobotDialogManager.java deleted file mode 100644 index d028cce..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/IRobotDialogManager.java +++ /dev/null @@ -1,30 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui; - - -import net.sf.robocode.ui.dialog.BattleButton; -import net.sf.robocode.ui.dialog.BattleDialog; -import net.sf.robocode.ui.dialog.RobotButton; -import net.sf.robocode.ui.dialog.RobotDialog; -import robocode.control.snapshot.IRobotSnapshot; - -import java.util.List; - - -/** - * @author Pavel Savara (original) - */ -public interface IRobotDialogManager { - void trim(List robots); - - void reset(); - - RobotDialog getRobotDialog(RobotButton robotButton, String name, boolean create); - BattleDialog getBattleDialog(BattleButton battleButton, boolean create); -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/IWindowManagerExt.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/IWindowManagerExt.java deleted file mode 100644 index f42eb4a..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/IWindowManagerExt.java +++ /dev/null @@ -1,71 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui; - - -import net.sf.robocode.battle.BattleProperties; -import net.sf.robocode.battle.BattleResultsTableModel; -import robocode.control.events.BattleCompletedEvent; - -import javax.swing.*; - - -/** - * @author Pavel Savara (original) - */ -public interface IWindowManagerExt extends IWindowManager { - void showAboutBox(); - - String showBattleOpenDialog(String defExt, String name); - - String saveBattleDialog(String path, String defExt, String name); - - void showReadMe(); - - void showVersionsTxt(); - - void showHelpApi(); - - void showFaq(); - - void showOnlineHelp(); - - void showJavaDocumentation(); - - void showRobocodeHome(); - - void showRoboWiki(); - - void showGoogleGroupRobocode(); - - void showRobocodeRepository(); - - void showOptionsPreferences(); - - void showResultsDialog(BattleCompletedEvent event); - - void showRankingDialog(boolean visible); - - void showRobocodeEditor(); - - void showRobotPackager(); - - void showRobotExtractor(JFrame owner); - - void showNewBattleDialog(BattleProperties battleProperties); - - boolean closeRobocodeEditor(); - - void showCreateTeamDialog(); - - void showImportRobotDialog(); - - void showSaveResultsDialog(BattleResultsTableModel tableModel); - - int getFPS(); -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/ImageManager.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/ImageManager.java deleted file mode 100644 index 2482c80..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/ImageManager.java +++ /dev/null @@ -1,236 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui; - - -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.ui.gfx.ImageUtil; -import net.sf.robocode.ui.gfx.RenderImage; - -import java.awt.*; -import java.util.*; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Titus Chen (contributor) - */ -public class ImageManager implements IImageManager { - - private final ISettingsManager properties; - - private Image[] groundImages; - - private RenderImage[][] explosionRenderImages; - private RenderImage debriseRenderImage; - - private Image bodyImage; - private Image gunImage; - private Image radarImage; - - private static final int MAX_NUM_COLORS = 256; - - private HashMap robotBodyImageCache; - private HashMap robotGunImageCache; - private HashMap robotRadarImageCache; - - public ImageManager(ISettingsManager properties) { - this.properties = properties; - } - - public void initialize() { - // Note that initialize could be called in order to reset all images (image buffering) - - // Reset image cache - groundImages = new Image[5]; - explosionRenderImages = null; - debriseRenderImage = null; - bodyImage = null; - gunImage = null; - radarImage = null; - robotBodyImageCache = new RenderCache(); - robotGunImageCache = new RenderCache(); - robotRadarImageCache = new RenderCache(); - - // Read images into the cache - getBodyImage(); - getGunImage(); - getRadarImage(); - getExplosionRenderImage(0, 0); - } - - public Image getGroundTileImage(int index) { - if (groundImages[index] == null) { - groundImages[index] = getImage("/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_" + index + ".png"); - } - return groundImages[index]; - } - - public RenderImage getExplosionRenderImage(int which, int frame) { - if (explosionRenderImages == null) { - int numExplosion, numFrame; - String filename; - - List> explosions = new ArrayList>(); - - boolean done = false; - - for (numExplosion = 1; !done; numExplosion++) { - List frames = new ArrayList(); - - for (numFrame = 1;; numFrame++) { - filename = "/net/sf/robocode/ui/images/explosion/explosion" + numExplosion + '-' + numFrame + ".png"; - - if (ImageManager.class.getResource(filename) == null) { - if (numFrame == 1) { - done = true; - } else { - explosions.add(frames); - } - break; - } - - frames.add(new RenderImage(getImage(filename))); - } - } - - numExplosion = explosions.size(); - explosionRenderImages = new RenderImage[numExplosion][]; - - for (int i = numExplosion - 1; i >= 0; i--) { - explosionRenderImages[i] = explosions.get(i).toArray(new RenderImage[explosions.size()]); - } - } - return explosionRenderImages[which][frame]; - } - - public RenderImage getExplosionDebriseRenderImage() { - if (debriseRenderImage == null) { - debriseRenderImage = new RenderImage(getImage("/net/sf/robocode/ui/images/ground/explode_debris.png")); - } - return debriseRenderImage; - } - - private Image getImage(String filename) { - Image image = ImageUtil.getImage(filename); - - if (properties.getOptionsRenderingBufferImages()) { - image = ImageUtil.getBufferedImage(image); - } - return image; - } - - /** - * Gets the body image - * Loads from disk if necessary. - * - * @return the body image - */ - private Image getBodyImage() { - if (bodyImage == null) { - bodyImage = getImage("/net/sf/robocode/ui/images/body.png"); - } - return bodyImage; - } - - /** - * Gets the gun image - * Loads from disk if necessary. - * - * @return the gun image - */ - private Image getGunImage() { - if (gunImage == null) { - gunImage = getImage("/net/sf/robocode/ui/images/turret.png"); - } - return gunImage; - } - - /** - * Gets the radar image - * Loads from disk if necessary. - * - * @return the radar image - */ - private Image getRadarImage() { - if (radarImage == null) { - radarImage = getImage("/net/sf/robocode/ui/images/radar.png"); - } - return radarImage; - } - - public RenderImage getColoredBodyRenderImage(Integer color) { - RenderImage img = robotBodyImageCache.get(color); - - if (img == null) { - img = new RenderImage(ImageUtil.createColouredRobotImage(getBodyImage(), new Color(color, true))); - robotBodyImageCache.put(color, img); - } - return img; - } - - public RenderImage getColoredGunRenderImage(Integer color) { - RenderImage img = robotGunImageCache.get(color); - - if (img == null) { - img = new RenderImage(ImageUtil.createColouredRobotImage(getGunImage(), new Color(color, true))); - robotGunImageCache.put(color, img); - } - return img; - } - - public RenderImage getColoredRadarRenderImage(Integer color) { - RenderImage img = robotRadarImageCache.get(color); - - if (img == null) { - img = new RenderImage(ImageUtil.createColouredRobotImage(getRadarImage(), new Color(color, true))); - robotRadarImageCache.put(color, img); - } - return img; - } - - /** - * Class used for caching rendered robot parts in various colors. - * - * @author Titus Chen - */ - @SuppressWarnings("serial") - private static class RenderCache extends LinkedHashMap { - - /* Note about initial capacity: - * To avoid rehashing (inefficient though probably unavoidable), initial - * capacity must be at least 1 greater than the maximum capacity. - * However, initial capacities are set to the smallest power of 2 greater - * than or equal to the passed argument, resulting in 512 with this code. - * I was not aware of this before, but notice: the current implementation - * behaves similarly. The simple solution would be to set maximum capacity - * to 255, but the problem with doing so is that in a battle of 256 robots - * of different colors, the net result would end up being real-time - * rendering due to the nature of access ordering. However, 256 robot - * battles are rarely fought. - */ - private static final int INITIAL_CAPACITY = MAX_NUM_COLORS + 1; - - private static final float LOAD_FACTOR = 1; - - public RenderCache() { - - /* The "true" parameter needed for access-order: - * when cache fills, the least recently accessed entry is removed - */ - super(INITIAL_CAPACITY, LOAD_FACTOR, true); - } - - @Override - protected boolean removeEldestEntry(Map.Entry eldest) { - return size() > MAX_NUM_COLORS; - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/Module.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/Module.java deleted file mode 100644 index 3d20542..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/Module.java +++ /dev/null @@ -1,47 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui; - - -import net.sf.robocode.core.BaseModule; -import net.sf.robocode.core.Container; -import net.sf.robocode.ui.battleview.BattleView; -import net.sf.robocode.ui.battleview.InteractiveHandler; -import net.sf.robocode.ui.dialog.*; -import net.sf.robocode.ui.packager.RobotPackager; - - -/** - * @author Pavel Savara (original) - */ -public class Module extends BaseModule { - static { - Container.cache.addComponent(AboutBox.class); - Container.cache.addComponent(BattleButton.class); - Container.cache.addComponent(BattleView.class); - Container.cache.addComponent(BattleDialog.class); - Container.cache.addComponent(IImageManager.class, ImageManager.class); - Container.cache.addComponent(IRobotDialogManager.class, RobotDialogManager.class); - Container.cache.addComponent(IWindowManagerExt.class, WindowManager.class); - Container.cache.addComponent(InteractiveHandler.class); - Container.cache.addComponent(PreferencesDialog.class); - Container.cache.addComponent(RankingDialog.class); - Container.cache.addComponent(RcSplashScreen.class); - Container.cache.addComponent(ResultsDialog.class); - Container.cache.addComponent(MenuBar.class); - Container.cache.addComponent(TeamCreator.class); - Container.cache.addComponent(RobocodeFrame.class); - - // new instance for every lookup - Container.factory.addComponent(RobotSelectionPanel.class); - Container.factory.addComponent(RobotDialog.class); - Container.factory.addComponent(RobotButton.class); - Container.factory.addComponent(RobotPackager.class); - Container.factory.addComponent(NewBattleDialog.class); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/RobotDialogManager.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/RobotDialogManager.java deleted file mode 100644 index ad8ea5c..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/RobotDialogManager.java +++ /dev/null @@ -1,97 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.ui.dialog.*; -import robocode.control.snapshot.IRobotSnapshot; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; -import java.util.concurrent.ConcurrentHashMap; - - -/** - * @author Mathew A. Nelson (orinal) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -public class RobotDialogManager implements IRobotDialogManager { - - public static final int MAX_PRE_ATTACHED = 25; - - private final Map robotDialogMap = new ConcurrentHashMap(); - private BattleDialog battleDialog = null; - - public RobotDialogManager() { - super(); - } - - public void trim(List robots) { - - // new ArrayList in order to prevent ConcurrentModificationException - for (String name : new ArrayList(robotDialogMap.keySet())) { - boolean found = false; - - for (IRobotSnapshot robot : robots) { - if (robot.getName().equals(name)) { - found = true; - break; - } - } - if (!found) { - RobotDialog dialog = robotDialogMap.get(name); - - robotDialogMap.remove(name); - dialog.dispose(); - dialog.detach(); - } - } - } - - public void reset() { - for (String name : robotDialogMap.keySet()) { - RobotDialog dialog = robotDialogMap.get(name); - - if (!dialog.isVisible()) { - robotDialogMap.remove(name); - dialog.detach(); - dialog.dispose(); - } - } - } - - public RobotDialog getRobotDialog(RobotButton robotButton, String name, boolean create) { - RobotDialog robotDialog = robotDialogMap.get(name); - - if (create && robotDialog == null) { - if (robotDialogMap.size() > MAX_PRE_ATTACHED) { - reset(); - } - robotDialog = Container.createComponent(RobotDialog.class); - robotDialog.setup(robotButton); - robotDialog.pack(); - WindowUtil.place(robotDialog); - robotDialogMap.put(name, robotDialog); - } - return robotDialog; - } - - public BattleDialog getBattleDialog(BattleButton battleButton, boolean create) { - - if (create && battleDialog == null) { - battleDialog = Container.getComponent(BattleDialog.class); - battleDialog.pack(); - WindowUtil.place(battleDialog); - } - return battleDialog; - } - -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/WindowManager.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/WindowManager.java deleted file mode 100644 index 476bc5b..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/WindowManager.java +++ /dev/null @@ -1,632 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui; - - -import net.sf.robocode.battle.BattleProperties; -import net.sf.robocode.battle.BattleResultsTableModel; -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.core.Container; -import net.sf.robocode.host.ICpuManager; -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.repository.IRepositoryManager; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.ui.battle.AwtBattleAdaptor; -import net.sf.robocode.ui.dialog.*; -import net.sf.robocode.ui.packager.RobotPackager; -import net.sf.robocode.ui.editor.IRobocodeEditor; -import net.sf.robocode.version.IVersionManager; -import robocode.control.events.BattleCompletedEvent; -import robocode.control.events.IBattleListener; -import robocode.control.snapshot.ITurnSnapshot; - -import javax.swing.*; -import javax.swing.filechooser.FileFilter; -import java.awt.*; -import java.io.File; -import java.io.IOException; -import java.util.Locale; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Luis Crespo (contributor) - */ -public class WindowManager implements IWindowManagerExt { - - private final static int TIMER_TICKS_PER_SECOND = 50; - private final AwtBattleAdaptor awtAdaptor; - private RobotPackager robotPackager; - private RobotExtractor robotExtractor; - private final ISettingsManager settingsManager; - private final IBattleManager battleManager; - private final ICpuManager cpuManager; - private final IRepositoryManager repositoryManager; - private final IVersionManager versionManager; - private final IImageManager imageManager; - private IRobotDialogManager robotDialogManager; - private RobocodeFrame robocodeFrame; - - private boolean isGUIEnabled = true; - private boolean isSlave; - private boolean centerRankings = true; - private boolean oldRankingHideState = true; - private boolean showResults = true; - - public WindowManager(ISettingsManager settingsManager, IBattleManager battleManager, ICpuManager cpuManager, IRepositoryManager repositoryManager, IImageManager imageManager, IVersionManager versionManager) { - this.settingsManager = settingsManager; - this.battleManager = battleManager; - this.repositoryManager = repositoryManager; - this.cpuManager = cpuManager; - this.versionManager = versionManager; - this.imageManager = imageManager; - awtAdaptor = new AwtBattleAdaptor(battleManager, TIMER_TICKS_PER_SECOND, true); - - // we will set UI better priority than robots and battle have - EventQueue.invokeLater(new Runnable() { - public void run() { - try { - Thread.currentThread().setPriority(Thread.NORM_PRIORITY + 2); - } catch (SecurityException ex) {// that's a pity - } - } - }); - } - - public void setBusyPointer(boolean enabled) { - robocodeFrame.setBusyPointer(enabled); - } - - public synchronized void addBattleListener(IBattleListener listener) { - awtAdaptor.addListener(listener); - } - - public synchronized void removeBattleListener(IBattleListener listener) { - awtAdaptor.removeListener(listener); - } - - public boolean isGUIEnabled() { - return isGUIEnabled; - } - - public void setEnableGUI(boolean enable) { - isGUIEnabled = enable; - - // Set the system property so the AWT headless mode. - // Read more about headless mode here: - // http://java.sun.com/developer/technicalArticles/J2SE/Desktop/headless/ - System.setProperty("java.awt.headless", "" + !enable); - } - - public void setSlave(boolean value) { - isSlave = value; - } - - public boolean isSlave() { - return isSlave; - } - - public boolean isIconified() { - return robocodeFrame.isIconified(); - } - - public boolean isShowResultsEnabled() { - return settingsManager.getOptionsCommonShowResults() && showResults; - } - - public void setEnableShowResults(boolean enable) { - showResults = enable; - } - - public ITurnSnapshot getLastSnapshot() { - return awtAdaptor.getLastSnapshot(); - } - - public int getFPS() { - return isIconified() ? 0 : awtAdaptor.getFPS(); - } - - public RobocodeFrame getRobocodeFrame() { - if (robocodeFrame == null) { - this.robocodeFrame = Container.getComponent(RobocodeFrame.class); - } - return robocodeFrame; - } - - public void showRobocodeFrame(boolean visible, boolean iconified) { - RobocodeFrame frame = getRobocodeFrame(); - - if (iconified) { - frame.setState(Frame.ICONIFIED); - } - - if (visible) { - // Pack frame to size all components - WindowUtil.packCenterShow(frame); - - WindowUtil.setStatusLabel(frame.getStatusLabel()); - - frame.checkUpdateOnStart(); - - } else { - frame.setVisible(false); - } - } - - public void showAboutBox() { - packCenterShow(Container.getComponent(AboutBox.class), true); - } - - public String showBattleOpenDialog(final String defExt, final String name) { - JFileChooser chooser = new JFileChooser(battleManager.getBattlePath()); - - chooser.setFileFilter( - new FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.isDirectory() - || pathname.getName().toLowerCase().lastIndexOf(defExt.toLowerCase()) - == pathname.getName().length() - defExt.length(); - } - - @Override - public String getDescription() { - return name; - } - }); - - if (chooser.showOpenDialog(getRobocodeFrame()) == JFileChooser.APPROVE_OPTION) { - return chooser.getSelectedFile().getPath(); - } - return null; - } - - public String saveBattleDialog(String path, final String defExt, final String name) { - File f = new File(path); - - JFileChooser chooser; - - chooser = new JFileChooser(f); - - javax.swing.filechooser.FileFilter filter = new javax.swing.filechooser.FileFilter() { - @Override - public boolean accept(File pathname) { - return pathname.isDirectory() - || pathname.getName().toLowerCase().lastIndexOf(defExt.toLowerCase()) - == pathname.getName().length() - defExt.length(); - } - - @Override - public String getDescription() { - return name; - } - }; - - chooser.setFileFilter(filter); - int rv = chooser.showSaveDialog(getRobocodeFrame()); - String result = null; - - if (rv == JFileChooser.APPROVE_OPTION) { - result = chooser.getSelectedFile().getPath(); - int idx = result.lastIndexOf('.'); - String extension = ""; - - if (idx > 0) { - extension = result.substring(idx); - } - if (!(extension.equalsIgnoreCase(defExt))) { - result += defExt; - } - } - return result; - } - - public void showVersionsTxt() { - showInBrowser("file://" + new File(FileUtil.getCwd(), "").getAbsoluteFile() + File.separator + "versions.md"); - } - - public void showHelpApi() { - showInBrowser( - "file://" + new File(FileUtil.getCwd(), "").getAbsoluteFile() + File.separator + "javadoc" + File.separator - + "index.html"); - } - - public void showReadMe() { - showInBrowser("file://" + new File(FileUtil.getCwd(), "ReadMe.html").getAbsoluteFile()); - } - - public void showFaq() { - showInBrowser("http://robowiki.net/w/index.php?title=Robocode/FAQ"); - } - - public void showOnlineHelp() { - showInBrowser("http://robowiki.net/w/index.php?title=Robocode/Getting_Started"); - } - - public void showJavaDocumentation() { - showInBrowser("http://docs.oracle.com/javase/6/docs/api/"); - } - - public void showRobocodeHome() { - showInBrowser("http://robocode.sourceforge.net"); - } - - public void showRoboWiki() { - showInBrowser("http://robowiki.net"); - } - - public void showGoogleGroupRobocode() { - showInBrowser("https://groups.google.com/forum/?fromgroups#!forum/robocode"); - } - - public void showRobocodeRepository() { - showInBrowser("http://robocoderepository.com"); - } - - public void showOptionsPreferences() { - try { - battleManager.pauseBattle(); - - WindowUtil.packCenterShow(getRobocodeFrame(), Container.getComponent(PreferencesDialog.class)); - } finally { - battleManager.resumeIfPausedBattle(); // THIS is just dirty hack-fix of more complex problem with desiredTPS and pausing. resumeBattle() belongs here. - } - } - - public void showResultsDialog(BattleCompletedEvent event) { - final ResultsDialog dialog = Container.getComponent(ResultsDialog.class); - - dialog.setup(event.getSortedResults(), event.getBattleRules().getNumRounds()); - packCenterShow(dialog, true); - } - - public void showRankingDialog(boolean visible) { - boolean currentRankingHideState = settingsManager.getOptionsCommonDontHideRankings(); - - // Check if the Ranking hide states has changed - if (currentRankingHideState != oldRankingHideState) { - // Remove current visible RankingDialog, if it is there - Container.getComponent(RankingDialog.class).dispose(); - - // Replace old RankingDialog, as the owner window must be replaced from the constructor - Container.cache.removeComponent(RankingDialog.class); - Container.cache.addComponent(RankingDialog.class); - - // Reset flag for centering the dialog the first time it is shown - centerRankings = true; - } - - RankingDialog rankingDialog = Container.getComponent(RankingDialog.class); - - if (visible) { - packCenterShow(rankingDialog, centerRankings); - centerRankings = false; // only center the first time Rankings are shown - } else { - rankingDialog.dispose(); - } - - // Save current Ranking hide state - oldRankingHideState = currentRankingHideState; - } - - public void showRobocodeEditor() { - JFrame editor = (JFrame) net.sf.robocode.core.Container.getComponent(IRobocodeEditor.class); - - if (!editor.isVisible()) { - WindowUtil.packCenterShow(editor); - } else { - editor.setVisible(true); - } - } - - public void showRobotPackager() { - if (robotPackager != null) { - robotPackager.dispose(); - robotPackager = null; - } - - robotPackager = net.sf.robocode.core.Container.factory.getComponent(RobotPackager.class); - WindowUtil.packCenterShow(robotPackager); - } - - public void showRobotExtractor(JFrame owner) { - if (robotExtractor != null) { - robotExtractor.dispose(); - robotExtractor = null; - } - - robotExtractor = new net.sf.robocode.ui.dialog.RobotExtractor(owner, this, repositoryManager); - WindowUtil.packCenterShow(robotExtractor); - } - - public void showSplashScreen() { - RcSplashScreen splashScreen = Container.getComponent(RcSplashScreen.class); - - packCenterShow(splashScreen, true); - - WindowUtil.setStatusLabel(splashScreen.getSplashLabel()); - - repositoryManager.reload(versionManager.isLastRunVersionChanged()); - - WindowUtil.setStatusLabel(splashScreen.getSplashLabel()); - cpuManager.getCpuConstant(); - - WindowUtil.setStatus(""); - WindowUtil.setStatusLabel(null); - - splashScreen.dispose(); - } - - public void showNewBattleDialog(BattleProperties battleProperties) { - try { - battleManager.pauseBattle(); - final NewBattleDialog battleDialog = Container.createComponent(NewBattleDialog.class); - - battleDialog.setup(settingsManager, battleProperties); - WindowUtil.packCenterShow(getRobocodeFrame(), battleDialog); - } finally { - battleManager.resumeBattle(); - } - } - - public boolean closeRobocodeEditor() { - IRobocodeEditor editor = net.sf.robocode.core.Container.getComponent(IRobocodeEditor.class); - - return editor == null || !((JFrame) editor).isVisible() || editor.close(); - } - - public void showCreateTeamDialog() { - TeamCreator teamCreator = Container.getComponent(TeamCreator.class); - - WindowUtil.packCenterShow(teamCreator); - } - - public void showImportRobotDialog() { - JFileChooser chooser = new JFileChooser(); - - chooser.setFileFilter(new FileFilter() { - @Override - public boolean accept(File pathname) { - if (pathname.isHidden()) { - return false; - } - if (pathname.isDirectory()) { - return true; - } - String filename = pathname.getName(); - - if (filename.equals("robocode.jar")) { - return false; - } - int idx = filename.lastIndexOf('.'); - - String extension = ""; - - if (idx >= 0) { - extension = filename.substring(idx); - } - return extension.equalsIgnoreCase(".jar") || extension.equalsIgnoreCase(".zip"); - } - - @Override - public String getDescription() { - return "Jar Files"; - } - }); - - chooser.setDialogTitle("Select the robot .jar file to copy to " + repositoryManager.getRobotsDirectory()); - - if (chooser.showDialog(getRobocodeFrame(), "Import") == JFileChooser.APPROVE_OPTION) { - File inputFile = chooser.getSelectedFile(); - String fileName = inputFile.getName(); - String extension = ""; - - int idx = fileName.lastIndexOf('.'); - - if (idx >= 0) { - extension = fileName.substring(idx); - } - if (!extension.equalsIgnoreCase(".jar")) { - fileName += ".jar"; - } - File outputFile = new File(repositoryManager.getRobotsDirectory(), fileName); - - if (inputFile.equals(outputFile)) { - JOptionPane.showMessageDialog(getRobocodeFrame(), - outputFile.getName() + " is already in the robots directory!"); - return; - } - if (outputFile.exists()) { - if (JOptionPane.showConfirmDialog(getRobocodeFrame(), outputFile + " already exists. Overwrite?", - "Warning", JOptionPane.YES_NO_OPTION) - == JOptionPane.NO_OPTION) { - return; - } - } - if (JOptionPane.showConfirmDialog(getRobocodeFrame(), - "Robocode will now copy " + inputFile.getName() + " to " + outputFile.getParent(), "Import robot", - JOptionPane.OK_CANCEL_OPTION) - == JOptionPane.OK_OPTION) { - try { - FileUtil.copy(inputFile, outputFile); - repositoryManager.refresh(); - JOptionPane.showMessageDialog(getRobocodeFrame(), "Robot imported successfully."); - } catch (IOException e) { - JOptionPane.showMessageDialog(getRobocodeFrame(), "Import failed: " + e); - } - } - } - } - - /** - * Shows a web page using the browser manager. - * - * @param url The URL of the web page - */ - private void showInBrowser(String url) { - try { - BrowserManager.openURL(url); - } catch (IOException e) { - JOptionPane.showMessageDialog(getRobocodeFrame(), e.getMessage(), "Unable to open browser!", - JOptionPane.ERROR_MESSAGE); - } - } - - public void showSaveResultsDialog(BattleResultsTableModel tableModel) { - JFileChooser chooser = new JFileChooser(); - - chooser.setFileFilter(new FileFilter() { - - @Override - public boolean accept(File pathname) { - if (pathname.isHidden()) { - return false; - } - if (pathname.isDirectory()) { - return true; - } - String filename = pathname.getName(); - int idx = filename.lastIndexOf('.'); - - String extension = ""; - - if (idx >= 0) { - extension = filename.substring(idx); - } - return extension.equalsIgnoreCase(".csv"); - } - - @Override - public String getDescription() { - return "Comma Separated Value (CSV) File Format"; - } - }); - - chooser.setDialogTitle("Save battle results"); - - if (chooser.showSaveDialog(getRobocodeFrame()) == JFileChooser.APPROVE_OPTION) { - - String filename = chooser.getSelectedFile().getPath(); - - if (!filename.endsWith(".csv")) { - filename += ".csv"; - } - - boolean append = settingsManager.getOptionsCommonAppendWhenSavingResults(); - - tableModel.saveToFile(filename, append); - } - } - - /** - * Packs, centers, and shows the specified window on the screen. - * @param window the window to pack, center, and show - * @param center {@code true} if the window must be centered; {@code false} otherwise - */ - private void packCenterShow(Window window, boolean center) { - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - window.pack(); - if (center) { - window.setLocation((screenSize.width - window.getWidth()) / 2, (screenSize.height - window.getHeight()) / 2); - } - window.setVisible(true); - } - - public void cleanup() { - if (isGUIEnabled()) { - getRobocodeFrame().dispose(); - } - } - - public void setStatus(String s) { - WindowUtil.setStatus(s); - } - - public void messageWarning(String s) { - WindowUtil.messageWarning(s); - } - - public IRobotDialogManager getRobotDialogManager() { - if (robotDialogManager == null) { - robotDialogManager = new RobotDialogManager(); - } - return robotDialogManager; - } - - public void init() { - setLookAndFeel(); - imageManager.initialize(); // Make sure this one is initialized so all images are available - awtAdaptor.subscribe(isGUIEnabled); - } - - /** - * Sets the Look and Feel (LAF). This method first try to set the LAF to the - * system's LAF. If this fails, it try to use the cross platform LAF. - * If this also fails, the LAF will not be changed. - */ - private void setLookAndFeel() { - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable t) { - // Work-around for problems with setting Look and Feel described here: - // http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=6468089 - Locale.setDefault(Locale.US); - - try { - UIManager.setLookAndFeel(UIManager.getSystemLookAndFeelClassName()); - } catch (Throwable t2) { - // For some reason Ubuntu 7 can cause a NullPointerException when trying to getting the LAF - System.err.println("Could not set the Look and Feel (LAF). The default LAF is used instead"); - } - } - // Java 1.6 provide system specific anti-aliasing. Enable it, if it has not been set - if (new Double(System.getProperty("java.specification.version")) >= 1.6) { - String aaFontSettings = System.getProperty("awt.useSystemAAFontSettings"); - - if (aaFontSettings == null) { - System.setProperty("awt.useSystemAAFontSettings", "on"); - } - } - } - - public void runIntroBattle() { - final File intro = new File(FileUtil.getCwd(), "battles/intro.battle"); - if (intro.exists()) { - battleManager.setBattleFilename(intro.getPath()); - battleManager.loadBattleProperties(); - - final boolean origShowResults = showResults; // save flag for showing the results - - showResults = false; - try { - battleManager.startNewBattle(battleManager.loadBattleProperties(), true, false); - battleManager.setDefaultBattleProperties(); - robocodeFrame.afterIntroBattle(); - } finally { - showResults = origShowResults; // always restore the original flag for showing the results - } - } - } - - public void setVisibleForRobotEngine(boolean visible) { - if (visible && !isGUIEnabled()) { - // The GUI must be enabled in order to show the window - setEnableGUI(true); - - // Set the Look and Feel (LAF) - init(); - } - - if (isGUIEnabled()) { - showRobocodeFrame(visible, false); - showResults = visible; - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battle/AwtBattleAdaptor.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battle/AwtBattleAdaptor.java deleted file mode 100644 index bfb479c..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battle/AwtBattleAdaptor.java +++ /dev/null @@ -1,335 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.battle; - - -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.battle.events.BattleEventDispatcher; -import net.sf.robocode.battle.snapshot.RobotSnapshot; -import net.sf.robocode.io.Logger; -import robocode.control.events.*; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.concurrent.atomic.AtomicBoolean; -import java.util.concurrent.atomic.AtomicReference; -import java.util.concurrent.atomic.AtomicInteger; - - -/** - * @author Pavel Savara (original) - */ -public final class AwtBattleAdaptor { - private boolean isEnabled; - private final IBattleManager battleManager; - private final BattleEventDispatcher battleEventDispatcher = new BattleEventDispatcher(); - private final BattleObserver observer; - private final Timer timerTask; - - private final AtomicReference snapshot; - private final AtomicBoolean isRunning; - private final AtomicBoolean isPaused; - private final AtomicInteger majorEvent; - private final AtomicInteger lastMajorEvent; - private ITurnSnapshot lastSnapshot; - private StringBuilder[] outCache; - - public AwtBattleAdaptor(IBattleManager battleManager, int maxFps, boolean skipSameFrames) { - this.battleManager = battleManager; - snapshot = new AtomicReference(null); - - this.skipSameFrames = skipSameFrames; - timerTask = new Timer(1000 / maxFps, new TimerTask()); - isRunning = new AtomicBoolean(false); - isPaused = new AtomicBoolean(false); - majorEvent = new AtomicInteger(0); - lastMajorEvent = new AtomicInteger(0); - - observer = new BattleObserver(); - } - - protected void finalize() throws Throwable { - try { - timerTask.stop(); - battleManager.removeListener(observer); - } finally { - super.finalize(); - } - } - - public void subscribe(boolean isEnabled) { - if (this.isEnabled && !isEnabled) { - battleManager.removeListener(observer); - timerTask.stop(); - isEnabled = false; - } else if (!this.isEnabled && isEnabled) { - battleManager.addListener(observer); - isEnabled = true; - } - } - - public synchronized void addListener(IBattleListener listener) { - battleEventDispatcher.addListener(listener); - } - - public synchronized void removeListener(IBattleListener listener) { - battleEventDispatcher.removeListener(listener); - } - - public ITurnSnapshot getLastSnapshot() { - return lastSnapshot; - } - - // this is always dispatched on AWT thread - private void awtOnTurnEnded(boolean forceRepaint, boolean readoutText) { - try { - ITurnSnapshot current = snapshot.get(); - - if (current == null) { // !isRunning.get() || - // paint logo - lastSnapshot = null; - battleEventDispatcher.onTurnEnded(new TurnEndedEvent(null)); - } else { - if (lastSnapshot != current || !skipSameFrames || forceRepaint) { - lastSnapshot = current; - - IRobotSnapshot[] robots = null; - - if (readoutText) { - synchronized (snapshot) { - robots = lastSnapshot.getRobots(); - - for (int i = 0; i < robots.length; i++) { - RobotSnapshot robot = (RobotSnapshot) robots[i]; - - final StringBuilder cache = outCache[i]; - - if (cache.length() > 0) { - robot.setOutputStreamSnapshot(cache.toString()); - outCache[i].setLength(0); - } - } - } - } - - battleEventDispatcher.onTurnEnded(new TurnEndedEvent(lastSnapshot)); - - if (readoutText) { - for (IRobotSnapshot robot : robots) { - ((RobotSnapshot) robot).setOutputStreamSnapshot(null); - } - } - - calculateFPS(); - } - } - } catch (Throwable t) { - Logger.logError(t); - } - } - - public int getFPS() { - return fps; - } - - // FPS (frames per second) calculation - private int fps; - private long measuredFrameCounter; - private long measuredFrameStartTime; - private final boolean skipSameFrames; - - private void calculateFPS() { - // Calculate the current frames per second (FPS) - - if (measuredFrameCounter++ == 0) { - measuredFrameStartTime = System.nanoTime(); - } - - long deltaTime = System.nanoTime() - measuredFrameStartTime; - - if (deltaTime / 1000000000 >= 1) { - fps = (int) (measuredFrameCounter * 1000000000L / deltaTime); - measuredFrameCounter = 0; - } - } - - private class TimerTask implements ActionListener { - public void actionPerformed(ActionEvent e) { - awtOnTurnEnded(false, true); - } - } - - - // BattleObserver methods are always called by battle thread - // but everything inside invokeLater {} block in on AWT thread - private class BattleObserver extends BattleAdaptor { - - @Override - public void onTurnEnded(final TurnEndedEvent event) { - if (lastMajorEvent.get() == majorEvent.get()) { - // snapshot is updated out of order, but always within the same major event - snapshot.set(event.getTurnSnapshot()); - } - - final IRobotSnapshot[] robots = event.getTurnSnapshot().getRobots(); - - for (int i = 0; i < robots.length; i++) { - RobotSnapshot robot = (RobotSnapshot) robots[i]; - final int r = i; - final String text = robot.getOutputStreamSnapshot(); - - if (text != null && text.length() != 0) { - robot.setOutputStreamSnapshot(null); - EventQueue.invokeLater(new Runnable() { - public void run() { - synchronized (snapshot) { - outCache[r].append(text); - } - } - }); - } - } - if (isPaused.get()) { - EventQueue.invokeLater(new Runnable() { - public void run() { - awtOnTurnEnded(false, true); - } - }); - } - } - - @Override - public void onRoundStarted(final RoundStartedEvent event) { - if (lastMajorEvent.get() == majorEvent.get()) { - snapshot.set(event.getStartSnapshot()); - } - majorEvent.incrementAndGet(); - EventQueue.invokeLater(new Runnable() { - public void run() { - awtOnTurnEnded(true, false); - battleEventDispatcher.onRoundStarted(event); - lastMajorEvent.incrementAndGet(); - } - }); - } - - @Override - public void onBattleStarted(final BattleStartedEvent event) { - majorEvent.incrementAndGet(); - EventQueue.invokeLater(new Runnable() { - public void run() { - isRunning.set(true); - isPaused.set(false); - synchronized (snapshot) { - outCache = new StringBuilder[event.getRobotsCount()]; - for (int i = 0; i < event.getRobotsCount(); i++) { - outCache[i] = new StringBuilder(1024); - } - } - snapshot.set(null); - battleEventDispatcher.onBattleStarted(event); - lastMajorEvent.incrementAndGet(); - awtOnTurnEnded(true, false); - timerTask.start(); - } - }); - } - - @Override - public void onBattleFinished(final BattleFinishedEvent event) { - majorEvent.incrementAndGet(); - EventQueue.invokeLater(new Runnable() { - public void run() { - isRunning.set(false); - isPaused.set(false); - timerTask.stop(); - // flush text cache - awtOnTurnEnded(true, true); - - battleEventDispatcher.onBattleFinished(event); - lastMajorEvent.incrementAndGet(); - snapshot.set(null); - - // paint logo - awtOnTurnEnded(true, true); - } - }); - } - - @Override - public void onBattleCompleted(final BattleCompletedEvent event) { - majorEvent.incrementAndGet(); - EventQueue.invokeLater(new Runnable() { - public void run() { - battleEventDispatcher.onBattleCompleted(event); - lastMajorEvent.incrementAndGet(); - awtOnTurnEnded(true, true); - } - }); - } - - @Override - public void onRoundEnded(final RoundEndedEvent event) { - majorEvent.incrementAndGet(); - EventQueue.invokeLater(new Runnable() { - public void run() { - battleEventDispatcher.onRoundEnded(event); - lastMajorEvent.incrementAndGet(); - awtOnTurnEnded(true, true); - } - }); - } - - @Override - public void onBattlePaused(final BattlePausedEvent event) { - EventQueue.invokeLater(new Runnable() { - public void run() { - timerTask.stop(); - battleEventDispatcher.onBattlePaused(event); - awtOnTurnEnded(true, true); - isPaused.set(true); - } - }); - } - - @Override - public void onBattleResumed(final BattleResumedEvent event) { - EventQueue.invokeLater(new Runnable() { - public void run() { - battleEventDispatcher.onBattleResumed(event); - if (isRunning.get()) { - timerTask.start(); - isPaused.set(false); - } - } - }); - } - - @Override - public void onBattleMessage(final BattleMessageEvent event) { - EventQueue.invokeLater(new Runnable() { - public void run() { - battleEventDispatcher.onBattleMessage(event); - } - }); - } - - @Override - public void onBattleError(final BattleErrorEvent event) { - EventQueue.invokeLater(new Runnable() { - public void run() { - battleEventDispatcher.onBattleError(event); - } - }); - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/BattleField.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/BattleField.java deleted file mode 100644 index e9781f1..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/BattleField.java +++ /dev/null @@ -1,49 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.battleview; - - -import net.sf.robocode.battle.BoundingRectangle; - -import java.io.Serializable; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (original) - */ -public class BattleField implements Serializable { - private static final long serialVersionUID = 1L; - - private final BoundingRectangle boundingBox; - - public BattleField(int width, int height) { - super(); - this.boundingBox = new BoundingRectangle(0, 0, width, height); - } - - public BoundingRectangle getBoundingBox() { - return boundingBox; - } - - public int getWidth() { - return (int) boundingBox.width; - } - - public void setWidth(int newWidth) { - boundingBox.width = newWidth; - } - - public int getHeight() { - return (int) boundingBox.height; - } - - public void setHeight(int newHeight) { - boundingBox.height = newHeight; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/BattleView.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/BattleView.java deleted file mode 100644 index aebdf06..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/BattleView.java +++ /dev/null @@ -1,698 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.battleview; - - -import net.sf.robocode.battle.snapshot.RobotSnapshot; -import net.sf.robocode.robotpaint.Graphics2DSerialized; -import net.sf.robocode.robotpaint.IGraphicsProxy; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.settings.ISettingsListener; -import net.sf.robocode.ui.IImageManager; -import net.sf.robocode.ui.IWindowManager; -import net.sf.robocode.ui.IWindowManagerExt; -import net.sf.robocode.ui.gfx.GraphicsState; -import net.sf.robocode.ui.gfx.RenderImage; -import net.sf.robocode.ui.gfx.RobocodeLogo; -import robocode.BattleRules; -import robocode.control.events.BattleAdaptor; -import robocode.control.events.BattleFinishedEvent; -import robocode.control.events.BattleStartedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IBulletSnapshot; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - -import java.awt.*; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.geom.*; -import java.awt.image.BufferStrategy; -import java.awt.image.BufferedImage; -import static java.lang.Math.*; -import java.util.Random; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (original) - * @author Pavel Savara (contributor) - */ -@SuppressWarnings("serial") -public class BattleView extends Canvas { - - private final static String ROBOCODE_SLOGAN = "Build the best, destroy the rest!"; - - private final static Color CANVAS_BG_COLOR = SystemColor.controlDkShadow; - - private final static Area BULLET_AREA = new Area(new Ellipse2D.Double(-0.5, -0.5, 1, 1)); - - private final static int ROBOT_TEXT_Y_OFFSET = 24; - - private BattleRules battleRules; - - // The battle and battlefield, - private BattleField battleField; - - private boolean initialized; - private double scale = 1.0; - - // Ground - private int[][] groundTiles; - - private final int groundTileWidth = 64; - private final int groundTileHeight = 64; - - private Image groundImage; - - // Draw option related things - private boolean drawRobotName; - private boolean drawRobotEnergy; - private boolean drawScanArcs; - private boolean drawExplosions; - private boolean drawGround; - private boolean drawExplosionDebris; - - private int numBuffers = 2; // defaults to double buffering - - private RenderingHints renderingHints; - - // Fonts and the like - private Font smallFont; - private FontMetrics smallFontMetrics; - - private final IImageManager imageManager; - private final ISettingsManager properties; - private final IWindowManagerExt windowManager; - - private BufferStrategy bufferStrategy; - - private final GeneralPath robocodeTextPath = new RobocodeLogo().getRobocodeText(); - - private static final MirroredGraphics mirroredGraphics = new MirroredGraphics(); - - private final GraphicsState graphicsState = new GraphicsState(); - private IGraphicsProxy[] robotGraphics; - - public BattleView(ISettingsManager properties, IWindowManager windowManager, IImageManager imageManager) { - this.properties = properties; - this.windowManager = (IWindowManagerExt) windowManager; - this.imageManager = imageManager; - - battleField = new BattleField(800, 600); - - new BattleObserver(windowManager); - - properties.addPropertyListener(new ISettingsListener() { - public void settingChanged(String property) { - loadDisplayOptions(); - if (property.startsWith("robocode.options.rendering")) { - initialized = false; - reinitialize(); - } - } - }); - - addComponentListener(new ComponentAdapter() { - public void componentResized(ComponentEvent e) { - initialized = false; - reinitialize(); - } - }); - } - - @Override - public void update(Graphics g) { - paint(g); - } - - @Override - public void paint(Graphics g) { - final ITurnSnapshot lastSnapshot = windowManager.getLastSnapshot(); - if (lastSnapshot != null) { - update(lastSnapshot); - } else { - paintRobocodeLogo((Graphics2D) g); - } - } - - public BufferedImage getScreenshot() { - BufferedImage screenshot = getGraphicsConfiguration().createCompatibleImage(getWidth(), getHeight()); - - if (windowManager.getLastSnapshot() == null) { - paintRobocodeLogo((Graphics2D) screenshot.getGraphics()); - } else { - drawBattle((Graphics2D) screenshot.getGraphics(), windowManager.getLastSnapshot()); - } - return screenshot; - } - - private void update(ITurnSnapshot snapshot) { - if (!initialized) { - initialize(); - } - - if (windowManager.isIconified() || !isDisplayable() || (getWidth() <= 0) || (getHeight() <= 0)) { - return; - } - - if (bufferStrategy != null) { - try { - Graphics2D g2 = (Graphics2D) bufferStrategy.getDrawGraphics(); - - if (g2 != null) { - do { - try { - g2.setRenderingHints(renderingHints); - - drawBattle(g2, snapshot); - } finally { - g2.dispose(); - } - bufferStrategy.show(); - } while (bufferStrategy.contentsLost()); - - Toolkit.getDefaultToolkit().sync(); // Update like... now! - } - } catch (NullPointerException e) {} - } - } - - private void loadDisplayOptions() { - ISettingsManager props = properties; - - drawRobotName = props.getOptionsViewRobotNames(); - drawRobotEnergy = props.getOptionsViewRobotEnergy(); - drawScanArcs = props.getOptionsViewScanArcs(); - drawGround = props.getOptionsViewGround(); - drawExplosions = props.getOptionsViewExplosions(); - drawExplosionDebris = props.getOptionsViewExplosionDebris(); - - renderingHints = props.getRenderingHints(); - numBuffers = props.getOptionsRenderingNoBuffers(); - } - - private void reinitialize() { - initialized = false; - bufferStrategy = null; - } - - private void initialize() { - loadDisplayOptions(); - - if (bufferStrategy == null) { - createBufferStrategy(numBuffers); - bufferStrategy = getBufferStrategy(); - } - - // If we are scaled... - if (getWidth() < battleField.getWidth() || getHeight() < battleField.getHeight()) { - // Use the smaller scale. - // Actually we don't need this, since - // the RobocodeFrame keeps our aspect ratio intact. - - scale = min((double) getWidth() / battleField.getWidth(), (double) getHeight() / battleField.getHeight()); - } else { - scale = 1; - } - - // Scale font - smallFont = new Font("Dialog", Font.PLAIN, (int) (10 / scale)); - smallFontMetrics = bufferStrategy.getDrawGraphics().getFontMetrics(); - - // Initialize ground image - if (drawGround) { - createGroundImage(); - } else { - groundImage = null; - } - - initialized = true; - } - - private void createGroundImage() { - // Reinitialize ground tiles - - Random r = new Random(); // independent - - final int NUM_HORZ_TILES = battleField.getWidth() / groundTileWidth + 1; - final int NUM_VERT_TILES = battleField.getHeight() / groundTileHeight + 1; - - if ((groundTiles == null) || (groundTiles.length != NUM_VERT_TILES) || (groundTiles[0].length != NUM_HORZ_TILES)) { - - groundTiles = new int[NUM_VERT_TILES][NUM_HORZ_TILES]; - for (int y = NUM_VERT_TILES - 1; y >= 0; y--) { - for (int x = NUM_HORZ_TILES - 1; x >= 0; x--) { - groundTiles[y][x] = (int) round(r.nextDouble() * 4); - } - } - } - - // Create new buffered image with the ground pre-rendered - - int groundWidth = (int) (battleField.getWidth() * scale); - int groundHeight = (int) (battleField.getHeight() * scale); - - groundImage = new BufferedImage(groundWidth, groundHeight, BufferedImage.TYPE_INT_RGB); - - Graphics2D groundGfx = (Graphics2D) groundImage.getGraphics(); - - groundGfx.setRenderingHints(renderingHints); - - groundGfx.setTransform(AffineTransform.getScaleInstance(scale, scale)); - - for (int y = NUM_VERT_TILES - 1; y >= 0; y--) { - for (int x = NUM_HORZ_TILES - 1; x >= 0; x--) { - Image img = imageManager.getGroundTileImage(groundTiles[y][x]); - - if (img != null) { - groundGfx.drawImage(img, x * groundTileWidth, y * groundTileHeight, null); - } - } - } - } - - private void drawBattle(Graphics2D g, ITurnSnapshot snapShot) { - // Save the graphics state - graphicsState.save(g); - - // Reset transform - g.setTransform(new AffineTransform()); - - // Reset clip - g.setClip(null); - - // Clear canvas - g.setColor(CANVAS_BG_COLOR); - g.fillRect(0, 0, getWidth(), getHeight()); - - // Calculate border space - double dx = (getWidth() - scale * battleField.getWidth()) / 2; - double dy = (getHeight() - scale * battleField.getHeight()) / 2; - - // Scale and translate the graphics - AffineTransform at = AffineTransform.getTranslateInstance(dx, dy); - - at.concatenate(AffineTransform.getScaleInstance(scale, scale)); - g.setTransform(at); - - // Set the clip rectangle - g.setClip(0, 0, battleField.getWidth(), battleField.getHeight()); - - // Draw ground - drawGround(g); - - if (snapShot != null) { - // Draw scan arcs - drawScanArcs(g, snapShot); - - // Draw robots - drawRobots(g, snapShot); - - // Draw robot (debug) paintings - drawRobotPaint(g, snapShot); - } - - // Draw the border of the battlefield - drawBorderEdge(g); - - if (snapShot != null) { - // Draw all bullets - drawBullets(g, snapShot); - - // Draw all text - drawText(g, snapShot); - } - - // Restore the graphics state - graphicsState.restore(g); - } - - private void drawGround(Graphics2D g) { - if (drawGround) { - // Create pre-rendered ground image if it is not available - if (groundImage == null) { - createGroundImage(); - } - // Draw the pre-rendered ground if it is available - if (groundImage != null) { - int groundWidth = (int) (battleField.getWidth() * scale) + 1; - int groundHeight = (int) (battleField.getHeight() * scale) + 1; - - int dx = (getWidth() - groundWidth) / 2; - int dy = (getHeight() - groundHeight) / 2; - - final AffineTransform savedTx = g.getTransform(); - - g.setTransform(new AffineTransform()); - g.drawImage(groundImage, dx, dy, groundWidth, groundHeight, null); - - g.setTransform(savedTx); - } - } else { - // Ground should not be drawn - g.setColor(Color.BLACK); - g.fillRect(0, 0, battleField.getWidth(), battleField.getHeight()); - } - - // Draw Sentry Border if it is enabled visually - if (properties.getOptionsViewSentryBorder()) { - drawSentryBorder(g); - } - } - - private void drawSentryBorder(Graphics2D g) { - int borderSentrySize = battleRules.getSentryBorderSize(); - - g.setColor(new Color(0xff, 0x00, 0x00, 0x80)); - g.fillRect(0, 0, borderSentrySize, battleField.getHeight()); - g.fillRect(battleField.getWidth() - borderSentrySize, 0, borderSentrySize, battleField.getHeight()); - g.fillRect(borderSentrySize, 0, battleField.getWidth() - 2 * borderSentrySize, borderSentrySize); - g.fillRect(borderSentrySize, battleField.getHeight() - borderSentrySize, - battleField.getWidth() - 2 * borderSentrySize, borderSentrySize); - } - - private void drawBorderEdge(Graphics2D g) { - final Shape savedClip = g.getClip(); - - g.setClip(null); - - g.setColor(Color.RED); - g.drawRect(-1, -1, battleField.getWidth() + 2, battleField.getHeight() + 2); - - g.setClip(savedClip); - } - - private void drawScanArcs(Graphics2D g, ITurnSnapshot snapShot) { - if (drawScanArcs) { - for (IRobotSnapshot robotSnapshot : snapShot.getRobots()) { - if (robotSnapshot.getState().isAlive()) { - drawScanArc(g, robotSnapshot); - } - } - } - } - - private void drawRobots(Graphics2D g, ITurnSnapshot snapShot) { - double x, y; - AffineTransform at; - int battleFieldHeight = battleField.getHeight(); - - if (drawGround && drawExplosionDebris) { - RenderImage explodeDebrise = imageManager.getExplosionDebriseRenderImage(); - - for (IRobotSnapshot robotSnapshot : snapShot.getRobots()) { - if (robotSnapshot.getState().isDead()) { - x = robotSnapshot.getX(); - y = battleFieldHeight - robotSnapshot.getY(); - - at = AffineTransform.getTranslateInstance(x, y); - - explodeDebrise.setTransform(at); - explodeDebrise.paint(g); - } - } - } - - for (IRobotSnapshot robotSnapshot : snapShot.getRobots()) { - if (robotSnapshot.getState().isAlive()) { - x = robotSnapshot.getX(); - y = battleFieldHeight - robotSnapshot.getY(); - - at = AffineTransform.getTranslateInstance(x, y); - at.rotate(robotSnapshot.getBodyHeading()); - - RenderImage robotRenderImage = imageManager.getColoredBodyRenderImage(robotSnapshot.getBodyColor()); - - robotRenderImage.setTransform(at); - robotRenderImage.paint(g); - - at = AffineTransform.getTranslateInstance(x, y); - at.rotate(robotSnapshot.getGunHeading()); - - RenderImage gunRenderImage = imageManager.getColoredGunRenderImage(robotSnapshot.getGunColor()); - - gunRenderImage.setTransform(at); - gunRenderImage.paint(g); - - if (!robotSnapshot.isDroid()) { - at = AffineTransform.getTranslateInstance(x, y); - at.rotate(robotSnapshot.getRadarHeading()); - - RenderImage radarRenderImage = imageManager.getColoredRadarRenderImage(robotSnapshot.getRadarColor()); - - radarRenderImage.setTransform(at); - radarRenderImage.paint(g); - } - } - } - } - - private void drawText(Graphics2D g, ITurnSnapshot snapShot) { - final Shape savedClip = g.getClip(); - - g.setClip(null); - - for (IRobotSnapshot robotSnapshot : snapShot.getRobots()) { - if (robotSnapshot.getState().isDead()) { - continue; - } - int x = (int) robotSnapshot.getX(); - int y = battleField.getHeight() - (int) robotSnapshot.getY(); - - if (drawRobotEnergy) { - g.setColor(Color.white); - int ll = (int) robotSnapshot.getEnergy(); - int rl = (int) ((robotSnapshot.getEnergy() - ll + .001) * 10.0); - - if (rl == 10) { - rl = 9; - } - String energyString = ll + "." + rl; - - if (robotSnapshot.getEnergy() == 0 && robotSnapshot.getState().isAlive()) { - energyString = "Disabled"; - } - centerString(g, energyString, x, y - ROBOT_TEXT_Y_OFFSET - smallFontMetrics.getHeight() / 2, smallFont, - smallFontMetrics); - } - if (drawRobotName) { - g.setColor(Color.white); - centerString(g, robotSnapshot.getVeryShortName(), x, - y + ROBOT_TEXT_Y_OFFSET + smallFontMetrics.getHeight() / 2, smallFont, smallFontMetrics); - } - } - - g.setClip(savedClip); - } - - private void drawRobotPaint(Graphics2D g, ITurnSnapshot turnSnapshot) { - - int robotIndex = 0; - - for (IRobotSnapshot robotSnapshot : turnSnapshot.getRobots()) { - final Object graphicsCalls = ((RobotSnapshot) robotSnapshot).getGraphicsCalls(); - - if (graphicsCalls == null || !robotSnapshot.isPaintEnabled()) { - continue; - } - - // Save the graphics state - GraphicsState gfxState = new GraphicsState(); - - gfxState.save(g); - - g.setClip(null); - g.setComposite(AlphaComposite.SrcAtop); - - IGraphicsProxy gfxProxy = getRobotGraphics(robotIndex); - - if (robotSnapshot.isSGPaintEnabled()) { - gfxProxy.processTo(g, graphicsCalls); - } else { - mirroredGraphics.bind(g, battleField.getHeight()); - gfxProxy.processTo(mirroredGraphics, graphicsCalls); - mirroredGraphics.release(); - } - - // Restore the graphics state - gfxState.restore(g); - - robotIndex++; - } - } - - private IGraphicsProxy getRobotGraphics(int robotIndex) { - if (robotGraphics[robotIndex] == null) { - robotGraphics[robotIndex] = new Graphics2DSerialized(); - robotGraphics[robotIndex].setPaintingEnabled(true); - } - return robotGraphics[robotIndex]; - } - - private void drawBullets(Graphics2D g, ITurnSnapshot snapShot) { - final Shape savedClip = g.getClip(); - - g.setClip(null); - - double x, y; - - for (IBulletSnapshot bulletSnapshot : snapShot.getBullets()) { - x = bulletSnapshot.getPaintX(); - y = battleField.getHeight() - bulletSnapshot.getPaintY(); - - AffineTransform at = AffineTransform.getTranslateInstance(x, y); - - if (bulletSnapshot.getState().isActive()) { - - // radius = sqrt(x^2 / 0.1 * power), where x is the width of 1 pixel for a minimum 0.1 bullet - double scale = max(2 * sqrt(2.5 * bulletSnapshot.getPower()), 2 / this.scale); - - at.scale(scale, scale); - Area bulletArea = BULLET_AREA.createTransformedArea(at); - - Color bulletColor; - - if (properties.getOptionsRenderingForceBulletColor()) { - bulletColor = Color.WHITE; - } else { - bulletColor = new Color(bulletSnapshot.getColor()); - } - g.setColor(bulletColor); - g.fill(bulletArea); - - } else if (drawExplosions) { - int explosionIndex = bulletSnapshot.getExplosionImageIndex(); - int frame = bulletSnapshot.getFrame(); - - // Sanity check to avoid bug-354 - Replaying an XML record can cause an ArrayIndexOutOfBoundsException - if (explosionIndex >= 0 && frame >= 0) { - if (!bulletSnapshot.isExplosion()) { - double scale = sqrt(1000 * bulletSnapshot.getPower()) / 128; - at.scale(scale, scale); - } - RenderImage explosionRenderImage = imageManager.getExplosionRenderImage(explosionIndex, frame); - explosionRenderImage.setTransform(at); - explosionRenderImage.paint(g); - } - } - } - g.setClip(savedClip); - } - - private void centerString(Graphics2D g, String s, int x, int y, Font font, FontMetrics fm) { - g.setFont(font); - - int width = fm.stringWidth(s); - int height = fm.getHeight(); - int descent = fm.getDescent(); - - double left = x - width / 2; - double top = y - height / 2; - - double scaledViewWidth = getWidth() / scale; - double scaledViewHeight = getHeight() / scale; - - double borderWidth = (scaledViewWidth - battleField.getWidth()) / 2; - double borderHeight = (scaledViewHeight - battleField.getHeight()) / 2; - - if (left + width > scaledViewWidth) { - left = scaledViewWidth - width; - } - if (top + height > scaledViewHeight) { - top = scaledViewHeight - height; - } - if (left < -borderWidth) { - left = -borderWidth; - } - if (top < -borderHeight) { - top = -borderHeight; - } - g.drawString(s, (int) (left + 0.5), (int) (top + height - descent + 0.5)); - } - - private void drawScanArc(Graphics2D g, IRobotSnapshot robotSnapshot) { - Arc2D.Double scanArc = (Arc2D.Double) ((RobotSnapshot) robotSnapshot).getScanArc(); - - if (scanArc == null) { - return; - } - - final Composite savedComposite = g.getComposite(); - - g.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.2f)); - - scanArc.setAngleStart((360 - scanArc.getAngleStart() - scanArc.getAngleExtent()) % 360); - scanArc.y = battleField.getHeight() - robotSnapshot.getY() - robocode.Rules.RADAR_SCAN_RADIUS; - - int scanColor = robotSnapshot.getScanColor(); - - g.setColor(new Color(scanColor, true)); - - if (abs(scanArc.getAngleExtent()) >= .5) { - g.fill(scanArc); - } else { - g.draw(scanArc); - } - - g.setComposite(savedComposite); - } - - private void paintRobocodeLogo(Graphics2D g) { - setBackground(Color.BLACK); - g.clearRect(0, 0, getWidth(), getHeight()); - - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - - g.transform(AffineTransform.getTranslateInstance((getWidth() - 320) / 2.0, (getHeight() - 46) / 2.0)); - g.setColor(new Color(0, 0x40, 0)); - g.fill(robocodeTextPath); - - Font font = new Font("Dialog", Font.BOLD, 14); - int width = g.getFontMetrics(font).stringWidth(ROBOCODE_SLOGAN); - - g.setTransform(new AffineTransform()); - g.setFont(font); - g.setColor(new Color(0, 0x50, 0)); - g.drawString(ROBOCODE_SLOGAN, (float) ((getWidth() - width) / 2.0), (float) (getHeight() / 2.0 + 50)); - } - - private class BattleObserver extends BattleAdaptor { - public BattleObserver(IWindowManager windowManager) { - windowManager.addBattleListener(this); - } - - @Override - public void onBattleStarted(BattleStartedEvent event) { - battleRules = event.getBattleRules(); - - battleField = new BattleField(battleRules.getBattlefieldWidth(), battleRules.getBattlefieldHeight()); - - initialized = false; - setVisible(true); - - super.onBattleStarted(event); - - robotGraphics = new IGraphicsProxy[event.getRobotsCount()]; - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - super.onBattleFinished(event); - robotGraphics = null; - } - - public void onTurnEnded(final TurnEndedEvent event) { - if (event.getTurnSnapshot() == null) { - repaint(); - } else { - update(event.getTurnSnapshot()); - } - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/InteractiveHandler.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/InteractiveHandler.java deleted file mode 100644 index a10cc6f..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/InteractiveHandler.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.battleview; - - -import net.sf.robocode.battle.BattleProperties; -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.security.SafeComponent; -import robocode.*; - -import java.awt.*; -import java.awt.event.KeyEvent; -import java.awt.event.MouseEvent; -import java.awt.event.*; -import static java.lang.Math.min; - - -/** - * This handler is used for observing keyboard and mouse events from the battle view, - * which must be process to the all robots interactive event handlers. - * The mouse events y coordinates are mirrored to comply to the coordinate system - * used in Robocode. - * - * @author Pavel Savara (original) - * @author Flemming N. Larsen (contributor) - */ -public final class InteractiveHandler implements KeyEventDispatcher, MouseListener, MouseMotionListener, MouseWheelListener { - private final IBattleManager battleManager; - private final BattleView battleView; - - public InteractiveHandler(IBattleManager battleManager, BattleView battleView) { - this.battleManager = battleManager; - this.battleView = battleView; - } - - public boolean dispatchKeyEvent(java.awt.event.KeyEvent e) { - switch (e.getID()) { - case KeyEvent.KEY_TYPED: - handleInteractiveEvent(new KeyTypedEvent(cloneKeyEvent(e))); - break; - - case KeyEvent.KEY_PRESSED: - handleInteractiveEvent(new KeyPressedEvent(cloneKeyEvent(e))); - break; - - case KeyEvent.KEY_RELEASED: - handleInteractiveEvent(new KeyReleasedEvent(cloneKeyEvent(e))); - break; - } - - // Allow KeyboardFocusManager to take further action with regard to the KeyEvent. - // This way the InteractiveHandler does not steal the event, but is only a keyboard observer. - return false; - } - - public void mouseClicked(MouseEvent e) { - handleInteractiveEvent(new MouseClickedEvent(mirroredMouseEvent(e))); - } - - public void mouseEntered(MouseEvent e) { - handleInteractiveEvent(new MouseEnteredEvent(mirroredMouseEvent(e))); - } - - public void mouseExited(MouseEvent e) { - handleInteractiveEvent(new MouseExitedEvent(mirroredMouseEvent(e))); - } - - public void mousePressed(MouseEvent e) { - handleInteractiveEvent(new MousePressedEvent(mirroredMouseEvent(e))); - } - - public void mouseReleased(MouseEvent e) { - handleInteractiveEvent(new MouseReleasedEvent(mirroredMouseEvent(e))); - } - - public void mouseMoved(MouseEvent e) { - handleInteractiveEvent(new MouseMovedEvent(mirroredMouseEvent(e))); - } - - public void mouseDragged(MouseEvent e) { - handleInteractiveEvent(new MouseDraggedEvent(mirroredMouseEvent(e))); - } - - public void mouseWheelMoved(MouseWheelEvent e) { - handleInteractiveEvent(new MouseWheelMovedEvent(mirroredMouseWheelEvent(e))); - } - - public static KeyEvent cloneKeyEvent(final KeyEvent e) { - return new KeyEvent(SafeComponent.getSafeEventComponent(), e.getID(), e.getWhen(), e.getModifiersEx(), - e.getKeyCode(), e.getKeyChar(), e.getKeyLocation()); - } - - private void handleInteractiveEvent(robocode.Event event) { - battleManager.sendInteractiveEvent(event); - } - - private MouseEvent mirroredMouseEvent(final MouseEvent e) { - - double scale; - BattleProperties battleProps = battleManager.getBattleProperties(); - - int vWidth = battleView.getWidth(); - int vHeight = battleView.getHeight(); - int fWidth = battleProps.getBattlefieldWidth(); - int fHeight = battleProps.getBattlefieldHeight(); - - if (vWidth < fWidth || vHeight < fHeight) { - scale = min((double) vWidth / fWidth, (double) fHeight / fHeight); - } else { - scale = 1; - } - - double dx = (vWidth - scale * fWidth) / 2; - double dy = (vHeight - scale * fHeight) / 2; - - int x = (int) ((e.getX() - dx) / scale + 0.5); - int y = (int) (fHeight - (e.getY() - dy) / scale + 0.5); - - return new MouseEvent(SafeComponent.getSafeEventComponent(), e.getID(), e.getWhen(), e.getModifiersEx(), x, y, - e.getClickCount(), e.isPopupTrigger(), e.getButton()); - } - - private MouseWheelEvent mirroredMouseWheelEvent(final MouseWheelEvent e) { - - double scale; - BattleProperties battleProps = battleManager.getBattleProperties(); - - int vWidth = battleView.getWidth(); - int vHeight = battleView.getHeight(); - int fWidth = battleProps.getBattlefieldWidth(); - int fHeight = battleProps.getBattlefieldHeight(); - - if (vWidth < fWidth || vHeight < fHeight) { - scale = min((double) vWidth / fWidth, (double) fHeight / fHeight); - } else { - scale = 1; - } - - double dx = (vWidth - scale * fWidth) / 2; - double dy = (vHeight - scale * fHeight) / 2; - - int x = (int) ((e.getX() - dx) / scale + 0.5); - int y = (int) (fHeight - (e.getY() - dy) / scale + 0.5); - - return new MouseWheelEvent(SafeComponent.getSafeEventComponent(), e.getID(), e.getWhen(), e.getModifiersEx(), x, - y, e.getClickCount(), e.isPopupTrigger(), e.getScrollType(), e.getScrollAmount(), e.getWheelRotation()); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/MirroredGraphics.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/MirroredGraphics.java deleted file mode 100644 index 2264a3c..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/MirroredGraphics.java +++ /dev/null @@ -1,567 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.battleview; - - -import net.sf.robocode.ui.gfx.GraphicsState; - -import java.awt.*; -import java.awt.RenderingHints.Key; -import java.awt.font.FontRenderContext; -import java.awt.font.GlyphVector; -import java.awt.geom.AffineTransform; -import java.awt.image.BufferedImage; -import java.awt.image.BufferedImageOp; -import java.awt.image.ImageObserver; -import java.awt.image.RenderedImage; -import java.awt.image.renderable.RenderableImage; -import java.text.AttributedCharacterIterator; -import java.util.Map; - - -/** - * This class is a Graphics2D wrapper class used for mirroring graphics on - * the Y-axis. This class ensures that strings that are painted using the - * drawBytes(), drawChars(), and drawString() methods are painted on the - * right location but that the text itself is not mirrored when painted. - * - * @author Flemming N. Larsen (original) - */ -public class MirroredGraphics extends Graphics2D { - - // The wrapped Graphics object - private Graphics2D g; - - // Save/restore of Graphics object - private final GraphicsState graphicsState = new GraphicsState(); - - // The original transform mirrored - private final AffineTransform origTxMirrored = new AffineTransform(); - - // A transform used for temporary transform operations (is reused) - private final AffineTransform tmpTx = new AffineTransform(); - - /** - * Binds a Graphics2D object to this wrapper object. - * When painting using this wrapper has finished the - * {@link #release() } method must be called. - * - * @param g the Graphics2D object to wrap - * @param height the height of the battlefield to mirror - * @see #release() - */ - public void bind(Graphics2D g, int height) { - this.g = g; - - graphicsState.save(g); - - origTxMirrored.setTransform(g.getTransform()); - origTxMirrored.translate(0, height); - origTxMirrored.scale(1, -1); - - g.setTransform(origTxMirrored); - } - - /** - * Releases the bounded Graphics2D object from this wrapper. - * - * @see #bind(Graphics2D, int) - */ - public void release() { - graphicsState.restore(g); - } - - // -------------------------------------------------------------------------- - // Overriding all methods from the extended Graphics class - // -------------------------------------------------------------------------- - - // Methods that should not be overridden or implemented: - // - finalize() - // - toString() - - @Override - public Graphics create() { - return g.create(); - } - - @Override - public Graphics create(int x, int y, int width, int height) { - return g.create(x, y, width, height); - } - - @Override - public void translate(int x, int y) { - g.translate(x, y); - } - - @Override - public Color getColor() { - return g.getColor(); - } - - @Override - public void setColor(Color c) { - g.setColor(c); - } - - @Override - public void setPaintMode() { - g.setPaintMode(); - } - - @Override - public void setXORMode(Color c1) { - g.setXORMode(c1); - } - - @Override - public Font getFont() { - return g.getFont(); - } - - @Override - public void setFont(Font font) { - g.setFont(font); - } - - @Override - public FontMetrics getFontMetrics(Font f) { - return g.getFontMetrics(f); - } - - @Override - public Rectangle getClipBounds() { - return g.getClipBounds(); - } - - @Override - public void clipRect(int x, int y, int width, int height) { - g.clipRect(x, y, width, height); - } - - @Override - public void setClip(int x, int y, int width, int height) { - g.setClip(x, y, width, height); - } - - @Override - public Shape getClip() { - return g.getClip(); - } - - @Override - public void setClip(Shape clip) { - g.setClip(clip); - } - - @Override - public void copyArea(int x, int y, int width, int height, int dx, int dy) { - g.copyArea(x, y, width, height, dx, dy); - } - - @Override - public void drawLine(int x1, int y1, int x2, int y2) { - g.drawLine(x1, y1, x2, y2); - } - - @Override - public void fillRect(int x, int y, int width, int height) { - g.fillRect(x, y, width, height); - } - - @Override - public void drawRect(int x, int y, int width, int height) { - g.drawRect(x, y, width, height); - } - - @Override - public void clearRect(int x, int y, int width, int height) { - g.clearRect(x, y, width, height); - } - - @Override - public void drawRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { - g.drawRoundRect(x, y, width, height, arcWidth, arcHeight); - } - - @Override - public void fillRoundRect(int x, int y, int width, int height, int arcWidth, int arcHeight) { - g.fillRoundRect(x, y, width, height, arcWidth, arcHeight); - } - - @Override - public void draw3DRect(int x, int y, int width, int height, boolean raised) { - g.draw3DRect(x, y, width, height, raised); - } - - @Override - public void fill3DRect(int x, int y, int width, int height, boolean raised) { - g.fill3DRect(x, y, width, height, raised); - } - - @Override - public void drawOval(int x, int y, int width, int height) { - g.drawOval(x, y, width, height); - } - - @Override - public void fillOval(int x, int y, int width, int height) { - g.fillOval(x, y, width, height); - } - - @Override - public void drawArc(int x, int y, int width, int height, int startAngle, int arcAngle) { - g.drawArc(x, y, width, height, startAngle - 90, arcAngle); // Translated into the Robocode coordinate system - } - - @Override - public void fillArc(int x, int y, int width, int height, int startAngle, int arcAngle) { - g.fillArc(x, y, width, height, startAngle - 90, arcAngle); // Translated into the Robocode coordinate system - } - - @Override - public void drawPolyline(int[] xPoints, int[] yPoints, int npoints) { - g.drawPolyline(xPoints, yPoints, npoints); - } - - @Override - public void drawPolygon(int[] xPoints, int[] yPoints, int npoints) { - g.drawPolyline(xPoints, yPoints, npoints); - } - - @Override - public void drawPolygon(Polygon p) { - g.drawPolygon(p); - } - - @Override - public void fillPolygon(int[] xPoints, int[] yPoints, int npoints) { - g.fillPolygon(xPoints, yPoints, npoints); - } - - @Override - public void fillPolygon(Polygon p) { - g.fillPolygon(p); - } - - // Modified so that the y-axis is mirrored - @Override - public void drawString(String str, int x, int y) { - // Change the transform to use the mirrored transform and save the current one - AffineTransform saveTx = setToMirroredTransform(); - - g.drawString(str, x, -y); - - // Restore the transform - g.setTransform(saveTx); - } - - // Modified so that the y-axis is mirrored - @Override - public void drawString(AttributedCharacterIterator iterator, int x, int y) { - // Change the transform to use the mirrored transform and save the current one - AffineTransform saveTx = setToMirroredTransform(); - - g.drawString(iterator, x, -y); - - // Restore the transform - g.setTransform(saveTx); - } - - // Modified so that the y-axis is mirrored - @Override - public void drawChars(char[] data, int offset, int length, int x, int y) { - // Change the transform to use the mirrored transform and save the current one - AffineTransform saveTx = setToMirroredTransform(); - - g.drawChars(data, offset, length, x, -y); - - // Restore the transform - g.setTransform(saveTx); - } - - // Modified so that the y-axis is mirrored - @Override - public void drawBytes(byte[] data, int offset, int length, int x, int y) { - // Change the transform to use the mirrored transform and save the current one - AffineTransform saveTx = setToMirroredTransform(); - - g.drawBytes(data, offset, length, x, -y); - - // Restore the transform - g.setTransform(saveTx); - } - - @Override - public boolean drawImage(Image img, int x, int y, ImageObserver observer) { - return g.drawImage(img, x, y, observer); - } - - @Override - public boolean drawImage(Image img, int x, int y, int width, int height, ImageObserver observer) { - return g.drawImage(img, x, y, width, height, observer); - } - - @Override - public boolean drawImage(Image img, int x, int y, Color bgcolor, ImageObserver observer) { - return g.drawImage(img, x, y, bgcolor, observer); - } - - @Override - public boolean drawImage(Image img, int x, int y, int width, int height, Color bgcolor, ImageObserver observer) { - return g.drawImage(img, x, y, width, height, bgcolor, observer); - } - - @Override - public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, - ImageObserver observer) { - return g.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, observer); - } - - @Override - public boolean drawImage(Image img, int dx1, int dy1, int dx2, int dy2, int sx1, int sy1, int sx2, int sy2, - Color bgcolor, ImageObserver observer) { - return g.drawImage(img, dx1, dy1, dx2, dy2, sx1, sy1, sx2, sy2, bgcolor, observer); - } - - @Override - public void dispose() { - g.dispose(); - } - - @Override - @Deprecated - public Rectangle getClipRect() { - return g.getClipBounds(); // Must use getClipBounds() instead of the deprecated getClipRect() method - } - - @Override - public boolean hitClip(int x, int y, int width, int height) { - return g.hitClip(x, y, width, height); - } - - @Override - public Rectangle getClipBounds(Rectangle r) { - return g.getClipBounds(r); - } - - // -------------------------------------------------------------------------- - // Overriding all methods from the extended Graphics2D class - // -------------------------------------------------------------------------- - - @Override - public void draw(Shape s) { - g.draw(s); - } - - @Override - public boolean drawImage(Image img, AffineTransform xform, ImageObserver obs) { - return g.drawImage(img, xform, obs); - } - - @Override - public void drawImage(BufferedImage img, BufferedImageOp op, int x, int y) { - g.drawImage(img, op, x, y); - } - - @Override - public void drawRenderedImage(RenderedImage img, AffineTransform xform) { - g.drawRenderedImage(img, xform); - } - - @Override - public void drawRenderableImage(RenderableImage img, AffineTransform xform) { - g.drawRenderableImage(img, xform); - } - - // Modified so that the y-axis is mirrored - @Override - public void drawString(String str, float x, float y) { - // Change the transform to use the mirrored transform and save the current one - AffineTransform saveTx = setToMirroredTransform(); - - g.drawString(str, x, -y); - - // Restore the transform - g.setTransform(saveTx); - } - - // Modified so that the y-axis is mirrored - @Override - public void drawString(AttributedCharacterIterator iterator, float x, float y) { - // Change the transform to use the mirrored transform and save the current one - AffineTransform saveTx = setToMirroredTransform(); - - g.drawString(iterator, x, -y); - - // Restore the transform - g.setTransform(saveTx); - } - - @Override - public void drawGlyphVector(GlyphVector gv, float x, float y) { - g.drawGlyphVector(gv, x, y); - } - - @Override - public void fill(Shape s) { - g.fill(s); - } - - @Override - public boolean hit(Rectangle rect, Shape s, boolean onStroke) { - return g.hit(rect, s, onStroke); - } - - @Override - public GraphicsConfiguration getDeviceConfiguration() { - return g.getDeviceConfiguration(); - } - - @Override - public void setComposite(Composite comp) { - g.setComposite(comp); - } - - @Override - public void setPaint(Paint paint) { - g.setPaint(paint); - } - - @Override - public void setStroke(Stroke s) { - g.setStroke(s); - } - - @Override - public void setRenderingHint(Key hintKey, Object hintValue) { - g.setRenderingHint(hintKey, hintValue); - } - - @Override - public Object getRenderingHint(Key hintKey) { - return g.getRenderingHint(hintKey); - } - - @Override - public void setRenderingHints(Map hints) { - g.setRenderingHints(hints); - } - - @Override - public void addRenderingHints(Map hints) { - g.addRenderingHints(hints); - } - - @Override - public RenderingHints getRenderingHints() { - return g.getRenderingHints(); - } - - @Override - public void translate(double tx, double ty) { - g.translate(tx, ty); - } - - @Override - public void rotate(double theta) { - g.rotate(theta); - } - - @Override - public void rotate(double theta, double x, double y) { - g.rotate(theta, x, y); - } - - @Override - public void scale(double sx, double sy) { - g.scale(sx, sy); - } - - @Override - public void shear(double shx, double shy) { - g.shear(shx, shy); - } - - @Override - public void transform(AffineTransform Tx) { - g.transform(Tx); - } - - // Transforming is handled on the y-axis mirrored transform - @Override - public void setTransform(AffineTransform Tx) { - // Set the current transform to by the original mirrored transform - // concatenated with the input transform. This way the new transform - // will automatically be mirrored around the y-axis - tmpTx.setTransform(origTxMirrored); - tmpTx.concatenate(Tx); - g.setTransform(tmpTx); - } - - @Override - public AffineTransform getTransform() { - return g.getTransform(); - } - - @Override - public Paint getPaint() { - return g.getPaint(); - } - - @Override - public Composite getComposite() { - return g.getComposite(); - } - - @Override - public void setBackground(Color color) { - g.setBackground(color); - } - - @Override - public Color getBackground() { - return g.getBackground(); - } - - @Override - public Stroke getStroke() { - return g.getStroke(); - } - - @Override - public void clip(Shape s) { - g.clip(s); - } - - @Override - public FontRenderContext getFontRenderContext() { - return g.getFontRenderContext(); - } - - // -------------------------------------------------------------------------- - // Private worker methods - // -------------------------------------------------------------------------- - - /** - * This methods translates the current transform on the internal Graphics2D - * object into a transform that is mirrored around the y-axis. - * - * @return the AffineTransform before calling this method, which must be - * used for restoring the AffineTransform later. - */ - private AffineTransform setToMirroredTransform() { - AffineTransform saveTx = g.getTransform(); - - tmpTx.setTransform(saveTx); - tmpTx.scale(1, -1); - g.setTransform(tmpTx); - - return saveTx; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/ScreenshotUtil.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/ScreenshotUtil.java deleted file mode 100644 index 62cbefd..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/battleview/ScreenshotUtil.java +++ /dev/null @@ -1,84 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.battleview; - - -import java.awt.image.BufferedImage; -import java.io.File; -import java.io.IOException; -import java.text.SimpleDateFormat; -import java.util.Date; -import java.util.Iterator; - -import javax.imageio.IIOImage; -import javax.imageio.ImageIO; -import javax.imageio.ImageWriteParam; -import javax.imageio.ImageWriter; -import javax.imageio.stream.FileImageOutputStream; - -import net.sf.robocode.io.FileUtil; - - -/** - * This utility class for saving screenshots of the battle view. - * - * @author Flemming N. Larsen (original) - * - * @since 1.7.2 - */ -public class ScreenshotUtil { - - private final static SimpleDateFormat DATE_FORMAT = new SimpleDateFormat("yyyy-MM-dd'T'HH.mm.ss.SSS"); - - public static void saveScreenshot(BufferedImage screenshot, String format, float compressionQuality) { - FileImageOutputStream output = null; - ImageWriter writer = null; - - File screenshotDir = FileUtil.getScreenshotsDir(); - - FileUtil.createDir(screenshotDir); - - File file = new File(screenshotDir, DATE_FORMAT.format(new Date()) + '.' + format.toLowerCase()); - - try { - // Instantiate an ImageWriteParam object with default compression options - Iterator it = ImageIO.getImageWritersByFormatName(format); - - writer = (ImageWriter) it.next(); - ImageWriteParam iwp = writer.getDefaultWriteParam(); - - // If compression is supported, then set the compression mode - if (iwp.canWriteCompressed()) { - // Use explicit compression mode - iwp.setCompressionMode(ImageWriteParam.MODE_EXPLICIT); - - // Set compression quality, where 1 specifies minimum compression and maximum quality - iwp.setCompressionQuality(compressionQuality); // float between 0 and 1 - } - // Write the screen shot to file - output = new FileImageOutputStream(file); - writer.setOutput(output); - IIOImage image = new IIOImage(screenshot, null, null); - - writer.write(null, image, iwp); - } catch (IOException e) { - e.printStackTrace(); - } finally { - if (writer != null) { - writer.dispose(); - } - if (output != null) { - try { - output.close(); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/AboutBox.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/AboutBox.java deleted file mode 100644 index 4ac7bad..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/AboutBox.java +++ /dev/null @@ -1,225 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.ui.BrowserManager; -import net.sf.robocode.version.IVersionManager; - -import javax.swing.*; -import javax.swing.event.HyperlinkEvent; -import javax.swing.event.HyperlinkListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.ByteArrayOutputStream; -import java.io.InputStream; -import java.io.IOException; -import java.net.URL; -import java.net.URLConnection; - - -/** - * The About box. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public final class AboutBox extends JDialog { - // Tag used for background color replacement - private final static Color BG_COLOR = new Color(0xF0, 0xF0, 0xF0); - // Tag used for Robocode version replacement - private final static String TAG_ROBOCODE_VERSION = "\\Q{$robocode-version}\\E"; - // Tag used for Robocode icon source replacement - private final static String TAG_ROBOCODE_ICON_SRC = "\\Q{$robocode-icon-url}\\E"; - // Tag used for background color replacement - private final static String TAG_BG_COLOR = "\\Q{$background-color}\\E"; - // Tag used for Java version replacement - private final static String TAG_JAVA_VERSION = "\\Q{$java-version}\\E"; - // Tag used for Java vendor replacement - private final static String TAG_JAVA_VENDOR = "\\Q{$java-vendor}\\E"; - // Tag used for transparent.png 1x1 px url replacement - private final static String TAG_TRANSPARENT = "\\Q{$transparent}\\E"; - - // Robocode version - private final String robocodeVersion; - // Robocode icon URL - private final java.net.URL iconURL; - // Transparent URL - private final java.net.URL transparentURL; - - // Content pane - private JPanel aboutBoxContentPane; - // Main panel - private JEditorPane mainPanel; - // Button panel - private JPanel buttonPanel; - // OK button - private JButton okButton; - // HTML text after tag replacements - private String html; - - private static String getHtmlTemplate() { - URL url = AboutBox.class.getResource("/net/sf/robocode/ui/html/about.html"); - - ByteArrayOutputStream baos = new ByteArrayOutputStream(); - - try { - URLConnection connection = url.openConnection(); - int contentLength = connection.getContentLength(); - InputStream in = url.openStream(); - byte[] buf = new byte[contentLength]; - int len; - - while (true) { - len = in.read(buf); - if (len == -1) { - break; - } - baos.write(buf, 0, len); - } - baos.close(); - } catch (IOException ignore) {} - return baos.toString(); - } - - // General event handler - private final transient ActionListener eventHandler = new ActionListener() { - public void actionPerformed(ActionEvent e) { - if (e.getSource() == AboutBox.this.getOkButton()) { - AboutBox.this.dispose(); - } - } - }; - - // Hyperlink event handler - private final transient HyperlinkListener hyperlinkHandler = new HyperlinkListener() { - public void hyperlinkUpdate(HyperlinkEvent event) { - if (event.getEventType() == HyperlinkEvent.EventType.ACTIVATED) { - try { - BrowserManager.openURL(event.getURL().toExternalForm()); - } catch (IOException e) { - e.printStackTrace(); - } - } - } - }; - - public AboutBox(RobocodeFrame owner, IVersionManager versionManager) { - super(owner, true); - - robocodeVersion = versionManager.getVersion(); - - iconURL = AboutBox.class.getResource("/net/sf/robocode/ui/icons/robocode-icon.png"); - transparentURL = AboutBox.class.getResource("/net/sf/robocode/ui/html/transparent.png"); - - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setTitle("About Robocode"); - setContentPane(getAboutBoxContentPane()); - setResizable(false); - } - - private JPanel getAboutBoxContentPane() { - if (aboutBoxContentPane == null) { - aboutBoxContentPane = new JPanel(); - aboutBoxContentPane.setLayout(new BorderLayout()); - aboutBoxContentPane.add(getButtonPanel(), BorderLayout.SOUTH); - aboutBoxContentPane.add(getMainPanel(), BorderLayout.CENTER); - } - return aboutBoxContentPane; - } - - private JEditorPane getMainPanel() { - if (mainPanel == null) { - String aaFontSettings = System.getProperty("awt.useSystemAAFontSettings"); - - if (aaFontSettings != null) { - mainPanel = new JEditorPane("text/html; charset=ISO-8859-1", getHtmlText()); - System.out.println(aaFontSettings); - } else { - mainPanel = new JEditorPane("text/html; charset=ISO-8859-1", getHtmlText()) { - @Override - public void paintComponent(Graphics g) { - Graphics2D g2 = (Graphics2D) g; - - g2.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - super.paintComponent(g); - } - }; - } - mainPanel.setBackground(BG_COLOR); - mainPanel.setEditable(false); - mainPanel.addHyperlinkListener(hyperlinkHandler); - } - return mainPanel; - } - - private JPanel getButtonPanel() { - if (buttonPanel == null) { - buttonPanel = new JPanel(); - buttonPanel.setBackground(BG_COLOR); - buttonPanel.setLayout(new FlowLayout()); - buttonPanel.add(getOkButton()); - } - return buttonPanel; - } - - private JButton getOkButton() { - if (okButton == null) { - okButton = new JButton(); - okButton.setText("OK"); - okButton.addActionListener(eventHandler); - } - return okButton; - } - - private String getHtmlText() { - if (html == null) { - html = getHtmlTemplate(); - html = html.replaceAll(TAG_ROBOCODE_VERSION, robocodeVersion); - html = html.replaceAll(TAG_ROBOCODE_ICON_SRC, iconURL.toString()); - html = html.replaceAll(TAG_BG_COLOR, toHtmlColor(BG_COLOR)); - html = html.replaceAll(TAG_JAVA_VERSION, getJavaVersion()); - html = html.replaceAll(TAG_JAVA_VENDOR, System.getProperty("java.vendor")); - html = html.replaceAll(TAG_TRANSPARENT, transparentURL.toString()); - } - return html; - } - - private static String toHtmlColor(Color color) { - return "#" + toHexDigits(color.getRed()) + toHexDigits(color.getGreen()) + toHexDigits(color.getBlue()); - } - - private static String toHexDigits(int value) { - return "" + toHexDigit(value >> 4) + toHexDigit(value & 0x0f); - } - - private static char toHexDigit(int value) { - int v = (value & 0xf); - - if (v < 10) { - return (char) ('0' + v); - } - return (char) ('A' + (v - 10)); - } - - private static String getJavaVersion() { - String javaVersion = System.getProperty("java.version"); - String javaArchModel = System.getProperty("sun.arch.data.model"); - - if (javaArchModel != null) { - try { - int numBits = Integer.parseInt(javaArchModel); - - javaVersion += " (" + numBits + "-bit)"; - } catch (NumberFormatException ignore) {} - } - return javaVersion; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/AvailableRobotsPanel.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/AvailableRobotsPanel.java deleted file mode 100644 index 5d97c2b..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/AvailableRobotsPanel.java +++ /dev/null @@ -1,421 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.ui.util.ShortcutUtil; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.*; -import java.awt.event.ComponentAdapter; -import java.awt.event.ComponentEvent; -import java.awt.event.MouseAdapter; -import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.CopyOnWriteArrayList; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -@SuppressWarnings("serial") -public class AvailableRobotsPanel extends JPanel { - - private final List availableRobots = new CopyOnWriteArrayList(); - private List robotList = new CopyOnWriteArrayList(); - private final List availablePackages = new CopyOnWriteArrayList(); - - private JScrollPane availableRobotsScrollPane; - private JList availableRobotsList; - - private final JButton actionButton; - - private final JList actionList; - private JList availablePackagesList; - - private JScrollPane availablePackagesScrollPane; - - private RobotNameCellRenderer robotNameCellRenderer; - - private final RobotSelectionPanel robotSelectionPanel; - - private final String title; - - private final EventHandler eventHandler = new EventHandler(); - - public AvailableRobotsPanel(JButton actionButton, String title, JList actionList, - RobotSelectionPanel robotSelectionPanel) { - super(); - this.title = title; - this.actionButton = actionButton; - this.actionList = actionList; - this.robotSelectionPanel = robotSelectionPanel; - initialize(); - } - - private void initialize() { - setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), title)); - setLayout(new BorderLayout()); - - JPanel top = new JPanel(); - - top.setLayout(new GridLayout(1, 2)); - - JPanel a = new JPanel(); - - a.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Packages")); - a.setLayout(new BorderLayout()); - a.add(getAvailablePackagesScrollPane()); - a.setPreferredSize(new Dimension(120, 100)); - top.add(a); - - JPanel b = new JPanel(); - - b.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEmptyBorder(), "Robots")); - b.setLayout(new BorderLayout()); - b.add(getAvailableRobotsScrollPane()); - b.setPreferredSize(new Dimension(120, 100)); - top.add(b); - - add(top, BorderLayout.CENTER); - - JLabel refreshLabel = new JLabel("Press " + ShortcutUtil.getModifierKeyText() + "+R to refresh"); - - refreshLabel.setHorizontalAlignment(SwingConstants.CENTER); - add(refreshLabel, BorderLayout.SOUTH); - } - - public List getAvailableRobots() { - return availableRobots; - } - - public List getRobotList() { - return robotList; - } - - public List getSelectedRobots() { - List selected = new ArrayList(); - - for (int i : getAvailableRobotsList().getSelectedIndices()) { - selected.add(availableRobots.get(i)); - } - return selected; - } - - /** - * Return the availableRobotsList. - * - * @return JList - */ - public JList getAvailableRobotsList() { - if (availableRobotsList == null) { - availableRobotsList = new JList(); - availableRobotsList.setModel(new AvailableRobotsModel()); - availableRobotsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - - availableRobotsList.setCellRenderer(getRobotNameCellRenderer()); - - MouseListener mouseListener = new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - // This does not work in Linux under IBM JRE 1.3.0... - if (e.getClickCount() >= 2) { - if (e.getClickCount() % 2 == 0) { - if (actionButton != null) { - actionButton.doClick(); - } - } - } - } - }; - - availableRobotsList.addMouseListener(mouseListener); - availableRobotsList.addListSelectionListener(eventHandler); - } - return availableRobotsList; - } - - /** - * Return the JScrollPane1 property value. - * - * @return JScrollPane - */ - private JScrollPane getAvailableRobotsScrollPane() { - if (availableRobotsScrollPane == null) { - availableRobotsScrollPane = new JScrollPane(); - availableRobotsScrollPane.setViewportView(getAvailableRobotsList()); - - // Bug fix [2975871] - Minor visual bug - Currently selected robot gets covered - availableRobotsScrollPane.addComponentListener(new ComponentAdapter() { - public void componentResized(ComponentEvent e) { - getAvailableRobotsList().ensureIndexIsVisible(getAvailableRobotsList().getSelectedIndex()); - } - }); - } - return availableRobotsScrollPane; - } - - public void setRobotList(List robotListList) { - robotList = robotListList; - SwingUtilities.invokeLater(new Runnable() { - public void run() { - availablePackages.clear(); - availableRobots.clear(); - - if (robotList == null) { - robotList = new CopyOnWriteArrayList(); - availablePackages.add("One moment please..."); - ((AvailablePackagesModel) getAvailablePackagesList().getModel()).changed(); - getAvailablePackagesList().clearSelection(); - ((AvailableRobotsModel) getAvailableRobotsList().getModel()).changed(); - } else { - availablePackages.add("(All)"); - String packageName; - - for (IRobotSpecItem robotSpec : robotList) { - packageName = robotSpec.getFullPackage(); - if (packageName == null) { - continue; - } - if (!availablePackages.contains(packageName)) { - availablePackages.add(packageName); - } - } - availablePackages.add("(No package)"); - - for (IRobotSpecItem robotSpec : robotList) { - availableRobots.add(new ItemWrapper(robotSpec)); - } - ((AvailablePackagesModel) getAvailablePackagesList().getModel()).changed(); - getAvailablePackagesList().setSelectedIndex(0); - ((AvailableRobotsModel) getAvailableRobotsList().getModel()).changed(); - getAvailablePackagesList().requestFocus(); - } - } - }); - } - - private void availablePackagesListSelectionChanged() { - int sel[] = getAvailablePackagesList().getSelectedIndices(); - - boolean useShortName = false; - - availableRobots.clear(); - if (sel.length == 1) { - useShortName = true; - getAvailablePackagesList().scrollRectToVisible(getAvailablePackagesList().getCellBounds(sel[0], sel[0])); - } - - for (int element : sel) { - String selectedPackage = availablePackages.get(element); - - if (selectedPackage.equals("(All)")) { - useShortName = false; - availableRobots.clear(); - for (IRobotSpecItem robotItem : robotList) { - getRobotNameCellRenderer().setUseShortName(useShortName); - availableRobots.add(new ItemWrapper(robotItem)); - } - break; - } - // Single package. - for (IRobotSpecItem robotItem : robotList) { - getRobotNameCellRenderer().setUseShortName(useShortName); - - if ((robotItem.getFullPackage() == null && selectedPackage.equals("(No package)")) - || selectedPackage.equals(robotItem.getFullPackage())) { - availableRobots.add(new ItemWrapper(robotItem)); - } - } - } - ((AvailableRobotsModel) getAvailableRobotsList().getModel()).changed(); - if (availableRobots.size() > 0) { - availableRobotsList.setSelectedIndex(0); - availableRobotsListSelectionChanged(); - } - } - - private void availableRobotsListSelectionChanged() { - int sel[] = getAvailableRobotsList().getSelectedIndices(); - - if (sel.length == 1) { - if (actionList != null) { - actionList.clearSelection(); - } - IRobotSpecItem robotSpecification = ((ItemWrapper) getAvailableRobotsList().getModel().getElementAt(sel[0])).getItem(); - - if (robotSelectionPanel != null) { - robotSelectionPanel.showDescription(robotSpecification); - } - } else { - if (robotSelectionPanel != null) { - robotSelectionPanel.showDescription(null); - } - } - } - - public void clearSelection() { - getAvailableRobotsList().clearSelection(); - ((AvailableRobotsModel) getAvailableRobotsList().getModel()).changed(); - } - - /** - * Return the availableRobotsList. - * - * @return JList - */ - private JList getAvailablePackagesList() { - if (availablePackagesList == null) { - availablePackagesList = new JList(); - availablePackagesList.setModel(new AvailablePackagesModel()); - availablePackagesList.setSelectionMode(ListSelectionModel.SINGLE_INTERVAL_SELECTION); - availablePackagesList.addListSelectionListener(eventHandler); - } - return availablePackagesList; - } - - /** - * Return the availablePackagesScrollPane - * - * @return JScrollPane - */ - private JScrollPane getAvailablePackagesScrollPane() { - if (availablePackagesScrollPane == null) { - availablePackagesScrollPane = new JScrollPane(); - availablePackagesScrollPane.setViewportView(getAvailablePackagesList()); - } - return availablePackagesScrollPane; - } - - private RobotNameCellRenderer getRobotNameCellRenderer() { - if (robotNameCellRenderer == null) { - robotNameCellRenderer = new RobotNameCellRenderer(); - } - return robotNameCellRenderer; - } - - private class EventHandler implements ListSelectionListener { - public void valueChanged(ListSelectionEvent e) { - if (e.getValueIsAdjusting()) { - return; - } - if (e.getSource() == getAvailableRobotsList()) { - availableRobotsListSelectionChanged(); - } else if (e.getSource() == getAvailablePackagesList()) { - availablePackagesListSelectionChanged(); - } - } - } - - - private class AvailablePackagesModel extends AbstractListModel { - public void changed() { - fireContentsChanged(this, 0, getSize()); - } - - public int getSize() { - return availablePackages.size(); - } - - public String getElementAt(int which) { - return availablePackages.get(which); - } - } - - - private class AvailableRobotsModel extends AbstractListModel { - public void changed() { - fireContentsChanged(this, 0, getSize()); - } - - public int getSize() { - return availableRobots.size(); - } - - public ItemWrapper getElementAt(int which) { - return availableRobots.get(which); - } - } - - - /** - * Is there because of keyboard navigation is tied to toString() method - */ - public static class ItemWrapper { - private final IRobotSpecItem item; - - public ItemWrapper(IRobotSpecItem item) { - this.item = item; - } - - public IRobotSpecItem getItem() { - return item; - } - - // Used writing the robot name in JList. Is used for keyboard typing in JList to find robot. Bugfix for [2658090] - public String toString() { - return item.getUniqueShortClassNameWithVersion(); - } - } - - - /** - * RobotNameCellRender, which renders the list cells with "Team: " prefix, and with or without package names. - * This is cheating, as the ItemWrapper.toString() delivers the string used for keyboard navigation etc. - */ - private static class RobotNameCellRenderer extends JLabel implements ListCellRenderer { - private boolean useShortName = false; - - public RobotNameCellRenderer() { - setOpaque(true); - } - - public void setUseShortName(boolean useShortNames) { - this.useShortName = useShortNames; - } - - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - - setComponentOrientation(list.getComponentOrientation()); - - if (isSelected) { - setBackground(list.getSelectionBackground()); - setForeground(list.getSelectionForeground()); - } else { - setBackground(list.getBackground()); - setForeground(list.getForeground()); - } - - String text; - - if (value instanceof ItemWrapper) { - IRobotSpecItem item = ((ItemWrapper) value).getItem(); - - text = (item.isTeam() ? "Team: " : ""); - text += useShortName - ? item.getUniqueShortClassNameWithVersion() - : item.getUniqueFullClassNameWithVersion(); - } else { - text = value.toString(); - } - setText(text); - - setEnabled(list.isEnabled()); - setFont(list.getFont()); - - return this; - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/BaseScoreDialog.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/BaseScoreDialog.java deleted file mode 100644 index a451d95..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/BaseScoreDialog.java +++ /dev/null @@ -1,179 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.ui.IWindowManager; -import net.sf.robocode.ui.IWindowManagerExt; - -import javax.swing.*; -import javax.swing.table.AbstractTableModel; -import javax.swing.table.TableColumn; -import java.awt.*; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; - - -/** - * @author Pavel Savara (original) - */ -@SuppressWarnings("serial") -public abstract class BaseScoreDialog extends JDialog { - protected final IWindowManagerExt windowManager; - - private final EventHandler eventHandler = new EventHandler(); - protected JPanel contentPane; - protected JScrollPane scrollPane; - protected JTable table; - protected Dimension tableSize; - - public BaseScoreDialog(IWindowManager windowManager, boolean modal) { - // In order to prevent the dialog from hiding, null must be given as 'owner' parameter - super(windowManager != null ? windowManager.getRobocodeFrame() : null, modal); - this.windowManager = (IWindowManagerExt) windowManager; - } - - protected void initialize() { - addComponentListener(eventHandler); - setContentPane(getDialogContentPane()); - } - - /** - * Return the content pane. - * - * @return JPanel - */ - protected JPanel getDialogContentPane() { - if (contentPane == null) { - contentPane = new JPanel(); - contentPane.setLayout(new BorderLayout()); - contentPane.add(getScrollPane(), "Center"); - } - return contentPane; - } - - /** - * Return the scroll pane - * - * @return JScrollPane - */ - protected JScrollPane getScrollPane() { - if (scrollPane == null) { - scrollPane = new JScrollPane(); - scrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_AS_NEEDED); - scrollPane.getViewport().setScrollMode(JViewport.BLIT_SCROLL_MODE); - scrollPane.setViewportView(getTable()); - scrollPane.setColumnHeaderView(table.getTableHeader()); - scrollPane.addComponentListener(eventHandler); - - tableSize = new Dimension(getTable().getColumnModel().getTotalColumnWidth(), - getTable().getModel().getRowCount() * (getTable().getRowHeight())); - table.setPreferredScrollableViewportSize(tableSize); - table.setPreferredSize(tableSize); - table.setMinimumSize(tableSize); - } - return scrollPane; - } - - /** - * Return the table. - * - * @return JTable - */ - protected JTable getTable() { - if (table == null) { - table = new JTable(); - table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - table.setColumnSelectionAllowed(true); - table.setRowSelectionAllowed(true); - table.getTableHeader().setReorderingAllowed(false); - } - return table; - } - - private class EventHandler implements ComponentListener { - public void componentShown(ComponentEvent e) { - onDialogShown(); - } - - public void componentHidden(ComponentEvent e) { - onDialogHidden(); - } - - public void componentResized(ComponentEvent e) { - if (e.getSource() == BaseScoreDialog.this.getScrollPane()) { - scrollPaneComponentResized(); - } - } - - public void componentMoved(ComponentEvent e) {} - } - - protected abstract AbstractTableModel getTableModel(); - - protected void onDialogShown() {} - - protected void onDialogHidden() { - dispose(); - } - - protected void scrollPaneComponentResized() { - // This code is not working... - Dimension scrollPaneExtent = getScrollPane().getViewport().getExtentSize(); - - if (tableSize != null && (tableSize.width < scrollPaneExtent.width)) { - getTable().setAutoResizeMode(JTable.AUTO_RESIZE_SUBSEQUENT_COLUMNS); - getTable().setSize(scrollPaneExtent); - getTable().sizeColumnsToFit(-1); - } else { - if (tableSize != null) { - getTable().setSize(tableSize); - getTable().sizeColumnsToFit(-1); - } - table.setAutoResizeMode(JTable.AUTO_RESIZE_OFF); - } - validate(); - repaint(); - } - - protected void setResultsData() { - getTable().setModel(getTableModel()); - int maxScoreColWidth = 0; - - for (int x = 0; x < getTableModel().getColumnCount(); x++) { - if (x != 1) { - getTable().getColumnModel().getColumn(x).setCellRenderer(new ResultsTableCellRenderer(false)); - } - TableColumn column = getTable().getColumnModel().getColumn(x); - Component comp; - - column.setHeaderRenderer(new ResultsTableCellRenderer(true)); - comp = column.getHeaderRenderer().getTableCellRendererComponent(null, column.getHeaderValue(), false, false, - 0, 0); - int width = comp.getPreferredSize().width; - - for (int y = 0; y < getTableModel().getRowCount(); y++) { - comp = getTable().getDefaultRenderer(getTableModel().getColumnClass(x)).getTableCellRendererComponent( - getTable(), getTableModel().getValueAt(y, x), false, false, 0, x); - if (comp.getPreferredSize().width > width) { - width = comp.getPreferredSize().width; - } - } - TableColumn col = getTable().getColumnModel().getColumn(x); - - col.setPreferredWidth(width); - col.setMinWidth(width); - col.setWidth(width); - - if (x >= 3 && width > maxScoreColWidth) { - maxScoreColWidth = width; - } - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/BattleButton.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/BattleButton.java deleted file mode 100644 index 0e506b8..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/BattleButton.java +++ /dev/null @@ -1,57 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - -/** - * @author Pavel Savara (original) - */ -public class BattleButton extends JButton implements ActionListener { - private static final long serialVersionUID = 1L; - - private final BattleDialog battleDialog; - - public BattleButton(BattleDialog battleDialog) { - this.battleDialog = battleDialog; - - initialize(); - } - - public void actionPerformed(ActionEvent e) { - attach(); - if (!battleDialog.isVisible() || battleDialog.getState() != Frame.NORMAL) { - WindowUtil.packPlaceShow(battleDialog); - } else { - battleDialog.setVisible(true); - } - } - - /** - * Initialize the class. - */ - private void initialize() { - addActionListener(this); - setPreferredSize(new Dimension(110, 25)); - setMinimumSize(new Dimension(110, 25)); - setMaximumSize(new Dimension(110, 25)); - setHorizontalAlignment(SwingConstants.CENTER); - setMargin(new Insets(0, 0, 0, 0)); - setText("Main battle log"); - setToolTipText("Main battle log"); - } - - public void attach() { - battleDialog.attach(); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/BattleDialog.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/BattleDialog.java deleted file mode 100644 index 7f5b58f..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/BattleDialog.java +++ /dev/null @@ -1,244 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.serialization.IXmlSerializable; -import net.sf.robocode.serialization.SerializableOptions; -import net.sf.robocode.serialization.XmlWriter; -import net.sf.robocode.ui.IWindowManager; -import robocode.control.events.*; -import robocode.control.snapshot.ITurnSnapshot; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.IOException; -import java.io.StringWriter; - - -/** - * @author Pavel Savara (original) - */ -public class BattleDialog extends JFrame { - private static final long serialVersionUID = 1L; - - private final BattleObserver battleObserver = new BattleObserver(); - - private ConsoleScrollPane consoleScrollPane; - private ConsoleScrollPane turnSnapshotScrollPane; - private JTabbedPane tabbedPane; - private JButton okButton; - private JButton clearButton; - private JPanel battleDialogContentPane; - private JPanel buttonPanel; - - private final IWindowManager windowManager; - private boolean isListening; - private ITurnSnapshot lastSnapshot; - private boolean paintSnapshot; - - public BattleDialog(IWindowManager windowManager) { - this.windowManager = windowManager; - initialize(); - } - - private void initialize() { - this.setTitle("Main battle log"); - this.add(getBattleDialogContentPane()); - pack(); - } - - public void detach() { - if (isListening) { - windowManager.removeBattleListener(battleObserver); - isListening = false; - } - } - - public void reset() { - getConsoleScrollPane().setText(null); - getTurnSnapshotScrollPane().setText(null); - lastSnapshot = null; - } - - public void attach() { - if (!isListening) { - isListening = true; - windowManager.addBattleListener(battleObserver); - } - } - - /** - * When robotDialog is packed, we want to set a reasonable size. However, - * after that, we need a null preferred size so the scroll pane will scroll. - * (preferred size should be based on the text inside) - */ - @Override - public void pack() { - getConsoleScrollPane().setPreferredSize(new Dimension(426, 200)); - super.pack(); - getTabbedPane().setPreferredSize(null); - } - - private JPanel getBattleDialogContentPane() { - if (battleDialogContentPane == null) { - battleDialogContentPane = new JPanel(); - battleDialogContentPane.setLayout(new BorderLayout()); - battleDialogContentPane.add(getTabbedPane()); - battleDialogContentPane.add(getButtonPanel(), BorderLayout.SOUTH); - } - return battleDialogContentPane; - } - - private JPanel getButtonPanel() { - if (buttonPanel == null) { - buttonPanel = new JPanel(); - buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); - buttonPanel.add(getOkButton()); - buttonPanel.add(getClearButton()); - } - return buttonPanel; - } - - private JButton getOkButton() { - if (okButton == null) { - okButton = getNewButton("OK"); - } - return okButton; - } - - private JButton getClearButton() { - if (clearButton == null) { - clearButton = getNewButton("Clear"); - } - return clearButton; - } - - private JButton getNewButton(String text) { - JButton button = new JButton(text); - - button.addActionListener(eventHandler); - return button; - } - - private final transient ActionListener eventHandler = new ActionListener() { - public void actionPerformed(ActionEvent e) { - Object src = e.getSource(); - - if (src == BattleDialog.this.getOkButton()) { - okButtonActionPerformed(); - } else if (src == BattleDialog.this.getClearButton()) { - clearButtonActionPerformed(); - } - } - }; - - private JTabbedPane getTabbedPane() { - if (tabbedPane == null) { - tabbedPane = new JTabbedPane(); - tabbedPane.setLayout(new BorderLayout()); - tabbedPane.addTab("Console", getConsoleScrollPane()); - tabbedPane.addTab("Turn Snapshot", getTurnSnapshotScrollPane()); - tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); - - tabbedPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - paintSnapshot = (tabbedPane.getSelectedIndex() == 1); - paintSnapshot(); - } - }); - } - return tabbedPane; - } - - private ConsoleScrollPane getConsoleScrollPane() { - if (consoleScrollPane == null) { - consoleScrollPane = new ConsoleScrollPane(); - } - return consoleScrollPane; - } - - private ConsoleScrollPane getTurnSnapshotScrollPane() { - if (turnSnapshotScrollPane == null) { - turnSnapshotScrollPane = new ConsoleScrollPane(); - } - return turnSnapshotScrollPane; - } - - private void okButtonActionPerformed() { - dispose(); - } - - private void clearButtonActionPerformed() { - reset(); - } - - private void paintSnapshot() { - if (paintSnapshot) { - String text = null; - - if (lastSnapshot != null) { - final StringWriter writer = new StringWriter(); - final XmlWriter xmlWriter = new XmlWriter(writer, true); - - try { - ((IXmlSerializable) lastSnapshot).writeXml(xmlWriter, new SerializableOptions(false)); - writer.close(); - } catch (IOException e) { - Logger.logError(e); - } - text = writer.toString(); - } - getTurnSnapshotScrollPane().setText(text); - } - } - - private class BattleObserver extends BattleAdaptor { - - @Override - public void onBattleMessage(BattleMessageEvent event) { - final String text = event.getMessage(); - - if (text != null && text.length() > 0) { - getConsoleScrollPane().append(text + "\n"); - getConsoleScrollPane().scrollToBottom(); - } - } - - @Override - public void onBattleError(BattleErrorEvent event) { - final String text = event.getError(); - - if (text != null && text.length() > 0) { - getConsoleScrollPane().append(text + "\n"); - getConsoleScrollPane().scrollToBottom(); - } - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - lastSnapshot = event.getTurnSnapshot(); - paintSnapshot(); - } - - public void onBattleStarted(final BattleStartedEvent event) { - reset(); - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - lastSnapshot = null; - paintSnapshot(); - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ConsoleDialog.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ConsoleDialog.java deleted file mode 100644 index c72fb18..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ConsoleDialog.java +++ /dev/null @@ -1,163 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import javax.swing.*; -import java.awt.*; -import java.awt.datatransfer.StringSelection; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class ConsoleDialog extends JDialog { - private JPanel consoleDialogContentPane; - private JPanel buttonsPanel; - private ConsoleScrollPane scrollPane; - private JButton okButton; - private JMenu editMenu; - private JMenuItem editCopyMenuItem; - private JMenuBar consoleDialogMenuBar; - private final EventHandler eventHandler = new EventHandler(); - - private class EventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - if (e.getSource() == ConsoleDialog.this.getOkButton() || e.getSource() == getConsoleDialogContentPane()) { - okButtonActionPerformed(); - } - if (e.getSource() == getEditCopyMenuItem()) { - editCopyActionPerformed(); - } - } - } - - public ConsoleDialog() { - super(); - initialize(); - } - - public ConsoleDialog(Frame owner, String title, boolean modal) { - super(owner, title, modal); - initialize(); - } - - public void append(String text) { - getScrollPane().append(text); - } - - public void editCopyActionPerformed() { - StringSelection ss; - String s = getScrollPane().getSelectedText(); - - if (s == null) { - s = getScrollPane().getText(); - } - ss = new StringSelection(s); - Toolkit.getDefaultToolkit().getSystemClipboard().setContents(ss, null); - } - - private JPanel getButtonsPanel() { - if (buttonsPanel == null) { - buttonsPanel = new JPanel(); - buttonsPanel.setPreferredSize(new Dimension(100, 30)); - buttonsPanel.setLayout(new GridBagLayout()); - buttonsPanel.setMinimumSize(new Dimension(20, 20)); - buttonsPanel.setMaximumSize(new Dimension(1000, 30)); - - GridBagConstraints constraintsOKButton = new GridBagConstraints(); - - constraintsOKButton.gridx = 1; - constraintsOKButton.gridy = 1; - constraintsOKButton.ipadx = 34; - constraintsOKButton.insets = new Insets(2, 173, 3, 168); - getButtonsPanel().add(getOkButton(), constraintsOKButton); - } - return buttonsPanel; - } - - private JPanel getConsoleDialogContentPane() { - if (consoleDialogContentPane == null) { - consoleDialogContentPane = new JPanel(); - consoleDialogContentPane.setLayout(new BorderLayout()); - consoleDialogContentPane.add(getButtonsPanel(), "South"); - consoleDialogContentPane.add(getScrollPane(), "Center"); - consoleDialogContentPane.registerKeyboardAction(eventHandler, KeyStroke.getKeyStroke(KeyEvent.VK_ENTER, 0), - JComponent.WHEN_FOCUSED); - } - return consoleDialogContentPane; - } - - public JMenuBar getConsoleDialogMenuBar() { - if (consoleDialogMenuBar == null) { - consoleDialogMenuBar = new JMenuBar(); - consoleDialogMenuBar.add(getEditMenu()); - } - return consoleDialogMenuBar; - } - - public JMenuItem getEditCopyMenuItem() { - if (editCopyMenuItem == null) { - editCopyMenuItem = new JMenuItem("Copy"); - editCopyMenuItem.addActionListener(eventHandler); - } - return editCopyMenuItem; - } - - public JMenu getEditMenu() { - if (editMenu == null) { - editMenu = new JMenu("Edit"); - editMenu.add(getEditCopyMenuItem()); - } - return editMenu; - } - - public JButton getOkButton() { - if (okButton == null) { - okButton = new JButton(); - okButton.setText("OK"); - okButton.addActionListener(eventHandler); - } - return okButton; - } - - private ConsoleScrollPane getScrollPane() { - if (scrollPane == null) { - scrollPane = new ConsoleScrollPane(); - } - return scrollPane; - } - - private void initialize() { - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setSize(500, 400); - setContentPane(getConsoleDialogContentPane()); - setJMenuBar(getConsoleDialogMenuBar()); - } - - public void okButtonActionPerformed() { - dispose(); - } - - public void processStream(java.io.InputStream in) { - scrollPane.processStream(in); - } - - public void scrollToBottom() { - getScrollPane().scrollToBottom(); - } - - public void setText(String text) { - getScrollPane().setText(text); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ConsoleScrollPane.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ConsoleScrollPane.java deleted file mode 100644 index 267d4dd..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ConsoleScrollPane.java +++ /dev/null @@ -1,170 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import javax.swing.*; -import javax.swing.text.DefaultCaret; - -import java.awt.*; -import java.io.BufferedReader; -import java.io.IOException; -import java.io.InputStream; -import java.io.InputStreamReader; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Pavel Savara (contributor) - */ -@SuppressWarnings("serial") -public class ConsoleScrollPane extends JScrollPane { - - private static final int MAX_ROWS = 500; - private static final String TEXT_TRUNCATED_MSG = "^^^ TEXT TRUNCATED ^^^"; - - private JTextArea textArea; - private int lines; - private int maxRows; - - public ConsoleScrollPane() { - super(); - setViewportView(getTextPane()); - } - - public JTextArea getTextPane() { - if (textArea == null) { - textArea = new JTextArea(); - - textArea.setEditable(false); - textArea.setTabSize(4); - textArea.setBackground(Color.DARK_GRAY); - textArea.setForeground(Color.WHITE); - textArea.setBounds(0, 0, 1000, 1000); - textArea.setFont(new Font(Font.MONOSPACED, Font.PLAIN, 12)); - - // Make sure the caret is not reset every time text is updated, meaning that - // the view will not reset it's position until we want it to. - ((DefaultCaret) textArea.getCaret()).setUpdatePolicy(DefaultCaret.NEVER_UPDATE); - } - return textArea; - } - - public void append(String str) { - // Return if the string is null or empty - if (str == null || str.length() == 0) { - return; - } - // Append the new string to the text pane - getTextPane().append(str); - - // Count number of new lines, i.e. lines ended with '\n' - int numNewLines = str.replaceAll("[^\\n]", "").length(); - - // Increment the current number of lines with the new lines - lines += numNewLines; - - // Calculate number lines exceeded compared to the max. number of lines - int linesExceeded = lines - MAX_ROWS; - - // Check if we exceeded the number of max. lines - if (linesExceeded > 0) { - // We use a rolling buffer so that the oldest lines are removed first. - // Remove the number of lines we are exceeding in the beginning of the contained text. - - // Cut down the number of lines to max. number of lines - lines = MAX_ROWS; - - // Find the index where to cut the number of exceeding lines in the beginning of the text - String text = getText(); - int cutIndex = -1; - - for (int c = 0; c < linesExceeded; c++) { - cutIndex = text.indexOf('\n', cutIndex + 1); - } - // Replace the first lines of the contained text till the cut index - textArea.replaceRange(null, 0, cutIndex + 1); - - // Replace first line with a message that text has been truncated - textArea.replaceRange(TEXT_TRUNCATED_MSG, 0, getText().indexOf('\n')); - } - - // Set the max. number of lines text pane - maxRows = Math.max(maxRows, lines); - textArea.setRows(maxRows); - } - - public String getSelectedText() { - return getTextPane().getSelectedText(); - } - - public String getText() { - return getTextPane().getText(); - } - - public void setText(String t) { - // Return if the string is null or empty - if (t == null || t.length() == 0) { - t = null; - lines = 0; - maxRows = 0; - } else { - // Calculate and set the new number of lines for the text pane - lines = t.replaceAll("[^\\n]", "").length(); - - // Calculate number lines exceeded compared to the max. number of lines - int linesExceeded = lines - MAX_ROWS; - - // Check if we exceeded the number of max. lines - if (linesExceeded > 0) { - // We use a rolling buffer so that the oldest lines are removed first. - // Remove the number of lines we are exceeding in the beginning of the contained text. - - // Cut down the number of lines to max. number of lines - lines = MAX_ROWS; - - // Find the index where to cut the number of exceeding lines in the beginning of the text - int index = -1; - - for (int c = 0; c < linesExceeded; c++) { - index = t.indexOf('\n', index + 1); - } - // Replace the first lines of the contained text till the cut index - t = t.substring(index + 1); - - // Replace first line with a message that text has been truncated - t = TEXT_TRUNCATED_MSG + t.substring(t.indexOf('\n') + 1); - } - } - // Set the text on the text pane - textArea.setText(t); - - // Set the max. number of lines text pane - maxRows = Math.max(maxRows, lines); - textArea.setRows(maxRows); - } - - public void processStream(InputStream input) { - BufferedReader br = new BufferedReader(new InputStreamReader(input)); - String line; - - try { - while ((line = br.readLine()) != null) { - append(line + "\n"); - } - } catch (IOException e) { - append("SYSTEM: IOException: " + e); - } - scrollToBottom(); - } - - public void scrollToBottom() { - textArea.setCaretPosition(textArea.getDocument().getLength()); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/MenuBar.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/MenuBar.java deleted file mode 100644 index ea9e7ab..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/MenuBar.java +++ /dev/null @@ -1,939 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.host.ICpuManager; -import net.sf.robocode.recording.BattleRecordFormat; -import net.sf.robocode.recording.IRecordManager; -import net.sf.robocode.serialization.SerializableOptions; -import net.sf.robocode.settings.ISettingsListener; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.ui.IWindowManagerExt; -import net.sf.robocode.ui.editor.IRobocodeEditor; -import static net.sf.robocode.ui.util.ShortcutUtil.MENU_SHORTCUT_KEY_MASK; - -import javax.swing.*; -import javax.swing.event.MenuEvent; -import javax.swing.event.MenuListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.InputEvent; -import java.awt.event.KeyEvent; - - -/** - * Handles menu display and interaction for Robocode. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Matthew Reeder (contributor) - * @author Luis Crespo (contributor) - */ -@SuppressWarnings("serial") -public class MenuBar extends JMenuBar { - - // Battle menu - private JMenu battleMenu; - private JMenuItem battleNewMenuItem; - private JMenuItem battleOpenMenuItem; - private JMenuItem battleSaveMenuItem; - private JMenuItem battleSaveAsMenuItem; - private JMenuItem battleExitMenuItem; - private JMenuItem battleOpenRecordMenuItem; - private JMenuItem battleSaveRecordAsMenuItem; - private JMenuItem battleExportRecordMenuItem; - private JMenuItem battleImportRecordMenuItem; - private JMenuItem battleTakeScreenshotMenuItem; - - // Robot menu - private JMenu robotMenu; - private JMenuItem robotEditorMenuItem; - private JMenuItem robotImportMenuItem; - private JMenuItem robotPackagerMenuItem; - private JMenuItem robotCreateTeamMenuItem; - - // Options menu - private JMenu optionsMenu; - private JMenuItem optionsPreferencesMenuItem; - private JMenuItem optionsFitWindowMenuItem; - private JCheckBoxMenuItem optionsShowRankingCheckBoxMenuItem; - private JMenuItem optionsRecalculateCpuConstantMenuItem; - private JMenuItem optionsCleanRobotCacheMenuItem; - - // Help Menu - private JMenu helpMenu; - private JMenuItem helpReadMeMenuItem; - private JMenuItem helpOnlineHelpMenuItem; - private JMenuItem helpCheckForNewVersionMenuItem; - private JMenuItem helpVersionsTxtMenuItem; - private JMenuItem helpRobocodeApiMenuItem; - private JMenuItem helpJavaDocumentationMenuItem; - private JMenuItem helpFaqMenuItem; - private JMenuItem helpAboutMenuItem; - private JMenuItem helpRobocodeMenuItem; - private JMenuItem helpRoboWikiMenuItem; - private JMenuItem helpGoogleGroupRobocodeMenuItem; - private JMenuItem helpRobocodeRepositoryMenuItem; - - private class EventHandler implements ActionListener, MenuListener { - public void actionPerformed(ActionEvent e) { - Object source = e.getSource(); - MenuBar mb = MenuBar.this; - - // Battle menu - if (source == mb.getBattleNewMenuItem()) { - battleNewActionPerformed(); - } else if (source == mb.getBattleOpenMenuItem()) { - battleOpenActionPerformed(); - } else if (source == mb.getBattleSaveMenuItem()) { - battleSaveActionPerformed(); - } else if (source == mb.getBattleSaveAsMenuItem()) { - battleSaveAsActionPerformed(); - } else if (source == mb.getBattleOpenRecordMenuItem()) { - battleOpenRecordActionPerformed(); - } else if (source == mb.getBattleImportRecordMenuItem()) { - battleImportRecordActionPerformed(); - } else if (source == mb.getBattleSaveRecordAsMenuItem()) { - battleSaveRecordAsActionPerformed(); - } else if (source == mb.getBattleExportRecordMenuItem()) { - battleExportRecordActionPerformed(); - } else if (source == mb.getBattleTakeScreenshotMenuItem()) { - battleTakeScreenshotActionPerformed(); - } else if (source == mb.getBattleExitMenuItem()) { - battleExitActionPerformed(); - - // Robot Editor menu - } else if (source == mb.getRobotEditorMenuItem()) { - robotEditorActionPerformed(); - } else if (source == mb.getRobotImportMenuItem()) { - robotImportActionPerformed(); - } else if (source == mb.getRobotPackagerMenuItem()) { - robotPackagerActionPerformed(); - - // Team / Create Team menu - } else if (source == mb.getRobotCreateTeamMenuItem()) { - teamCreateTeamActionPerformed(); - - // Options / Preferences menu - } else if (source == mb.getOptionsPreferencesMenuItem()) { - optionsPreferencesActionPerformed(); - } else if (source == mb.getOptionsFitWindowMenuItem()) { - optionsFitWindowActionPerformed(); - } else if (source == mb.getOptionsShowRankingCheckBoxMenuItem()) { - optionsShowRankingActionPerformed(); - } else if (source == mb.getOptionsRecalculateCpuConstantMenuItem()) { - optionsRecalculateCpuConstantPerformed(); - } else if (source == mb.getOptionsCleanRobotCacheMenuItem()) { - optionsCleanRobotCachePerformed(); - - // Help menu - } else if (source == mb.getReadMeMenuItem()) { - helpReadMeActionPerformed(); - } else if (source == mb.getHelpOnlineHelpMenuItem()) { - helpOnlineHelpActionPerformed(); - } else if (source == mb.getHelpRobocodeApiMenuItem()) { - helpRobocodeApiActionPerformed(); - } else if (source == mb.getHelpJavaDocumentationMenuItem()) { - helpJavaDocumentationActionPerformed(); - } else if (source == mb.getHelpFaqMenuItem()) { - helpFaqActionPerformed(); - } else if (source == mb.getHelpRobocodeMenuItem()) { - helpRobocodeHomeMenuItemActionPerformed(); - } else if (source == mb.getHelpRoboWikiMenuItem()) { - helpRoboWikiMenuItemActionPerformed(); - } else if (source == mb.getHelpGoogleGroupRobocodeMenuItem()) { - helpGoogleGroupRobocodeActionPerformed(); - } else if (source == mb.getHelpRobocodeRepositoryMenuItem()) { - helpRobocodeRepositoryActionPerformed(); - } else if (source == mb.getHelpCheckForNewVersionMenuItem()) { - helpCheckForNewVersionActionPerformed(); - } else if (source == mb.getHelpVersionsTxtMenuItem()) { - helpVersionsTxtActionPerformed(); - } else if (source == mb.getHelpAboutMenuItem()) { - helpAboutActionPerformed(); - } - } - - public void menuDeselected(MenuEvent e) { - battleManager.resumeBattle(); - } - - public void menuSelected(MenuEvent e) { - battleManager.pauseBattle(); - } - - public void menuCanceled(MenuEvent e) {} - } - - public final MenuBar.EventHandler eventHandler = new EventHandler(); - - private RobocodeFrame robocodeFrame; - private final ISettingsManager properties; - private final IWindowManagerExt windowManager; - private final IBattleManager battleManager; - private final IRecordManager recordManager; - private final ICpuManager cpuManager; - - public MenuBar(ISettingsManager properties, - IWindowManagerExt windowManager, - IBattleManager battleManager, - IRecordManager recordManager, - ICpuManager cpuManager) { - this.properties = properties; - this.windowManager = windowManager; - this.battleManager = battleManager; - this.recordManager = recordManager; - this.cpuManager = cpuManager; - - // FNL: Make sure that menus are heavy-weight components so that the menus are not painted - // behind the BattleView which is a heavy-weight component. This must be done before - // adding any menu to the menubar. - JPopupMenu.setDefaultLightWeightPopupEnabled(false); - - add(getBattleMenu()); - add(getRobotMenu()); - add(getOptionsMenu()); - add(getHelpMenu()); - } - - public void setup(RobocodeFrame robocodeFrame) { - this.robocodeFrame = robocodeFrame; - } - - private void battleExitActionPerformed() { - robocodeFrame.dispose(); - } - - /** - * Handle battleNew menu item action - */ - private void battleNewActionPerformed() { - windowManager.showNewBattleDialog(battleManager.getBattleProperties()); - } - - private void battleOpenActionPerformed() { - try { - battleManager.pauseBattle(); - - String path = windowManager.showBattleOpenDialog(".battle", "Battles"); - if (path != null) { - battleManager.setBattleFilename(path); - windowManager.showNewBattleDialog(battleManager.loadBattleProperties()); - } - } finally { - battleManager.resumeBattle(); - } - } - - private void battleSaveActionPerformed() { - try { - battleManager.pauseBattle(); - String path = battleManager.getBattleFilename(); - - if (path == null) { - path = windowManager.saveBattleDialog(battleManager.getBattlePath(), ".battle", "Battles"); - } - if (path != null) { - battleManager.setBattleFilename(path); - battleManager.saveBattleProperties(); - } - } finally { - battleManager.resumeBattle(); - } - } - - private void battleSaveAsActionPerformed() { - try { - battleManager.pauseBattle(); - - String path = windowManager.saveBattleDialog(battleManager.getBattlePath(), ".battle", "Battles"); - - if (path != null) { - battleManager.setBattleFilename(path); - battleManager.saveBattleProperties(); - } - } finally { - battleManager.resumeBattle(); - } - } - - private void battleOpenRecordActionPerformed() { - try { - battleManager.pauseBattle(); - - String path = windowManager.showBattleOpenDialog(".br", "Records"); - - if (path != null) { - battleManager.stop(true); - - robocodeFrame.getReplayButton().setVisible(true); - robocodeFrame.getReplayButton().setEnabled(true); - - getBattleSaveRecordAsMenuItem().setEnabled(true); - getBattleExportRecordMenuItem().setEnabled(true); - - try { - robocodeFrame.setBusyPointer(true); - recordManager.loadRecord(path, BattleRecordFormat.BINARY_ZIP); - } finally { - robocodeFrame.setBusyPointer(false); - } - battleManager.replay(); - } - } finally { - battleManager.resumeBattle(); - } - } - - private void battleImportRecordActionPerformed() { - try { - battleManager.pauseBattle(); - - String path = windowManager.showBattleOpenDialog(".br.xml", "XML Records"); - - if (path != null) { - battleManager.stop(true); - - robocodeFrame.getReplayButton().setVisible(true); - robocodeFrame.getReplayButton().setEnabled(true); - - getBattleSaveRecordAsMenuItem().setEnabled(true); - getBattleExportRecordMenuItem().setEnabled(true); - - try { - robocodeFrame.setBusyPointer(true); - recordManager.loadRecord(path, BattleRecordFormat.XML); - } finally { - robocodeFrame.setBusyPointer(false); - } - battleManager.replay(); - } - } finally { - battleManager.resumeBattle(); - } - } - - private void battleSaveRecordAsActionPerformed() { - if (recordManager.hasRecord()) { - try { - battleManager.pauseBattle(); - - String path = windowManager.saveBattleDialog(battleManager.getBattlePath(), ".br", "Records"); - - if (path != null) { - try { - robocodeFrame.setBusyPointer(true); - recordManager.saveRecord(path, BattleRecordFormat.BINARY_ZIP, new SerializableOptions(false)); - } finally { - robocodeFrame.setBusyPointer(false); - } - } - } finally { - battleManager.resumeBattle(); - } - } - } - - private void battleExportRecordActionPerformed() { - if (recordManager.hasRecord()) { - try { - battleManager.pauseBattle(); - - String path = windowManager.saveBattleDialog(battleManager.getBattlePath(), ".br.xml", "XML Records"); - - if (path != null) { - try { - robocodeFrame.setBusyPointer(true); - recordManager.saveRecord(path, BattleRecordFormat.XML, new SerializableOptions(false)); - } finally { - robocodeFrame.setBusyPointer(false); - } - } - } finally { - battleManager.resumeBattle(); - } - } - } - - private void battleTakeScreenshotActionPerformed() { - robocodeFrame.takeScreenshot(); - } - - private JMenuItem getBattleExitMenuItem() { - if (battleExitMenuItem == null) { - battleExitMenuItem = new JMenuItem(); - battleExitMenuItem.setText("Exit"); - battleExitMenuItem.setMnemonic('x'); - battleExitMenuItem.setDisplayedMnemonicIndex(1); - battleExitMenuItem.addActionListener(eventHandler); - } - return battleExitMenuItem; - } - - public JMenu getBattleMenu() { - if (battleMenu == null) { - battleMenu = new JMenu(); - battleMenu.setText("Battle"); - battleMenu.setMnemonic('B'); - battleMenu.add(getBattleNewMenuItem()); - battleMenu.add(getBattleOpenMenuItem()); - battleMenu.add(new JSeparator()); - battleMenu.add(getBattleSaveMenuItem()); - battleMenu.add(getBattleSaveAsMenuItem()); - battleMenu.add(new JSeparator()); - battleMenu.add(getBattleOpenRecordMenuItem()); - battleMenu.add(getBattleSaveRecordAsMenuItem()); - battleMenu.add(getBattleImportRecordMenuItem()); - battleMenu.add(getBattleExportRecordMenuItem()); - battleMenu.add(new JSeparator()); - battleMenu.add(getBattleTakeScreenshotMenuItem()); - battleMenu.add(new JSeparator()); - battleMenu.add(getBattleExitMenuItem()); - battleMenu.addMenuListener(eventHandler); - } - return battleMenu; - } - - private JMenuItem getBattleNewMenuItem() { - if (battleNewMenuItem == null) { - battleNewMenuItem = new JMenuItem(); - battleNewMenuItem.setText("New"); - battleNewMenuItem.setMnemonic('N'); - battleNewMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_N, MENU_SHORTCUT_KEY_MASK, false)); - battleNewMenuItem.addActionListener(eventHandler); - } - return battleNewMenuItem; - } - - private JMenuItem getBattleOpenMenuItem() { - if (battleOpenMenuItem == null) { - battleOpenMenuItem = new JMenuItem(); - battleOpenMenuItem.setText("Open"); - battleOpenMenuItem.setMnemonic('O'); - battleOpenMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_O, MENU_SHORTCUT_KEY_MASK, false)); - battleOpenMenuItem.addActionListener(eventHandler); - } - return battleOpenMenuItem; - } - - public JMenuItem getBattleSaveAsMenuItem() { - if (battleSaveAsMenuItem == null) { - battleSaveAsMenuItem = new JMenuItem(); - battleSaveAsMenuItem.setText("Save As"); - battleSaveAsMenuItem.setMnemonic('A'); - battleSaveAsMenuItem.setDisplayedMnemonicIndex(5); - battleSaveAsMenuItem.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_SHORTCUT_KEY_MASK | InputEvent.SHIFT_MASK, false)); - battleSaveAsMenuItem.setEnabled(false); - battleSaveAsMenuItem.addActionListener(eventHandler); - } - return battleSaveAsMenuItem; - } - - public JMenuItem getBattleSaveMenuItem() { - if (battleSaveMenuItem == null) { - battleSaveMenuItem = new JMenuItem(); - battleSaveMenuItem.setText("Save"); - battleSaveMenuItem.setMnemonic('S'); - battleSaveMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_S, MENU_SHORTCUT_KEY_MASK, false)); - battleSaveMenuItem.setEnabled(false); - battleSaveMenuItem.addActionListener(eventHandler); - } - return battleSaveMenuItem; - } - - private JMenuItem getBattleOpenRecordMenuItem() { - if (battleOpenRecordMenuItem == null) { - battleOpenRecordMenuItem = new JMenuItem(); - battleOpenRecordMenuItem.setText("Open Record"); - battleOpenRecordMenuItem.setMnemonic('d'); - battleOpenRecordMenuItem.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_O, MENU_SHORTCUT_KEY_MASK | InputEvent.SHIFT_MASK, false)); - battleOpenRecordMenuItem.addActionListener(eventHandler); - } - return battleOpenRecordMenuItem; - } - - private JMenuItem getBattleImportRecordMenuItem() { - if (battleImportRecordMenuItem == null) { - battleImportRecordMenuItem = new JMenuItem(); - battleImportRecordMenuItem.setText("Import XML Record"); - battleImportRecordMenuItem.setMnemonic('I'); - battleImportRecordMenuItem.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_I, MENU_SHORTCUT_KEY_MASK, false)); - battleImportRecordMenuItem.addActionListener(eventHandler); - } - return battleImportRecordMenuItem; - } - - public JMenuItem getBattleSaveRecordAsMenuItem() { - if (battleSaveRecordAsMenuItem == null) { - battleSaveRecordAsMenuItem = new JMenuItem(); - battleSaveRecordAsMenuItem.setText("Save Record"); - battleSaveRecordAsMenuItem.setMnemonic('R'); - battleSaveRecordAsMenuItem.setDisplayedMnemonicIndex(5); - battleSaveRecordAsMenuItem.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_R, MENU_SHORTCUT_KEY_MASK, false)); - battleSaveRecordAsMenuItem.setEnabled(false); - battleSaveRecordAsMenuItem.addActionListener(eventHandler); - - ISettingsManager props = properties; - - props.addPropertyListener( - new ISettingsListener() { - public void settingChanged(String property) { - if (property.equals(ISettingsManager.OPTIONS_COMMON_ENABLE_REPLAY_RECORDING)) { - final boolean canReplayRecord = recordManager.hasRecord(); - final boolean enableSaveRecord = properties.getOptionsCommonEnableReplayRecording() - & canReplayRecord; - - battleSaveRecordAsMenuItem.setEnabled(enableSaveRecord); - } - } - }); - } - return battleSaveRecordAsMenuItem; - } - - public JMenuItem getBattleExportRecordMenuItem() { - if (battleExportRecordMenuItem == null) { - battleExportRecordMenuItem = new JMenuItem(); - battleExportRecordMenuItem.setText("Export XML Record"); - battleExportRecordMenuItem.setMnemonic('E'); - battleExportRecordMenuItem.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_X, MENU_SHORTCUT_KEY_MASK, false)); - battleExportRecordMenuItem.setEnabled(false); - battleExportRecordMenuItem.addActionListener(eventHandler); - - ISettingsManager props = properties; - - props.addPropertyListener( - new ISettingsListener() { - public void settingChanged(String property) { - if (property.equals(ISettingsManager.OPTIONS_COMMON_ENABLE_REPLAY_RECORDING)) { - final boolean canReplayRecord = recordManager.hasRecord(); - final boolean enableSaveRecord = properties.getOptionsCommonEnableReplayRecording() - & canReplayRecord; - - battleExportRecordMenuItem.setEnabled(enableSaveRecord); - } - } - }); - } - return battleExportRecordMenuItem; - } - - private JMenuItem getBattleTakeScreenshotMenuItem() { - if (battleTakeScreenshotMenuItem == null) { - battleTakeScreenshotMenuItem = new JMenuItem(); - battleTakeScreenshotMenuItem.setText("Take Screenshot"); - battleTakeScreenshotMenuItem.setMnemonic('T'); - battleTakeScreenshotMenuItem.setAccelerator( - KeyStroke.getKeyStroke(KeyEvent.VK_T, MENU_SHORTCUT_KEY_MASK, false)); - battleTakeScreenshotMenuItem.addActionListener(eventHandler); - } - return battleTakeScreenshotMenuItem; - } - - private JMenuItem getHelpAboutMenuItem() { - if (helpAboutMenuItem == null) { - helpAboutMenuItem = new JMenuItem(); - helpAboutMenuItem.setText("About"); - helpAboutMenuItem.setMnemonic('A'); - helpAboutMenuItem.addActionListener(eventHandler); - } - return helpAboutMenuItem; - } - - private JMenuItem getHelpCheckForNewVersionMenuItem() { - if (helpCheckForNewVersionMenuItem == null) { - helpCheckForNewVersionMenuItem = new JMenuItem(); - helpCheckForNewVersionMenuItem.setText("Check for new version"); - helpCheckForNewVersionMenuItem.setMnemonic('C'); - helpCheckForNewVersionMenuItem.addActionListener(eventHandler); - } - return helpCheckForNewVersionMenuItem; - } - - @Override - public JMenu getHelpMenu() { - if (helpMenu == null) { - helpMenu = new JMenu(); - helpMenu.setText("Help"); - helpMenu.setMnemonic('H'); - helpMenu.add(getReadMeMenuItem()); - helpMenu.add(getHelpRobocodeApiMenuItem()); - helpMenu.add(getHelpJavaDocumentationMenuItem()); - helpMenu.add(new JSeparator()); - helpMenu.add(getHelpOnlineHelpMenuItem()); - helpMenu.add(getHelpRoboWikiMenuItem()); - helpMenu.add(getHelpGoogleGroupRobocodeMenuItem()); - helpMenu.add(getHelpFaqMenuItem()); - helpMenu.add(new JSeparator()); - helpMenu.add(getHelpRobocodeMenuItem()); - helpMenu.add(getHelpRobocodeRepositoryMenuItem()); - helpMenu.add(new JSeparator()); - helpMenu.add(getHelpCheckForNewVersionMenuItem()); - helpMenu.add(getHelpVersionsTxtMenuItem()); - helpMenu.add(new JSeparator()); - helpMenu.add(getHelpAboutMenuItem()); - helpMenu.addMenuListener(eventHandler); - } - return helpMenu; - } - - private JMenuItem getHelpFaqMenuItem() { - if (helpFaqMenuItem == null) { - helpFaqMenuItem = new JMenuItem(); - helpFaqMenuItem.setText("Robocode FAQ"); - helpFaqMenuItem.setMnemonic('F'); - helpFaqMenuItem.setDisplayedMnemonicIndex(9); - helpFaqMenuItem.addActionListener(eventHandler); - } - return helpFaqMenuItem; - } - - private JMenuItem getReadMeMenuItem() { - if (helpReadMeMenuItem == null) { - helpReadMeMenuItem = new JMenuItem(); - helpReadMeMenuItem.setText("ReadMe"); - helpReadMeMenuItem.setMnemonic('M'); - helpReadMeMenuItem.setDisplayedMnemonicIndex(4); - helpReadMeMenuItem.addActionListener(eventHandler); - } - return helpReadMeMenuItem; - } - - private JMenuItem getHelpOnlineHelpMenuItem() { - if (helpOnlineHelpMenuItem == null) { - helpOnlineHelpMenuItem = new JMenuItem(); - helpOnlineHelpMenuItem.setText("Online help"); - helpOnlineHelpMenuItem.setMnemonic('O'); - helpOnlineHelpMenuItem.addActionListener(eventHandler); - } - return helpOnlineHelpMenuItem; - } - - private JMenuItem getHelpVersionsTxtMenuItem() { - if (helpVersionsTxtMenuItem == null) { - helpVersionsTxtMenuItem = new JMenuItem(); - helpVersionsTxtMenuItem.setText("Version info"); - helpVersionsTxtMenuItem.setMnemonic('V'); - helpVersionsTxtMenuItem.addActionListener(eventHandler); - } - return helpVersionsTxtMenuItem; - } - - private JMenuItem getHelpRobocodeApiMenuItem() { - if (helpRobocodeApiMenuItem == null) { - helpRobocodeApiMenuItem = new JMenuItem(); - helpRobocodeApiMenuItem.setText("Robocode API"); - helpRobocodeApiMenuItem.setMnemonic('I'); - helpRobocodeApiMenuItem.setDisplayedMnemonicIndex(11); - helpRobocodeApiMenuItem.addActionListener(eventHandler); - } - return helpRobocodeApiMenuItem; - } - - private JMenuItem getHelpRobocodeMenuItem() { - if (helpRobocodeMenuItem == null) { - helpRobocodeMenuItem = new JMenuItem(); - helpRobocodeMenuItem.setText("Robocode home page"); - helpRobocodeMenuItem.setMnemonic('H'); - helpRobocodeMenuItem.setDisplayedMnemonicIndex(9); - helpRobocodeMenuItem.addActionListener(eventHandler); - } - return helpRobocodeMenuItem; - } - - private JMenuItem getHelpJavaDocumentationMenuItem() { - if (helpJavaDocumentationMenuItem == null) { - helpJavaDocumentationMenuItem = new JMenuItem(); - helpJavaDocumentationMenuItem.setText("Java 6 documentation"); - helpJavaDocumentationMenuItem.setMnemonic('J'); - helpJavaDocumentationMenuItem.addActionListener(eventHandler); - } - return helpJavaDocumentationMenuItem; - } - - private JMenuItem getHelpRoboWikiMenuItem() { - if (helpRoboWikiMenuItem == null) { - helpRoboWikiMenuItem = new JMenuItem(); - helpRoboWikiMenuItem.setText("RoboWiki site"); - helpRoboWikiMenuItem.setMnemonic('W'); - helpRoboWikiMenuItem.setDisplayedMnemonicIndex(4); - helpRoboWikiMenuItem.addActionListener(eventHandler); - } - return helpRoboWikiMenuItem; - } - - private JMenuItem getHelpGoogleGroupRobocodeMenuItem() { - if (helpGoogleGroupRobocodeMenuItem == null) { - helpGoogleGroupRobocodeMenuItem = new JMenuItem(); - helpGoogleGroupRobocodeMenuItem.setText("Google Group for Robocode"); - helpGoogleGroupRobocodeMenuItem.setMnemonic('Y'); - helpGoogleGroupRobocodeMenuItem.addActionListener(eventHandler); - } - return helpGoogleGroupRobocodeMenuItem; - } - - private JMenuItem getHelpRobocodeRepositoryMenuItem() { - if (helpRobocodeRepositoryMenuItem == null) { - helpRobocodeRepositoryMenuItem = new JMenuItem(); - helpRobocodeRepositoryMenuItem.setText("Robocode Repository"); - helpRobocodeRepositoryMenuItem.setMnemonic('R'); - helpRobocodeRepositoryMenuItem.setDisplayedMnemonicIndex(9); - helpRobocodeRepositoryMenuItem.addActionListener(eventHandler); - } - return helpRobocodeRepositoryMenuItem; - } - - private JMenuItem getOptionsFitWindowMenuItem() { - if (optionsFitWindowMenuItem == null) { - optionsFitWindowMenuItem = new JMenuItem(); - optionsFitWindowMenuItem.setText("Default window size"); - optionsFitWindowMenuItem.setMnemonic('D'); - optionsFitWindowMenuItem.addActionListener(eventHandler); - } - return optionsFitWindowMenuItem; - } - - public JCheckBoxMenuItem getOptionsShowRankingCheckBoxMenuItem() { - if (optionsShowRankingCheckBoxMenuItem == null) { - optionsShowRankingCheckBoxMenuItem = new JCheckBoxMenuItem(); - optionsShowRankingCheckBoxMenuItem.setText("Show current rankings"); - optionsShowRankingCheckBoxMenuItem.setMnemonic('r'); - optionsShowRankingCheckBoxMenuItem.setDisplayedMnemonicIndex(13); - optionsShowRankingCheckBoxMenuItem.addActionListener(eventHandler); - optionsShowRankingCheckBoxMenuItem.setEnabled(false); - } - return optionsShowRankingCheckBoxMenuItem; - } - - private JMenuItem getOptionsRecalculateCpuConstantMenuItem() { - if (optionsRecalculateCpuConstantMenuItem == null) { - optionsRecalculateCpuConstantMenuItem = new JMenuItem(); - optionsRecalculateCpuConstantMenuItem.setText("Recalculate CPU constant"); - optionsRecalculateCpuConstantMenuItem.setMnemonic('e'); - optionsRecalculateCpuConstantMenuItem.setDisplayedMnemonicIndex(1); - optionsRecalculateCpuConstantMenuItem.addActionListener(eventHandler); - } - return optionsRecalculateCpuConstantMenuItem; - } - - private JMenuItem getOptionsCleanRobotCacheMenuItem() { - if (optionsCleanRobotCacheMenuItem == null) { - optionsCleanRobotCacheMenuItem = new JMenuItem(); - optionsCleanRobotCacheMenuItem.setText("Clean robot cache"); - optionsCleanRobotCacheMenuItem.setMnemonic('C'); - optionsCleanRobotCacheMenuItem.addActionListener(eventHandler); - } - return optionsCleanRobotCacheMenuItem; - } - - private JMenu getOptionsMenu() { - if (optionsMenu == null) { - optionsMenu = new JMenu(); - optionsMenu.setText("Options"); - optionsMenu.setMnemonic('O'); - optionsMenu.add(getOptionsPreferencesMenuItem()); - optionsMenu.add(getOptionsFitWindowMenuItem()); - optionsMenu.add(new JSeparator()); - optionsMenu.add(getOptionsShowRankingCheckBoxMenuItem()); - optionsMenu.add(new JSeparator()); - optionsMenu.add(getOptionsRecalculateCpuConstantMenuItem()); - optionsMenu.add(getOptionsCleanRobotCacheMenuItem()); - optionsMenu.addMenuListener(eventHandler); - } - return optionsMenu; - } - - private JMenuItem getOptionsPreferencesMenuItem() { - if (optionsPreferencesMenuItem == null) { - optionsPreferencesMenuItem = new JMenuItem(); - optionsPreferencesMenuItem.setText("Preferences"); - optionsPreferencesMenuItem.setMnemonic('P'); - optionsPreferencesMenuItem.addActionListener(eventHandler); - } - return optionsPreferencesMenuItem; - } - - private JMenuItem getRobotEditorMenuItem() { - if (robotEditorMenuItem == null) { - robotEditorMenuItem = new JMenuItem(); - robotEditorMenuItem.setText("Source Editor"); - robotEditorMenuItem.setMnemonic('E'); - robotEditorMenuItem.setVisible(net.sf.robocode.core.Container.getComponent(IRobocodeEditor.class) != null); - robotEditorMenuItem.setAccelerator(KeyStroke.getKeyStroke(KeyEvent.VK_E, MENU_SHORTCUT_KEY_MASK, false)); - robotEditorMenuItem.addActionListener(eventHandler); - } - return robotEditorMenuItem; - } - - private JMenuItem getRobotImportMenuItem() { - if (robotImportMenuItem == null) { - robotImportMenuItem = new JMenuItem(); - robotImportMenuItem.setText("Import robot or team"); - robotImportMenuItem.setMnemonic('I'); - robotImportMenuItem.addActionListener(eventHandler); - } - return robotImportMenuItem; - } - - public JMenu getRobotMenu() { - if (robotMenu == null) { - robotMenu = new JMenu(); - robotMenu.setText("Robot"); - robotMenu.setMnemonic('R'); - robotMenu.add(getRobotEditorMenuItem()); - robotMenu.add(new JSeparator()); - robotMenu.add(getRobotImportMenuItem()); - robotMenu.add(getRobotPackagerMenuItem()); - robotMenu.add(new JSeparator()); - robotMenu.add(getRobotCreateTeamMenuItem()); - robotMenu.addMenuListener(eventHandler); - } - return robotMenu; - } - - private JMenuItem getRobotPackagerMenuItem() { - if (robotPackagerMenuItem == null) { - robotPackagerMenuItem = new JMenuItem(); - robotPackagerMenuItem.setText("Package robot or team"); - robotPackagerMenuItem.setMnemonic('P'); - robotPackagerMenuItem.addActionListener(eventHandler); - } - return robotPackagerMenuItem; - } - - private JMenuItem getRobotCreateTeamMenuItem() { - if (robotCreateTeamMenuItem == null) { - robotCreateTeamMenuItem = new JMenuItem(); - robotCreateTeamMenuItem.setText("Create a robot team"); - robotCreateTeamMenuItem.setMnemonic('C'); - robotCreateTeamMenuItem.addActionListener(eventHandler); - } - return robotCreateTeamMenuItem; - } - - private void teamCreateTeamActionPerformed() { - windowManager.showCreateTeamDialog(); - } - - private void helpAboutActionPerformed() { - windowManager.showAboutBox(); - } - - private void helpCheckForNewVersionActionPerformed() { - if (!robocodeFrame.checkForNewVersion(true)) { - WindowUtil.messageError("Unable to check for new version "); - } - } - - private void helpFaqActionPerformed() { - windowManager.showFaq(); - } - - private void helpReadMeActionPerformed() { - windowManager.showReadMe(); - } - - private void helpOnlineHelpActionPerformed() { - windowManager.showOnlineHelp(); - } - - private void helpVersionsTxtActionPerformed() { - windowManager.showVersionsTxt(); - } - - private void helpRobocodeApiActionPerformed() { - windowManager.showHelpApi(); - } - - private void helpRobocodeHomeMenuItemActionPerformed() { - windowManager.showRobocodeHome(); - } - - private void helpJavaDocumentationActionPerformed() { - windowManager.showJavaDocumentation(); - } - - private void helpRoboWikiMenuItemActionPerformed() { - windowManager.showRoboWiki(); - } - - private void helpGoogleGroupRobocodeActionPerformed() { - windowManager.showGoogleGroupRobocode(); - } - - private void helpRobocodeRepositoryActionPerformed() { - windowManager.showRobocodeRepository(); - } - - private void optionsFitWindowActionPerformed() { - JFrame robocodeFrame = windowManager.getRobocodeFrame(); - - robocodeFrame.setSize(robocodeFrame.getPreferredSize()); - WindowUtil.fitWindow(robocodeFrame); - } - - private void optionsShowRankingActionPerformed() { - windowManager.showRankingDialog(getOptionsShowRankingCheckBoxMenuItem().getState()); - } - - private void optionsRecalculateCpuConstantPerformed() { - int ok = JOptionPane.showConfirmDialog(this, "Do you want to recalculate the CPU constant?", - "Recalculate CPU constant", JOptionPane.YES_NO_OPTION); - - if (ok == JOptionPane.YES_OPTION) { - try { - robocodeFrame.setBusyPointer(true); - cpuManager.calculateCpuConstant(); - } finally { - robocodeFrame.setBusyPointer(false); - } - - long cpuConstant = cpuManager.getCpuConstant(); - - JOptionPane.showMessageDialog(this, "CPU constant: " + cpuConstant + " nanoseconds per turn", - "New CPU constant", JOptionPane.INFORMATION_MESSAGE); - } - } - - private void optionsCleanRobotCachePerformed() { - int ok = JOptionPane.showConfirmDialog(this, "Do you want to clean the robot cache?", "Clean Robot Cache", - JOptionPane.YES_NO_OPTION); - - if (ok == JOptionPane.YES_OPTION) { - try { - robocodeFrame.setBusyPointer(true); - net.sf.robocode.cachecleaner.CacheCleaner.clean(); - } finally { - robocodeFrame.setBusyPointer(false); - } - } - } - - private void optionsPreferencesActionPerformed() { - windowManager.showOptionsPreferences(); - } - - private void robotEditorActionPerformed() { - windowManager.showRobocodeEditor(); - } - - private void robotImportActionPerformed() { - windowManager.showImportRobotDialog(); - } - - private void robotPackagerActionPerformed() { - windowManager.showRobotPackager(); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/NewBattleDialog.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/NewBattleDialog.java deleted file mode 100644 index 406bcb9..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/NewBattleDialog.java +++ /dev/null @@ -1,217 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.battle.BattleProperties; -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.core.Container; -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.ui.IWindowManager; -import static net.sf.robocode.ui.util.ShortcutUtil.MENU_SHORTCUT_KEY_MASK; - -import javax.swing.*; -import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; - -import java.awt.BorderLayout; -import java.awt.Dimension; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Matthew Reeder (contributor) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -@SuppressWarnings("serial") -public class NewBattleDialog extends JDialog implements WizardListener { - - private final static int MAX_ROBOTS = 256; // 64; - private final static int MIN_ROBOTS = 1; - - private final EventHandler eventHandler = new EventHandler(); - - private ISettingsManager settingsManager; - private BattleProperties battleProperties; - - private WizardTabbedPane tabbedPane; - private NewBattleRulesTab battleFieldTab; - - private WizardController wizardController; - - private RobotSelectionPanel robotSelectionPanel; - - private final IBattleManager battleManager; - - public NewBattleDialog(IWindowManager windowManager, IBattleManager battleManager) { - super(windowManager.getRobocodeFrame(), true); - this.battleManager = battleManager; - } - - public void setup(ISettingsManager settingsManager, BattleProperties battleProperties) { // XXX - this.settingsManager = settingsManager; - this.battleProperties = battleProperties; - - robotSelectionPanel = null; - - setTitle("New Battle"); - setPreferredSize(new Dimension(850, 650)); - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - - addCancelByEscapeKey(); - - add(createNewBattleDialogPanel()); - } - - public void cancelButtonActionPerformed() { - dispose(); - } - - public void finishButtonActionPerformed() { - if (robotSelectionPanel.getSelectedRobotsCount() > 24) { - if (JOptionPane.showConfirmDialog(this, - "Warning: The battle you are about to start (" + robotSelectionPanel.getSelectedRobotsCount() - + " robots) " + " is very large and will consume a lot of CPU and memory. Do you wish to proceed?", - "Large Battle Warning", - JOptionPane.YES_NO_OPTION, - JOptionPane.WARNING_MESSAGE) - == JOptionPane.NO_OPTION) { - return; - } - } - if (robotSelectionPanel.getSelectedRobotsCount() == 1) { - if (JOptionPane.showConfirmDialog(this, - "You have only selected one robot. For normal battles you should select at least 2.\nDo you wish to proceed anyway?", - "Just one robot?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE) - == JOptionPane.NO_OPTION) { - return; - } - } - // Dispose this dialog before starting the battle due to pause/resume battle state - dispose(); - - // Start new battle after the dialog has been disposed and hence has called resumeBattle() - battleManager.startNewBattle(battleProperties, false, false); - } - - private NewBattleRulesTab getBattleFieldTab() { - if (battleFieldTab == null) { - battleFieldTab = new NewBattleRulesTab(); - battleFieldTab.setup(settingsManager, battleProperties); - } - return battleFieldTab; - } - - private JPanel createNewBattleDialogPanel() { - JPanel panel = new JPanel(); - - panel.setLayout(new BorderLayout()); - panel.add(getWizardController(), BorderLayout.SOUTH); - panel.add(getTabbedPane(), BorderLayout.CENTER); - panel.registerKeyboardAction(eventHandler, "Refresh", - KeyStroke.getKeyStroke(KeyEvent.VK_R, MENU_SHORTCUT_KEY_MASK), JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - return panel; - } - - public List getSelectedRobots() { - return getRobotSelectionPanel().getSelectedRobots(); - } - - private void addCancelByEscapeKey() { - String CANCEL_ACTION_KEY = "CANCEL_ACTION_KEY"; - int noModifiers = 0; - KeyStroke escapeKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, noModifiers, false); - InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - - inputMap.put(escapeKey, CANCEL_ACTION_KEY); - AbstractAction cancelAction = new AbstractAction() { - public void actionPerformed(ActionEvent e) { - cancelButtonActionPerformed(); - } - }; - - getRootPane().getActionMap().put(CANCEL_ACTION_KEY, cancelAction); - } - - /** - * Return the wizardController - * - * @return JButton - */ - private WizardController getWizardController() { - if (wizardController == null) { - wizardController = getTabbedPane().getWizardController(); - wizardController.setFinishButtonTextAndMnemonic("Start Battle", 'S', 0); - wizardController.setFocusOnEnabled(true); - } - return wizardController; - } - - /** - * Return the Page property value. - * - * @return JPanel - */ - private RobotSelectionPanel getRobotSelectionPanel() { - if (robotSelectionPanel == null) { - robotSelectionPanel = Container.createComponent(RobotSelectionPanel.class); - robotSelectionPanel.addAncestorListener(eventHandler); - - final boolean ignoreTeamRobots = false; // TODO do we really want to have this !properties.getOptionsTeamShowTeamRobots(); - String selectedRobots = (battleProperties == null) ? "" : battleProperties.getSelectedRobots(); - - robotSelectionPanel.setup(MIN_ROBOTS, MAX_ROBOTS, true, "Select robots for the battle", false, false, false, - false, false, ignoreTeamRobots, selectedRobots); - } - return robotSelectionPanel; - } - - /** - * Return the tabbedPane. - * - * @return JTabbedPane - */ - private WizardTabbedPane getTabbedPane() { - if (tabbedPane == null) { - tabbedPane = new WizardTabbedPane(this); - tabbedPane.insertTab("Robots", null, getRobotSelectionPanel(), null, 0); - tabbedPane.setMnemonicAt(0, KeyEvent.VK_R); - tabbedPane.setDisplayedMnemonicIndexAt(0, 0); - tabbedPane.insertTab("Rules", null, getBattleFieldTab(), null, 1); - tabbedPane.setMnemonicAt(1, KeyEvent.VK_U); - tabbedPane.setDisplayedMnemonicIndexAt(1, 1); - } - return tabbedPane; - } - - private class EventHandler implements AncestorListener, ActionListener { - @Override - public void ancestorAdded(AncestorEvent event) {} - - @Override - public void ancestorRemoved(AncestorEvent event) { - battleProperties.setSelectedRobots(getRobotSelectionPanel().getSelectedRobotsAsString()); - } - - @Override - public void ancestorMoved(AncestorEvent event) {} - - @Override - public void actionPerformed(ActionEvent event) { - if (event.getActionCommand().equals("Refresh")) { - getRobotSelectionPanel().refreshRobotList(true); - } - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/NewBattleRulesTab.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/NewBattleRulesTab.java deleted file mode 100644 index 45ee473..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/NewBattleRulesTab.java +++ /dev/null @@ -1,492 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import javax.swing.*; -import javax.swing.GroupLayout.Alignment; -import javax.swing.border.Border; -import javax.swing.event.AncestorEvent; -import javax.swing.event.AncestorListener; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; - -import net.sf.robocode.battle.BattleProperties; -import net.sf.robocode.settings.ISettingsManager; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class NewBattleRulesTab extends JPanel { - - private final static int MIN_BATTLEFIELD_SIZE = 400; - private final static int MAX_BATTLEFIELD_SIZE = 5000; - private final static int BATTLEFIELD_STEP_SIZE = 100; - - private ISettingsManager settingsManager; - private BattleProperties battleProperties; - - private final EventHandler eventHandler = new EventHandler(); - - private SizeButton[] predefinedSizeButtons = { - new SizeButton(400, 400), new SizeButton(600, 400), new SizeButton(600, 600), new SizeButton(800, 600), - new SizeButton(800, 800), new SizeButton(1000, 800), new SizeButton(1000, 1000), new SizeButton(1200, 1200), - new SizeButton(2000, 2000), new SizeButton(5000, 5000) - }; - - private final JLabel numberOfRoundsLabel = new JLabel("Number of Rounds:"); - private final JLabel gunCoolingRateLabel = new JLabel("Gun Cooling Rate:"); - private final JLabel inactivityTimeLabel = new JLabel("Inactivity Time:"); - private final JLabel sentryBorderSizeLabel = new JLabel("Sentry Border Size"); - private final JLabel hideEnemyNamesLabel = new JLabel("Hide Enemy Names:"); - - private final JButton restoreDefaultsButton = new JButton("Restore Defaults"); - - private JTextField numberOfRoundsTextField; - private JTextField gunCoolingRateTextField; - private JTextField inactivityTimeTextField; - private JTextField sentryBorderSizeTextField; - private final JCheckBox hideEnemyNamesCheckBox = new JCheckBox(); - - private JSlider battlefieldWidthSlider; - private JSlider battlefieldHeightSlider; - private JLabel battlefieldSizeLabel; - - public NewBattleRulesTab() { - super(); - } - - public void setup(ISettingsManager settingsManager, BattleProperties battleProperties) { - this.settingsManager = settingsManager; - this.battleProperties = battleProperties; - - EventHandler eventHandler = new EventHandler(); - - battlefieldWidthSlider = createBattlefieldSizeSlider(); - battlefieldWidthSlider.setOrientation(SwingConstants.HORIZONTAL); - - battlefieldHeightSlider = createBattlefieldSizeSlider(); - battlefieldHeightSlider.setOrientation(SwingConstants.VERTICAL); - battlefieldHeightSlider.setInverted(true); - - battlefieldSizeLabel = new BattlefieldSizeLabel(); - battlefieldSizeLabel.setHorizontalAlignment(SwingConstants.CENTER); - battlefieldSizeLabel.setMinimumSize(new Dimension(50, 50)); - battlefieldSizeLabel.setMaximumSize(new Dimension(500, 500)); - - battlefieldWidthSlider.addChangeListener(eventHandler); - battlefieldHeightSlider.addChangeListener(eventHandler); - - JPanel rulesPanel = createRulesPanel(); - rulesPanel.addAncestorListener(eventHandler); - - restoreDefaultsButton.addActionListener(eventHandler); - - setLayout(new BorderLayout()); - - add(rulesPanel, BorderLayout.WEST); - add(restoreDefaultsButton, BorderLayout.SOUTH); - add(createBattlefieldSizePanel(), BorderLayout.CENTER); - } - - private JPanel createBattlefieldSizePanel() { - JPanel panel = new JPanel(); - panel.addAncestorListener(eventHandler); - - Border border = BorderFactory.createCompoundBorder( - BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Battlefield Size"), - BorderFactory.createEmptyBorder(10, 10, 10, 10)); - panel.setBorder(border); - - panel.setLayout(new BorderLayout()); - - JPanel sliderPanel = createBattlefieldSlidersPanel(); - panel.add(sliderPanel, BorderLayout.CENTER); - - JPanel buttonsPanel = createPredefinedSizesPanel(); - panel.add(buttonsPanel, BorderLayout.EAST); - - return panel; - } - - private JPanel createBattlefieldSlidersPanel() { - JPanel panel = new JPanel(); - - GroupLayout layout = new GroupLayout(panel); - panel.setLayout(layout); - - GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); - - GroupLayout.ParallelGroup left = layout.createParallelGroup(); - left.addComponent(battlefieldSizeLabel); - left.addComponent(battlefieldWidthSlider); - leftToRight.addGroup(left); - - GroupLayout.ParallelGroup right = layout.createParallelGroup(); - right.addComponent(battlefieldHeightSlider); - leftToRight.addGroup(right); - - GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); - - GroupLayout.ParallelGroup top = layout.createParallelGroup(); - top.addComponent(battlefieldSizeLabel); - top.addComponent(battlefieldHeightSlider); - topToBottom.addGroup(top); - - GroupLayout.ParallelGroup bottom = layout.createParallelGroup(); - bottom.addComponent(battlefieldWidthSlider); - topToBottom.addGroup(bottom); - - layout.setHorizontalGroup(leftToRight); - layout.setVerticalGroup(topToBottom); - - return panel; - } - - private JPanel createPredefinedSizesPanel() { - JPanel panel = new JPanel(); - - Border border = BorderFactory.createCompoundBorder(BorderFactory.createEmptyBorder(0, 20, 0, 0), - BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Predefined Sizes")); - panel.setBorder(border); - - panel.setLayout(new GridLayout(predefinedSizeButtons.length, 1)); - - for (SizeButton button : predefinedSizeButtons) { - panel.add(button); - } - return panel; - } - - private JPanel createRulesPanel() { - JPanel panel = new JPanel(); - - panel.addAncestorListener(new EventHandler()); - panel.setBorder(BorderFactory.createEtchedBorder()); - - GroupLayout layout = new GroupLayout(panel); - layout.setAutoCreateContainerGaps(true); - layout.setAutoCreateGaps(true); - panel.setLayout(layout); - - GroupLayout.SequentialGroup leftToRight = layout.createSequentialGroup(); - - GroupLayout.ParallelGroup left = layout.createParallelGroup(); - left.addComponent(numberOfRoundsLabel); - left.addComponent(gunCoolingRateLabel); - left.addComponent(inactivityTimeLabel); - left.addComponent(sentryBorderSizeLabel); - left.addComponent(hideEnemyNamesLabel); - leftToRight.addGroup(left); - - GroupLayout.ParallelGroup right = layout.createParallelGroup(); - right.addComponent(getNumberOfRoundsTextField()); - right.addComponent(getGunCoolingRateTextField()); - right.addComponent(getInactivityTimeTextField()); - right.addComponent(getSentryBorderSizeTextField()); - right.addComponent(hideEnemyNamesCheckBox); - leftToRight.addGroup(right); - - GroupLayout.SequentialGroup topToBottom = layout.createSequentialGroup(); - - GroupLayout.ParallelGroup row0 = layout.createParallelGroup(Alignment.BASELINE); - row0.addComponent(numberOfRoundsLabel); - row0.addComponent(numberOfRoundsTextField); - topToBottom.addGroup(row0); - - GroupLayout.ParallelGroup row1 = layout.createParallelGroup(Alignment.BASELINE); - row1.addComponent(gunCoolingRateLabel); - row1.addComponent(getGunCoolingRateTextField()); - topToBottom.addGroup(row1); - - GroupLayout.ParallelGroup row2 = layout.createParallelGroup(Alignment.BASELINE); - row2.addComponent(inactivityTimeLabel); - row2.addComponent(inactivityTimeTextField); - topToBottom.addGroup(row2); - - GroupLayout.ParallelGroup row3 = layout.createParallelGroup(Alignment.BASELINE); - row3.addComponent(sentryBorderSizeLabel); - row3.addComponent(sentryBorderSizeTextField); - topToBottom.addGroup(row3); - - GroupLayout.ParallelGroup row4 = layout.createParallelGroup(Alignment.CENTER); - row4.addComponent(hideEnemyNamesLabel); - row4.addComponent(hideEnemyNamesCheckBox); - topToBottom.addGroup(row4); - - layout.setHorizontalGroup(leftToRight); - layout.setVerticalGroup(topToBottom); - - return panel; - } - - private JTextField getNumberOfRoundsTextField() { - if (numberOfRoundsTextField == null) { - numberOfRoundsTextField = new JTextField(5); - numberOfRoundsTextField.setText("" + battleProperties.getNumRounds()); - numberOfRoundsTextField.setInputVerifier( - new InputVerifier() { - @Override - public boolean verify(JComponent input) { - boolean isValid = false; - - String text = ((JTextField) input).getText(); - if (text != null && text.matches("\\d+")) { - int numRounds = Integer.parseInt(text); - isValid = (numRounds > 0); - } - if (!isValid) { - WindowUtil.messageError( - "'Number of Rounds' must be an integer value > 0.\n" + "Default value is 10."); - numberOfRoundsTextField.setText("" + battleProperties.getNumRounds()); - } - return isValid; - } - }); - } - return numberOfRoundsTextField; - } - - private JTextField getGunCoolingRateTextField() { - if (gunCoolingRateTextField == null) { - gunCoolingRateTextField = new JTextField(5); - gunCoolingRateTextField.setText("" + battleProperties.getGunCoolingRate()); - gunCoolingRateTextField.setInputVerifier( - new InputVerifier() { - @Override - public boolean verify(JComponent input) { - boolean isValid = false; - - String text = ((JTextField) input).getText(); - if (text != null && text.matches("\\d*(\\.\\d+)?")) { - double gunCoolingRate = Double.parseDouble(text); - isValid = (gunCoolingRate > 0 && gunCoolingRate <= 0.7); - } - if (!isValid) { - WindowUtil.messageError( - "'Gun Cooling Rate' must be a floating point number > 0 and <= 0.7.\n" - + "Default value is 0.1."); - gunCoolingRateTextField.setText("" + battleProperties.getGunCoolingRate()); - } - return isValid; - } - }); - } - return gunCoolingRateTextField; - } - - private JTextField getInactivityTimeTextField() { - if (inactivityTimeTextField == null) { - inactivityTimeTextField = new JTextField(5); - inactivityTimeTextField.setText("" + battleProperties.getInactivityTime()); - inactivityTimeTextField.setInputVerifier( - new InputVerifier() { - @Override - public boolean verify(JComponent input) { - boolean isValid = false; - - String text = ((JTextField) input).getText(); - if (text != null && text.matches("\\d+")) { - int inactivityTime = Integer.parseInt(text); - isValid = (inactivityTime >= 0); - } - if (!isValid) { - WindowUtil.messageError( - "'Inactivity Time' must be an integer value >= 0.\n" + "Default value is 450."); - inactivityTimeTextField.setText("" + battleProperties.getInactivityTime()); - } - return isValid; - } - }); - } - return inactivityTimeTextField; - } - - private JTextField getSentryBorderSizeTextField() { - if (sentryBorderSizeTextField == null) { - sentryBorderSizeTextField = new JTextField(5); - sentryBorderSizeTextField.setText("" + battleProperties.getSentryBorderSize()); - sentryBorderSizeTextField.setInputVerifier( - new InputVerifier() { - @Override - public boolean verify(JComponent input) { - boolean isValid = false; - - String text = ((JTextField) input).getText(); - if (text != null && text.matches("\\d+")) { - int borderSize = Integer.parseInt(text); - isValid = (borderSize >= 50); - } - if (!isValid) { - WindowUtil.messageError( - "'Sentry Border Size' must be an integer value >= 50.\n" + "Default value is 100."); - sentryBorderSizeTextField.setText("" + battleProperties.getSentryBorderSize()); - } - return isValid; - } - }); - } - return sentryBorderSizeTextField; - } - - private JSlider createBattlefieldSizeSlider() { - JSlider slider = new JSlider(); - slider.setMinimum(MIN_BATTLEFIELD_SIZE); - slider.setMaximum(MAX_BATTLEFIELD_SIZE); - slider.setMajorTickSpacing(BATTLEFIELD_STEP_SIZE); - slider.setSnapToTicks(true); - slider.setPaintTicks(true); - return slider; - } - - private void updateBattlefieldSizeLabel() { - int w = battlefieldWidthSlider.getValue(); - int h = battlefieldHeightSlider.getValue(); - battlefieldSizeLabel.setText(w + " x " + h); - } - - private class SizeButton extends JButton { - final int width; - final int height; - - public SizeButton(int width, int height) { - super(width + "x" + height); - this.width = width; - this.height = height; - addActionListener(eventHandler); - } - } - - - private class EventHandler implements AncestorListener, ActionListener, ChangeListener { - @Override - public void ancestorAdded(AncestorEvent event) { - pushBattlePropertiesToUIComponents(); - } - - @Override - public void ancestorRemoved(AncestorEvent event) { - Integer numberOfRounds; - try { - numberOfRounds = Integer.parseInt(getNumberOfRoundsTextField().getText()); - } catch (NumberFormatException e) { - numberOfRounds = null; - } - if (numberOfRounds != null) { - settingsManager.setBattleDefaultNumberOfRounds(numberOfRounds); - battleProperties.setNumRounds(numberOfRounds); - } - Double gunCoolingRate; - try { - gunCoolingRate = Double.parseDouble(getGunCoolingRateTextField().getText()); - } catch (NumberFormatException e) { - gunCoolingRate = null; - } - if (gunCoolingRate != null) { - settingsManager.setBattleDefaultGunCoolingRate(gunCoolingRate); - battleProperties.setGunCoolingRate(gunCoolingRate); - } - Integer inactivityTime; - try { - inactivityTime = Integer.parseInt(getInactivityTimeTextField().getText()); - } catch (NumberFormatException e) { - inactivityTime = null; - } - if (inactivityTime != null) { - settingsManager.setBattleDefaultInactivityTime(inactivityTime); - battleProperties.setInactivityTime(inactivityTime); - } - Integer sentryBorderSize; - try { - sentryBorderSize = Integer.parseInt(getSentryBorderSizeTextField().getText()); - } catch (NumberFormatException e) { - sentryBorderSize = null; - } - if (sentryBorderSize != null) { - settingsManager.setBattleDefaultSentryBorderSize(sentryBorderSize); - battleProperties.setSentryBorderSize(sentryBorderSize); - } - boolean hideEnemyNames = hideEnemyNamesCheckBox.isSelected(); - settingsManager.setBattleDefaultHideEnemyNames(hideEnemyNames); - battleProperties.setHideEnemyNames(hideEnemyNames); - - int weight = battlefieldWidthSlider.getValue(); - int height = battlefieldHeightSlider.getValue(); - - settingsManager.setBattleDefaultBattlefieldWidth(weight); - settingsManager.setBattleDefaultBattlefieldHeight(height); - - battleProperties.setBattlefieldWidth(weight); - battleProperties.setBattlefieldHeight(height); - } - - @Override - public void ancestorMoved(AncestorEvent event) {} - - @Override - public void actionPerformed(ActionEvent event) { - if (event.getSource() instanceof SizeButton) { - SizeButton button = (SizeButton) event.getSource(); - battlefieldWidthSlider.setValue(button.width); - battlefieldHeightSlider.setValue(button.height); - updateBattlefieldSizeLabel(); - - } else if (event.getSource() == restoreDefaultsButton) { - battleProperties.setBattlefieldWidth(800); - battleProperties.setBattlefieldHeight(600); - battleProperties.setNumRounds(10); - battleProperties.setGunCoolingRate(0.1); - battleProperties.setInactivityTime(450); - battleProperties.setHideEnemyNames(false); - battleProperties.setSentryBorderSize(100); - - pushBattlePropertiesToUIComponents(); - } - } - - @Override - public void stateChanged(ChangeEvent event) { - if ((event.getSource() == battlefieldWidthSlider) || (event.getSource() == battlefieldHeightSlider)) { - updateBattlefieldSizeLabel(); - } - } - - private void pushBattlePropertiesToUIComponents() { - battlefieldWidthSlider.setValue(battleProperties.getBattlefieldWidth()); - battlefieldHeightSlider.setValue(battleProperties.getBattlefieldHeight()); - updateBattlefieldSizeLabel(); - - getNumberOfRoundsTextField().setText("" + battleProperties.getNumRounds()); - getGunCoolingRateTextField().setText("" + battleProperties.getGunCoolingRate()); - getInactivityTimeTextField().setText("" + battleProperties.getInactivityTime()); - getSentryBorderSizeTextField().setText("" + battleProperties.getSentryBorderSize()); - hideEnemyNamesCheckBox.setSelected(battleProperties.getHideEnemyNames()); - } - } - - - private class BattlefieldSizeLabel extends JLabel { - @Override - public void paintComponent(Graphics g) { - g.setColor(SystemColor.activeCaption); - - int width = getWidth() * battlefieldWidthSlider.getValue() / MAX_BATTLEFIELD_SIZE; - int height = getHeight() * battlefieldHeightSlider.getValue() / MAX_BATTLEFIELD_SIZE; - - g.fillRect(0, 0, width, height); - super.paintComponent(g); - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesCommonOptionsTab.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesCommonOptionsTab.java deleted file mode 100644 index 3bc8795..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesCommonOptionsTab.java +++ /dev/null @@ -1,155 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.settings.ISettingsManager; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - -/** - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class PreferencesCommonOptionsTab extends WizardPanel { - - private JPanel optionsPanel; - - private JCheckBox notifyAboutBetaVersionsCheckBox; - private JCheckBox showResultsCheckBox; - private JCheckBox dontHideRankingsCheckBox; - private JCheckBox appendWhenSavingResultsCheckBox; - private JCheckBox enableReplayRecordingCheckBox; - private JCheckBox enableAutoRecordingCheckBox; - - private final ISettingsManager properties; - - public PreferencesCommonOptionsTab(ISettingsManager properties) { - super(); - this.properties = properties; - initialize(); - } - - private void initialize() { - setLayout(new GridLayout(1, 2)); - add(getOptionsPanel()); - loadPreferences(properties); - } - - private JPanel getOptionsPanel() { - if (optionsPanel == null) { - optionsPanel = new JPanel(); - optionsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Common")); - optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS)); - optionsPanel.add(getNotifyAboutBetaVersionsCheckBox()); - optionsPanel.add(new JLabel(" ")); - optionsPanel.add(getShowResultsCheckBox()); - optionsPanel.add(getDontHideRankingsCheckBox()); - optionsPanel.add(getAppendWhenSavingResultsCheckBox()); - optionsPanel.add(new JLabel(" ")); - optionsPanel.add(getEnableReplayRecordingCheckBox()); - optionsPanel.add(getEnableAutoRecordingCheckBox()); - } - return optionsPanel; - } - - private JCheckBox getNotifyAboutBetaVersionsCheckBox() { - if (notifyAboutBetaVersionsCheckBox == null) { - notifyAboutBetaVersionsCheckBox = new JCheckBox("Notify about new Beta versions of Robocode"); - notifyAboutBetaVersionsCheckBox.setMnemonic('B'); - notifyAboutBetaVersionsCheckBox.setDisplayedMnemonicIndex(17); - } - return notifyAboutBetaVersionsCheckBox; - } - - private JCheckBox getShowResultsCheckBox() { - if (showResultsCheckBox == null) { - showResultsCheckBox = new JCheckBox("Show results when battle(s) ends"); - showResultsCheckBox.setMnemonic('h'); - showResultsCheckBox.setDisplayedMnemonicIndex(1); - } - return showResultsCheckBox; - } - - private JCheckBox getDontHideRankingsCheckBox() { - if (dontHideRankingsCheckBox == null) { - dontHideRankingsCheckBox = new JCheckBox("Don't hide current rankings when main window is minimized"); - dontHideRankingsCheckBox.setMnemonic('t'); - dontHideRankingsCheckBox.setDisplayedMnemonicIndex(4); - } - return dontHideRankingsCheckBox; - } - - private JCheckBox getAppendWhenSavingResultsCheckBox() { - if (appendWhenSavingResultsCheckBox == null) { - appendWhenSavingResultsCheckBox = new JCheckBox("Append when saving results"); - appendWhenSavingResultsCheckBox.setMnemonic('A'); - } - return appendWhenSavingResultsCheckBox; - } - - private JCheckBox getEnableReplayRecordingCheckBox() { - if (enableReplayRecordingCheckBox == null) { - enableReplayRecordingCheckBox = new JCheckBox("Enable replay recording (uses memory and disk space)"); - enableReplayRecordingCheckBox.setMnemonic('E'); - } - return enableReplayRecordingCheckBox; - } - - private JCheckBox getEnableAutoRecordingCheckBox() { - if (enableAutoRecordingCheckBox == null) { - enableAutoRecordingCheckBox = new JCheckBox( - "Enable auto recording (every finished battle is automatically saved into battles folder)"); - enableAutoRecordingCheckBox.setMnemonic('u'); - enableAutoRecordingCheckBox.setDisplayedMnemonicIndex(8); - - enableAutoRecordingCheckBox.addActionListener( - new ActionListener() { - public void actionPerformed(ActionEvent e) { - boolean isSelected = enableAutoRecordingCheckBox.isSelected(); - - enableReplayRecordingCheckBox.setEnabled(!isSelected); - enableReplayRecordingCheckBox.setSelected( - isSelected ? true : properties.getOptionsCommonEnableReplayRecording()); - } - }); - } - return enableAutoRecordingCheckBox; - } - - private void loadPreferences(ISettingsManager props) { - getNotifyAboutBetaVersionsCheckBox().setSelected(props.getOptionsCommonNotifyAboutNewBetaVersions()); - getShowResultsCheckBox().setSelected(props.getOptionsCommonShowResults()); - getDontHideRankingsCheckBox().setSelected(props.getOptionsCommonDontHideRankings()); - getAppendWhenSavingResultsCheckBox().setSelected(props.getOptionsCommonAppendWhenSavingResults()); - getEnableReplayRecordingCheckBox().setSelected(props.getOptionsCommonEnableReplayRecording()); - getEnableAutoRecordingCheckBox().setSelected(props.getOptionsCommonEnableAutoRecording()); - } - - public void storePreferences() { - ISettingsManager props = properties; - - props.setOptionsCommonNotifyAboutNewBetaVersions(getNotifyAboutBetaVersionsCheckBox().isSelected()); - props.setOptionsCommonShowResults(getShowResultsCheckBox().isSelected()); - props.setOptionsCommonDontHideRankings(getDontHideRankingsCheckBox().isSelected()); - props.setOptionsCommonAppendWhenSavingResults(getAppendWhenSavingResultsCheckBox().isSelected()); - props.setOptionsCommonEnableReplayRecording(getEnableReplayRecordingCheckBox().isSelected()); - props.setOptionsCommonEnableAutoRecording(getEnableAutoRecordingCheckBox().isSelected()); - - properties.saveProperties(); - } - - @Override - public boolean isReady() { - return true; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesDevelopmentOptionsTab.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesDevelopmentOptionsTab.java deleted file mode 100644 index 29ac579..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesDevelopmentOptionsTab.java +++ /dev/null @@ -1,198 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.ui.CheckList; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Ruben Moreno Montoliu (contributor) - */ -@SuppressWarnings("serial") -public class PreferencesDevelopmentOptionsTab extends WizardPanel { - - private JPanel optionsPanel; - - private JButton addButton; - private JButton removeButton; - private CheckList pathList; - - public final ISettingsManager properties; - - private final EventHandler eventHandler = new EventHandler(); - - private class EventHandler implements ActionListener, ListSelectionListener { - public void actionPerformed(ActionEvent e) { - if (e.getSource() == getAddButton()) { - handleAddAction(); - } else if (e.getSource() == getRemoveButton()) { - handleRemoveAction(); - } - } - - public void valueChanged(ListSelectionEvent e) { - updateRemoveButton(); - } - } - - public PreferencesDevelopmentOptionsTab(ISettingsManager properties) { - super(); - this.properties = properties; - initialize(); - } - - private void initialize() { - setLayout(new GridLayout(1, 2)); - add(getOptionsPanel()); - loadPreferences(properties); - } - - private JPanel getOptionsPanel() { - if (optionsPanel == null) { - optionsPanel = new JPanel(); - optionsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Development")); - - GridBagLayout layout = new GridBagLayout(); - - optionsPanel.setLayout(layout); - GridBagConstraints c = new GridBagConstraints(); - - c.insets = new Insets(0, 5, 5, 5); - c.anchor = GridBagConstraints.NORTHWEST; - - c.fill = GridBagConstraints.HORIZONTAL; - c.gridwidth = 2; - c.weightx = 0; - c.gridy = 1; - - optionsPanel.add( - new JLabel( - "If you are using an external IDE to develop robots, you may enter the classpath(s) to those robots here."), - c); - c.gridy++; - optionsPanel.add( - new JLabel( - "If you are using Eclipse, you can enter the root dir of robot projects inside a workspace as well (recommended)"), - c); - c.gridy++; - optionsPanel.add(new JLabel("Double-click the path(s) the enable or disable it (checked means enabled)"), c); - - c.gridwidth = 1; - c.gridy++; - c.insets = new Insets(3, 3, 3, 3); - optionsPanel.add(getAddButton(), c); - - c.gridy++; - optionsPanel.add(getRemoveButton(), c); - - c.fill = GridBagConstraints.BOTH; - c.weightx = 1; - c.weighty = 1; - c.gridx = 1; - c.gridy--; - c.gridheight = 3; - c.insets = new Insets(5, 5, 5, 5); - JScrollPane pathListScroller = new JScrollPane(getPathList()); - - optionsPanel.add(pathListScroller, c); - } - return optionsPanel; - } - - private JButton getAddButton() { - if (addButton == null) { - addButton = new JButton("Add"); - addButton.setDisplayedMnemonicIndex(2); - addButton.addActionListener(eventHandler); - } - return addButton; - } - - private JButton getRemoveButton() { - if (removeButton == null) { - removeButton = new JButton("Remove"); - removeButton.setDisplayedMnemonicIndex(3); - removeButton.addActionListener(eventHandler); - } - return removeButton; - } - - private CheckList getPathList() { - if (pathList == null) { - pathList = new CheckList(); - pathList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - pathList.setLayoutOrientation(JList.VERTICAL); - pathList.setVisibleRowCount(-1); - pathList.addListSelectionListener(eventHandler); - } - return pathList; - } - - private void loadPreferences(ISettingsManager robocodeProperties) { - getPathList().clear(); - - for (String path : robocodeProperties.getOptionsDevelopmentPaths()) { - getPathList().add(path); - } - for (String excludedPath : robocodeProperties.getOptionsExcludedDevelopmentPaths()) { - getPathList().setChecked(excludedPath, false); - } - updateRemoveButton(); - } - - public void storePreferences() { - properties.setOptionsDevelopmentPaths(getPathList().getAll()); - properties.setOptionsExcludedDevelopmentPaths(getPathList().getUnchecked()); - properties.saveProperties(); - } - - @Override - public boolean isReady() { - return true; - } - - private void handleAddAction() { - JFileChooser chooser = new JFileChooser(); - - chooser.setFileSelectionMode(JFileChooser.DIRECTORIES_ONLY); - if (chooser.showOpenDialog(optionsPanel) == JFileChooser.APPROVE_OPTION) { - String path = chooser.getSelectedFile().getAbsolutePath(); - - if (!getPathList().contains(path)) { - getPathList().add(path); - getPathList().sort(); - } - } - updateRemoveButton(); - } - - private void handleRemoveAction() { - int[] indices = getPathList().getSelectedIndices(); - - for (int i = indices.length - 1; i >= 0; i--) { - getPathList().remove(indices[i]); - } - updateRemoveButton(); - } - - private void updateRemoveButton() { - getRemoveButton().setEnabled(getPathList().getSelectedIndex() >= 0); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesDialog.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesDialog.java deleted file mode 100644 index 903ab26..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesDialog.java +++ /dev/null @@ -1,149 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.ui.IImageManager; -import net.sf.robocode.ui.IWindowManager; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.KeyEvent; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Matthew Reeder (contributor) - */ -@SuppressWarnings("serial") -public class PreferencesDialog extends JDialog implements WizardListener { - - private JPanel preferencesDialogContentPane; - private WizardTabbedPane tabbedPane; - private WizardController buttonsPanel; - - private PreferencesCommonOptionsTab commonOptionsTab; - private PreferencesDevelopmentOptionsTab developmentOptionsTab; - private PreferencesViewOptionsTab viewOptionsTab; - private PreferencesRenderingOptionsTab renderingOptionsTab; - private PreferencesSoundOptionsTab soundOptionsTab; - - private final ISettingsManager properties; - private final IImageManager imageManager; - - public PreferencesDialog(ISettingsManager properties, IWindowManager windowManager, IImageManager imageManager) { - super(windowManager.getRobocodeFrame(), true); - this.properties = properties; - this.imageManager = imageManager; - initialize(); - } - - private void initialize() { - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setTitle("Preferences"); - setContentPane(getPreferencesDialogContentPane()); - } - - public void cancelButtonActionPerformed() { - dispose(); - } - - private WizardController getButtonsPanel() { - if (buttonsPanel == null) { - buttonsPanel = getTabbedPane().getWizardController(); - } - return buttonsPanel; - } - - private JPanel getPreferencesDialogContentPane() { - getButtonsPanel(); - if (preferencesDialogContentPane == null) { - preferencesDialogContentPane = new JPanel(); - preferencesDialogContentPane.setLayout(new BorderLayout()); - preferencesDialogContentPane.add(getTabbedPane(), BorderLayout.CENTER); - preferencesDialogContentPane.add(getButtonsPanel(), BorderLayout.SOUTH); - } - return preferencesDialogContentPane; - } - - private WizardTabbedPane getTabbedPane() { - if (tabbedPane == null) { - tabbedPane = new WizardTabbedPane(this); - - int tabIndex = 0; - - tabbedPane.insertTab("Common Options", null, getCommonOptionsTab(), null, tabIndex); - tabbedPane.setMnemonicAt(tabIndex, KeyEvent.VK_O); - tabbedPane.setDisplayedMnemonicIndexAt(tabIndex++, 1); - - tabbedPane.insertTab("Development Options", null, getDevelopmentOptionsTab(), null, tabIndex); - tabbedPane.setMnemonicAt(tabIndex, KeyEvent.VK_D); - tabbedPane.setDisplayedMnemonicIndexAt(tabIndex++, 0); - - tabbedPane.insertTab("View Options", null, getViewOptionsTab(), null, tabIndex); - tabbedPane.setMnemonicAt(tabIndex, KeyEvent.VK_W); - tabbedPane.setDisplayedMnemonicIndexAt(tabIndex++, 3); - - tabbedPane.insertTab("Rendering Options", null, getRenderingOptionsTab(), null, tabIndex); - tabbedPane.setMnemonicAt(tabIndex, KeyEvent.VK_R); - tabbedPane.setDisplayedMnemonicIndexAt(tabIndex++, 0); - - tabbedPane.insertTab("Sound Options", null, getSoundOptionsTab(), null, tabIndex); - tabbedPane.setMnemonicAt(tabIndex, KeyEvent.VK_S); - tabbedPane.setDisplayedMnemonicIndexAt(tabIndex++, 0); - } - return tabbedPane; - } - - private JPanel getCommonOptionsTab() { - if (commonOptionsTab == null) { - commonOptionsTab = new PreferencesCommonOptionsTab(properties); - } - return commonOptionsTab; - } - - private JPanel getDevelopmentOptionsTab() { - if (developmentOptionsTab == null) { - developmentOptionsTab = new PreferencesDevelopmentOptionsTab(properties); - } - return developmentOptionsTab; - } - - private JPanel getViewOptionsTab() { - if (viewOptionsTab == null) { - viewOptionsTab = new PreferencesViewOptionsTab(properties); - } - return viewOptionsTab; - } - - private JPanel getRenderingOptionsTab() { - if (renderingOptionsTab == null) { - renderingOptionsTab = new PreferencesRenderingOptionsTab(properties, imageManager); - } - return renderingOptionsTab; - } - - private JPanel getSoundOptionsTab() { - if (soundOptionsTab == null) { - soundOptionsTab = new PreferencesSoundOptionsTab(properties); - } - return soundOptionsTab; - } - - public void finishButtonActionPerformed() { - commonOptionsTab.storePreferences(); - developmentOptionsTab.storePreferences(); - viewOptionsTab.storePreferences(); - renderingOptionsTab.storePreferences(); - soundOptionsTab.storePreferences(); - - dispose(); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesRenderingOptionsTab.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesRenderingOptionsTab.java deleted file mode 100644 index 34fc834..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesRenderingOptionsTab.java +++ /dev/null @@ -1,297 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.ui.IImageManager; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - -/** - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class PreferencesRenderingOptionsTab extends WizardPanel { - - private final ISettingsManager properties; - - private JPanel specificSettingsPanel; - private JPanel predefinedSettingsPanel; - private JPanel otherSettingsPanel; - - private JComboBox optionsRenderingAntialiasingComboBox; - private JComboBox optionsRenderingTextAntialiasingComboBox; - private JComboBox optionsRenderingMethodComboBox; - private JComboBox optionsRenderingNoBuffersComboBox; - private JCheckBox optionsRenderingBufferImagesCheckBox; - private JCheckBox optionsRenderingForceBulletColorCheckBox; - - private JButton predefinedPlaformDefaultButton; - private JButton predefinedSpeedButton; - private JButton predefinedQualityButton; - - private EventHandler eventHandler; - private final IImageManager imageManager; - - public PreferencesRenderingOptionsTab(ISettingsManager properties, IImageManager imageManager) { - super(); - this.properties = properties; - this.imageManager = imageManager; - initialize(); - } - - private void initialize() { - eventHandler = new EventHandler(); - - setLayout(new GridLayout(1, 3)); - - add(getSpecificSettingsPanel()); - add(getPredefinedSettingsPanel()); - add(getOtherSettingsPanel()); - - loadPreferences(properties); - } - - private JPanel getSpecificSettingsPanel() { - if (specificSettingsPanel == null) { - specificSettingsPanel = new JPanel(); - specificSettingsPanel.setBorder( - BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Specific settings")); - specificSettingsPanel.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - - c.fill = GridBagConstraints.HORIZONTAL; - c.insets = new Insets(5, 5, 5, 5); - c.anchor = GridBagConstraints.PAGE_START; - - c.weightx = 0; - - c.gridwidth = 2; - - c.gridx = 0; - c.gridy = 0; - specificSettingsPanel.add(new JLabel("Set individual rendering options:"), c); - - c.gridwidth = 1; - - c.gridy = 1; - specificSettingsPanel.add(new JLabel("Antialiasing", SwingConstants.RIGHT), c); - c.gridx = 1; - specificSettingsPanel.add(getOptionsRenderingAntialiasingComboBox(), c); - - c.gridx = 0; - c.gridy = 2; - specificSettingsPanel.add(new JLabel("Text Antialiasing", SwingConstants.RIGHT), c); - c.gridx = 1; - specificSettingsPanel.add(getOptionsRenderingTextAntialiasingComboBox(), c); - - c.gridx = 0; - c.gridy = 3; - specificSettingsPanel.add(new JLabel("Rendering Method", SwingConstants.RIGHT), c); - c.gridx = 1; - specificSettingsPanel.add(getOptionsRenderingMethodComboBox(), c); - - c.gridx = 0; - c.gridy = 4; - specificSettingsPanel.add(new JLabel(" "), c); - - c.gridx = 0; - c.gridy = 5; - specificSettingsPanel.add(new JLabel("Number of buffers", SwingConstants.RIGHT), c); - c.gridx = 1; - specificSettingsPanel.add(getOptionsRenderingNoBuffersComboBox(), c); - } - return specificSettingsPanel; - } - - private JPanel getPredefinedSettingsPanel() { - if (predefinedSettingsPanel == null) { - predefinedSettingsPanel = new JPanel(); - predefinedSettingsPanel.setBorder( - BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Predefined settings")); - predefinedSettingsPanel.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - - c.fill = GridBagConstraints.HORIZONTAL; - c.insets = new Insets(5, 5, 5, 5); - c.anchor = GridBagConstraints.PAGE_START; - - c.gridx = 0; - c.gridy = 0; - c.gridwidth = 3; - predefinedSettingsPanel.add(new JLabel("Set all rendering settings towards:"), c); - - c.weightx = 1f / 3; - c.gridwidth = 1; - c.gridy = 2; - predefinedSettingsPanel.add(getPredefinedPlatformDefaultButton(), c); - c.gridx = 1; - predefinedSettingsPanel.add(getPredefinedSpeedButton(), c); - c.gridx = 2; - predefinedSettingsPanel.add(getPredefinedQualityButton(), c); - } - return predefinedSettingsPanel; - } - - private JPanel getOtherSettingsPanel() { - if (otherSettingsPanel == null) { - otherSettingsPanel = new JPanel(); - otherSettingsPanel.setBorder( - BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Other settings")); - otherSettingsPanel.setLayout(new BoxLayout(otherSettingsPanel, BoxLayout.Y_AXIS)); - otherSettingsPanel.add(getOptionsRenderingBufferImagesCheckBox()); - otherSettingsPanel.add(getOptionsRenderingForceBulletColorCheckBox()); - } - return otherSettingsPanel; - } - - private JComboBox getOptionsRenderingAntialiasingComboBox() { - if (optionsRenderingAntialiasingComboBox == null) { - optionsRenderingAntialiasingComboBox = new JComboBox(new String[] { "Default", "On", "Off"}); - optionsRenderingAntialiasingComboBox.addActionListener(eventHandler); - } - return optionsRenderingAntialiasingComboBox; - } - - private JComboBox getOptionsRenderingTextAntialiasingComboBox() { - if (optionsRenderingTextAntialiasingComboBox == null) { - optionsRenderingTextAntialiasingComboBox = new JComboBox(new String[] { "Default", "On", "Off"}); - optionsRenderingTextAntialiasingComboBox.addActionListener(eventHandler); - } - return optionsRenderingTextAntialiasingComboBox; - } - - private JComboBox getOptionsRenderingMethodComboBox() { - if (optionsRenderingMethodComboBox == null) { - optionsRenderingMethodComboBox = new JComboBox(new String[] { "Default", "Quality", "Speed"}); - optionsRenderingMethodComboBox.addActionListener(eventHandler); - } - return optionsRenderingMethodComboBox; - } - - private JComboBox getOptionsRenderingNoBuffersComboBox() { - if (optionsRenderingNoBuffersComboBox == null) { - optionsRenderingNoBuffersComboBox = new JComboBox( - new String[] { "Single buffering", "Double buffering", "Triple buffering"}); - optionsRenderingNoBuffersComboBox.addActionListener(eventHandler); - } - return optionsRenderingNoBuffersComboBox; - } - - private JButton getPredefinedPlatformDefaultButton() { - if (predefinedPlaformDefaultButton == null) { - predefinedPlaformDefaultButton = new JButton("Default"); - predefinedPlaformDefaultButton.setMnemonic('u'); - predefinedPlaformDefaultButton.setDisplayedMnemonicIndex(4); - predefinedPlaformDefaultButton.addActionListener(eventHandler); - } - return predefinedPlaformDefaultButton; - } - - private JButton getPredefinedSpeedButton() { - if (predefinedSpeedButton == null) { - predefinedSpeedButton = new JButton("Speed"); - predefinedSpeedButton.setMnemonic('p'); - predefinedSpeedButton.setDisplayedMnemonicIndex(1); - predefinedSpeedButton.addActionListener(eventHandler); - } - return predefinedSpeedButton; - } - - private JButton getPredefinedQualityButton() { - if (predefinedQualityButton == null) { - predefinedQualityButton = new JButton("Quality"); - predefinedQualityButton.setMnemonic('Q'); - predefinedQualityButton.addActionListener(eventHandler); - } - return predefinedQualityButton; - } - - private JCheckBox getOptionsRenderingBufferImagesCheckBox() { - if (optionsRenderingBufferImagesCheckBox == null) { - optionsRenderingBufferImagesCheckBox = new JCheckBox("Buffer images (uses memory)"); - optionsRenderingBufferImagesCheckBox.setMnemonic('i'); - optionsRenderingBufferImagesCheckBox.setDisplayedMnemonicIndex(7); - optionsRenderingBufferImagesCheckBox.addActionListener(eventHandler); - } - return optionsRenderingBufferImagesCheckBox; - } - - private JCheckBox getOptionsRenderingForceBulletColorCheckBox() { - if (optionsRenderingForceBulletColorCheckBox == null) { - optionsRenderingForceBulletColorCheckBox = new JCheckBox("Make all bullets white"); - optionsRenderingForceBulletColorCheckBox.setMnemonic('M'); - optionsRenderingForceBulletColorCheckBox.addActionListener(eventHandler); - } - return optionsRenderingForceBulletColorCheckBox; - } - - private void loadPreferences(ISettingsManager props) { - getOptionsRenderingAntialiasingComboBox().setSelectedIndex(props.getOptionsRenderingAntialiasing()); - getOptionsRenderingTextAntialiasingComboBox().setSelectedIndex(props.getOptionsRenderingTextAntialiasing()); - getOptionsRenderingMethodComboBox().setSelectedIndex(props.getOptionsRenderingMethod()); - getOptionsRenderingNoBuffersComboBox().setSelectedIndex(props.getOptionsRenderingNoBuffers() - 1); - getOptionsRenderingBufferImagesCheckBox().setSelected(props.getOptionsRenderingBufferImages()); - getOptionsRenderingForceBulletColorCheckBox().setSelected(props.getOptionsRenderingForceBulletColor()); - } - - public void storePreferences() { - ISettingsManager props = properties; - - props.setOptionsRenderingAntialiasing(optionsRenderingAntialiasingComboBox.getSelectedIndex()); - props.setOptionsRenderingTextAntialiasing(optionsRenderingTextAntialiasingComboBox.getSelectedIndex()); - props.setOptionsRenderingMethod(optionsRenderingMethodComboBox.getSelectedIndex()); - props.setOptionsRenderingNoBuffers(optionsRenderingNoBuffersComboBox.getSelectedIndex() + 1); - props.setOptionsRenderingBufferImages(optionsRenderingBufferImagesCheckBox.isSelected()); - props.setOptionsRenderingForceBulletColor(optionsRenderingForceBulletColorCheckBox.isSelected()); - properties.saveProperties(); - } - - @Override - public boolean isReady() { - return true; - } - - private void setPredefinedSettings(int index) { - optionsRenderingAntialiasingComboBox.setSelectedIndex(index); - optionsRenderingTextAntialiasingComboBox.setSelectedIndex(index); - optionsRenderingMethodComboBox.setSelectedIndex(index); - } - - private class EventHandler implements ActionListener { - - public void actionPerformed(ActionEvent e) { - Object src = e.getSource(); - - if (src == predefinedPlaformDefaultButton) { - setPredefinedSettings(0); - } else if (src == predefinedQualityButton) { - setPredefinedSettings(1); - } else if (src == predefinedSpeedButton) { - setPredefinedSettings(2); - } else if (src == optionsRenderingBufferImagesCheckBox) { - // Reset images so they are reloaded and gets buffered or unbuffered - new Thread() { - @Override - public void run() { - storePreferences(); - imageManager.initialize(); - } - }.start(); - return; - } - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java deleted file mode 100644 index 37a71e3..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesSoundOptionsTab.java +++ /dev/null @@ -1,397 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.settings.ISettingsManager; - -import javax.sound.sampled.*; -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.Vector; - - -/** - * @author Flemming N. Larsen (original) - */ -@SuppressWarnings("serial") -public class PreferencesSoundOptionsTab extends WizardPanel { - - private final ISettingsManager properties; - - private final EventHandler eventHandler = new EventHandler(); - - private JPanel soundOptionsPanel; - private JPanel mixerOptionsPanel; - - private JCheckBox enableSoundCheckBox; - private JCheckBox enableGunshotCheckBox; - private JCheckBox enableBulletHitCheckBox; - private JCheckBox enableRobotDeathCheckBox; - private JCheckBox enableWallCollisionCheckBox; - private JCheckBox enableRobotCollisionCheckBox; - - private JButton enableAllSoundsButton; - private JButton disableAllSoundsButton; - - private JComboBox mixerComboBox; - private JButton mixerDefaultButton; - - private JCheckBox enableMixerVolumeCheckBox; - private JCheckBox enableMixerPanCheckBox; - - public PreferencesSoundOptionsTab(ISettingsManager properties) { - super(); - this.properties = properties; - initialize(); - } - - private void initialize() { - setLayout(new GridLayout(1, 2)); - - add(getSoundOptionsPanel()); - add(getMixerOptionsPanel()); - - loadPreferences(properties); - } - - private JPanel getSoundOptionsPanel() { - if (soundOptionsPanel == null) { - soundOptionsPanel = new JPanel(); - soundOptionsPanel.setBorder( - BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Sound Effects")); - - soundOptionsPanel.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - c.fill = 1; - c.weightx = 1; - c.anchor = GridBagConstraints.NORTHWEST; - - c.gridwidth = GridBagConstraints.REMAINDER; - soundOptionsPanel.add(getEnableSoundCheckBox(), c); - soundOptionsPanel.add(getEnableGunshotCheckBox(), c); - soundOptionsPanel.add(getEnableBulletHitCheckBox(), c); - soundOptionsPanel.add(getEnableRobotDeathCheckBox(), c); - soundOptionsPanel.add(getEnableWallCollisionCheckBox(), c); - soundOptionsPanel.add(getEnableRobotCollisionCheckBox(), c); - - c.insets = new Insets(10, 0, 0, 10); - c.gridwidth = 1; - c.fill = 0; - c.weighty = 1; - c.weightx = 0; - soundOptionsPanel.add(getEnableAllSoundsButton(), c); - c.weightx = 1; - c.gridwidth = GridBagConstraints.REMAINDER; - soundOptionsPanel.add(getDisableAllSoundsButton(), c); - - if (AudioSystem.getMixerInfo().length == 0) { - for (Component child : soundOptionsPanel.getComponents()) { - child.setEnabled(false); - } - } - } - return soundOptionsPanel; - } - - private JCheckBox getEnableSoundCheckBox() { - if (enableSoundCheckBox == null) { - enableSoundCheckBox = new JCheckBox("Enable Sound"); - enableSoundCheckBox.setMnemonic('E'); - } - return enableSoundCheckBox; - } - - private JCheckBox getEnableGunshotCheckBox() { - if (enableGunshotCheckBox == null) { - enableGunshotCheckBox = new JCheckBox("Gun Shots"); - enableGunshotCheckBox.setMnemonic('G'); - } - return enableGunshotCheckBox; - } - - private JCheckBox getEnableBulletHitCheckBox() { - if (enableBulletHitCheckBox == null) { - enableBulletHitCheckBox = new JCheckBox("Bullet Hit"); - enableBulletHitCheckBox.setMnemonic('H'); - enableBulletHitCheckBox.setDisplayedMnemonicIndex(7); - } - return enableBulletHitCheckBox; - } - - private JCheckBox getEnableRobotDeathCheckBox() { - if (enableRobotDeathCheckBox == null) { - enableRobotDeathCheckBox = new JCheckBox("Robot Death Explosions"); - enableRobotDeathCheckBox.setMnemonic('x'); - enableRobotDeathCheckBox.setDisplayedMnemonicIndex(13); - } - return enableRobotDeathCheckBox; - } - - private JCheckBox getEnableRobotCollisionCheckBox() { - if (enableRobotCollisionCheckBox == null) { - enableRobotCollisionCheckBox = new JCheckBox("Robot Collisions"); - enableRobotCollisionCheckBox.setMnemonic('t'); - enableRobotCollisionCheckBox.setDisplayedMnemonicIndex(4); - } - return enableRobotCollisionCheckBox; - } - - private JCheckBox getEnableWallCollisionCheckBox() { - if (enableWallCollisionCheckBox == null) { - enableWallCollisionCheckBox = new JCheckBox("Wall Collisions"); - enableWallCollisionCheckBox.setMnemonic('l'); - enableWallCollisionCheckBox.setDisplayedMnemonicIndex(2); - } - return enableWallCollisionCheckBox; - } - - private JButton getEnableAllSoundsButton() { - if (enableAllSoundsButton == null) { - enableAllSoundsButton = new JButton("Enable all"); - enableAllSoundsButton.setMnemonic('a'); - enableAllSoundsButton.setDisplayedMnemonicIndex(7); - enableAllSoundsButton.addActionListener(eventHandler); - } - return enableAllSoundsButton; - } - - private JButton getDisableAllSoundsButton() { - if (disableAllSoundsButton == null) { - disableAllSoundsButton = new JButton("Disable all"); - disableAllSoundsButton.setMnemonic('i'); - disableAllSoundsButton.setDisplayedMnemonicIndex(1); - disableAllSoundsButton.addActionListener(eventHandler); - } - return disableAllSoundsButton; - } - - private JPanel getMixerOptionsPanel() { - if (mixerOptionsPanel == null) { - mixerOptionsPanel = new JPanel(); - mixerOptionsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Mixer")); - - mixerOptionsPanel.setLayout(new GridBagLayout()); - GridBagConstraints c = new GridBagConstraints(); - - c.anchor = GridBagConstraints.NORTHWEST; - c.fill = GridBagConstraints.NONE; - c.weightx = 1; - - c.insets = new Insets(8, 4, 0, 0); - mixerOptionsPanel.add(new JLabel("Select mixer:"), c); - - c.gridy = 1; - mixerOptionsPanel.add(getMixerComboBox(), c); - - c.gridy = 2; - mixerOptionsPanel.add(getMixerDefaultButton(), c); - - c.insets = new Insets(16, 4, 0, 0); - c.gridy = 3; - mixerOptionsPanel.add(new JLabel("Enable mixer features:"), c); - - c.insets = new Insets(6, 0, 0, 0); - c.gridy = 4; - mixerOptionsPanel.add(getEnableMixerVolumeCheckBox(), c); - - c.insets = new Insets(0, 0, 0, 0); - c.gridy = 5; - mixerOptionsPanel.add(getEnableMixerPanCheckBox(), c); - - if (AudioSystem.getMixerInfo().length == 0) { - for (Component child : mixerOptionsPanel.getComponents()) { - child.setEnabled(false); - } - } - } - return mixerOptionsPanel; - } - - private JComboBox getMixerComboBox() { - if (mixerComboBox == null) { - Mixer.Info[] mixerInfo = AudioSystem.getMixerInfo(); - - Line.Info clipLineInfo = new Line.Info(Clip.class); - - Vector mixers = new Vector(); - - for (Mixer.Info mi : mixerInfo) { - if (AudioSystem.getMixer(mi).getSourceLineInfo(clipLineInfo).length > 0) { - mixers.add(mi); - } - } - - mixerComboBox = new JComboBox(mixers); - mixerComboBox.setRenderer(new MixerInfoCellRenderer()); - mixerComboBox.addActionListener(eventHandler); - } - return mixerComboBox; - } - - private JButton getMixerDefaultButton() { - if (mixerDefaultButton == null) { - mixerDefaultButton = new JButton("Default"); - mixerDefaultButton.setMnemonic('u'); - mixerDefaultButton.setDisplayedMnemonicIndex(4); - mixerDefaultButton.addActionListener(eventHandler); - } - return mixerDefaultButton; - } - - private JCheckBox getEnableMixerVolumeCheckBox() { - if (enableMixerVolumeCheckBox == null) { - enableMixerVolumeCheckBox = new JCheckBox("Volume"); - enableMixerVolumeCheckBox.setMnemonic('V'); - enableMixerVolumeCheckBox.addActionListener(eventHandler); - } - return enableMixerVolumeCheckBox; - } - - private JCheckBox getEnableMixerPanCheckBox() { - if (enableMixerPanCheckBox == null) { - enableMixerPanCheckBox = new JCheckBox("Pan"); - enableMixerPanCheckBox.setMnemonic('P'); - enableMixerPanCheckBox.addActionListener(eventHandler); - } - return enableMixerPanCheckBox; - } - - private void loadPreferences(ISettingsManager robocodeProperties) { - getEnableSoundCheckBox().setSelected(robocodeProperties.getOptionsSoundEnableSound()); - getEnableGunshotCheckBox().setSelected(robocodeProperties.getOptionsSoundEnableGunshot()); - getEnableBulletHitCheckBox().setSelected(robocodeProperties.getOptionsSoundEnableBulletHit()); - getEnableRobotDeathCheckBox().setSelected(robocodeProperties.getOptionsSoundEnableRobotDeath()); - getEnableRobotCollisionCheckBox().setSelected(robocodeProperties.getOptionsSoundEnableRobotCollision()); - getEnableWallCollisionCheckBox().setSelected(robocodeProperties.getOptionsSoundEnableWallCollision()); - getEnableMixerVolumeCheckBox().setSelected(robocodeProperties.getOptionsSoundEnableMixerVolume()); - getEnableMixerPanCheckBox().setSelected(robocodeProperties.getOptionsSoundEnableMixerPan()); - - setMixerCompoBox(robocodeProperties.getOptionsSoundMixer()); - } - - public void storePreferences() { - ISettingsManager props = properties; - - props.setOptionsSoundEnableSound(getEnableSoundCheckBox().isSelected()); - props.setOptionsSoundEnableGunshot(getEnableGunshotCheckBox().isSelected()); - props.setOptionsSoundEnableBulletHit(getEnableBulletHitCheckBox().isSelected()); - props.setOptionsSoundEnableRobotDeath(getEnableRobotDeathCheckBox().isSelected()); - props.setOptionsSoundEnableRobotCollision(getEnableRobotCollisionCheckBox().isSelected()); - props.setOptionsSoundEnableWallCollision(getEnableWallCollisionCheckBox().isSelected()); - props.setOptionsSoundEnableMixerVolume(getEnableMixerVolumeCheckBox().isSelected()); - props.setOptionsSoundEnableMixerPan(getEnableMixerPanCheckBox().isSelected()); - - String mixerClassName = null; - Mixer.Info mixerInfo = (Mixer.Info) getMixerComboBox().getSelectedItem(); - - if (mixerInfo != null) { - Mixer mixer = AudioSystem.getMixer((Mixer.Info) getMixerComboBox().getSelectedItem()); - - if (mixer != null) { - mixerClassName = mixer.getClass().getSimpleName(); - } - } - if (mixerClassName != null) { - props.setOptionsSoundMixer(mixerClassName); - } - - properties.saveProperties(); - } - - @Override - public boolean isReady() { - return true; - } - - private void setMixerCompoBox(String mixerName) { - for (Mixer.Info mi : AudioSystem.getMixerInfo()) { - if (AudioSystem.getMixer(mi).getClass().getSimpleName().equals(mixerName)) { - getMixerComboBox().setSelectedItem(mi); - break; - } - } - } - - private class EventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - Object src = e.getSource(); - - if (src == enableAllSoundsButton) { - setAllSoundsButtonsEnabled(true); - } else if (src == disableAllSoundsButton) { - setAllSoundsButtonsEnabled(false); - } else if (src == mixerComboBox) { - mixerComboBoxActionPerformed(); - } else if (src == mixerDefaultButton) { - mixerDefaultButtonActionPerformed(); - } - } - } - - private void setAllSoundsButtonsEnabled(boolean enabled) { - enableSoundCheckBox.setSelected(enabled); - enableGunshotCheckBox.setSelected(enabled); - enableBulletHitCheckBox.setSelected(enabled); - enableRobotDeathCheckBox.setSelected(enabled); - enableWallCollisionCheckBox.setSelected(enabled); - enableRobotCollisionCheckBox.setSelected(enabled); - } - - private void mixerComboBoxActionPerformed() { - Mixer mixer = AudioSystem.getMixer((Mixer.Info) mixerComboBox.getSelectedItem()); - - Line.Info lineInfo = mixer.getSourceLineInfo(new Line.Info(Clip.class))[0]; - - boolean volumeSupported; - boolean panSupported; - - try { - Line line = mixer.getLine(lineInfo); - - volumeSupported = line.isControlSupported(FloatControl.Type.MASTER_GAIN); - panSupported = line.isControlSupported(FloatControl.Type.PAN); - } catch (LineUnavailableException e) { - volumeSupported = false; - panSupported = false; - } - - enableMixerVolumeCheckBox.setEnabled(volumeSupported); - enableMixerPanCheckBox.setEnabled(panSupported); - } - - private void mixerDefaultButtonActionPerformed() { - setMixerCompoBox("DirectAudioDevice"); - } - - private static class MixerInfoCellRenderer extends javax.swing.plaf.basic.BasicComboBoxRenderer { - - @Override - public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { - Component component = super.getListCellRendererComponent(list, value, index, isSelected, cellHasFocus); - - Mixer.Info mi = (Mixer.Info) value; - - if (mi != null) { - String text = mi.getName(); - - if (!"Unknown Version".equals(mi.getVersion())) { - text += ' ' + mi.getVersion(); - } - if (!"Unknown Vendor".equals(mi.getVendor())) { - text += " by " + mi.getVendor(); - } - setText(text); - } - return component; - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesViewOptionsTab.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesViewOptionsTab.java deleted file mode 100644 index e064903..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/PreferencesViewOptionsTab.java +++ /dev/null @@ -1,470 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.settings.ISettingsListener; -import net.sf.robocode.settings.ISettingsManager; - -import javax.swing.*; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Matthew Reeder (contributor) - */ -@SuppressWarnings("serial") -public class PreferencesViewOptionsTab extends WizardPanel { - - private static final int MIN_TPS = 1; - private static final int DEFAULT_TPS = 30; - private static final int FAST_TPS = 45; - private static final int MAX_TPS = 10000; - - private final EventHandler eventHandler = new EventHandler(); - - private JCheckBox visibleRobotEnergyCheckBox; - private JCheckBox visibleRobotNameCheckBox; - private JCheckBox visibleScanArcsCheckBox; - private JCheckBox visibleExplosionsCheckBox; - private JCheckBox visibleGroundCheckBox; - private JCheckBox visibleExplosionDebrisCheckBox; - private JCheckBox visibleSentryBorderCheckBox; - - private JButton defaultViewOptionsButton; - private JButton enableAllViewOptionsButton; - private JButton disableAllViewOptionsButton; - - private JTextField desiredTpsTextField; - private JLabel desiredTpsLabel; - private JCheckBox displayFpsCheckBox; - private JCheckBox displayTpsCheckBox; - - private JPanel visibleOptionsPanel; - private JPanel tpsOptionsPanel; - - private JButton minTpsButton; - private JButton defaultTpsButton; - private JButton fastTpsButton; - private JButton maxTpsButton; - - private JCheckBox preventSpeedupWhenMinimizedCheckBox; - - private final ISettingsManager properties; - - private class EventHandler implements ActionListener, DocumentListener { - public void actionPerformed(ActionEvent e) { - Object src = e.getSource(); - - if (src == enableAllViewOptionsButton) { - setAllViewOptionsButtonsEnabled(true); - } else if (src == disableAllViewOptionsButton) { - setAllViewOptionsButtonsEnabled(false); - } else if (src == defaultViewOptionsButton) { - defaultViewOptionsButtonActionPerformed(); - } else if (src == defaultTpsButton) { - defaultTpsButtonActionPerformed(); - } else if (src == minTpsButton) { - minTpsButtonActionPerformed(); - } else if (src == fastTpsButton) { - fastTpsButtonActionPerformed(); - } else if (src == maxTpsButton) { - maxTpsButtonActionPerformed(); - } - } - - public void changedUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void insertUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void removeUpdate(DocumentEvent e) { - fireStateChanged(); - } - } - - public PreferencesViewOptionsTab(ISettingsManager properties) { - super(); - this.properties = properties; - initialize(); - } - - private void defaultViewOptionsButtonActionPerformed() { - setAllViewOptionsButtonsEnabled(true); - getVisibleScanArcsCheckBox().setSelected(false); - } - - private void setAllViewOptionsButtonsEnabled(boolean enabled) { - getVisibleRobotEnergyCheckBox().setSelected(enabled); - getVisibleRobotNameCheckBox().setSelected(enabled); - getVisibleScanArcsCheckBox().setSelected(enabled); - getVisibleExplosionsCheckBox().setSelected(enabled); - getVisibleGroundCheckBox().setSelected(enabled); - getVisibleExplosionDebrisCheckBox().setSelected(enabled); - getVisibleSentryBorderCheckBox().setSelected(enabled); - } - - private void maxTpsButtonActionPerformed() { - getDesiredTpsTextField().setText("" + MAX_TPS); - } - - private void minTpsButtonActionPerformed() { - getDesiredTpsTextField().setText("" + MIN_TPS); - } - - private void fastTpsButtonActionPerformed() { - getDesiredTpsTextField().setText("" + FAST_TPS); - } - - private void defaultTpsButtonActionPerformed() { - getDesiredTpsTextField().setText("" + DEFAULT_TPS); - } - - private JButton getDefaultViewOptionsButton() { - if (defaultViewOptionsButton == null) { - defaultViewOptionsButton = new JButton("Defaults"); - defaultViewOptionsButton.setMnemonic('u'); - defaultViewOptionsButton.setDisplayedMnemonicIndex(4); - defaultViewOptionsButton.addActionListener(eventHandler); - } - return defaultViewOptionsButton; - } - - private JButton getEnableAllViewOptionsButton() { - if (enableAllViewOptionsButton == null) { - enableAllViewOptionsButton = new JButton("Enable all"); - enableAllViewOptionsButton.setMnemonic('a'); - enableAllViewOptionsButton.setDisplayedMnemonicIndex(7); - enableAllViewOptionsButton.addActionListener(eventHandler); - } - return enableAllViewOptionsButton; - } - - private JButton getDisableAllViewOptionsButton() { - if (disableAllViewOptionsButton == null) { - disableAllViewOptionsButton = new JButton("Disable all"); - disableAllViewOptionsButton.setMnemonic('i'); - disableAllViewOptionsButton.setDisplayedMnemonicIndex(1); - disableAllViewOptionsButton.addActionListener(eventHandler); - } - return disableAllViewOptionsButton; - } - - private JLabel getDesiredTpsLabel() { - if (desiredTpsLabel == null) { - desiredTpsLabel = new JLabel("Desired TPS (" + MIN_TPS + '-' + MAX_TPS + "): "); - } - return desiredTpsLabel; - } - - private JTextField getDesiredTpsTextField() { - if (desiredTpsTextField == null) { - desiredTpsTextField = new JTextField(); - desiredTpsTextField.setColumns(5); - desiredTpsTextField.getDocument().addDocumentListener(eventHandler); - - desiredTpsTextField.setInputVerifier( - new InputVerifier() { - @Override - public boolean verify(JComponent c) { - String text = desiredTpsTextField.getText(); - - int inputTps; - - try { - inputTps = new Integer(text); - } catch (NumberFormatException e) { - inputTps = -1; - } - return inputTps >= MIN_TPS && inputTps <= MAX_TPS; - } - - public boolean shouldYieldFocus(JComponent input) { - if (verify(input)) { - return true; - } - JOptionPane.showMessageDialog(null, - "The specified value for 'Desired TPS' (" + MIN_TPS + '-' + MAX_TPS + ") is invalid.", - "Invalid input", JOptionPane.ERROR_MESSAGE); - return false; - } - }); - } - return desiredTpsTextField; - } - - private JCheckBox getDisplayFpsCheckBox() { - if (displayFpsCheckBox == null) { - displayFpsCheckBox = new JCheckBox("Display FPS in titlebar"); - displayFpsCheckBox.setMnemonic('P'); - displayFpsCheckBox.setDisplayedMnemonicIndex(9); - } - return displayFpsCheckBox; - } - - private JCheckBox getDisplayTpsCheckBox() { - if (displayTpsCheckBox == null) { - displayTpsCheckBox = new JCheckBox("Display TPS in titlebar"); - displayTpsCheckBox.setMnemonic('T'); - displayTpsCheckBox.setDisplayedMnemonicIndex(8); - } - return displayTpsCheckBox; - } - - private JButton getDefaultTpsButton() { - if (defaultTpsButton == null) { - defaultTpsButton = new JButton("Default"); - defaultTpsButton.addActionListener(eventHandler); - } - return defaultTpsButton; - } - - private JButton getMinTpsButton() { - if (minTpsButton == null) { - minTpsButton = new JButton("Minimum"); - minTpsButton.addActionListener(eventHandler); - } - return minTpsButton; - } - - private JButton getMaxTpsButton() { - if (maxTpsButton == null) { - maxTpsButton = new JButton("Max"); - maxTpsButton.addActionListener(eventHandler); - } - return maxTpsButton; - } - - private JButton getFastTpsButton() { - if (fastTpsButton == null) { - fastTpsButton = new JButton("Fast"); - fastTpsButton.addActionListener(eventHandler); - } - return fastTpsButton; - } - - private JCheckBox getPreventSpeedupWhenMinimizedCheckBox() { - if (preventSpeedupWhenMinimizedCheckBox == null) { - preventSpeedupWhenMinimizedCheckBox = new JCheckBox("Prevent speedup when minimized"); - } - return preventSpeedupWhenMinimizedCheckBox; - } - - private JPanel getTpsOptionsPanel() { - if (tpsOptionsPanel == null) { - tpsOptionsPanel = new JPanel(); - tpsOptionsPanel.setBorder( - BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Turns Per Second (TPS)")); - tpsOptionsPanel.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - - c.anchor = GridBagConstraints.NORTHWEST; - c.gridwidth = 4; - - tpsOptionsPanel.add(getDisplayTpsCheckBox(), c); - c.gridy = 1; - tpsOptionsPanel.add(getDisplayFpsCheckBox(), c); - - JPanel tpsPanel = new JPanel(); - - tpsPanel.add(getDesiredTpsLabel()); - tpsPanel.add(getDesiredTpsTextField()); - - c.fill = GridBagConstraints.VERTICAL; - c.gridy = 2; - c.insets = new Insets(10, 0, 0, 0); - tpsOptionsPanel.add(tpsPanel, c); - - c.fill = GridBagConstraints.NONE; - c.gridx = 0; - c.gridy = 3; - c.gridwidth = 1; - c.weightx = 0.25; - tpsOptionsPanel.add(getMinTpsButton(), c); - c.gridx = 1; - tpsOptionsPanel.add(getDefaultTpsButton(), c); - c.gridx = 2; - tpsOptionsPanel.add(getFastTpsButton(), c); - c.gridx = 3; - tpsOptionsPanel.add(getMaxTpsButton(), c); - - c.insets = new Insets(20, 0, 0, 0); - c.gridwidth = 4; - c.gridx = 0; - c.gridy = 4; - c.weighty = 1; - tpsOptionsPanel.add(getPreventSpeedupWhenMinimizedCheckBox(), c); - } - return tpsOptionsPanel; - } - - private JPanel getVisibleOptionsPanel() { - if (visibleOptionsPanel == null) { - visibleOptionsPanel = new JPanel(); - visibleOptionsPanel.setBorder(BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Arena")); - visibleOptionsPanel.setLayout(new GridBagLayout()); - - GridBagConstraints c = new GridBagConstraints(); - - c.anchor = GridBagConstraints.NORTHWEST; - c.gridwidth = GridBagConstraints.REMAINDER; - c.weightx = 1; - - visibleOptionsPanel.add(getVisibleRobotEnergyCheckBox(), c); - visibleOptionsPanel.add(getVisibleRobotNameCheckBox(), c); - visibleOptionsPanel.add(getVisibleScanArcsCheckBox(), c); - visibleOptionsPanel.add(getVisibleExplosionsCheckBox(), c); - visibleOptionsPanel.add(getVisibleGroundCheckBox(), c); - visibleOptionsPanel.add(getVisibleExplosionDebrisCheckBox(), c); - visibleOptionsPanel.add(getVisibleSentryBorderCheckBox(), c); - - c.insets = new Insets(10, 0, 0, 10); - c.gridwidth = 1; - c.fill = GridBagConstraints.NONE; - c.weighty = 1; - c.weightx = 0; - visibleOptionsPanel.add(getEnableAllViewOptionsButton(), c); - visibleOptionsPanel.add(getDisableAllViewOptionsButton(), c); - visibleOptionsPanel.add(getDefaultViewOptionsButton(), c); - } - return visibleOptionsPanel; - } - - private JCheckBox getVisibleRobotEnergyCheckBox() { - if (visibleRobotEnergyCheckBox == null) { - visibleRobotEnergyCheckBox = new JCheckBox("Visible Robot Energy"); - visibleRobotEnergyCheckBox.setMnemonic('y'); - visibleRobotEnergyCheckBox.setDisplayedMnemonicIndex(19); - } - return visibleRobotEnergyCheckBox; - } - - private JCheckBox getVisibleRobotNameCheckBox() { - if (visibleRobotNameCheckBox == null) { - visibleRobotNameCheckBox = new JCheckBox("Visible Robot Name"); - visibleRobotNameCheckBox.setMnemonic('V'); - } - return visibleRobotNameCheckBox; - } - - private JCheckBox getVisibleScanArcsCheckBox() { - if (visibleScanArcsCheckBox == null) { - visibleScanArcsCheckBox = new JCheckBox("Visible Scan Arcs"); - visibleScanArcsCheckBox.setMnemonic('b'); - visibleScanArcsCheckBox.setDisplayedMnemonicIndex(4); - } - return visibleScanArcsCheckBox; - } - - private JCheckBox getVisibleExplosionsCheckBox() { - if (visibleExplosionsCheckBox == null) { - visibleExplosionsCheckBox = new JCheckBox("Visible Explosions"); - visibleExplosionsCheckBox.setMnemonic('x'); - visibleExplosionsCheckBox.setDisplayedMnemonicIndex(9); - } - return visibleExplosionsCheckBox; - } - - private JCheckBox getVisibleGroundCheckBox() { - if (visibleGroundCheckBox == null) { - visibleGroundCheckBox = new JCheckBox("Visible Ground"); - visibleGroundCheckBox.setMnemonic('G'); - visibleGroundCheckBox.setDisplayedMnemonicIndex(8); - } - return visibleGroundCheckBox; - } - - private JCheckBox getVisibleExplosionDebrisCheckBox() { - if (visibleExplosionDebrisCheckBox == null) { - visibleExplosionDebrisCheckBox = new JCheckBox("Visible Explosion Debris"); - visibleExplosionDebrisCheckBox.setMnemonic('E'); - visibleExplosionDebrisCheckBox.setDisplayedMnemonicIndex(8); - } - return visibleExplosionDebrisCheckBox; - } - - private JCheckBox getVisibleSentryBorderCheckBox() { - if (visibleSentryBorderCheckBox == null) { - visibleSentryBorderCheckBox = new JCheckBox("Visible Sentry Border"); - visibleSentryBorderCheckBox.setMnemonic('l'); - visibleSentryBorderCheckBox.setDisplayedMnemonicIndex(5); - } - return visibleSentryBorderCheckBox; - } - - private void initialize() { - setLayout(new GridLayout(1, 2)); - add(getVisibleOptionsPanel()); - add(getTpsOptionsPanel()); - - final ISettingsManager props = properties; - - loadPreferences(props); - - props.addPropertyListener(new ISettingsListener() { - public void settingChanged(String property) { - if (property.equals(ISettingsManager.OPTIONS_BATTLE_DESIREDTPS)) { - PreferencesViewOptionsTab.this.desiredTpsTextField.setText("" + props.getOptionsBattleDesiredTPS()); - } - } - }); - } - - private void loadPreferences(ISettingsManager robocodeProperties) { - getDisplayFpsCheckBox().setSelected(robocodeProperties.getOptionsViewFPS()); - getDisplayTpsCheckBox().setSelected(robocodeProperties.getOptionsViewTPS()); - getVisibleRobotNameCheckBox().setSelected(robocodeProperties.getOptionsViewRobotNames()); - getVisibleRobotEnergyCheckBox().setSelected(robocodeProperties.getOptionsViewRobotEnergy()); - getVisibleScanArcsCheckBox().setSelected(robocodeProperties.getOptionsViewScanArcs()); - getVisibleExplosionsCheckBox().setSelected(robocodeProperties.getOptionsViewExplosions()); - getVisibleGroundCheckBox().setSelected(robocodeProperties.getOptionsViewGround()); - getVisibleExplosionDebrisCheckBox().setSelected(robocodeProperties.getOptionsViewExplosionDebris()); - getVisibleSentryBorderCheckBox().setSelected(robocodeProperties.getOptionsViewSentryBorder()); - getDesiredTpsTextField().setText("" + robocodeProperties.getOptionsBattleDesiredTPS()); - getPreventSpeedupWhenMinimizedCheckBox().setSelected( - robocodeProperties.getOptionsViewPreventSpeedupWhenMinimized()); - } - - public void storePreferences() { - ISettingsManager props = properties; - - props.setOptionsViewFPS(getDisplayFpsCheckBox().isSelected()); - props.setOptionsViewTPS(getDisplayTpsCheckBox().isSelected()); - props.setOptionsViewRobotNames(getVisibleRobotNameCheckBox().isSelected()); - props.setOptionsViewRobotEnergy(getVisibleRobotEnergyCheckBox().isSelected()); - props.setOptionsViewScanArcs(getVisibleScanArcsCheckBox().isSelected()); - props.setOptionsViewExplosions(getVisibleExplosionsCheckBox().isSelected()); - props.setOptionsViewGround(getVisibleGroundCheckBox().isSelected()); - props.setOptionsViewExplosionDebris(getVisibleExplosionDebrisCheckBox().isSelected()); - props.setOptionsViewSentryBorder(getVisibleSentryBorderCheckBox().isSelected()); - props.setOptionsBattleDesiredTPS(Integer.parseInt(getDesiredTpsTextField().getText())); - props.setOptionsViewPreventSpeedupWhenMinimized(getPreventSpeedupWhenMinimizedCheckBox().isSelected()); - properties.saveProperties(); - } - - @Override - public boolean isReady() { - try { - int tps = Integer.parseInt(getDesiredTpsTextField().getText()); - - return (tps >= MIN_TPS && tps <= MAX_TPS); - } catch (Exception e) { - return false; - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RankingDialog.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RankingDialog.java deleted file mode 100644 index 66db429..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RankingDialog.java +++ /dev/null @@ -1,117 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.battle.BattleRankingTableModel; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.ui.IWindowManager; -import robocode.control.events.BattleAdaptor; -import robocode.control.events.BattleFinishedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.ITurnSnapshot; - -import javax.swing.*; -import javax.swing.table.AbstractTableModel; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.concurrent.atomic.AtomicReference; - - -/** - * Frame to display the battle results or ranking during battles. - * - * @author Mathew A. Nelson (original) - * @author Luis Crespo (original) - * @author Flemming N. Larsen (contributor) - * @author Nathaniel Troutman (contributor) - */ -@SuppressWarnings("serial") -public class RankingDialog extends BaseScoreDialog { - private final BattleRankingTableModel tableModel; - private final Timer timerTask; - private final BattleObserver battleObserver; - private final AtomicReference snapshot; - private ITurnSnapshot lastSnapshot; - private int lastRows; - private final MenuBar menu; - private final IWindowManager windowManager; - - public RankingDialog(IWindowManager windowManager, ISettingsManager settingsManager, MenuBar menu) { - super(settingsManager.getOptionsCommonDontHideRankings() ? null : windowManager, false); - - initialize(); - - this.windowManager = windowManager; - battleObserver = new BattleObserver(); - timerTask = new Timer(1000 / 2, new TimerTask()); - snapshot = new AtomicReference(); - lastRows = 0; - tableModel = new BattleRankingTableModel(); - this.menu = menu; - setTitle("Ranking"); - } - - @Override - protected AbstractTableModel getTableModel() { - return tableModel; - } - - private void update() { - final ITurnSnapshot current = snapshot.get(); - - if (lastSnapshot != current) { - setResultsData(); - - lastSnapshot = current; - tableModel.updateSource(lastSnapshot); - if (table.getModel().getRowCount() != lastRows) { - lastRows = table.getModel().getRowCount(); - - table.setPreferredSize( - new Dimension(table.getColumnModel().getTotalColumnWidth(), - table.getModel().getRowCount() * table.getRowHeight())); - table.setPreferredScrollableViewportSize(table.getPreferredSize()); - pack(); - } - repaint(); - } - } - - protected void onDialogShown() { - windowManager.addBattleListener(battleObserver); - timerTask.start(); - } - - protected void onDialogHidden() { - menu.getOptionsShowRankingCheckBoxMenuItem().setState(false); - timerTask.stop(); - windowManager.removeBattleListener(battleObserver); - dispose(); - } - - private class BattleObserver extends BattleAdaptor { - @Override - public void onBattleFinished(BattleFinishedEvent event) { - snapshot.set(null); - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - snapshot.set(event.getTurnSnapshot()); - } - } - - - private class TimerTask implements ActionListener { - public void actionPerformed(ActionEvent e) { - update(); - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RcSplashScreen.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RcSplashScreen.java deleted file mode 100644 index 89f9729..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RcSplashScreen.java +++ /dev/null @@ -1,114 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.ui.gfx.RobocodeLogo; -import net.sf.robocode.version.IVersionManager; - -import javax.swing.*; -import javax.swing.border.EtchedBorder; -import java.awt.*; -import java.awt.event.WindowAdapter; -import java.awt.event.WindowEvent; -import java.awt.event.WindowListener; -import java.awt.image.BufferedImage; - - -/** - * The splash screen. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class RcSplashScreen extends JWindow { - - private final static Color LABEL_COLOR = Color.WHITE; - - private JLabel splashLabel; - private JPanel splashPanel; - private JPanel splashScreenContentPane; - private Image splashImage; - private final String version; - - private final transient WindowListener eventHandler = new WindowAdapter() { - - @Override - public void windowClosing(WindowEvent e) { - if (e.getSource() == RcSplashScreen.this) { - RcSplashScreen.this.dispose(); - } - } - }; - - public RcSplashScreen(IVersionManager versionManager) { - super(); - this.version = versionManager.getVersion(); - initialize(); - } - - public JLabel getSplashLabel() { - if (splashLabel == null) { - splashLabel = new JLabel(); - splashLabel.setText(""); - splashLabel.setForeground(LABEL_COLOR); - splashLabel.setOpaque(false); - } - return splashLabel; - } - - private JPanel getSplashPanel() { - if (splashPanel == null) { - splashPanel = new JPanel() { - @Override - public void paintComponent(Graphics g) { - g.drawImage(splashImage, 0, 0, null); - g.setColor(LABEL_COLOR); - g.setFont(new Font("Arial", 1, 12)); - FontMetrics fm = g.getFontMetrics(); - - g.drawString("Version: " + version, - splashImage.getWidth(null) - fm.stringWidth("Version: " + version), - splashImage.getHeight(null) - 4); - } - - @Override - public Dimension getPreferredSize() { - return new Dimension(splashImage.getWidth(null), splashImage.getHeight(null)); - } - }; - splashPanel.setLayout(new BorderLayout()); - splashPanel.add(getSplashLabel(), BorderLayout.NORTH); - } - return splashPanel; - } - - private JPanel getSplashScreenContentPane() { - if (splashScreenContentPane == null) { - splashScreenContentPane = new JPanel(); - splashScreenContentPane.setBorder(new EtchedBorder()); - splashScreenContentPane.setLayout(new BorderLayout()); - splashScreenContentPane.add(getSplashPanel(), "Center"); - } - return splashScreenContentPane; - } - - private void initialize() { - splashImage = new BufferedImage(RobocodeLogo.WIDTH, RobocodeLogo.HEIGHT, BufferedImage.TYPE_INT_RGB); - new RobocodeLogo().paintLogoWithTanks(splashImage.getGraphics()); - - setContentPane(getSplashScreenContentPane()); - addWindowListener(eventHandler); - } - - @Override - public void paint(Graphics g) { - super.paint(g); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ResultsDialog.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ResultsDialog.java deleted file mode 100644 index 1c40a64..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ResultsDialog.java +++ /dev/null @@ -1,140 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.battle.BattleResultsTableModel; -import net.sf.robocode.ui.IWindowManager; -import robocode.BattleResults; - -import javax.swing.*; -import javax.swing.table.AbstractTableModel; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; - - -/** - * Dialog to display results (scores) of a battle. - *

- * This class is just a wrapper class used for storing the window position and - * dimension. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class ResultsDialog extends BaseScoreDialog { - - private JPanel buttonPanel; - private JButton okButton; - private JButton saveButton; - private BattleResultsTableModel tableModel; - private final ButtonEventHandler buttonEventHandler; - - public ResultsDialog(IWindowManager manager) { - super(manager, true); - buttonEventHandler = new ButtonEventHandler(); - initialize(); - addCancelByEscapeKey(); - } - - public void setup(BattleResults[] results, int numRounds) { - tableModel = new BattleResultsTableModel(results, numRounds); - setTitle(((BattleResultsTableModel) getTableModel()).getTitle()); - setResultsData(); - - table.setPreferredSize( - new Dimension(table.getColumnModel().getTotalColumnWidth(), - table.getModel().getRowCount() * table.getRowHeight())); - table.setPreferredScrollableViewportSize(table.getPreferredSize()); - } - - private void saveButtonActionPerformed() { - windowManager.showSaveResultsDialog(tableModel); - } - - private void okButtonActionPerformed() { - setVisible(false); - } - - @Override - protected AbstractTableModel getTableModel() { - return tableModel; - } - - @Override - protected JPanel getDialogContentPane() { - if (contentPane == null) { - contentPane = new JPanel(); - contentPane.setLayout(new BorderLayout()); - contentPane.add(getScrollPane(), "Center"); - contentPane.add(getButtonPanel(), "South"); - } - return contentPane; - } - - private JPanel getButtonPanel() { - if (buttonPanel == null) { - buttonPanel = new JPanel(); - buttonPanel.setLayout(new BorderLayout()); - buttonPanel.add(getOkButton(), "East"); - buttonPanel.add(getSaveButton(), "West"); - } - return buttonPanel; - } - - private JButton getOkButton() { - if (okButton == null) { - okButton = new JButton(); - okButton.setText("OK"); - okButton.addActionListener(buttonEventHandler); - WindowUtil.setFixedSize(okButton, new Dimension(80, 25)); - } - return okButton; - } - - private JButton getSaveButton() { - if (saveButton == null) { - saveButton = new JButton(); - saveButton.setText("Save"); - saveButton.addActionListener(buttonEventHandler); - WindowUtil.setFixedSize(saveButton, new Dimension(80, 25)); - } - return saveButton; - } - - private void addCancelByEscapeKey() { - String CANCEL_ACTION_KEY = "CANCEL_ACTION_KEY"; - int noModifiers = 0; - KeyStroke escapeKey = KeyStroke.getKeyStroke(KeyEvent.VK_ESCAPE, noModifiers, false); - InputMap inputMap = getRootPane().getInputMap(JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - - inputMap.put(escapeKey, CANCEL_ACTION_KEY); - AbstractAction cancelAction = new AbstractAction() { - public void actionPerformed(ActionEvent e) { - okButtonActionPerformed(); - } - }; - - getRootPane().getActionMap().put(CANCEL_ACTION_KEY, cancelAction); - } - - private class ButtonEventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - Object source = e.getSource(); - - if (source == ResultsDialog.this.getOkButton()) { - okButtonActionPerformed(); - } else if (source == ResultsDialog.this.getSaveButton()) { - saveButtonActionPerformed(); - } - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ResultsTableCellRenderer.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ResultsTableCellRenderer.java deleted file mode 100644 index 1d99f65..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/ResultsTableCellRenderer.java +++ /dev/null @@ -1,51 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import javax.swing.*; -import javax.swing.border.EtchedBorder; -import javax.swing.table.DefaultTableCellRenderer; -import java.awt.*; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class ResultsTableCellRenderer extends DefaultTableCellRenderer { - - private final boolean isBordered; - - public ResultsTableCellRenderer(boolean isBordered) { - super(); - this.isBordered = isBordered; - setHorizontalAlignment(SwingConstants.CENTER); - setLayout(new FlowLayout(FlowLayout.CENTER, 0, 0)); - } - - @Override - public Component getTableCellRendererComponent(JTable table, Object value, boolean isSelected, - boolean hasFocus, int row, int column) { - if (isBordered) { - setBorder(new EtchedBorder(EtchedBorder.RAISED)); - setBackground(SystemColor.menu); - setForeground(SystemColor.menuText); - } else if (isSelected) { - setBackground(SystemColor.textHighlight); - setForeground(SystemColor.textHighlightText); - } else { - setBackground(SystemColor.text); - setForeground(SystemColor.textText); - } - setText(value.toString()); - - return this; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobocodeFrame.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobocodeFrame.java deleted file mode 100644 index 23f6f82..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobocodeFrame.java +++ /dev/null @@ -1,1011 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.recording.IRecordManager; -import net.sf.robocode.settings.ISettingsManager; -import net.sf.robocode.settings.ISettingsListener; -import net.sf.robocode.ui.*; -import net.sf.robocode.ui.battleview.BattleView; -import net.sf.robocode.ui.battleview.InteractiveHandler; -import net.sf.robocode.ui.battleview.ScreenshotUtil; -import net.sf.robocode.ui.gfx.ImageUtil; -import net.sf.robocode.version.IVersionManager; -import net.sf.robocode.version.Version; -import robocode.control.events.*; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.*; -import java.io.IOException; -import java.lang.management.ManagementFactory; -import java.lang.management.MemoryUsage; -import java.util.*; -import java.util.List; - - -/** - * @author Mathew Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Matthew Reeder (contributor) - * @author Luis Crespo (contributor) - * @author Pavel Savara (contributor) - */ -@SuppressWarnings("serial") -public class RobocodeFrame extends JFrame { - - private final static int MAX_TPS = 10000; - private final static int MAX_TPS_SLIDER_VALUE = 61; - - private final static int UPDATE_TITLE_INTERVAL = 500; // milliseconds - private final static String INSTALL_URL = "http://robocode.sourceforge.net/installer"; - - private static final Cursor BUSY_CURSOR = Cursor.getPredefinedCursor(Cursor.WAIT_CURSOR); - private static final Cursor DEFAULT_CURSOR = Cursor.getPredefinedCursor(Cursor.DEFAULT_CURSOR); - - private final EventHandler eventHandler = new EventHandler(); - private BattleObserver battleObserver; - - private final InteractiveHandler interactiveHandler; - - private JPanel robocodeContentPane; - private JLabel statusLabel; - - private JScrollPane robotButtonsScrollPane; - - private JPanel mainPanel; - private JPanel battleViewPanel; - private JPanel sidePanel; - private JPanel robotButtonsPanel; - - private JToolBar toolBar; - - private JToggleButton pauseButton; - private JButton nextTurnButton; - private JButton stopButton; - private JButton restartButton; - private JButton replayButton; - - private JSlider tpsSlider; - private JLabel tpsLabel; - - private boolean iconified; - private boolean exitOnClose = true; - - private final ISettingsManager properties; - - private final IWindowManagerExt windowManager; - private final IVersionManager versionManager; - private final IBattleManager battleManager; - private final IRobotDialogManager dialogManager; - private final IRecordManager recordManager; - private final BattleView battleView; - private final MenuBar menuBar; - - final List robotButtons = new ArrayList(); - - public RobocodeFrame(ISettingsManager properties, - IWindowManager windowManager, - IRobotDialogManager dialogManager, - IVersionManager versionManager, - IBattleManager battleManager, - IRecordManager recordManager, - InteractiveHandler interactiveHandler, - MenuBar menuBar, - BattleView battleView - ) { - this.windowManager = (IWindowManagerExt) windowManager; - this.properties = properties; - this.interactiveHandler = interactiveHandler; - this.versionManager = versionManager; - this.battleManager = battleManager; - this.dialogManager = dialogManager; - this.recordManager = recordManager; - this.battleView = battleView; - this.menuBar = menuBar; - menuBar.setup(this); - initialize(); - } - - protected void finalize() throws Throwable { - try { - windowManager.removeBattleListener(battleObserver); - } finally { - super.finalize(); - } - } - - public void setBusyPointer(boolean enabled) { - setCursor(enabled ? BUSY_CURSOR : DEFAULT_CURSOR); - } - - public void addRobotButton(JButton b) { - if (b instanceof RobotButton) { - robotButtons.add((RobotButton) b); - } - getRobotButtonsPanel().add(b); - b.setVisible(true); - getRobotButtonsPanel().validate(); - } - - public void checkUpdateOnStart() { - if (!isIconified()) { - Date lastCheckedDate = properties.getVersionChecked(); - - Date today = new Date(); - - if (lastCheckedDate == null) { - lastCheckedDate = today; - properties.setVersionChecked(lastCheckedDate); - properties.saveProperties(); - } - Calendar checkDate = Calendar.getInstance(); - - checkDate.setTime(lastCheckedDate); - checkDate.add(Calendar.DATE, 5); - - if (checkDate.getTime().before(today) && checkForNewVersion(false)) { - properties.setVersionChecked(today); - properties.saveProperties(); - } - } - } - - public boolean checkForNewVersion(boolean notifyNoUpdate) { - String currentVersion = versionManager.getVersion(); - String newVersion = versionManager.checkForNewVersion(); - - boolean newVersionAvailable = false; - - if (newVersion != null && currentVersion != null) { - if (Version.compare(newVersion, currentVersion) > 0) { - newVersionAvailable = true; - if (Version.isFinal(newVersion) - || (Version.isBeta(newVersion) && properties.getOptionsCommonNotifyAboutNewBetaVersions())) { - showNewVersion(newVersion); - } - } - } - if (notifyNoUpdate && !newVersionAvailable) { - showLatestVersion(currentVersion); - } - return true; - } - - public void takeScreenshot() { - setBusyPointer(true); - try { - ScreenshotUtil.saveScreenshot(battleView.getScreenshot(), "PNG", 1); - } finally { - setBusyPointer(false); - } - } - - private void showLatestVersion(String version) { - JOptionPane.showMessageDialog(this, "You have version " + version + ". This is the latest version of Robocode.", - "No update available", JOptionPane.INFORMATION_MESSAGE); - } - - private void showNewVersion(String newVersion) { - if (JOptionPane.showConfirmDialog(this, - "Version " + newVersion + " of Robocode is now available. Would you like to download it?", - "Version " + newVersion + " available", JOptionPane.YES_NO_OPTION) - == JOptionPane.YES_OPTION) { - try { - BrowserManager.openURL(INSTALL_URL); - } catch (IOException e) { - JOptionPane.showMessageDialog(this, e.getMessage(), "Unable to open browser!", - JOptionPane.INFORMATION_MESSAGE); - } - } else if (Version.isFinal(newVersion)) { - JOptionPane.showMessageDialog(this, - "It is highly recommended that you always download the latest version. You may get it at " + INSTALL_URL, - "Update when you can!", JOptionPane.INFORMATION_MESSAGE); - } - } - - /** - * Rather than use a layout manager for the battleview panel, we just - * calculate the proper aspect ratio and set the battleview's size. We could - * use a layout manager if someone wants to write one... - */ - private void battleViewPanelResized() { - battleView.setBounds(getBattleViewPanel().getBounds()); - } - - /** - * Return the MainPanel (which contains the BattleView and the robot - * buttons) - * - * @return JPanel - */ - private JPanel getMainPanel() { - if (mainPanel == null) { - mainPanel = new JPanel(); - mainPanel.setLayout(new BorderLayout()); - mainPanel.add(getSidePanel(), BorderLayout.EAST); - mainPanel.add(getBattleViewPanel()); - } - return mainPanel; - } - - /** - * Return the BattleViewMainPanel (which contains the BattleView and a - * spacer) - * - * @return JPanel - */ - private JPanel getBattleViewPanel() { - if (battleViewPanel == null) { - battleViewPanel = new JPanel(); - battleViewPanel.setPreferredSize(new Dimension(800, 600)); - battleViewPanel.setLayout(null); - battleViewPanel.add(battleView); - battleViewPanel.addComponentListener(eventHandler); - } - return battleViewPanel; - } - - /** - * Return the JFrameContentPane. - * - * @return JPanel - */ - private JPanel getRobocodeContentPane() { - if (robocodeContentPane == null) { - robocodeContentPane = new JPanel(); - robocodeContentPane.setLayout(new BorderLayout()); - robocodeContentPane.add(getToolBar(), "South"); - robocodeContentPane.add(getMainPanel(), "Center"); - } - return robocodeContentPane; - } - - /** - * Return the sidePanel. - * - * @return JPanel - */ - private JPanel getSidePanel() { - if (sidePanel == null) { - sidePanel = new JPanel(); - sidePanel.setLayout(new BorderLayout()); - sidePanel.add(getRobotButtonsScrollPane(), BorderLayout.CENTER); - final BattleButton btn = net.sf.robocode.core.Container.getComponent(BattleButton.class); - - btn.attach(); - sidePanel.add(btn, BorderLayout.SOUTH); - } - return sidePanel; - } - - /** - * Return the robotButtons panel. - * - * @return JPanel - */ - private JPanel getRobotButtonsPanel() { - if (robotButtonsPanel == null) { - robotButtonsPanel = new JPanel(); - robotButtonsPanel.setLayout(new BoxLayout(robotButtonsPanel, BoxLayout.Y_AXIS)); - robotButtonsPanel.addContainerListener(eventHandler); - } - return robotButtonsPanel; - } - - /** - * Return the robotButtonsScrollPane - * - * @return JScrollPane - */ - private JScrollPane getRobotButtonsScrollPane() { - if (robotButtonsScrollPane == null) { - robotButtonsScrollPane = new JScrollPane(); - robotButtonsScrollPane.setAutoscrolls(false); - robotButtonsScrollPane.setVerticalScrollBarPolicy(ScrollPaneConstants.VERTICAL_SCROLLBAR_AS_NEEDED); - robotButtonsScrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER); - robotButtonsScrollPane.setAlignmentY(Component.TOP_ALIGNMENT); - robotButtonsScrollPane.setMaximumSize(new Dimension(113, 32767)); - robotButtonsScrollPane.setPreferredSize(new Dimension(113, 28)); - robotButtonsScrollPane.setAlignmentX(Component.CENTER_ALIGNMENT); - robotButtonsScrollPane.setMinimumSize(new Dimension(113, 53)); - robotButtonsScrollPane.setViewportView(getRobotButtonsPanel()); - } - return robotButtonsScrollPane; - } - - /** - * Return the statusLabel - * - * @return JLabel - */ - public JLabel getStatusLabel() { - if (statusLabel == null) { - statusLabel = new JLabel(); - statusLabel.setText(""); - } - return statusLabel; - } - - /** - * Return the pauseButton - * - * @return JToggleButton - */ - private JToggleButton getPauseButton() { - if (pauseButton == null) { - pauseButton = new JToggleButton("Pause/Debug"); - pauseButton.setMnemonic('P'); - pauseButton.setHorizontalTextPosition(SwingConstants.CENTER); - pauseButton.setVerticalTextPosition(SwingConstants.BOTTOM); - pauseButton.addActionListener(eventHandler); - } - return pauseButton; - } - - /** - * Return the nextTurnButton - * - * @return JButton - */ - private Component getNextTurnButton() { - if (nextTurnButton == null) { - nextTurnButton = new JButton("Next Turn"); - nextTurnButton.setMnemonic('N'); - nextTurnButton.setHorizontalTextPosition(SwingConstants.CENTER); - nextTurnButton.setVerticalTextPosition(SwingConstants.BOTTOM); - nextTurnButton.addActionListener(eventHandler); - - nextTurnButton.setEnabled(false); - } - return nextTurnButton; - } - - /** - * Return the stopButton - * - * @return JButton - */ - private JButton getStopButton() { - if (stopButton == null) { - stopButton = new JButton("Stop"); - stopButton.setMnemonic('S'); - stopButton.setHorizontalTextPosition(SwingConstants.CENTER); - stopButton.setVerticalTextPosition(SwingConstants.BOTTOM); - stopButton.addActionListener(eventHandler); - - stopButton.setEnabled(false); - } - return stopButton; - } - - /** - * Return the restartButton - * - * @return JButton - */ - private JButton getRestartButton() { - if (restartButton == null) { - restartButton = new JButton("Restart"); - restartButton.setMnemonic('t'); - restartButton.setDisplayedMnemonicIndex(3); - restartButton.setHorizontalTextPosition(SwingConstants.CENTER); - restartButton.setVerticalTextPosition(SwingConstants.BOTTOM); - restartButton.addActionListener(eventHandler); - - restartButton.setEnabled(false); - } - return restartButton; - } - - /** - * Return the replayButton - * - * @return JButton - */ - public JButton getReplayButton() { - if (replayButton == null) { - replayButton = new JButton("Replay"); - replayButton.setMnemonic('y'); - replayButton.setDisplayedMnemonicIndex(5); - replayButton.setHorizontalTextPosition(SwingConstants.CENTER); - replayButton.setVerticalTextPosition(SwingConstants.BOTTOM); - replayButton.addActionListener(eventHandler); - - ISettingsManager props = properties; - - replayButton.setVisible(props.getOptionsCommonEnableReplayRecording()); - - props.addPropertyListener(new ISettingsListener() { - public void settingChanged(String property) { - if (property.equals(ISettingsManager.OPTIONS_COMMON_ENABLE_REPLAY_RECORDING)) { - replayButton.setVisible(properties.getOptionsCommonEnableReplayRecording()); - } - } - }); - - replayButton.setEnabled(false); - } - return replayButton; - } - - /** - * Return the tpsSlider - * - * @return JSlider - */ - private JSlider getTpsSlider() { - if (tpsSlider == null) { - final ISettingsManager props = properties; - - int tps = Math.max(props.getOptionsBattleDesiredTPS(), 1); - - tpsSlider = new JSlider(0, MAX_TPS_SLIDER_VALUE, tpsToSliderValue(tps)); - tpsSlider.setPaintLabels(true); - tpsSlider.setPaintTicks(true); - tpsSlider.setMinorTickSpacing(1); - - tpsSlider.addChangeListener(eventHandler); - - Dictionary labels = new Hashtable(); - - labels.put(0, new JLabel("0")); - labels.put(5, new JLabel("5")); - labels.put(10, new JLabel("10")); - labels.put(15, new JLabel("15")); - labels.put(20, new JLabel("20")); - labels.put(25, new JLabel("25")); - labels.put(30, new JLabel("30")); - labels.put(35, new JLabel("40")); - labels.put(40, new JLabel("50")); - labels.put(45, new JLabel("65")); - labels.put(50, new JLabel("90")); - labels.put(55, new JLabel("150")); - labels.put(60, new JLabel("1000")); - - tpsSlider.setMajorTickSpacing(5); - tpsSlider.setLabelTable(labels); - - WindowUtil.setFixedSize(tpsSlider, new Dimension((MAX_TPS_SLIDER_VALUE + 1) * 6, 40)); - - props.addPropertyListener(new ISettingsListener() { - public void settingChanged(String property) { - if (property.equals(ISettingsManager.OPTIONS_BATTLE_DESIREDTPS)) { - setTpsOnSlider(props.getOptionsBattleDesiredTPS()); - } - } - }); - } - return tpsSlider; - } - - /** - * Return the tpsLabel - * - * @return JLabel - */ - private JLabel getTpsLabel() { - if (tpsLabel == null) { - tpsLabel = new JLabel(getTpsFromSliderAsString()); - } - return tpsLabel; - } - - /** - * Return the toolBar. - * - * @return JToolBar - */ - private JToolBar getToolBar() { - if (toolBar == null) { - toolBar = new JToolBar(); - toolBar.add(getPauseButton()); - toolBar.add(getNextTurnButton()); - toolBar.add(getStopButton()); - toolBar.add(getRestartButton()); - toolBar.add(getReplayButton()); - - toolBar.addSeparator(); - - toolBar.add(getTpsSlider()); - toolBar.add(getTpsLabel()); - - toolBar.addSeparator(); - - toolBar.add(getStatusLabel()); - WindowUtil.setDefaultStatusLabel(getStatusLabel()); - } - return toolBar; - } - - /** - * Initialize the class. - */ - private void initialize() { - setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE); - setTitle("Robocode"); - setIconImage(ImageUtil.getImage("/net/sf/robocode/ui/icons/robocode-icon.png")); - setResizable(true); - setVisible(false); - - setContentPane(getRobocodeContentPane()); - setJMenuBar(menuBar); - - battleObserver = new BattleObserver(); - - addWindowListener(eventHandler); - - battleView.addMouseListener(interactiveHandler); - battleView.addMouseMotionListener(interactiveHandler); - battleView.addMouseWheelListener(interactiveHandler); - battleView.setFocusable(true); - KeyboardFocusManager.getCurrentKeyboardFocusManager().addKeyEventDispatcher(interactiveHandler); - - if (windowManager.isSlave()) { - menuBar.getBattleMenu().setEnabled(false); - menuBar.getRobotMenu().setEnabled(false); - getStopButton().setEnabled(false); - getPauseButton().setEnabled(false); - getNextTurnButton().setEnabled(false); - getRestartButton().setEnabled(false); - getReplayButton().setEnabled(false); - exitOnClose = false; - } - } - - private void pauseResumeButtonActionPerformed() { - battleManager.togglePauseResumeBattle(); - } - - /** - * Gets the iconified. - * - * @return Returns a boolean - */ - public boolean isIconified() { - return iconified; - } - - public void afterIntroBattle() { - getRestartButton().setEnabled(false); - getRobotButtonsPanel().removeAll(); - getRobotButtonsPanel().repaint(); - } - - /** - * Sets the iconified. - * - * @param iconified The iconified to set - */ - private void setIconified(boolean iconified) { - this.iconified = iconified; - } - - private int getTpsFromSlider() { - final int value = getTpsSlider().getValue(); - - if (value <= 30) { - return value; - } - if (value <= 40) { - return 2 * value - 30; - } - if (value <= 45) { - return 3 * value - 70; - } - if (value <= 52) { - return 5 * value - 160; - } - switch (value) { - case 53: - return 110; - - case 54: - return 130; - - case 55: - return 150; - - case 56: - return 200; - - case 57: - return 300; - - case 58: - return 500; - - case 59: - return 750; - - case 60: - return 1000; - } - return MAX_TPS; - } - - private void setTpsOnSlider(int tps) { - tpsSlider.setValue(tpsToSliderValue(tps)); - } - - private int tpsToSliderValue(int tps) { - if (tps <= 30) { - return tps; - } - if (tps <= 50) { - return (tps + 30) / 2; - } - if (tps <= 65) { - return (tps + 70) / 3; - } - if (tps <= 100) { - return (tps + 160) / 5; - } - if (tps <= 110) { - return 53; - } - if (tps <= 130) { - return 54; - } - if (tps <= 150) { - return 55; - } - if (tps <= 200) { - return 56; - } - if (tps <= 300) { - return 57; - } - if (tps <= 500) { - return 58; - } - if (tps <= 750) { - return 59; - } - if (tps <= 1000) { - return 60; - } - return MAX_TPS_SLIDER_VALUE; - } - - private String getTpsFromSliderAsString() { - int tps = getTpsFromSlider(); - - return " " + ((tps == MAX_TPS) ? "max" : "" + tps) + " "; - } - - private class EventHandler implements ComponentListener, ActionListener, ContainerListener, WindowListener, - ChangeListener { - - public void actionPerformed(ActionEvent e) { - final Object source = e.getSource(); - - if (source == getPauseButton()) { - pauseResumeButtonActionPerformed(); - } else if (source == getStopButton()) { - battleManager.stop(false); - } else if (source == getRestartButton()) { - battleManager.restart(); - } else if (source == getNextTurnButton()) { - battleManager.nextTurn(); - } else if (source == getReplayButton()) { - battleManager.replay(); - } - } - - public void componentResized(ComponentEvent e) { - if (e.getSource() == getBattleViewPanel()) { - battleViewPanelResized(); - } - } - - public void componentShown(ComponentEvent e) {} - - public void componentHidden(ComponentEvent e) {} - - public void componentRemoved(ContainerEvent e) {} - - public void componentAdded(ContainerEvent e) {} - - public void componentMoved(ComponentEvent e) {} - - public void windowActivated(WindowEvent e) {} - - public void windowClosed(WindowEvent e) { - if (exitOnClose) { - System.exit(0); - } - } - - public void windowClosing(WindowEvent e) { - exitOnClose = true; - if (windowManager.isSlave()) { - WindowUtil.message("If you wish to exit Robocode, please exit the program controlling it."); - exitOnClose = false; - return; - } - if (windowManager.closeRobocodeEditor()) { - WindowUtil.saveWindowPositions(); - battleObserver = null; - dispose(); - } - properties.saveProperties(); - } - - public void windowDeactivated(WindowEvent e) {} - - public void windowDeiconified(WindowEvent e) { - setIconified(false); - battleManager.setManagedTPS(true); - } - - public void windowIconified(WindowEvent e) { - setIconified(true); - battleManager.setManagedTPS(properties.getOptionsViewPreventSpeedupWhenMinimized()); - } - - public void windowOpened(WindowEvent e) { - battleManager.setManagedTPS(true); - } - - public void stateChanged(ChangeEvent e) { - if (e.getSource() == getTpsSlider()) { - int tps = getTpsFromSlider(); - - // TODO refactor - if (tps == 0) { - battleManager.pauseIfResumedBattle(); - } else { - // Only set desired TPS if it is not set to zero - properties.setOptionsBattleDesiredTPS(tps); - battleManager.resumeIfPausedBattle(); // TODO causing problems when called from PreferencesViewOptionsTab.storePreferences() - } - - tpsLabel.setText(getTpsFromSliderAsString()); - } - } - } - - - private class BattleObserver extends BattleAdaptor { - private int tps; - private int currentRound; - private int numberOfRounds; - private int currentTurn; - private boolean isBattleRunning; - private boolean isBattlePaused; - private boolean isBattleReplay; - private long lastTitleUpdateTime; - - public BattleObserver() { - windowManager.addBattleListener(this); - } - - protected void finalize() throws Throwable { - try { - windowManager.removeBattleListener(this); - } finally { - super.finalize(); - } - } - - @Override - public void onBattleStarted(BattleStartedEvent event) { - numberOfRounds = event.getBattleRules().getNumRounds(); - isBattleRunning = true; - isBattleReplay = event.isReplay(); - - getStopButton().setEnabled(true); - getRestartButton().setEnabled(battleManager.getBattleProperties().getSelectedRobots() != null); - getReplayButton().setEnabled(event.isReplay()); - menuBar.getBattleSaveRecordAsMenuItem().setEnabled(false); - menuBar.getBattleExportRecordMenuItem().setEnabled(false); - menuBar.getBattleSaveAsMenuItem().setEnabled(true); - menuBar.getBattleSaveMenuItem().setEnabled(true); - - JCheckBoxMenuItem rankingCheckBoxMenuItem = menuBar.getOptionsShowRankingCheckBoxMenuItem(); - - rankingCheckBoxMenuItem.setEnabled(!isBattleReplay); - if (rankingCheckBoxMenuItem.isSelected()) { - windowManager.showRankingDialog(!isBattleReplay); - } - - validate(); - - updateTitle(); - } - - public void onRoundStarted(final RoundStartedEvent event) { - if (event.getRound() == 0) { - getRobotButtonsPanel().removeAll(); - - final List robots = Arrays.asList(event.getStartSnapshot().getRobots()); - - dialogManager.trim(robots); - - int maxEnergy = 0; - - for (IRobotSnapshot robot : robots) { - if (maxEnergy < robot.getEnergy()) { - maxEnergy = (int) robot.getEnergy(); - } - } - if (maxEnergy == 0) { - maxEnergy = 1; - } - for (int index = 0; index < robots.size(); index++) { - final IRobotSnapshot robot = robots.get(index); - final boolean attach = index < RobotDialogManager.MAX_PRE_ATTACHED; - final RobotButton button = net.sf.robocode.core.Container.createComponent(RobotButton.class); - - button.setup(robot.getName(), maxEnergy, index, robot.getContestantIndex(), attach); - button.setText(robot.getShortName()); - addRobotButton(button); - } - getRobotButtonsPanel().repaint(); - } - } - - @Override - public void onBattleFinished(BattleFinishedEvent event) { - isBattleRunning = false; - - for (RobotButton robotButton : robotButtons) { - robotButton.detach(); - } - robotButtons.clear(); - - final boolean canReplayRecord = recordManager.hasRecord(); - final boolean enableSaveRecord = (properties.getOptionsCommonEnableReplayRecording() & canReplayRecord); - - getStopButton().setEnabled(false); - getReplayButton().setEnabled(canReplayRecord); - getNextTurnButton().setEnabled(false); - - menuBar.getBattleSaveRecordAsMenuItem().setEnabled(enableSaveRecord); - menuBar.getBattleExportRecordMenuItem().setEnabled(enableSaveRecord); - menuBar.getOptionsShowRankingCheckBoxMenuItem().setEnabled(false); - - updateTitle(); - } - - @Override - public void onBattlePaused(BattlePausedEvent event) { - isBattlePaused = true; - - getPauseButton().setSelected(true); - getNextTurnButton().setEnabled(true); - - updateTitle(); - } - - @Override - public void onBattleResumed(BattleResumedEvent event) { - isBattlePaused = false; - - getPauseButton().setSelected(false); - getNextTurnButton().setEnabled(false); - - // TODO: Refactor? - if (getTpsFromSlider() == 0) { - setTpsOnSlider(1); - } - - updateTitle(); - } - - public void onTurnEnded(TurnEndedEvent event) { - if (event == null) { - return; - } - final ITurnSnapshot turn = event.getTurnSnapshot(); - - if (turn == null) { - return; - } - - tps = event.getTurnSnapshot().getTPS(); - currentRound = event.getTurnSnapshot().getRound(); - currentTurn = event.getTurnSnapshot().getTurn(); - - // Only update every half second to spare CPU cycles - if ((System.currentTimeMillis() - lastTitleUpdateTime) >= UPDATE_TITLE_INTERVAL) { - updateTitle(); - } - } - - private void updateTitle() { - StringBuffer title = new StringBuffer("Robocode"); - - if (isBattleRunning) { - title.append(": "); - - if (currentTurn == 0) { - title.append("Starting round"); - } else { - if (isBattleReplay) { - title.append("Replaying: "); - } - title.append("Turn "); - title.append(currentTurn); - - title.append(", Round "); - title.append(currentRound + 1).append(" of ").append(numberOfRounds); - - if (!isBattlePaused) { - boolean dispTps = properties.getOptionsViewTPS(); - boolean dispFps = properties.getOptionsViewFPS(); - - if (dispTps | dispFps) { - title.append(", "); - - if (dispTps) { - title.append(tps).append(" TPS"); - } - if (dispTps & dispFps) { - title.append(", "); - } - if (dispFps) { - title.append(windowManager.getFPS()).append(" FPS"); - } - } - } - } - } - if (isBattlePaused) { - title.append(" (paused)"); - } - - MemoryUsage memUsage = ManagementFactory.getMemoryMXBean().getHeapMemoryUsage(); - - long usedMem = memUsage.getUsed() / (1024 * 1024); - - title.append(", Used mem: ").append(usedMem); - - long maxMem = memUsage.getMax(); - - if (maxMem >= 0) { - maxMem /= (1024 * 1024); - title.append(" of ").append(maxMem); - } - title.append(" MB"); - - setTitle(title.toString()); - - lastTitleUpdateTime = System.currentTimeMillis(); - } - - @Override - public void onBattleCompleted(BattleCompletedEvent event) { - if (windowManager.isShowResultsEnabled()) { - // show on ATW thread - ResultsTask resultTask = new ResultsTask(event); - - EventQueue.invokeLater(resultTask); - } - } - - private class ResultsTask implements Runnable { - final BattleCompletedEvent event; - - ResultsTask(BattleCompletedEvent event) { - this.event = event; - } - - public void run() { - windowManager.showResultsDialog(event); - } - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotButton.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotButton.java deleted file mode 100644 index 16e5e38..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotButton.java +++ /dev/null @@ -1,228 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.ui.IRobotDialogManager; -import net.sf.robocode.ui.IWindowManager; -import net.sf.robocode.ui.IWindowManagerExt; -import robocode.BattleResults; -import robocode.control.events.BattleAdaptor; -import robocode.control.events.BattleCompletedEvent; -import robocode.control.events.BattleFinishedEvent; -import robocode.control.events.TurnEndedEvent; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.control.snapshot.IScoreSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class RobotButton extends JButton implements ActionListener { - - private static final int BAR_MARGIN = 2; - private static final int BAR_HEIGHT = 3; - - private final IWindowManagerExt windowManager; - private final IBattleManager battleManager; - private final BattleObserver battleObserver = new BattleObserver(); - private final IRobotDialogManager dialogManager; - private RobotDialog robotDialog; - private String name; - private int robotIndex; - private int contestantIndex; - private int maxEnergy = 1; - private int maxScore = 1; - private int lastEnergy; - private int lastScore; - private boolean isListening; - - public RobotButton(IWindowManager windowManager, IBattleManager battleManager, IRobotDialogManager dialogManager) { - this.windowManager = (IWindowManagerExt) windowManager; - this.battleManager = battleManager; - this.dialogManager = dialogManager; - } - - public void setup(String name, int maxEnergy, int robotIndex, int contestantIndex, boolean attach) { - this.name = name; - this.robotIndex = robotIndex; - this.contestantIndex = contestantIndex; - this.lastEnergy = maxEnergy; - this.maxEnergy = maxEnergy; - initialize(); - if (attach) { - attach(); - robotDialog.reset(); - battleManager.setPaintEnabled(robotIndex, robotDialog.isPaintEnabled()); - battleManager.setSGPaintEnabled(robotIndex, robotDialog.isSGPaintEnabled()); - } - } - - public void actionPerformed(ActionEvent e) { - if (robotDialog == null) { - attach(); - if (!robotDialog.isVisible() || robotDialog.getState() != Frame.NORMAL) { - WindowUtil.packPlaceShow(robotDialog); - } - } else { - robotDialog.setVisible(true); - } - } - - @Override - public void paint(Graphics g) { - super.paint(g); - - Graphics2D g2 = (Graphics2D) g; - - final int barMaxWidth = getWidth() - (2 * BAR_MARGIN); - - g2.setComposite(AlphaComposite.getInstance(AlphaComposite.SRC_OVER, 0.75f)); - - if (lastEnergy > 0) { - Color color; - - if (lastEnergy > 50) { - color = Color.GREEN; - } else if (lastEnergy > 25) { - color = Color.YELLOW; - } else { - color = Color.RED; - } - g.setColor(color); - - final int widthLife = Math.max(Math.min(barMaxWidth * lastEnergy / maxEnergy, barMaxWidth), 0); - - g.fillRect(BAR_MARGIN, getHeight() - (2 * BAR_HEIGHT + BAR_MARGIN), widthLife, BAR_HEIGHT); - } - if (lastScore > 0) { - g.setColor(Color.BLUE); - - final int widthScore = Math.max(Math.min(barMaxWidth * lastScore / maxScore, barMaxWidth), 0); - - g.fillRect(BAR_MARGIN, getHeight() - (BAR_HEIGHT + BAR_MARGIN), widthScore, BAR_HEIGHT); - } - } - - /** - * Initialize the class. - */ - private void initialize() { - addActionListener(this); - setPreferredSize(new Dimension(110, 25)); - setMinimumSize(new Dimension(110, 25)); - setMaximumSize(new Dimension(110, 25)); - setHorizontalAlignment(SwingConstants.LEFT); - setMargin(new Insets(0, 0, 0, 0)); - setToolTipText(name); - } - - public void attach() { - if (!isListening) { - isListening = true; - windowManager.addBattleListener(battleObserver); - } - if (robotDialog == null) { - robotDialog = dialogManager.getRobotDialog(this, name, true); - } - robotDialog.attach(this); - } - - public void detach() { - if (isListening) { - windowManager.removeBattleListener(battleObserver); - isListening = false; - } - if (robotDialog != null) { - final RobotDialog dialog = robotDialog; - - robotDialog = null; - dialog.detach(); - } - } - - public int getRobotIndex() { - return robotIndex; - } - - public String getRobotName() { - return name; - } - - private class BattleObserver extends BattleAdaptor { - - @Override - public void onTurnEnded(TurnEndedEvent event) { - final ITurnSnapshot turn = event.getTurnSnapshot(); - - if (turn == null) { - return; - } - final IRobotSnapshot[] robots = turn.getRobots(); - final IScoreSnapshot[] scoreSnapshotList = event.getTurnSnapshot().getIndexedTeamScores(); - - maxEnergy = 0; - for (IRobotSnapshot robot : robots) { - if (maxEnergy < robot.getEnergy()) { - maxEnergy = (int) robot.getEnergy(); - } - } - if (maxEnergy == 0) { - maxEnergy = 1; - } - - maxScore = 0; - for (IScoreSnapshot team : scoreSnapshotList) { - if (maxScore < team.getCurrentScore()) { - maxScore = (int) team.getCurrentScore(); - } - } - if (maxScore == 0) { - maxScore = 1; - } - - final int newScore = (int) scoreSnapshotList[contestantIndex].getCurrentScore(); - final int newEnergy = (int) robots[robotIndex].getEnergy(); - boolean rep = (lastEnergy != newEnergy || lastScore != newScore); - - lastEnergy = newEnergy; - lastScore = newScore; - if (rep) { - repaint(); - } - } - - public void onBattleCompleted(final BattleCompletedEvent event) { - maxScore = 0; - for (BattleResults team : event.getIndexedResults()) { - if (maxScore < team.getScore()) { - maxScore = team.getScore(); - } - } - if (maxScore == 0) { - maxScore = 1; - } - lastScore = event.getIndexedResults()[contestantIndex].getScore(); - repaint(); - } - - public void onBattleFinished(final BattleFinishedEvent event) { - lastEnergy = 0; - repaint(); - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotDescriptionPanel.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotDescriptionPanel.java deleted file mode 100644 index 02cddb9..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotDescriptionPanel.java +++ /dev/null @@ -1,230 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.ui.BrowserManager; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.io.IOException; -import java.io.UnsupportedEncodingException; -import java.net.URL; -import java.net.URLDecoder; -import java.util.StringTokenizer; - - -/** - * @author Mathew A. Nelson (original) - * @author Matthew Reeder (contributor) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class RobotDescriptionPanel extends JPanel { - private JLabel robotNameLabel; - private final JLabel[] descriptionLabel = new JLabel[3]; - private JPanel descriptionPanel; - private JButton webpageButton; - private JLabel robocodeVersionLabel; - private JLabel filePathLabel; - private IRobotSpecItem currentRobotSpecification; - - private final static String BLANK_STRING = " "; - - private final EventHandler eventHandler = new EventHandler(); - - private class EventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - if (e.getSource() == getWebpageButton()) { - if (currentRobotSpecification != null) { - URL htmlFile = currentRobotSpecification.getWebpage(); - - if (htmlFile != null && htmlFile.toString().length() > 0) { - try { - BrowserManager.openURL(htmlFile.toString()); - } catch (IOException ignored) {} - } - } - } - } - } - - public RobotDescriptionPanel() { - super(); - initialize(); - } - - private JLabel getFilePathLabel() { - if (filePathLabel == null) { - filePathLabel = new JLabel(); - filePathLabel.setText(" "); - } - return filePathLabel; - } - - private JLabel getDescriptionLabel(int index) { - if (descriptionLabel[index] == null) { - descriptionLabel[index] = new JLabel(); - descriptionLabel[index].setFont(new Font("Monospaced", Font.PLAIN, 12)); - descriptionLabel[index].setHorizontalAlignment(SwingConstants.LEFT); - descriptionLabel[index].setText(BLANK_STRING); - } - return descriptionLabel[index]; - } - - private JPanel getDescriptionPanel() { - if (descriptionPanel == null) { - descriptionPanel = new JPanel(); - descriptionPanel.setAlignmentY(Component.CENTER_ALIGNMENT); - descriptionPanel.setLayout(new BoxLayout(descriptionPanel, BoxLayout.Y_AXIS)); - descriptionPanel.setBorder(BorderFactory.createEtchedBorder()); - for (int i = 0; i < 3; i++) { - descriptionPanel.add(getDescriptionLabel(i)); - } - } - return descriptionPanel; - } - - private JButton getWebpageButton() { - if (webpageButton == null) { - webpageButton = new JButton("Webpage"); - webpageButton.setMnemonic('W'); - webpageButton.setVisible(false); - webpageButton.setAlignmentY(Component.CENTER_ALIGNMENT); - webpageButton.addActionListener(eventHandler); - } - return webpageButton; - } - - private JLabel getRobocodeVersionLabel() { - if (robocodeVersionLabel == null) { - robocodeVersionLabel = new JLabel(); - } - return robocodeVersionLabel; - } - - private JLabel getRobotNameLabel() { - if (robotNameLabel == null) { - robotNameLabel = new JLabel(); - robotNameLabel.setHorizontalAlignment(SwingConstants.CENTER); - robotNameLabel.setText(" "); - } - return robotNameLabel; - } - - private void initialize() { - setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - - JPanel p = new JPanel(); - - p.setLayout(new BorderLayout()); - p.add(getRobotNameLabel(), BorderLayout.CENTER); - - JPanel q = new JPanel(); - - q.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 1)); - q.add(getRobocodeVersionLabel()); - p.add(q, BorderLayout.EAST); - - q = new JPanel(); - q.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 1)); - p.add(q, BorderLayout.WEST); - add(p); - - p = new JPanel(); - p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 1)); - p.add(getDescriptionPanel()); - add(p); - - p = new JPanel(); - p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 1)); - p.add(getWebpageButton()); - add(p); - - p = new JPanel(); - p.setLayout(new FlowLayout(FlowLayout.CENTER, 1, 1)); - p.add(getFilePathLabel()); - add(p); - } - - public void showDescription(IRobotSpecItem robotSpecification) { - this.currentRobotSpecification = robotSpecification; - if (robotSpecification == null) { - getRobotNameLabel().setText(" "); - for (int i = 0; i < 3; i++) { - getDescriptionLabel(i).setText(BLANK_STRING); - } - getWebpageButton().setVisible(false); - getRobocodeVersionLabel().setText(" "); - getFilePathLabel().setText(" "); - } else { - String name = robotSpecification.getUniqueFullClassNameWithVersion(); - - if (name.charAt(name.length() - 1) == '*') { - name = name.substring(0, name.length() - 1) + " (development version)"; - } - - String s = robotSpecification.getAuthorName(); - - if (s != null && s.length() > 0) { - name += " by " + s; - } - getRobotNameLabel().setText(name); - final URL url = robotSpecification.getItemURL(); - - if (url != null) { - String path = url.toString(); - - try { - path = URLDecoder.decode(url.toString(), "UTF-8"); - } catch (UnsupportedEncodingException ignore) {} - - getFilePathLabel().setText(path); - } else { - getFilePathLabel().setText(""); - } - - String desc = robotSpecification.getDescription(); - int count = 0; - - if (desc != null) { - StringTokenizer tok = new StringTokenizer(desc, "\n"); - - while (tok.hasMoreTokens() && count < 3) { - StringBuffer line = new StringBuffer(tok.nextToken()); - - if (line != null) { - if (line.length() > BLANK_STRING.length()) { - line.delete(BLANK_STRING.length(), line.length()); - } - for (int i = line.length(); i < BLANK_STRING.length(); i++) { - line.append(' '); - } - getDescriptionLabel(count).setText(line.toString()); - } - count++; - } - } - for (int i = count; i < 3; i++) { - getDescriptionLabel(i).setText(BLANK_STRING); - } - - URL u = robotSpecification.getWebpage(); - - getWebpageButton().setVisible(u != null && u.toString().length() > 0); - - String v = robotSpecification.getRobocodeVersion(); - - getRobocodeVersionLabel().setText(v == null ? "" : "Built for " + v); - } - getDescriptionPanel().setMaximumSize(getDescriptionPanel().getPreferredSize()); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotDialog.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotDialog.java deleted file mode 100644 index 25fe87f..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotDialog.java +++ /dev/null @@ -1,450 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.battle.IBattleManager; -import net.sf.robocode.ui.IWindowManager; -import robocode.control.events.*; -import robocode.control.snapshot.IDebugProperty; -import robocode.control.snapshot.IRobotSnapshot; -import robocode.control.snapshot.ITurnSnapshot; - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.util.HashMap; -import java.util.Map; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class RobotDialog extends JFrame { - private final Color grayGreen = new Color(0x0080C080); - private RobotButton robotButton; - private JTabbedPane tabbedPane; - private ConsoleScrollPane consoleScrollPane; - private ConsoleScrollPane propertiesScrollPane; - private JPanel robotDialogContentPane; - private JPanel buttonPanel; - private JButton okButton; - private JButton clearButton; - private JButton killButton; - private JToggleButton paintButton; - private JCheckBox sgCheckBox; - private JToggleButton pauseButton; - private boolean isListening; - private int robotIndex; - private IRobotSnapshot lastSnapshot; - private boolean printSnapshot; - private boolean grayGreenButton; - private final Map debugProperties = new HashMap(); - - private final BattleObserver battleObserver = new BattleObserver(); - private final IWindowManager windowManager; - private final IBattleManager battleManager; - - public RobotDialog(IWindowManager windowManager, IBattleManager battleManager) { - super(); - this.battleManager = battleManager; - this.windowManager = windowManager; - } - - public void setup(RobotButton robotButton) { - this.robotButton = robotButton; - initialize(); - } - - private void initialize() { - robotIndex = robotButton.getRobotIndex(); - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setContentPane(getRobotDialogContentPane()); - if (windowManager.isSlave()) { - getKillButton().setEnabled(false); - } - this.setTitle(robotButton.getRobotName()); - pack(); - } - - @Override - protected void finalize() throws Throwable { - try { - detach(); - } finally { - super.finalize(); - } - } - - public void detach() { - if (isListening) { - windowManager.removeBattleListener(battleObserver); - isListening = false; - } - robotButton.detach(); - - getPauseButton().setEnabled(false); - getKillButton().setEnabled(false); - - lastSnapshot = null; - printSnapshot(); - } - - public void attach(RobotButton robotButton) { - this.robotButton = robotButton; - robotIndex = this.robotButton.getRobotIndex(); - if (!isListening) { - isListening = true; - windowManager.addBattleListener(battleObserver); - } - getPauseButton().setEnabled(true); - if (!windowManager.isSlave()) { - getKillButton().setEnabled(true); - } - } - - public void reset() { - getConsoleScrollPane().setText(null); - lastSnapshot = null; - debugProperties.clear(); - } - - /** - * When robotDialog is packed, we want to set a reasonable size. However, - * after that, we need a null preferred size so the scrollpane will scroll. - * (preferred size should be based on the text inside) - */ - @Override - public void pack() { - getConsoleScrollPane().setPreferredSize(new Dimension(426, 200)); - super.pack(); - getTabbedPane().setPreferredSize(null); - } - - /** - * Returns true if Paint is enabled; false otherwise - * - * @return true if Paint is enabled; false otherwise - */ - public boolean isPaintEnabled() { - return getPaintButton().isSelected(); - } - - /** - * Returns true if the Robocode SG paint is enabled; false otherwise - * - * @return true if the Robocode SG paint enabled; false otherwise - */ - public boolean isSGPaintEnabled() { - return getSGCheckBox().isSelected(); - } - - private final transient ActionListener eventHandler = new ActionListener() { - public void actionPerformed(ActionEvent e) { - Object src = e.getSource(); - - if (src == RobotDialog.this.getOkButton()) { - okButtonActionPerformed(); - } else if (src == RobotDialog.this.getClearButton()) { - clearButtonActionPerformed(); - } else if (src == RobotDialog.this.getKillButton()) { - killButtonActionPerformed(); - } else if (src == RobotDialog.this.getPaintButton()) { - paintButtonActionPerformed(); - } else if (src == RobotDialog.this.getSGCheckBox()) { - sgCheckBoxActionPerformed(); - } else if (src == RobotDialog.this.getPauseButton()) { - pauseResumeButtonActionPerformed(); - } - } - }; - - /** - * Returns the dialog's content pane - * - * @return the dialog's content pane - */ - private JPanel getRobotDialogContentPane() { - if (robotDialogContentPane == null) { - robotDialogContentPane = new JPanel(); - robotDialogContentPane.setLayout(new BorderLayout()); - robotDialogContentPane.add(getTabbedPane()); - robotDialogContentPane.add(getButtonPanel(), BorderLayout.SOUTH); - } - return robotDialogContentPane; - } - - private JTabbedPane getTabbedPane() { - if (tabbedPane == null) { - tabbedPane = new JTabbedPane(); - tabbedPane.setLayout(new BorderLayout()); - tabbedPane.addTab("Console", getConsoleScrollPane()); - tabbedPane.addTab("Properties", getPropertiesScrollPane()); - tabbedPane.setTabLayoutPolicy(JTabbedPane.SCROLL_TAB_LAYOUT); - - tabbedPane.addChangeListener(new ChangeListener() { - public void stateChanged(ChangeEvent e) { - printSnapshot = (tabbedPane.getSelectedIndex() == 1); - printSnapshot(); - } - }); - } - return tabbedPane; - } - - private void printSnapshot() { - if (printSnapshot) { - String text = null; - - if (lastSnapshot != null) { - StringBuilder sb = new StringBuilder(); - - sb.append("energy: ").append(lastSnapshot.getEnergy()).append('\n'); - sb.append("x: ").append(lastSnapshot.getX()).append('\n'); - sb.append("y: ").append(lastSnapshot.getY()).append('\n'); - sb.append("velocity: ").append(lastSnapshot.getVelocity()).append('\n'); - sb.append("heat: ").append(lastSnapshot.getGunHeat()).append('\n'); - sb.append("bodyHeading: rad: ").append(lastSnapshot.getBodyHeading()).append(" deg: ").append(Math.toDegrees(lastSnapshot.getBodyHeading())).append( - '\n'); - sb.append("gunHeading: rad: ").append(lastSnapshot.getGunHeading()).append(" deg: ").append(Math.toDegrees(lastSnapshot.getGunHeading())).append( - '\n'); - sb.append("radarHeading: rad: ").append(lastSnapshot.getRadarHeading()).append(" deg: ").append(Math.toDegrees(lastSnapshot.getRadarHeading())).append( - '\n'); - sb.append("state: ").append(lastSnapshot.getState()).append('\n'); - sb.append('\n'); - IDebugProperty[] debugPropeties = lastSnapshot.getDebugProperties(); - - if (debugPropeties != null) { - for (IDebugProperty prop : debugPropeties) { - if (prop.getValue() == null || prop.getValue().length() == 0) { - debugProperties.remove(prop.getKey()); - } else { - debugProperties.put(prop.getKey(), prop.getValue()); - } - } - } - for (Map.Entry prop : debugProperties.entrySet()) { - sb.append(prop.getKey()).append(": ").append(prop.getValue()).append('\n'); - } - - text = sb.toString(); - } - getPropertiesScrollPane().setText(text); - } - } - - private ConsoleScrollPane getPropertiesScrollPane() { - if (propertiesScrollPane == null) { - propertiesScrollPane = new ConsoleScrollPane(); - } - return propertiesScrollPane; - } - - /** - * Returns the console scroll pane - * - * @return the console scroll pane - */ - private ConsoleScrollPane getConsoleScrollPane() { - if (consoleScrollPane == null) { - consoleScrollPane = new ConsoleScrollPane(); - } - return consoleScrollPane; - } - - /** - * Returns the button panel - * - * @return the button panel - */ - private JPanel getButtonPanel() { - if (buttonPanel == null) { - buttonPanel = new JPanel(); - buttonPanel.setLayout(new FlowLayout(FlowLayout.LEFT)); - buttonPanel.add(getOkButton()); - buttonPanel.add(getClearButton()); - buttonPanel.add(getKillButton()); - buttonPanel.add(getPaintButton()); - buttonPanel.add(getSGCheckBox()); - buttonPanel.add(getPauseButton()); - } - return buttonPanel; - } - - /** - * Returns the OK button - * - * @return the OK button - */ - private JButton getOkButton() { - if (okButton == null) { - okButton = getNewButton("OK"); - } - return okButton; - } - - /** - * Returns the Clear button - * - * @return the Clear button - */ - private JButton getClearButton() { - if (clearButton == null) { - clearButton = getNewButton("Clear"); - } - return clearButton; - } - - /** - * Returns the Kill button. - * - * @return the Kill button - */ - private JButton getKillButton() { - if (killButton == null) { - killButton = getNewButton("Kill Robot"); - } - return killButton; - } - - /** - * Returns the Paint button. - * - * @return the Paint button - */ - private JToggleButton getPaintButton() { - if (paintButton == null) { - paintButton = new JToggleButton("Paint"); - paintButton.addActionListener(eventHandler); - } - return paintButton; - } - - /** - * Returns the SG checkbox. - * - * @return the SG checkbox - */ - private JCheckBox getSGCheckBox() { - if (sgCheckBox == null) { - sgCheckBox = new JCheckBox("Robocode SG"); - sgCheckBox.addActionListener(eventHandler); - } - return sgCheckBox; - } - - /** - * Returns the Pause button. - * - * @return the Pause button - */ - private JToggleButton getPauseButton() { - if (pauseButton == null) { - pauseButton = new JToggleButton("Pause/Debug"); - pauseButton.addActionListener(eventHandler); - } - return pauseButton; - } - - /** - * Returns a new button with event handler and with the specified text - * - * @param text The text of the button - * @return a new button with event handler and with the specified text - */ - private JButton getNewButton(String text) { - JButton button = new JButton(text); - - button.addActionListener(eventHandler); - return button; - } - - /** - * Is called when the OK button has been activated - */ - private void okButtonActionPerformed() { - dispose(); - } - - /** - * Is called when the Clear button has been activated - */ - private void clearButtonActionPerformed() { - reset(); - } - - /** - * Is called when the Kill button has been activated - */ - private void killButtonActionPerformed() { - battleManager.killRobot(robotIndex); - } - - /** - * Is called when the Paint button has been activated - */ - private void paintButtonActionPerformed() { - battleManager.setPaintEnabled(robotIndex, getPaintButton().isSelected()); - } - - /** - * Is called when the SG check box has been activated - */ - private void sgCheckBoxActionPerformed() { - battleManager.setSGPaintEnabled(robotIndex, getSGCheckBox().isSelected()); - } - - /** - * Is called when the Pause/Resume button has been activated - */ - private void pauseResumeButtonActionPerformed() { - battleManager.togglePauseResumeBattle(); - } - - private class BattleObserver extends BattleAdaptor { - - @Override - public void onBattlePaused(BattlePausedEvent event) { - getPauseButton().setSelected(true); - } - - @Override - public void onBattleResumed(BattleResumedEvent event) { - getPauseButton().setSelected(false); - } - - @Override - public void onTurnEnded(TurnEndedEvent event) { - final ITurnSnapshot turn = event.getTurnSnapshot(); - - if (turn == null) { - return; - } - - lastSnapshot = turn.getRobots()[robotIndex]; - final String text = lastSnapshot.getOutputStreamSnapshot(); - - if (text != null && text.length() > 0) { - getConsoleScrollPane().append(text); - getConsoleScrollPane().scrollToBottom(); - } - - if (lastSnapshot.isPaintRobot() && !grayGreenButton) { - grayGreenButton = true; - getPaintButton().setBackground(grayGreen); - } - - printSnapshot(); - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotExtractor.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotExtractor.java deleted file mode 100644 index 6b6bee1..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotExtractor.java +++ /dev/null @@ -1,164 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.repository.IRepositoryManager; -import net.sf.robocode.ui.IWindowManager; -import static net.sf.robocode.ui.util.ShortcutUtil.MENU_SHORTCUT_KEY_MASK; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.io.PrintWriter; -import java.io.StringWriter; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Matthew Reeder (contributor) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -@SuppressWarnings("serial") -public class RobotExtractor extends JDialog implements WizardListener { - String unusedrobotPath; - - private static final int MIN_ROBOTS = 1; - private static final int MAX_ROBOTS = 1; // 250; - - private JPanel robotImporterContentPane; - - private WizardCardPanel wizardPanel; - private WizardController buttonsPanel; - private RobotSelectionPanel robotSelectionPanel; - - public byte buf[] = new byte[4096]; - private StringWriter output; - private final IWindowManager windowManager; - private final IRepositoryManager repositoryManager; - - private final EventHandler eventHandler = new EventHandler(); - - class EventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("Refresh")) { - getRobotSelectionPanel().refreshRobotList(false); - } - } - } - - public RobotExtractor(JFrame owner, IWindowManager windowManager, IRepositoryManager repositoryManager) { - super(owner); - this.repositoryManager = repositoryManager; - this.windowManager = windowManager; - initialize(); - } - - public void update() { - getRobotSelectionPanel().refreshRobotList(false); - } - - public void cancelButtonActionPerformed() { - dispose(); - } - - public void finishButtonActionPerformed() { - int rc = extractRobot(); - ConsoleDialog d; - - d = new ConsoleDialog(windowManager.getRobocodeFrame(), "Extract results", false); - d.setText(output.toString()); - d.pack(); - d.pack(); - WindowUtil.packCenterShow(this, d); - if (rc < 8) { - this.dispose(); - } - } - - private WizardController getButtonsPanel() { - if (buttonsPanel == null) { - buttonsPanel = getWizardPanel().getWizardController(); - } - return buttonsPanel; - } - - private JPanel getRobotImporterContentPane() { - if (robotImporterContentPane == null) { - robotImporterContentPane = new JPanel(); - robotImporterContentPane.setLayout(new BorderLayout()); - robotImporterContentPane.add(getButtonsPanel(), BorderLayout.SOUTH); - robotImporterContentPane.add(getWizardPanel(), BorderLayout.CENTER); - getWizardPanel().getWizardController().setFinishButtonTextAndMnemonic("Extract!", 'E', 0); - robotImporterContentPane.registerKeyboardAction(eventHandler, "Refresh", - KeyStroke.getKeyStroke(KeyEvent.VK_R, MENU_SHORTCUT_KEY_MASK), - JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - robotImporterContentPane.registerKeyboardAction(eventHandler, "Refresh", - KeyStroke.getKeyStroke(KeyEvent.VK_R, MENU_SHORTCUT_KEY_MASK), JComponent.WHEN_FOCUSED); - } - return robotImporterContentPane; - } - - public RobotSelectionPanel getRobotSelectionPanel() { - if (robotSelectionPanel == null) { - robotSelectionPanel = net.sf.robocode.core.Container.createComponent(RobotSelectionPanel.class); - robotSelectionPanel.setup(MIN_ROBOTS, MAX_ROBOTS, false, - "Select the robot you would like to extract to the robots directory. Robots not shown do not include source.", - true, true, true, false, true, true, null); - } - return robotSelectionPanel; - } - - private WizardCardPanel getWizardPanel() { - if (wizardPanel == null) { - wizardPanel = new WizardCardPanel(this); - wizardPanel.add(getRobotSelectionPanel(), "Select robot"); - } - return wizardPanel; - } - - private void initialize() { - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setTitle("Robot Extract"); - setContentPane(getRobotImporterContentPane()); - } - - private int extractRobot() { - repositoryManager.refresh(); - int rv = 0; - - output = new StringWriter(); - PrintWriter out = new PrintWriter(output); - - out.println("Robot Extract"); - List selectedRobots = getRobotSelectionPanel().getSelectedRobots(); - IRobotSpecItem spec = selectedRobots.get(0); - - try { - WindowUtil.setStatusWriter(out); - - rv = repositoryManager.extractJar(spec); - WindowUtil.setStatusWriter(null); - WindowUtil.setStatus(""); - if (rv == 0) { - out.println("Robot extracted successfully."); - } else if (rv == -1) { - out.println("Cancelled."); - } - } catch (Exception e) { - out.println(e); - rv = 8; - } - return rv; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotSelectionPanel.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotSelectionPanel.java deleted file mode 100644 index 71cbe8a..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/RobotSelectionPanel.java +++ /dev/null @@ -1,487 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.core.Container; -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.repository.IRepositoryManager; -import net.sf.robocode.ui.IWindowManager; - -import javax.swing.*; -import javax.swing.event.ListSelectionEvent; -import javax.swing.event.ListSelectionListener; -import java.awt.*; -import java.awt.event.*; -import java.util.List; -import java.util.ArrayList; - - -/** - * @author Mathew A. Nelson (original) - * @author Matthew Reeder (contributor) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -@SuppressWarnings("serial") -public class RobotSelectionPanel extends WizardPanel { - - private AvailableRobotsPanel availableRobotsPanel; - - private JPanel selectedRobotsPanel; - private JScrollPane selectedRobotsScrollPane; - private JList selectedRobotsList; - - private JPanel buttonsPanel; - private JPanel addButtonsPanel; - private JPanel removeButtonsPanel; - private JButton addButton; - private JButton addAllButton; - private JButton removeButton; - private JButton removeAllButton; - - private final EventHandler eventHandler = new EventHandler(); - private RobotDescriptionPanel descriptionPanel; - private String instructions; - private JLabel instructionsLabel; - private JPanel mainPanel; - private int maxRobots = 1; - private int minRobots = 1; - private boolean onlyShowSource; - private boolean onlyShowWithPackage; - private boolean onlyShowRobots; - private boolean onlyShowDevelopment; - private boolean onlyShowInJar; - private boolean ignoreTeamRobots; - private String preSelectedRobots; - private final List selectedRobots = new ArrayList(); - private final IRepositoryManager repositoryManager; - - public RobotSelectionPanel(IRepositoryManager repositoryManager) { - super(); - this.repositoryManager = repositoryManager; - } - - public void setup(int minRobots, int maxRobots, - boolean showNumRoundsPanel, String instructions, boolean onlyShowSource, boolean onlyShowWithPackage, - boolean onlyShowRobots, boolean onlyShowDevelopment, boolean onlyShowInJar, boolean ignoreTeamRobots, - String preSelectedRobots) { - this.minRobots = minRobots; - this.maxRobots = maxRobots; - this.instructions = instructions; - this.onlyShowSource = onlyShowSource; - this.onlyShowWithPackage = onlyShowWithPackage; - this.onlyShowRobots = onlyShowRobots; - this.onlyShowDevelopment = onlyShowDevelopment; - this.onlyShowInJar = onlyShowInJar; - - this.ignoreTeamRobots = ignoreTeamRobots; - this.preSelectedRobots = preSelectedRobots; - initialize(); - } - - private class EventHandler implements ActionListener, ListSelectionListener { - public void actionPerformed(ActionEvent e) { - if (e.getSource() == getAddAllButton()) { - addAllButtonActionPerformed(); - } else if (e.getSource() == getAddButton()) { - addButtonActionPerformed(); - } else if (e.getSource() == getRemoveAllButton()) { - removeAllButtonActionPerformed(); - } else if (e.getSource() == getRemoveButton()) { - removeButtonActionPerformed(); - } - } - - public void valueChanged(ListSelectionEvent e) { - if (e.getValueIsAdjusting()) { - return; - } - if (e.getSource() == getSelectedRobotsList()) { - selectedRobotsListSelectionChanged(); - } - } - } - - private void addAllButtonActionPerformed() { - JList selectedList = getSelectedRobotsList(); - SelectedRobotsModel selectedModel = (SelectedRobotsModel) selectedList.getModel(); - - for (AvailableRobotsPanel.ItemWrapper selected : availableRobotsPanel.getAvailableRobots()) { - selectedRobots.add(selected); - } - - selectedList.clearSelection(); - selectedModel.changed(); - fireStateChanged(); - if (selectedModel.getSize() >= minRobots && selectedModel.getSize() <= maxRobots) { - showInstructions(); - } else if (selectedModel.getSize() > maxRobots) { - showWrongNumInstructions(); - } - - availableRobotsPanel.getAvailableRobotsList().requestFocus(); - } - - private void addButtonActionPerformed() { - SelectedRobotsModel selectedModel = (SelectedRobotsModel) getSelectedRobotsList().getModel(); - List moves = availableRobotsPanel.getSelectedRobots(); - - for (AvailableRobotsPanel.ItemWrapper move : moves) { - selectedRobots.add(new AvailableRobotsPanel.ItemWrapper(move.getItem())); - } - - selectedModel.changed(); - fireStateChanged(); - if (selectedModel.getSize() >= minRobots && selectedModel.getSize() <= maxRobots) { - showInstructions(); - } else if (selectedModel.getSize() > maxRobots) { - showWrongNumInstructions(); - } - - availableRobotsPanel.getAvailableRobotsList().requestFocus(); - } - - private JButton getAddAllButton() { - if (addAllButton == null) { - addAllButton = new JButton(); - addAllButton.setText("Add All ->"); - addAllButton.setMnemonic('l'); - addAllButton.setDisplayedMnemonicIndex(5); - addAllButton.addActionListener(eventHandler); - } - return addAllButton; - } - - private JButton getAddButton() { - if (addButton == null) { - addButton = new JButton(); - addButton.setText("Add ->"); - addButton.setMnemonic('A'); - addButton.addActionListener(eventHandler); - } - return addButton; - } - - private JPanel getAddButtonsPanel() { - if (addButtonsPanel == null) { - addButtonsPanel = new JPanel(); - addButtonsPanel.setLayout(new GridLayout(2, 1)); - addButtonsPanel.add(getAddButton()); - addButtonsPanel.add(getAddAllButton()); - } - return addButtonsPanel; - } - - private JPanel getButtonsPanel() { - if (buttonsPanel == null) { - buttonsPanel = new JPanel(); - buttonsPanel.setLayout(new BorderLayout(5, 5)); - buttonsPanel.setBorder(BorderFactory.createEmptyBorder(21, 5, 5, 5)); - buttonsPanel.add(getAddButtonsPanel(), BorderLayout.NORTH); - buttonsPanel.add(getRemoveButtonsPanel(), BorderLayout.SOUTH); - } - return buttonsPanel; - } - - private JButton getRemoveAllButton() { - if (removeAllButton == null) { - removeAllButton = new JButton(); - removeAllButton.setText("<- Remove All"); - removeAllButton.setMnemonic('v'); - removeAllButton.setDisplayedMnemonicIndex(7); - removeAllButton.addActionListener(eventHandler); - } - return removeAllButton; - } - - private JButton getRemoveButton() { - if (removeButton == null) { - removeButton = new JButton(); - removeButton.setText("<- Remove"); - removeButton.setMnemonic('m'); - removeButton.setDisplayedMnemonicIndex(5); - removeButton.addActionListener(eventHandler); - } - return removeButton; - } - - private JPanel getRemoveButtonsPanel() { - if (removeButtonsPanel == null) { - removeButtonsPanel = new JPanel(); - removeButtonsPanel.setLayout(new GridLayout(2, 1)); - removeButtonsPanel.add(getRemoveButton()); - removeButtonsPanel.add(getRemoveAllButton()); - } - return removeButtonsPanel; - } - - public String getSelectedRobotsAsString() { - StringBuffer sb = new StringBuffer(); - - for (int i = 0; i < selectedRobots.size(); i++) { - if (i != 0) { - sb.append(','); - } - sb.append(selectedRobots.get(i).getItem().getUniqueFullClassNameWithVersion()); - } - return sb.toString(); - } - - public List getSelectedRobots() { - List res = new ArrayList(); - - for (AvailableRobotsPanel.ItemWrapper item : selectedRobots) { - res.add(item.getItem()); - } - return res; - } - - private JList getSelectedRobotsList() { - if (selectedRobotsList == null) { - selectedRobotsList = new JList(); - selectedRobotsList.setModel(new SelectedRobotsModel()); - selectedRobotsList.setSelectionMode(ListSelectionModel.MULTIPLE_INTERVAL_SELECTION); - MouseListener mouseListener = new MouseAdapter() { - @Override - public void mouseClicked(MouseEvent e) { - if (e.getClickCount() == 2) { - removeButtonActionPerformed(); - } - if ((e.getModifiers() & InputEvent.BUTTON3_MASK) != 0) { - contextMenuActionPerformed(); - } - } - }; - - selectedRobotsList.addMouseListener(mouseListener); - selectedRobotsList.addListSelectionListener(eventHandler); - } - return selectedRobotsList; - } - - private JPanel getSelectedRobotsPanel() { - if (selectedRobotsPanel == null) { - selectedRobotsPanel = new JPanel(); - selectedRobotsPanel.setLayout(new BorderLayout()); - selectedRobotsPanel.setPreferredSize(new Dimension(120, 100)); - selectedRobotsPanel.setBorder( - BorderFactory.createTitledBorder(BorderFactory.createEtchedBorder(), "Selected Robots")); - selectedRobotsPanel.add(getSelectedRobotsScrollPane(), BorderLayout.CENTER); - } - return selectedRobotsPanel; - } - - private JScrollPane getSelectedRobotsScrollPane() { - if (selectedRobotsScrollPane == null) { - selectedRobotsScrollPane = new JScrollPane(); - selectedRobotsScrollPane.setViewportView(getSelectedRobotsList()); - } - return selectedRobotsScrollPane; - } - - private void initialize() { - setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - setLayout(new BorderLayout()); - add(getInstructionsLabel(), BorderLayout.NORTH); - add(getMainPanel(), BorderLayout.CENTER); - add(getDescriptionPanel(), BorderLayout.SOUTH); - setVisible(true); - showInstructions(); - refreshRobotList(false); - } - - private void removeAllButtonActionPerformed() { - JList selectedList = getSelectedRobotsList(); - SelectedRobotsModel selectedModel = (SelectedRobotsModel) selectedList.getModel(); - - selectedRobots.clear(); - selectedList.clearSelection(); - selectedModel.changed(); - fireStateChanged(); - showInstructions(); - } - - private void contextMenuActionPerformed() {} - - private void removeButtonActionPerformed() { - JList selectedList = getSelectedRobotsList(); - SelectedRobotsModel selectedModel = (SelectedRobotsModel) selectedList.getModel(); - int sel[] = selectedList.getSelectedIndices(); - - for (int i = 0; i < sel.length; i++) { - selectedRobots.remove(sel[i] - i); - } - selectedList.clearSelection(); - selectedModel.changed(); - fireStateChanged(); - if (selectedModel.getSize() < minRobots || selectedModel.getSize() > maxRobots) { - showWrongNumInstructions(); - } else { - showInstructions(); - } - } - - class SelectedRobotsModel extends AbstractListModel { - public void changed() { - fireContentsChanged(this, 0, getSize()); - } - - public int getSize() { - return selectedRobots.size(); - } - - public Object getElementAt(int which) { - return selectedRobots.get(which); - } - } - - public AvailableRobotsPanel getAvailableRobotsPanel() { - if (availableRobotsPanel == null) { - availableRobotsPanel = new AvailableRobotsPanel(getAddButton(), "Available Robots", getSelectedRobotsList(), - this); - } - return availableRobotsPanel; - } - - private RobotDescriptionPanel getDescriptionPanel() { - if (descriptionPanel == null) { - descriptionPanel = new RobotDescriptionPanel(); - descriptionPanel.setBorder(BorderFactory.createEmptyBorder(1, 10, 1, 10)); - } - return descriptionPanel; - } - - private JLabel getInstructionsLabel() { - if (instructionsLabel == null) { - instructionsLabel = new JLabel(); - if (instructions != null) { - instructionsLabel.setText(instructions); - } - } - return instructionsLabel; - } - - private JPanel getMainPanel() { - if (mainPanel == null) { - mainPanel = new JPanel(); - mainPanel.setPreferredSize(new Dimension(550, 300)); - GridBagLayout layout = new GridBagLayout(); - - mainPanel.setLayout(layout); - - GridBagConstraints constraints = new GridBagConstraints(); - - constraints.fill = GridBagConstraints.BOTH; - constraints.weightx = 2; - constraints.weighty = 1; - constraints.anchor = GridBagConstraints.NORTHWEST; - constraints.gridwidth = 2; - layout.setConstraints(getAvailableRobotsPanel(), constraints); - mainPanel.add(getAvailableRobotsPanel()); - constraints.gridwidth = 1; - constraints.weightx = 0; - constraints.weighty = 0; - constraints.anchor = GridBagConstraints.CENTER; - layout.setConstraints(getButtonsPanel(), constraints); - mainPanel.add(getButtonsPanel()); - constraints.gridwidth = GridBagConstraints.REMAINDER; - constraints.weightx = 1; - constraints.weighty = 1; - constraints.anchor = GridBagConstraints.NORTHWEST; - layout.setConstraints(getSelectedRobotsPanel(), constraints); - mainPanel.add(getSelectedRobotsPanel()); - } - return mainPanel; - } - - public int getSelectedRobotsCount() { - return selectedRobots.size(); - } - - @Override - public boolean isReady() { - return (getSelectedRobotsCount() >= minRobots && getSelectedRobotsCount() <= maxRobots); - } - - public void refreshRobotList(final boolean withClear) { - - final Runnable runnable = new Runnable() { - public void run() { - final IWindowManager windowManager = Container.getComponent(IWindowManager.class); - - try { - windowManager.setBusyPointer(true); - repositoryManager.refresh(withClear); - - List robotList = repositoryManager.getRepositoryItems(onlyShowSource, - onlyShowWithPackage, onlyShowRobots, onlyShowDevelopment, false, ignoreTeamRobots, onlyShowInJar); - - getAvailableRobotsPanel().setRobotList(robotList); - if (preSelectedRobots != null && preSelectedRobots.length() > 0) { - setSelectedRobots(preSelectedRobots); - preSelectedRobots = null; - } - } finally { - windowManager.setBusyPointer(false); - } - } - }; - - SwingUtilities.invokeLater(runnable); - } - - private void selectedRobotsListSelectionChanged() { - int sel[] = getSelectedRobotsList().getSelectedIndices(); - - if (sel.length == 1) { - availableRobotsPanel.clearSelection(); - IRobotSpecItem robotSpecification = ((AvailableRobotsPanel.ItemWrapper) getSelectedRobotsList().getModel().getElementAt(sel[0])).getItem(); - - showDescription(robotSpecification); - } else { - showDescription(null); - } - } - - private void setSelectedRobots(String selectedRobotsString) { - if (selectedRobotsString != null) { - for (IRobotSpecItem item: repositoryManager.getSelectedSpecifications(selectedRobotsString)) { - this.selectedRobots.add(new AvailableRobotsPanel.ItemWrapper(item)); - } - } - ((SelectedRobotsModel) getSelectedRobotsList().getModel()).changed(); - fireStateChanged(); - } - - public void showDescription(IRobotSpecItem robotSpecification) { - getDescriptionPanel().showDescription(robotSpecification); - } - - public void showInstructions() { - if (instructions != null) { - instructionsLabel.setText(instructions); - instructionsLabel.setVisible(true); - } else { - instructionsLabel.setVisible(false); - } - } - - public void showWrongNumInstructions() { - if (minRobots == maxRobots) { - if (minRobots == 1) { - instructionsLabel.setText("Please select exactly 1 robot."); - } else { - instructionsLabel.setText("Please select exactly " + minRobots + " robots."); - } - } else { - instructionsLabel.setText("Please select between " + minRobots + " and " + maxRobots + " robots."); - } - instructionsLabel.setVisible(true); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java deleted file mode 100644 index 920ac0b..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreator.java +++ /dev/null @@ -1,189 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.IRepositoryManager; -import net.sf.robocode.repository.TeamProperties; -import net.sf.robocode.ui.IWindowManager; -import static net.sf.robocode.ui.util.ShortcutUtil.MENU_SHORTCUT_KEY_MASK; - -import javax.swing.*; - -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.io.File; -import java.io.IOException; -import java.net.MalformedURLException; -import java.net.URL; - - -/** - * @author Mathew A. Nelson (original) - * @author Matthew Reeder (contributor) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class TeamCreator extends JDialog implements WizardListener { - - private JPanel teamCreatorContentPane; - - private WizardCardPanel wizardPanel; - private WizardController wizardController; - - private RobotSelectionPanel robotSelectionPanel; - private TeamCreatorOptionsPanel teamCreatorOptionsPanel; - - private final int minRobots = 2; - private final int maxRobots = 10; - - private final EventHandler eventHandler = new EventHandler(); - - class EventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("Refresh")) { - getRobotSelectionPanel().refreshRobotList(true); - } - } - } - - private final IRepositoryManager repositoryManager; - - public TeamCreator(IWindowManager windowManager, IRepositoryManager repositoryManager) { - super(windowManager.getRobocodeFrame()); - this.repositoryManager = repositoryManager; - initialize(); - } - - protected TeamCreatorOptionsPanel getTeamCreatorOptionsPanel() { - if (teamCreatorOptionsPanel == null) { - teamCreatorOptionsPanel = new TeamCreatorOptionsPanel(this); - } - return teamCreatorOptionsPanel; - } - - private JPanel getTeamCreatorContentPane() { - if (teamCreatorContentPane == null) { - teamCreatorContentPane = new JPanel(); - teamCreatorContentPane.setLayout(new BorderLayout()); - teamCreatorContentPane.add(getWizardController(), BorderLayout.SOUTH); - teamCreatorContentPane.add(getWizardPanel(), BorderLayout.CENTER); - getWizardPanel().getWizardController().setFinishButtonTextAndMnemonic("Create Team!", 'C', 0); - teamCreatorContentPane.registerKeyboardAction(eventHandler, "Refresh", - KeyStroke.getKeyStroke(KeyEvent.VK_R, MENU_SHORTCUT_KEY_MASK), - JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - teamCreatorContentPane.registerKeyboardAction(eventHandler, "Refresh", - KeyStroke.getKeyStroke(KeyEvent.VK_R, MENU_SHORTCUT_KEY_MASK), JComponent.WHEN_FOCUSED); - } - return teamCreatorContentPane; - } - - protected RobotSelectionPanel getRobotSelectionPanel() { - if (robotSelectionPanel == null) { - robotSelectionPanel = net.sf.robocode.core.Container.createComponent(RobotSelectionPanel.class); - robotSelectionPanel.setup(minRobots, maxRobots, false, "Select the robots for this team.", false, true, true, - false, false, false, null); - } - return robotSelectionPanel; - } - - private WizardCardPanel getWizardPanel() { - if (wizardPanel == null) { - wizardPanel = new WizardCardPanel(this); - wizardPanel.add(getRobotSelectionPanel(), "Select robots"); - wizardPanel.add(getTeamCreatorOptionsPanel(), "Select options"); - } - return wizardPanel; - } - - public void initialize() { - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setTitle("Create a team"); - setContentPane(getTeamCreatorContentPane()); - } - - private WizardController getWizardController() { - if (wizardController == null) { - wizardController = getWizardPanel().getWizardController(); - } - return wizardController; - } - - public void cancelButtonActionPerformed() { - dispose(); - } - - public void finishButtonActionPerformed() { - try { - int rc = createTeam(); - - if (rc == 0) { - JOptionPane.showMessageDialog(this, "Team created successfully.", "Success", - JOptionPane.INFORMATION_MESSAGE, null); - this.dispose(); - } else { - JOptionPane.showMessageDialog(this, "Team creation cancelled", "Cancelled", - JOptionPane.INFORMATION_MESSAGE, null); - } - } catch (IOException e) { - JOptionPane.showMessageDialog(this, e.toString(), "Team Creation Failed", JOptionPane.ERROR_MESSAGE, null); - } - } - - public int createTeam() throws IOException { - File file = new File(repositoryManager.getRobotsDirectory(), - teamCreatorOptionsPanel.getTeamPackage().replace('.', File.separatorChar) - + teamCreatorOptionsPanel.getTeamNameField().getText() + ".team"); - - if (file.exists()) { - int ok = JOptionPane.showConfirmDialog(this, file + " already exists. Are you sure you want to replace it?", - "Warning", JOptionPane.YES_NO_CANCEL_OPTION); - - if (ok == JOptionPane.NO_OPTION || ok == JOptionPane.CANCEL_OPTION) { - return -1; - } - } - if (!file.getParentFile().exists()) { - if (!file.getParentFile().mkdirs()) { - Logger.logError("Can't create " + file.getParentFile().toString()); - } - } - - URL webPageUrl = null; - String webPageFieldString = teamCreatorOptionsPanel.getWebpageField().getText(); - - if (webPageFieldString != null && webPageFieldString.length() > 0) { - try { - webPageUrl = new URL(webPageFieldString); - } catch (MalformedURLException e) { - try { - webPageUrl = new URL("http://" + webPageFieldString); - teamCreatorOptionsPanel.getWebpageField().setText(webPageUrl.toString()); - } catch (MalformedURLException ignored) {} - } - } - - String members = robotSelectionPanel.getSelectedRobotsAsString(); - String version = teamCreatorOptionsPanel.getVersionField().getText(); - String author = teamCreatorOptionsPanel.getAuthorField().getText(); - String desc = teamCreatorOptionsPanel.getDescriptionArea().getText(); - - TeamProperties props = new TeamProperties(); - props.setMembers(members); - props.setVersion(version); - props.setAuthor(author); - props.setDescription(desc); - props.setWebPage(webPageUrl); - - repositoryManager.createTeam(file, props); - return 0; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreatorOptionsPanel.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreatorOptionsPanel.java deleted file mode 100644 index 24f2579..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/TeamCreatorOptionsPanel.java +++ /dev/null @@ -1,326 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.ui.packager.RobotPackager; -import net.sf.robocode.ui.util.LimitedClassnameDocument; -import net.sf.robocode.ui.util.LimitedDocument; - -import javax.swing.*; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; - -import java.awt.*; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; -import java.net.URL; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -@SuppressWarnings("serial") -public class TeamCreatorOptionsPanel extends WizardPanel { - private TeamCreator teamCreator; - private RobotPackager teamPackager; - private final EventHandler eventHandler = new EventHandler(); - - private JLabel authorLabel; - private JTextField authorField; - private JLabel descriptionLabel; - private JTextArea descriptionArea; - private JLabel versionLabel; - private JTextField versionField; - private JLabel webpageLabel; - private JTextField webpageField; - private JLabel webpageHelpLabel; - - private JLabel teamNameLabel; - private JLabel teamPackageLabel; - private JTextField teamNameField; - - private String teamPackage; - - private class EventHandler implements ComponentListener, DocumentListener { - public void insertUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void changedUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void removeUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void componentMoved(ComponentEvent e) {} - - public void componentHidden(ComponentEvent e) {} - - public void componentShown(ComponentEvent e) { - List selectedRobots; - - if (teamCreator != null) { - selectedRobots = teamCreator.getRobotSelectionPanel().getSelectedRobots(); - } else { - selectedRobots = teamPackager.getRobotSelectionPanel().getSelectedRobots(); - } - - if (selectedRobots != null) { - IRobotSpecItem robotSpecification = selectedRobots.get(0); - - getTeamNameLabel().setText("Please choose a name for your team: (Must be a valid Java classname)"); - getTeamNameField().setText(robotSpecification.getShortClassName() + "Team"); - getTeamPackageLabel().setText(robotSpecification.getFullPackage() + "."); - teamPackage = robotSpecification.getFullPackage(); - if (teamPackage != null) { - teamPackage += "."; - } - - String d = robotSpecification.getDescription(); - - if (d == null) { - d = ""; - } - getDescriptionArea().setText(d); - String a = robotSpecification.getAuthorName(); - - if (a == null) { - a = ""; - } - getAuthorField().setText(a); - URL u = robotSpecification.getWebpage(); - - if (u == null) { - getWebpageField().setText(""); - } else { - getWebpageField().setText(u.toString()); - } - - getVersionLabel().setVisible(true); - getVersionField().setVisible(true); - getAuthorLabel().setVisible(true); - getAuthorField().setVisible(true); - getWebpageLabel().setVisible(true); - getWebpageField().setVisible(true); - getWebpageHelpLabel().setVisible(true); - getDescriptionLabel().setText( - "Please enter a short description of this team (up to 3 lines of 72 chars each)."); - } - } - - public void componentResized(ComponentEvent e) {} - } - - public JPanel robotListPanel; - - public TeamCreatorOptionsPanel(TeamCreator teamCreator) { - super(); - this.teamCreator = teamCreator; - initialize(); - } - - public TeamCreatorOptionsPanel(RobotPackager teamPackager) { - super(); - this.teamPackager = teamPackager; - initialize(); - } - - private void initialize() { - setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - getTeamNameLabel().setAlignmentX(Component.LEFT_ALIGNMENT); - add(getTeamNameLabel()); - - JPanel teamNamePanel = new JPanel(); - teamNamePanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - teamNamePanel.setAlignmentX(Component.LEFT_ALIGNMENT); - getTeamNameField().setAlignmentX(Component.LEFT_ALIGNMENT); - getTeamNameField().setMaximumSize(getTeamNameField().getPreferredSize()); - // getVersionField().setMaximumSize(getVersionField().getPreferredSize()); - teamNamePanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, getTeamNameField().getPreferredSize().height)); - teamNamePanel.add(getTeamPackageLabel()); - teamNamePanel.add(getTeamNameField()); - add(teamNamePanel); - JLabel label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - add(getVersionLabel()); - - JPanel versionPanel = new JPanel(); - versionPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - versionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - getVersionField().setAlignmentX(Component.LEFT_ALIGNMENT); - getVersionField().setMaximumSize(getVersionField().getPreferredSize()); - versionPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, getVersionField().getPreferredSize().height)); - versionPanel.add(getVersionField()); - add(versionPanel); - - label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - add(getDescriptionLabel()); - - JScrollPane scrollPane = new JScrollPane(getDescriptionArea(), ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, - ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); - - scrollPane.setMaximumSize(scrollPane.getPreferredSize()); - scrollPane.setMinimumSize(new Dimension(100, scrollPane.getPreferredSize().height)); - scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT); - add(scrollPane); - - label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - add(getAuthorLabel()); - - getAuthorField().setAlignmentX(Component.LEFT_ALIGNMENT); - getAuthorField().setMaximumSize(getAuthorField().getPreferredSize()); - add(getAuthorField()); - - label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - add(getWebpageLabel()); - - getWebpageField().setAlignmentX(Component.LEFT_ALIGNMENT); - getWebpageField().setMaximumSize(getWebpageField().getPreferredSize()); - add(getWebpageField()); - - getWebpageHelpLabel().setAlignmentX(Component.LEFT_ALIGNMENT); - add(getWebpageHelpLabel()); - - JPanel panel = new JPanel(); - - panel.setAlignmentX(Component.LEFT_ALIGNMENT); - add(panel); - addComponentListener(eventHandler); - } - - @Override - public boolean isReady() { - return getTeamNameField().getText().length() != 0 && getDescriptionArea().getText().length() != 0; - } - - private JLabel getAuthorLabel() { - if (authorLabel == null) { - authorLabel = new JLabel("Please enter your name. (optional)"); - authorLabel.setAlignmentX(Component.LEFT_ALIGNMENT); - } - return authorLabel; - } - - public JTextField getAuthorField() { - if (authorField == null) { - authorField = new JTextField(40); - } - return authorField; - } - - public JLabel getDescriptionLabel() { - if (descriptionLabel == null) { - descriptionLabel = new JLabel(""); - descriptionLabel.setAlignmentX(Component.LEFT_ALIGNMENT); - } - return descriptionLabel; - } - - public JTextArea getDescriptionArea() { - if (descriptionArea == null) { - LimitedDocument doc = new LimitedDocument(3, 72); - - descriptionArea = new JTextArea(doc, null, 3, 72); - doc.addDocumentListener(eventHandler); - } - return descriptionArea; - } - - private JLabel getVersionLabel() { - if (versionLabel == null) { - versionLabel = new JLabel( - "Please enter a version number for this robot (up to 10 word chars: letters, digits, dots, but no spaces)."); - versionLabel.setAlignmentX(Component.LEFT_ALIGNMENT); - } - return versionLabel; - } - - public JTextField getVersionField() { - if (versionField == null) { - LimitedDocument doc = new LimitedDocument(1, 10); - - versionField = new JTextField(doc, null, 10); - doc.addDocumentListener(eventHandler); - } - return versionField; - } - - public JLabel getWebpageLabel() { - if (webpageLabel == null) { - webpageLabel = new JLabel("Please enter a URL for your team's webpage (optional)"); - webpageLabel.setAlignmentX(Component.LEFT_ALIGNMENT); - } - return webpageLabel; - } - - public JTextField getWebpageField() { - if (webpageField == null) { - webpageField = new JTextField(40); - } - return webpageField; - } - - public JLabel getWebpageHelpLabel() { - if (webpageHelpLabel == null) { - webpageHelpLabel = new JLabel(""); - } - return webpageHelpLabel; - } - - public JTextField getTeamNameField() { - if (teamNameField == null) { - LimitedDocument doc = new LimitedClassnameDocument(1, 32); - - teamNameField = new JTextField(doc, null, 32); - doc.addDocumentListener(eventHandler); - } - return teamNameField; - } - - public JLabel getTeamNameLabel() { - if (teamNameLabel == null) { - teamNameLabel = new JLabel(""); - } - return teamNameLabel; - } - - public JLabel getTeamPackageLabel() { - if (teamPackageLabel == null) { - teamPackageLabel = new JLabel(""); - } - return teamPackageLabel; - } - - /** - * Gets the teamPackage. - * - * @return Returns a String - */ - public String getTeamPackage() { - return (teamPackage != null) ? teamPackage : "."; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WindowPositionManager.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WindowPositionManager.java deleted file mode 100644 index 4f3bf61..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WindowPositionManager.java +++ /dev/null @@ -1,154 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; - -import java.awt.*; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; -import java.io.FileInputStream; -import java.io.FileNotFoundException; -import java.io.FileOutputStream; -import java.io.IOException; -import java.util.Properties; -import java.util.StringTokenizer; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class WindowPositionManager implements ComponentListener { - - private Properties windowPositions; - - public WindowPositionManager() { - super(); - } - - public Properties getWindowPositions() { - if (windowPositions == null) { - windowPositions = new Properties(); - - FileInputStream in = null; - - try { - in = new FileInputStream(FileUtil.getWindowConfigFile()); - windowPositions.load(in); - } catch (FileNotFoundException e) { - Logger.logMessage("Creating " + FileUtil.getWindowConfigFile().getName() + " file"); - } catch (Exception e) { - Logger.logError(e); - } finally { - if (in != null) { - try { - in.close(); - } catch (IOException ignored) {} - } - } - } - return windowPositions; - } - - public void componentHidden(ComponentEvent e) {} - - public void componentMoved(ComponentEvent e) { - // Hack, because we cannot detect maximized frame in Java 1.3 - if (e.getComponent().getBounds().getWidth() >= Toolkit.getDefaultToolkit().getScreenSize().width - || e.getComponent().getBounds().getHeight() >= Toolkit.getDefaultToolkit().getScreenSize().height) { - return; - } - setWindowRect((Window) e.getComponent(), e.getComponent().getBounds()); - } - - public void componentResized(ComponentEvent e) { - // Hack, because we cannot detect maximized frame in Java 1.3 - if (e.getComponent().getBounds().getWidth() >= Toolkit.getDefaultToolkit().getScreenSize().width - || e.getComponent().getBounds().getHeight() >= Toolkit.getDefaultToolkit().getScreenSize().height) { - return; - } - setWindowRect((Window) e.getComponent(), e.getComponent().getBounds()); - } - - public void componentShown(ComponentEvent e) {} - - public void setWindowRect(Window w, Rectangle rect) { - String rString = rect.x + "," + rect.y + "," + rect.width + "," + rect.height; - - getWindowPositions().put(w.getClass().getName(), rString); - } - - public Rectangle getWindowRect(Window window) { - window.addComponentListener(this); - - String rString = (String) getWindowPositions().get(window.getClass().getName()); - - if (rString == null) { - return null; - } - - StringTokenizer tokenizer = new StringTokenizer(rString, ","); - int x = Integer.parseInt(tokenizer.nextToken()); - int y = Integer.parseInt(tokenizer.nextToken()); - int width = Integer.parseInt(tokenizer.nextToken()); - int height = Integer.parseInt(tokenizer.nextToken()); - - return fitWindowBoundsToScreen(new Rectangle(x, y, width, height)); - } - - public void saveWindowPositions() { - FileOutputStream out = null; - - try { - out = new FileOutputStream(FileUtil.getWindowConfigFile()); - - getWindowPositions().store(out, "Robocode window sizes"); - } catch (IOException e) { - Logger.logWarning("Unable to save window positions: " + e); - } finally { - if (out != null) { - try { - out.close(); - } catch (IOException ignored) {} - } - } - } - - private Rectangle fitWindowBoundsToScreen(Rectangle windowBounds) { - if (windowBounds == null) { - return null; - } - - // Return the input window bounds, if we can find a screen device that contains these bounds - - final GraphicsEnvironment gfxEnv = GraphicsEnvironment.getLocalGraphicsEnvironment(); - final GraphicsDevice[] screenDevices = gfxEnv.getScreenDevices(); - - for (int i = screenDevices.length - 1; i >= 0; i--) { - GraphicsConfiguration[] gfxCfg = screenDevices[i].getConfigurations(); - - for (int j = gfxCfg.length - 1; j >= 0; j--) { - if (gfxCfg[j].getBounds().contains(windowBounds.getLocation())) { - return windowBounds; // Found the bounds - } - } - } - - // Otherwise, return window bounds at a location within the current screen - - final Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - - int x = (screenSize.width - windowBounds.width) / 2; - int y = (screenSize.height - windowBounds.height) / 2; - - return new Rectangle(x, y, windowBounds.width, windowBounds.height); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WindowUtil.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WindowUtil.java deleted file mode 100644 index 17c3f2f..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WindowUtil.java +++ /dev/null @@ -1,207 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import javax.swing.*; -import java.awt.*; -import java.io.PrintWriter; - - -/** - * This is a class for window utilization. - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public class WindowUtil { - - private static final Point origin = new Point(0, 0); - private static final WindowPositionManager windowPositionManager = new WindowPositionManager(); - private static JLabel statusLabel; - private static PrintWriter statusWriter; - private static JLabel defaultStatusLabel; - - public static void center(Window w) { - WindowUtil.center(null, w); - } - - public static void center(Window main, Window w) { - WindowUtil.center(main, w, true); - } - - public static void center(Window main, Window w, boolean move) { - Point location = null; - Dimension size = null; - - Rectangle windowRect = windowPositionManager.getWindowRect(w); - - if (windowRect != null) { - location = new Point(windowRect.x, windowRect.y); - size = new Dimension(windowRect.width, windowRect.height); - } - if (!move) { - size = null; - } - if (location == null || size == null) { - // Center a window - Dimension screenSize; - - if (main != null) { - screenSize = main.getSize(); - } else { - screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - } - size = w.getSize(); - if (size.height > screenSize.height - 20 || size.width > screenSize.width - 20) { - // Keep aspect ratio for the robocode frame. - if (w.getName().equals("RobocodeFrame")) { - int shrink = size.width - screenSize.width + 20; - - if (size.height - screenSize.height + 20 > shrink) { - shrink = size.height - screenSize.height + 20; - } - - size.width -= shrink; - size.height -= shrink; - } else { - if (size.height > screenSize.height - 20) { - size.height = screenSize.height - 20; - } - if (size.width > screenSize.width - 20) { - size.width = screenSize.width - 20; - } - } - } - if (main != null) { - location = main.getLocation(); - location.x += (screenSize.width - size.width) / 2; - location.y += (screenSize.height - size.height) / 2; - } else { - location = new Point((screenSize.width - size.width) / 2, (screenSize.height - size.height) / 2); - } - } - - w.setSize(size); - if (move) { - w.setLocation(location); - } - } - - public static void centerShow(Window main, Window window) { - center(main, window); - window.setVisible(true); - } - - public static void setFixedSize(JComponent component, Dimension size) { - component.setPreferredSize(size); - component.setMinimumSize(size); - component.setMaximumSize(size); - } - - public static void error(JFrame frame, String msg) { - Object[] options = { "OK"}; - - JOptionPane.showOptionDialog(frame, msg, "Error", JOptionPane.DEFAULT_OPTION, JOptionPane.ERROR_MESSAGE, null, - options, options[0]); - } - - public static void fitWindow(Window w) { - // We don't want to receive the resize event for this pack! - // ... yes we do! - // w.removeComponentListener(windowPositionManager); - w.pack(); - - center(null, w, false); - } - - public static void packCenterShow(Window window) { - // We don't want to receive the resize event for this pack! - window.removeComponentListener(windowPositionManager); - window.pack(); - center(window); - window.setVisible(true); - } - - public static void packCenterShow(Window main, Window window) { - // We don't want to receive the resize event for this pack! - window.removeComponentListener(windowPositionManager); - window.pack(); - center(main, window); - window.setVisible(true); - } - - public static void packPlaceShow(Window window) { - window.pack(); - WindowUtil.place(window); - window.setVisible(true); - } - - public static void place(Window w) { - // Center a window - Dimension screenSize = Toolkit.getDefaultToolkit().getScreenSize(); - Dimension size = w.getSize(); - - if (size.height > screenSize.height) { - size.height = screenSize.height; - } - if (size.width > screenSize.width) { - size.width = screenSize.width; - } - - w.setLocation(origin); - origin.y += 150; - if (origin.y + size.height > screenSize.height) { - origin.y = 0; - origin.x += 40; - } - if (origin.x + size.width > screenSize.width) { - origin.x = 0; - } - } - - public static void saveWindowPositions() { - windowPositionManager.saveWindowPositions(); - } - - public static void message(String s) { - JOptionPane.showMessageDialog(null, s, "Message", JOptionPane.INFORMATION_MESSAGE); - } - - public static void messageWarning(String s) { - JOptionPane.showMessageDialog(null, s, "Warning", JOptionPane.WARNING_MESSAGE); - } - - public static void messageError(String s) { - Toolkit.getDefaultToolkit().beep(); - JOptionPane.showMessageDialog(null, s, "Message", JOptionPane.ERROR_MESSAGE); - } - - public static void setStatus(String s) { - if (statusWriter != null) { - statusWriter.println(s); - } - if (statusLabel != null) { - statusLabel.setText(s); - } else if (defaultStatusLabel != null) { - defaultStatusLabel.setText(s); - } - } - - public static void setStatusLabel(JLabel label) { - statusLabel = label; - } - - public static void setDefaultStatusLabel(JLabel label) { - defaultStatusLabel = label; - } - - public static void setStatusWriter(PrintWriter out) { - statusWriter = out; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/Wizard.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/Wizard.java deleted file mode 100644 index 4effe7b..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/Wizard.java +++ /dev/null @@ -1,35 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import java.awt.*; - - -/** - * @author Mathew A. Nelson (original) - */ -public interface Wizard { - abstract void back(); - - abstract Component getCurrentPanel(); - - abstract WizardController getWizardController(); - - WizardListener getWizardListener(); - - abstract boolean isBackAvailable(); - - abstract boolean isNextAvailable(); - - abstract boolean isReady(); - - abstract void next(); - - void setWizardControllerOnPanel(WizardPanel panel); -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardCardPanel.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardCardPanel.java deleted file mode 100644 index 3744916..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardCardPanel.java +++ /dev/null @@ -1,116 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import java.awt.*; -import java.awt.event.ContainerEvent; -import java.awt.event.ContainerListener; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class WizardCardPanel extends JPanel implements Wizard { - private WizardController wizardController; - private CardLayout cardLayout = null; - private int currentIndex = 0; - private final WizardListener listener; - private final EventHandler eventHandler = new EventHandler(); - - public class EventHandler implements ContainerListener { - public void componentRemoved(ContainerEvent e) {} - - public void componentAdded(ContainerEvent e) { - if (e.getChild() instanceof WizardPanel) { - setWizardControllerOnPanel((WizardPanel) e.getChild()); - getWizardController().stateChanged(new ChangeEvent(e.getChild())); - } - } - } - - /** - * WizardCardLayout constructor - * - * @param listener WizardListener - */ - public WizardCardPanel(WizardListener listener) { - this.listener = listener; - initialize(); - } - - public void back() { - currentIndex--; - getWizardController().stateChanged(null); - getCardLayout().previous(this); - } - - public CardLayout getCardLayout() { - if (cardLayout == null) { - cardLayout = new CardLayout(); - } - return cardLayout; - } - - public Component getCurrentPanel() { - return getComponent(currentIndex); - } - - public WizardController getWizardController() { - if (wizardController == null) { - wizardController = new WizardController(this); - } - return wizardController; - } - - public WizardListener getWizardListener() { - return listener; - } - - public void initialize() { - this.setLayout(getCardLayout()); - this.addContainerListener(eventHandler); - } - - public boolean isBackAvailable() { - return (currentIndex > 0); - } - - public boolean isCurrentPanelReady() { - Component c = getCurrentPanel(); - - return (!(c instanceof WizardPanel)) || ((WizardPanel) c).isReady(); - } - - public boolean isNextAvailable() { - return ((currentIndex < getComponentCount() - 1) && isCurrentPanelReady()); - } - - public boolean isReady() { - for (Component c : getComponents()) { - if (!((WizardPanel) c).isReady()) { - return false; - } - } - return true; - } - - public void next() { - currentIndex++; - getWizardController().stateChanged(null); - getCardLayout().next(this); - } - - public void setWizardControllerOnPanel(WizardPanel panel) { - panel.setWizardController(getWizardController()); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardController.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardController.java deleted file mode 100644 index 3796002..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardController.java +++ /dev/null @@ -1,195 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; - - -/** - * @author Mathew A. Nelson (original) - * @author Matthew Reeder (contributor) - * @author Flemming N. Larsen (contributor) - */ -@SuppressWarnings("serial") -public class WizardController extends JPanel implements ChangeListener { - - private final EventHandler eventHandler = new EventHandler(); - - private JButton backButton; - private JButton nextButton; - private JButton finishButton; - private JButton cancelButton; - private boolean focusOnEnabled; - - class EventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - if (e.getSource() == WizardController.this.getFinishButton()) { - finishButtonActionPerformed(); - } - if (e.getSource() == WizardController.this.getCancelButton()) { - cancelButtonActionPerformed(); - } - if (e.getSource() == WizardController.this.getNextButton()) { - nextButtonActionPerformed(); - } - if (e.getSource() == WizardController.this.getBackButton()) { - backButtonActionPerformed(); - } - } - } - - private void backButtonActionPerformed() { - wizard.back(); - } - - private void cancelButtonActionPerformed() { - wizard.getWizardListener().cancelButtonActionPerformed(); - } - - private void finishButtonActionPerformed() { - wizard.getWizardListener().finishButtonActionPerformed(); - } - - /** - * Return the backButton - * - * @return JButton - */ - private JButton getBackButton() { - if (backButton == null) { - backButton = new JButton(); - backButton.setText("Back"); - backButton.setMnemonic('B'); - backButton.addActionListener(eventHandler); - } - return backButton; - } - - /** - * Return the cancelButton - * - * @return JButton - */ - private JButton getCancelButton() { - if (cancelButton == null) { - cancelButton = new JButton(); - cancelButton.setText("Cancel"); - cancelButton.setMnemonic('C'); - cancelButton.addActionListener(eventHandler); - } - return cancelButton; - } - - /** - * Return the finishButton - * - * @return JButton - */ - private JButton getFinishButton() { - if (finishButton == null) { - finishButton = new JButton(); - finishButton.setText("Finish"); - finishButton.setMnemonic('F'); - finishButton.addActionListener(eventHandler); - } - return finishButton; - } - - public void setFinishButtonText(String text) { - getFinishButton().setText(text); - } - - public void setFinishButtonTextAndMnemonic(String text, char mnemonic, int mnemonicIndex) { - getFinishButton().setText(text); - getFinishButton().setMnemonic(mnemonic); - getFinishButton().setDisplayedMnemonicIndex(mnemonicIndex); - } - - /** - * Return the nextButton - * - * @return JButton - */ - private JButton getNextButton() { - if (nextButton == null) { - nextButton = new JButton(); - nextButton.setText("Next"); - nextButton.setMnemonic('N'); - nextButton.addActionListener(eventHandler); - } - return nextButton; - } - - /** - * Initialize the class. - */ - private void initialize() { - add(getBackButton()); - add(getNextButton()); - add(new JLabel(" ")); - add(getFinishButton()); - add(getCancelButton()); - } - - private void nextButtonActionPerformed() { - wizard.next(); - } - - private void setBackButtonEnabled(boolean enabled) { - getBackButton().setEnabled(enabled); - } - - public void setFinishButtonEnabled(boolean enabled) { - getFinishButton().setEnabled(enabled); - if (focusOnEnabled && enabled) { - getFinishButton().requestFocus(); - } - } - - private void setNextButtonEnabled(boolean enabled) { - getNextButton().setEnabled(enabled); - } - - private Wizard wizard = null; - - protected WizardController(Wizard wizard) { - super(); - this.wizard = wizard; - initialize(); - stateChanged(null); - } - - public void stateChanged(ChangeEvent e) { - setBackButtonEnabled(wizard.isBackAvailable()); - setNextButtonEnabled(wizard.isNextAvailable()); - setFinishButtonEnabled(wizard.isReady()); - } - - /** - * Gets the focusOnEnabled. - * - * @return Returns a boolean - */ - public boolean getFocusOnEnabled() { - return focusOnEnabled; - } - - /** - * Sets the focusOnEnabled. - * - * @param focusOnEnabled The focusOnEnabled to set - */ - public void setFocusOnEnabled(boolean focusOnEnabled) { - this.focusOnEnabled = focusOnEnabled; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardListener.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardListener.java deleted file mode 100644 index 83171f8..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardListener.java +++ /dev/null @@ -1,18 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -/** - * @author Mathew A. Nelson (original) - */ -public interface WizardListener { - void cancelButtonActionPerformed(); - - void finishButtonActionPerformed(); -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardPanel.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardPanel.java deleted file mode 100644 index f6061ba..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardPanel.java +++ /dev/null @@ -1,34 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import javax.swing.event.ChangeEvent; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - */ -public abstract class WizardPanel extends javax.swing.JPanel { - private static final long serialVersionUID = 1L; - - private WizardController wizardController; - - public void fireStateChanged() { - if (wizardController != null) { - wizardController.stateChanged(new ChangeEvent(this)); - } - } - - public abstract boolean isReady(); - - public void setWizardController(WizardController wizardController) { - this.wizardController = wizardController; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardTabbedPane.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardTabbedPane.java deleted file mode 100644 index 51958a9..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/dialog/WizardTabbedPane.java +++ /dev/null @@ -1,106 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.dialog; - - -import javax.swing.*; -import javax.swing.event.ChangeEvent; -import javax.swing.event.ChangeListener; -import java.awt.*; -import java.awt.event.ContainerEvent; -import java.awt.event.ContainerListener; - - -/** - * @author Mathew A. Nelson (original) - */ -@SuppressWarnings("serial") -public class WizardTabbedPane extends JTabbedPane implements Wizard { - private WizardController wizardController; - private int currentIndex = 0; - private final WizardListener listener; - private final EventHandler eventHandler = new EventHandler(); - - public class EventHandler implements ContainerListener, ChangeListener { - public void componentRemoved(ContainerEvent e) {} - - public void componentAdded(ContainerEvent e) { - if (e.getChild() instanceof WizardPanel) { - setWizardControllerOnPanel((WizardPanel) e.getChild()); - getWizardController().stateChanged(new ChangeEvent(e.getChild())); - } - } - - public void stateChanged(javax.swing.event.ChangeEvent e) { - currentIndex = getSelectedIndex(); - getWizardController().stateChanged(e); - } - } - - public WizardTabbedPane(WizardListener listener) { - this.listener = listener; - initialize(); - } - - public void back() { - setSelectedIndex(currentIndex - 1); - } - - public Component getCurrentPanel() { - return getSelectedComponent(); - } - - public WizardController getWizardController() { - if (wizardController == null) { - wizardController = new WizardController(this); - } - return wizardController; - } - - public WizardListener getWizardListener() { - return listener; - } - - public void initialize() { - addChangeListener(eventHandler); - addContainerListener(eventHandler); - } - - public boolean isBackAvailable() { - return (currentIndex > 0); - } - - public boolean isCurrentPanelReady() { - Component c = getCurrentPanel(); - - return (!(c instanceof WizardPanel)) || ((WizardPanel) c).isReady(); - } - - public boolean isNextAvailable() { - return ((currentIndex < getComponentCount() - 1) && isCurrentPanelReady()); - } - - public boolean isReady() { - for (Component c : getComponents()) { - if (c instanceof WizardPanel) { - if (!((WizardPanel) c).isReady()) { - return false; - } - } - } - return true; - } - - public void next() { - setSelectedIndex(currentIndex + 1); - } - - public void setWizardControllerOnPanel(WizardPanel panel) { - panel.setWizardController(getWizardController()); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/editor/IRobocodeEditor.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/editor/IRobocodeEditor.java deleted file mode 100644 index 30a02a1..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/editor/IRobocodeEditor.java +++ /dev/null @@ -1,16 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.editor; - - -/** - * @author Pavel Savara (original) - */ -public interface IRobocodeEditor { - boolean close(); -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/ColorUtil.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/ColorUtil.java deleted file mode 100644 index 6100b82..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/ColorUtil.java +++ /dev/null @@ -1,153 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.gfx; - - -import static robocode.util.Utils.isNear; - -import java.awt.*; - - -/** - * Class used for utilizing colors. - * - * @author Flemming N. Larsen (original) - */ -class ColorUtil { - - /** - * Return a Color based on a color in RGB565 format. - * - * @param rgb565 the color in RGB565 format. - * @return a Color based on the specifed color in RGB565 format. - */ - public static Color toColor(short rgb565) { - if (rgb565 == 0) { - return null; - } - if (rgb565 == 0x20) { - return Color.BLACK; - } - return new Color(255 * ((rgb565 & 0xF800) >> 11) / 31, 255 * ((rgb565 & 0x07e0) >> 5) / 63, - 255 * (rgb565 & 0x001f) / 31); - } - - /** - * Returns a color in the RGB565 format based on a Color instance. - * - * @param c the color to convert into a RGB565 color. - * @return a color in the RGB565 format based on the specified Color. - */ - public static short toRGB565(Color c) { - if (c == null) { - return 0; - } - short rgb = (short) (((c.getRed() & 0xf8) << 8) | ((c.getGreen() & 0xfc) << 3) | (c.getBlue() >> 3)); - - // 0 is reserved for null -> set green (has highest resolution) to 1 - if (rgb == 0) { - return 0x20; - } - // If the color actually was 0x20 then set it to 0x40 (to the nearest green) - if (rgb == 0x20) { - return 0x40; - } - return rgb; - } - - /** - * Converts a RGB color into a HSL color. - * - * @param r the red color component. - * @param g the green color component. - * @param b the blue color component. - * @return a {@code float[] { H, S, L }} representing the HSL color. - */ - public static float[] fromRGBtoHSL(int r, int g, int b) { - float R = (float) r / 255; - float G = (float) g / 255; - float B = (float) b / 255; - - float min = Math.min(Math.min(R, G), B); // Min. value of RGB - float max = Math.max(Math.max(R, G), B); // Max. value of RGB - float delta = max - min; // Delta RGB value - - float L = (max + min) / 2; - - float H, S; - - if (delta == 0) { // This is a gray, no chroma... - H = 0; - S = 0; - } else { // Chromatic data... - if (L < 0.5f) { - S = delta / (max + min); - } else { - S = delta / (2 - max - min); - } - - float deltaR = (((max - R) / 6) + (delta / 2)) / delta; - float deltaG = (((max - G) / 6) + (delta / 2)) / delta; - float deltaB = (((max - B) / 6) + (delta / 2)) / delta; - - if (isNear(R, max)) { - H = deltaB - deltaG; - } else if (isNear(G, max)) { - H = (1f / 3) + deltaR - deltaB; - } else { - H = (2f / 3) + deltaG - deltaR; - } - - if (H < 0) { - H++; - } - if (H > 1) { - H--; - } - } - return new float[] { H, S, L}; - } - - /** - * Converts a HSL color into a RGB color integer value. - * - * @param h the color hue. - * @param s the color saturation. - * @param l the color lumination. - * @return an RGB integer value. - */ - public static int fromHSLtoRGB(float h, float s, float l) { - float m2 = (l <= 0.5f) ? (l * (s + 1)) : (l + s - l * s); - float m1 = 2 * l - m2; - - int r = (int) (255 * fromHUEtoRGB(m1, m2, h + (1f / 3))); - int g = (int) (255 * fromHUEtoRGB(m1, m2, h)); - int b = (int) (255 * fromHUEtoRGB(m1, m2, h - (1f / 3))); - - return (((r << 8) | g) << 8) | b; - } - - private static float fromHUEtoRGB(float m1, float m2, float h) { - if (h < 0) { - h++; - } - if (h > 1) { - h--; - } - if ((h * 6) < 1) { - return m1 + (m2 - m1) * h * 6; - } - if ((h * 2) < 1) { - return m2; - } - if ((h * 3) < 2) { - return m1 + (m2 - m1) * ((2f / 3) - h) * 6; - } - return m1; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/GraphicsState.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/GraphicsState.java deleted file mode 100644 index 30fcb71..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/GraphicsState.java +++ /dev/null @@ -1,60 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.gfx; - - -import java.awt.*; -import java.awt.geom.AffineTransform; - - -/** - * This class is used for storing the state of a Graphics object, which can be - * restored later. - * - * @author Flemming N. Larsen (original) - */ -public class GraphicsState { - - private Paint paint; - private Font font; - private Stroke stroke; - private AffineTransform transform; - private Composite composite; - private Shape clip; - private RenderingHints renderingHints; - private Color color; - private Color background; - - public void save(Graphics g) { - Graphics2D g2 = (Graphics2D) g; - - paint = g2.getPaint(); - font = g2.getFont(); - stroke = g2.getStroke(); - transform = g2.getTransform(); - composite = g2.getComposite(); - clip = g2.getClip(); - renderingHints = g2.getRenderingHints(); - color = g2.getColor(); - background = g2.getBackground(); - } - - public void restore(Graphics g) { - Graphics2D g2 = (Graphics2D) g; - - g2.setPaint(paint); - g2.setFont(font); - g2.setStroke(stroke); - g2.setTransform(transform); - g2.setComposite(composite); - g2.setClip(clip); - g2.setRenderingHints(renderingHints); - g2.setColor(color); - g2.setBackground(background); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/ImageUtil.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/ImageUtil.java deleted file mode 100644 index c69c97c..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/ImageUtil.java +++ /dev/null @@ -1,121 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.gfx; - - -import net.sf.robocode.io.Logger; - -import javax.imageio.ImageIO; -import java.awt.*; -import java.awt.image.BufferedImage; -import java.awt.image.FilteredImageSource; -import java.awt.image.RGBImageFilter; -import java.io.IOException; -import java.net.URL; - - -/** - * Class used for utilizing images. - * - * @author Flemming N. Larsen (original) - */ -public class ImageUtil { - - /** - * Returns an image resource. - * - * @param filename the filename of the image to load - * @return the loaded image - */ - public static Image getImage(String filename) { - URL url = ImageUtil.class.getResource(filename); - - if (url == null) { - Logger.logError("Could not load image because of invalid filename: " + filename); - return null; - } - - try { - final BufferedImage result = ImageIO.read(url); - - if (result == null) { - final String message = "Could not load image: " + filename; - - Logger.logError(message); - throw new Error(); - } - return result; - } catch (IOException e) { - Logger.logError("Could not load image: " + filename); - return null; - } - - } - - /** - * Creates and returns a buffered version of the specified image. - * - * @param image the image to create a buffered image for - * @return a buffered image based on the specified image - */ - public static BufferedImage getBufferedImage(Image image) { - BufferedImage bufferedImage = new BufferedImage(image.getWidth(null), image.getHeight(null), - BufferedImage.TYPE_INT_ARGB); - - Graphics g = bufferedImage.getGraphics(); - - g.drawImage(image, 0, 0, null); - - return bufferedImage; - } - - /** - * Create a copy of an robot image into a coloured robot image. The colors of the - * input image are changed into the input color, but with the same lumination. - * - * @param img the source image - * @param color the new color that substitutes the old color(s) in the source image - * @return a new image - */ - public static Image createColouredRobotImage(Image img, Color color) { - return (color == null) - ? img - : (img == null) - ? null - : Toolkit.getDefaultToolkit().createImage(new FilteredImageSource(img.getSource(), new ColorFilter(color))); - } - - /** - * A color filter used for changing colors into another color. - * - * @author Flemming N. Larsen - */ - private static class ColorFilter extends RGBImageFilter { - private final float[] hsl; - - public ColorFilter(Color color) { - hsl = ColorUtil.fromRGBtoHSL(color.getRed(), color.getGreen(), color.getBlue()); - } - - @Override - public int filterRGB(int x, int y, int argb) { - int r = (argb >> 16) & 0xff; - int g = (argb >> 8) & 0xff; - int b = argb & 0xff; - - float[] HSL = ColorUtil.fromRGBtoHSL(r, g, b); - - if (HSL[1] > 0) { - float L = Math.min(1, (hsl[2] + HSL[2]) / 2 + hsl[2] / 7); - - return argb & 0xff000000 | ColorUtil.fromHSLtoRGB(hsl[0], hsl[1], L); - } - return argb; - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/RenderImage.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/RenderImage.java deleted file mode 100644 index a2f3ae5..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/RenderImage.java +++ /dev/null @@ -1,88 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.gfx; - - -import java.awt.*; -import java.awt.geom.AffineTransform; -import java.awt.geom.Area; - - -/** - * An image that can be rendered. - * - * @author Flemming N. Larsen (original) - */ -public class RenderImage extends RenderObject { - - /** - * Image - */ - protected final Image image; - - /** - * Area containing the bounds of the image to paint - */ - protected final Area boundArea; - - /** - * Constructs a new {@code RenderImage}, which has it's origin in the center - * of the image. - * - * @param image the image to be rendered - */ - public RenderImage(Image image) { - this(image, ((double) image.getWidth(null) / 2), ((double) image.getHeight(null) / 2)); - } - - /** - * Constructs a new {@code RenderImage} - * - * @param image the image to be rendered - * @param originX the x coordinate of the origin for the rendered image - * @param originY the y coordinate of the origin for the rendered image - */ - public RenderImage(Image image, double originX, double originY) { - super(); - - this.image = image; - - baseTransform = AffineTransform.getTranslateInstance(-originX, -originY); - - boundArea = new Area(new Rectangle(0, 0, image.getWidth(null), image.getHeight(null))); - } - - /** - * Constructs a new {@code RenderImage} that is a copy of another - * {@code RenderImage}. - * - * @param ri the {@code RenderImage} to copy - */ - public RenderImage(RenderImage ri) { - super(ri); - - image = ri.image; - - boundArea = new Area(ri.boundArea); - } - - @Override - public void paint(Graphics2D g) { - g.drawImage(image, transform, null); - } - - @Override - public Rectangle getBounds() { - return boundArea.createTransformedArea(transform).getBounds(); - } - - @Override - public RenderObject copy() { - return new RenderImage(this); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/RenderObject.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/RenderObject.java deleted file mode 100644 index 6a1b462..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/RenderObject.java +++ /dev/null @@ -1,139 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.gfx; - - -import java.awt.*; -import java.awt.geom.AffineTransform; - - -/** - * The base of all renderable objects. - * An {@code RenderObject} is an object that can be painted and transformed. - * - * @author Flemming N. Larsen (original) - */ -public class RenderObject { - - /** - * Base transform, e.g. the initial rotation and translation - */ - protected AffineTransform baseTransform; - - /** - * Current transform that is concatenated with the base transform - */ - protected final AffineTransform transform; - - /** - * Current frame that must be rendered - */ - protected int frame; - - /** - * Constructs a new {@code RenderObject}. - */ - public RenderObject() { - baseTransform = new AffineTransform(); - transform = new AffineTransform(); - } - - /** - * Constructs a new {@code RenderObject} that is a copy of another {@code RenderObject}. - * - * @param renderObject the RenderObject to copy. - */ - public RenderObject(RenderObject renderObject) { - baseTransform = new AffineTransform(renderObject.baseTransform); - transform = new AffineTransform(renderObject.transform); - frame = renderObject.frame; - } - - /** - * Sets the base transform which is pre-concatenated with the current transform. - * - * @param Tx the new transform - */ - public void setBaseTransform(AffineTransform Tx) { - baseTransform.setTransform(Tx); - } - - /** - * Returns a copy of the base transform - * - * @return a copy of the base transform - */ - public AffineTransform getBaseTransform() { - return new AffineTransform(baseTransform); - } - - /** - * Sets the current transform, which is concatenated with the base transform. - * - * @param Tx the new transform - */ - public void setTransform(AffineTransform Tx) { - transform.setTransform(Tx); - transform.concatenate(baseTransform); - } - - /** - * Returns a copy of the current transform - * - * @return a copy of the current transform - */ - public AffineTransform getTransform() { - return transform; - } - - /** - * Sets the current frame number - * - * @param frame the new frame number - */ - public void setFrame(int frame) { - this.frame = frame; - } - - /** - * Returns the current frame number - * - * @return the current frame number - */ - public int getFrame() { - return frame; - } - - /** - * Paint this object. - * This method must be overridden in derived classes. - * - * @param g the graphics context where this object must be painted. - */ - public void paint(Graphics2D g) {} - - /** - * Returns the bounds of this object based on it's current transform. - * This method must be overridden in derived classes. - * - * @return the bounds of this object based on it's current transform. - */ - public Rectangle getBounds() { - return new Rectangle(); - } - - /** - * Returns a copy of this object. - * This method must be overridden in derived classes. - * - * @return a copy of this object. - */ - public RenderObject copy() { - return new RenderObject(this); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/RobocodeLogo.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/RobocodeLogo.java deleted file mode 100644 index 48f2d4e..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/gfx/RobocodeLogo.java +++ /dev/null @@ -1,445 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.gfx; - - -import java.awt.*; -import java.awt.geom.*; - - -/** - * This class is used for rendering the Robocode logo. - * - * @author Flemming N. Larsen (original) - */ -public class RobocodeLogo { - - public final static int WIDTH = 570; - public final static int HEIGHT = 213; - - private final static Color WHITE_ALPHA_7F = new Color(0xff, 0xff, 0xff, 0x7f); - - private final static Color GLOW_GREEN = new Color(0x0A, 0xff, 0x0A, 0x66); - - private final static Color DARK_GREEN_ALPHA_80 = new Color(0x00, 0x70, 0x00, 0x80); - private final static Color GREEN_ALPHA_08 = new Color(0x00, 0xff, 0x00, 0x08); - private final static Color GREEN_ALPHA_20 = new Color(0x00, 0xff, 0x00, 0x20); - private final static Color GREEN_ALPHA_40 = new Color(0x00, 0xff, 0x00, 0x40); - private final static Color GREEN_ALPHA_48 = new Color(0x00, 0xff, 0x00, 0x48); - private final static Color GREEN_ALPHA_80 = new Color(0x00, 0xff, 0x00, 0x80); - - private final static Shape I_SHAPE = new Rectangle2D.Float(0, 0, 13, 46); - - private final static Stroke THIN_STROKE = new BasicStroke(1.5f); - - public void paintLogoWithTanks(Graphics graphics) { - Graphics2D g = (Graphics2D) graphics; - AffineTransform origTransform = g.getTransform(); - - g.setColor(Color.BLACK); - g.fillRect(0, 0, WIDTH, HEIGHT); - - g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON); - g.setRenderingHint(RenderingHints.KEY_RENDERING, RenderingHints.VALUE_RENDER_QUALITY); - - drawTanks(g); - drawOuterDecoration(g); - drawMiddleEllipse(g); - drawMiddleDecoration(g); - drawInnerDecoration(g); - drawInnerSubDecoration(g); - drawRobocodeText(g); - - g.setTransform(origTransform); - } - - private void transform(Graphics2D g, AffineTransform tx) { - AffineTransform at = new AffineTransform(); - - if (tx != null) { - at.concatenate(tx); - } - g.setTransform(at); - } - - private void drawTanks(Graphics2D g) { - AffineTransform origTransform = g.getTransform(); - - drawRobot(g, 22, 192, (float) Math.PI / 2, -0.2f, -0.2f, new Color(0x30, 0x00, 0x10, 0xff)); - drawRobot(g, 22, 92, (float) Math.PI / 2, (float) Math.PI, (float) Math.PI, new Color(0x16, 0x00, 0x2c, 0xff)); - - drawRobot(g, 212, 173, 0.75f, 0.75f, 0.75f, new Color(0x02, 0x01, 0x00, 0xff)); - - drawRobot(g, 455, 50, 2.4f, 2f, 2f, new Color(0x02, 0x00, 0x01, 0xff)); - drawRobot(g, 492, 82, -0.3f, -0.27f, -0.27f, new Color(0x00, 0x00, 0x01, 0xff)); - - transform(g, AffineTransform.getTranslateInstance(270, -25)); - RenderImage explRenderImage1 = new RenderImage( - ImageUtil.getImage("/net/sf/robocode/ui/images/explosion/explosion2-24.png")); - - explRenderImage1.paint(g); - - transform(g, AffineTransform.getTranslateInstance(23, 102)); - RenderImage explRenderImage2 = new RenderImage( - ImageUtil.getImage("/net/sf/robocode/ui/images/explosion/explosion1-8.png")); - - explRenderImage2.setTransform(AffineTransform.getScaleInstance(0.3, 0.3)); - explRenderImage2.paint(g); - - transform(g, AffineTransform.getTranslateInstance(464, 55)); - RenderImage explRenderImage3 = new RenderImage( - ImageUtil.getImage("/net/sf/robocode/ui/images/explosion/explosion1-1.png")); - - explRenderImage3.setTransform(AffineTransform.getScaleInstance(0.5, 0.5)); - explRenderImage3.paint(g); - - transform(g, AffineTransform.getTranslateInstance(488, 72)); - RenderImage explRenderImage4 = new RenderImage( - ImageUtil.getImage("/net/sf/robocode/ui/images/explosion/explosion1-6.png")); - - explRenderImage4.setTransform(AffineTransform.getScaleInstance(0.4, 0.4)); - explRenderImage4.paint(g); - - transform(g, origTransform); - g.setColor(Color.LIGHT_GRAY); - g.fillOval(20, 154, 3, 3); - } - - private void drawRobot(Graphics2D g, int x, int y, float bodyAngle, float gunAngle, float radarAngle, Color color) { - transform(g, AffineTransform.getTranslateInstance(x, y)); - - RenderImage bodyRenderImage = new RenderImage( - ImageUtil.createColouredRobotImage(ImageUtil.getImage("/net/sf/robocode/ui/images/body.png"), color)); - - bodyRenderImage.setTransform(AffineTransform.getRotateInstance(bodyAngle)); - bodyRenderImage.paint(g); - - RenderImage gunRenderImage = new RenderImage( - ImageUtil.createColouredRobotImage(ImageUtil.getImage("/net/sf/robocode/ui/images/turret.png"), color)); - - gunRenderImage.setTransform(AffineTransform.getRotateInstance(gunAngle)); - gunRenderImage.paint(g); - - RenderImage radarRenderImage = new RenderImage( - ImageUtil.createColouredRobotImage(ImageUtil.getImage("/net/sf/robocode/ui/images/radar.png"), color)); - - radarRenderImage.setTransform(AffineTransform.getRotateInstance(radarAngle)); - radarRenderImage.paint(g); - } - - private void drawOuterDecoration(Graphics2D g) { - Shape shape = getOuterDecoration(); - - transform(g, AffineTransform.getTranslateInstance(26, 24)); - - g.setColor(WHITE_ALPHA_7F); - g.fill(shape); - - g.setStroke(THIN_STROKE); - g.drawOval(16, 5, 490, 163); - } - - private void drawMiddleEllipse(Graphics2D g) { - transform(g, null); - - Shape ellipse = new Ellipse2D.Float(68, 38, 440, 146); - - g.setColor(DARK_GREEN_ALPHA_80); - g.fill(ellipse); - - g.setColor(GREEN_ALPHA_40); - g.setStroke(THIN_STROKE); - g.draw(ellipse); - } - - private void drawMiddleDecoration(Graphics2D g) { - Shape shape = getMiddleDecoration(); - - transform(g, AffineTransform.getTranslateInstance(77, 41)); - - g.setColor(GREEN_ALPHA_20); - g.fill(shape); - - g.setStroke(THIN_STROKE); - g.setColor(GREEN_ALPHA_48); - g.draw(shape); - } - - private void drawInnerDecoration(Graphics2D g) { - Shape shape = getInnerDecoration(); - - transform(g, AffineTransform.getTranslateInstance(103, 52)); - - g.setColor(DARK_GREEN_ALPHA_80); - g.fill(shape); - - g.setStroke(THIN_STROKE); - g.setColor(GLOW_GREEN); - g.draw(shape); - } - - private void drawInnerSubDecoration(Graphics2D g) { - Shape shape = getInnerSubDecoration(); - - transform(g, AffineTransform.getTranslateInstance(110, 54)); - - g.setColor(GREEN_ALPHA_08); - g.fill(shape); - - g.setStroke(THIN_STROKE); - g.setColor(GREEN_ALPHA_48); - g.draw(shape); - } - - private void drawRobocodeText(Graphics2D g) { - Shape shape = getRobocodeText(); - - transform(g, AffineTransform.getTranslateInstance(121, 88)); - - g.setColor(GREEN_ALPHA_40); - g.fill(shape); - - g.setStroke(THIN_STROKE); - g.setColor(GREEN_ALPHA_80); - g.draw(shape); - } - - private Area outerDecoration; - - private Shape getOuterDecoration() { - if (outerDecoration == null) { - float W = 523; - float H = 174; - - outerDecoration = new Area(new Ellipse2D.Float(0, 0, W, H)); - outerDecoration.subtract(new Area(new Ellipse2D.Float(16, 5, W - 2 * 16, H - 2 * 5))); - - outerDecoration.subtract(new Area(new Rectangle2D.Float(W / 2, 0, W / 2, H / 2))); - outerDecoration.subtract(new Area(new Rectangle2D.Float(0, H / 2, W / 2, H / 2))); - } - return outerDecoration; - } - - private Area middleDecoration; - - private Shape getMiddleDecoration() { - if (middleDecoration == null) { - middleDecoration = new Area(new Ellipse2D.Float(0, 0, 420, 140)); - - Rectangle2D.Float rect = new Rectangle2D.Float(180, 69, 500, 3); - - for (float deg = 120; deg <= 335; deg += 4.8f) { - Area rectArea = new Area(rect); - - rectArea.transform(AffineTransform.getRotateInstance(Math.toRadians(deg), 151, 72)); - middleDecoration.subtract(rectArea); - } - - middleDecoration.subtract(new Area(new Ellipse2D.Float(18, 2, 408, 144))); - } - return middleDecoration; - } - - private Area innerSubDecoration; - - private Shape getInnerSubDecoration() { - if (innerSubDecoration == null) { - innerSubDecoration = new Area(new Ellipse2D.Float(0, 0, 356, 114)); - innerSubDecoration.subtract( - new Area(new Rectangle2D.Float(Float.MIN_VALUE, Float.MIN_VALUE, Float.MAX_VALUE, 88))); - innerSubDecoration.subtract( - new Area(new Rectangle2D.Float(Float.MIN_VALUE, Float.MIN_VALUE, 184, Float.MAX_VALUE))); - innerSubDecoration.subtract(new Area(new Rectangle2D.Float(209, Float.MIN_VALUE, 3, Float.MAX_VALUE))); - } - return innerSubDecoration; - } - - private Area innerDecoration; - - private Shape getInnerDecoration() { - if (innerDecoration == null) { - innerDecoration = new Area(new Ellipse2D.Float(0, 0, 368, 120)); - innerDecoration.subtract(new Area(new Rectangle2D.Float(Float.MIN_VALUE, 30, Float.MAX_VALUE, 56))); - innerDecoration.subtract(new Area(new Rectangle2D.Float(181, Float.MIN_VALUE, 7, Float.MAX_VALUE))); - } - return innerDecoration; - } - - private GeneralPath robocodeTextPath; - - public GeneralPath getRobocodeText() { - if (robocodeTextPath == null) { - robocodeTextPath = new GeneralPath(); - - GeneralPath R = getPathR(); - GeneralPath o = getPathO(); - GeneralPath b = getPathB(); - GeneralPath c = getPathC(); - GeneralPath d = getPathD(); - GeneralPath e = getPathE(); - - robocodeTextPath.append(R, false); - - o.transform(AffineTransform.getTranslateInstance(42, 16)); - robocodeTextPath.append(o, false); - - b.transform(AffineTransform.getTranslateInstance(84, 0)); - robocodeTextPath.append(b, false); - - o.transform(AffineTransform.getTranslateInstance(127 - 42, 0)); - robocodeTextPath.append(o, false); - - c.transform(AffineTransform.getTranslateInstance(170, 16)); - robocodeTextPath.append(c, false); - - o.transform(AffineTransform.getTranslateInstance(204 - 127, 0)); - robocodeTextPath.append(o, false); - - d.transform(AffineTransform.getTranslateInstance(246, 0)); - robocodeTextPath.append(d, false); - - e.transform(AffineTransform.getTranslateInstance(290, 16)); - robocodeTextPath.append(e, false); - } - return robocodeTextPath; - } - - private GeneralPath getPathR() { - GeneralPath path = new GeneralPath(I_SHAPE); - - GeneralPath bow = getPathPBow(); - - bow.transform(AffineTransform.getTranslateInstance(15, 0)); - path.append(bow, false); - - path.moveTo(21, 29); - path.lineTo(31, 46); - path.lineTo(44.5f, 46); - path.lineTo(33.5f, 27); - path.curveTo(33.5f, 27, 31, 29, 21, 29); - path.closePath(); - - return path; - } - - private GeneralPath getPathO() { - GeneralPath path = getPathOBow(); - - path.transform(AffineTransform.getTranslateInstance(20, 0)); - - GeneralPath bow2 = getPathOBow(); - - bow2.transform(AffineTransform.getScaleInstance(-1, 1)); - bow2.transform(AffineTransform.getTranslateInstance(18, 0)); - path.append(bow2, false); - - return path; - } - - private GeneralPath getPathB() { - GeneralPath path = new GeneralPath(I_SHAPE); - - GeneralPath bow = getPathPBow(); - - bow.transform(AffineTransform.getTranslateInstance(15, 20)); - path.append(bow, false); - - return path; - } - - private GeneralPath getPathC() { - GeneralPath path = getPathCBow(); - - GeneralPath bow2 = getPathCBow(); - - bow2.transform(AffineTransform.getScaleInstance(1, -1)); - bow2.transform(AffineTransform.getTranslateInstance(0, 31)); - path.append(bow2, false); - - return path; - } - - private GeneralPath getPathD() { - GeneralPath path = new GeneralPath(I_SHAPE); - - path.transform(AffineTransform.getTranslateInstance(27, 0)); - - GeneralPath bow = getPathPBow(); - - bow.transform(AffineTransform.getScaleInstance(-1, 1)); - bow.transform(AffineTransform.getTranslateInstance(25, 20)); - path.append(bow, false); - - return path; - } - - private GeneralPath getPathE() { - GeneralPath path = new GeneralPath(); - - path.moveTo(0, 14.5f); - path.lineTo(31, 14.5f); - path.curveTo(31, -4.5f, 0, -4.5f, 0, 14.5f); - path.closePath(); - - path.moveTo(12, 11); - path.lineTo(20, 11); - path.curveTo(20, 8, 12, 8, 12, 11); - path.closePath(); - - GeneralPath bow2 = getPathCBow(); - - bow2.transform(AffineTransform.getScaleInstance(1, -1)); - bow2.transform(AffineTransform.getTranslateInstance(0, 31)); - path.append(bow2, false); - - return path; - } - - private GeneralPath getPathPBow() { - GeneralPath path = new GeneralPath(); - - path.moveTo(0, 0); - path.lineTo(10, 0); - path.curveTo(30, 0, 30, 26, 10, 26); - path.lineTo(0, 26); - path.lineTo(0, 17); - path.lineTo(8, 17); - path.curveTo(14, 18, 14, 9, 8, 9); - path.lineTo(0, 9); - path.lineTo(0, 0); - path.closePath(); - - return path; - } - - private GeneralPath getPathOBow() { - GeneralPath path = new GeneralPath(); - - path.moveTo(0, 0); - path.curveTo(23, 0, 23, 31, 0, 31); - path.lineTo(0, 20); - path.curveTo(8, 20, 8, 11, 0, 11); - path.lineTo(0, 0); - path.closePath(); - - return path; - } - - private GeneralPath getPathCBow() { - GeneralPath path = new GeneralPath(); - - path.moveTo(31, 12); - path.curveTo(29, -3.5f, 2, -5.5f, 0, 14.5f); - path.lineTo(11, 14.5f); - path.curveTo(11, 8.5f, 18, 9, 18, 12); - path.lineTo(31, 12); - path.closePath(); - - return path; - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/ConfirmPanel.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/ConfirmPanel.java deleted file mode 100644 index 2b68ac3..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/ConfirmPanel.java +++ /dev/null @@ -1,123 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.packager; - - -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.ui.dialog.WizardPanel; - -import javax.swing.*; -import java.awt.*; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -@SuppressWarnings("serial") -public class ConfirmPanel extends WizardPanel { - private final RobotPackager robotPackager; - private final EventHandler eventHandler = new EventHandler(); - private boolean visible; - private JPanel robotListPanel; - - private class EventHandler implements ComponentListener { - public void componentMoved(ComponentEvent e) {} - - public void componentResized(ComponentEvent e) {} - - public void componentHidden(ComponentEvent e) { - visible = false; - fireStateChanged(); - } - - public void componentShown(ComponentEvent e) { - if (robotPackager != null) { - visible = true; - updateFields(); - fireStateChanged(); - repaint(); - } - } - } - - public ConfirmPanel(RobotPackager robotPackager) { - super(); - this.robotPackager = robotPackager; - initialize(); - } - - public JPanel getRobotListPanel() { - if (robotListPanel == null) { - robotListPanel = new JPanel(); - robotListPanel.setLayout(new BoxLayout(robotListPanel, BoxLayout.Y_AXIS)); - robotListPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - } - return robotListPanel; - } - - private void initialize() { - setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - addComponentListener(eventHandler); - add(new JPanel()); - } - - @Override - public boolean isReady() { - return visible; - } - - public void setSelectedRobots(List selectedRobots) { - getRobotListPanel().removeAll(); - - if (selectedRobots == null || selectedRobots.size() == 0) { - getRobotListPanel().add(new JLabel("You have not yet selected any robots.")); - } else if (selectedRobots.size() == 1) { - String robotName = (selectedRobots.get(0)).getFullClassName(); - getRobotListPanel().add(new JLabel("You have selected " + robotName + " for packaging.")); - } else { - getRobotListPanel().add(new JLabel("You have selected the following robots for packaging:")); - for (IRobotSpecItem selected : selectedRobots) { - getRobotListPanel().add(new JLabel(selected.getFullClassName())); - } - } - getRobotListPanel().add(new JLabel("")); - getRobotListPanel().setMaximumSize(new Dimension(10000, robotListPanel.getPreferredSize().height)); - - validate(); - } - - public void updateFields() { - removeAll(); - setSelectedRobots(robotPackager.getRobotSelectionPanel().getSelectedRobots()); - add(getRobotListPanel()); - add(Box.createVerticalStrut(20)); - if (robotPackager.getPackagerOptionsPanel().getIncludeSource().isSelected()) { - add(new JLabel("Java source files will be included.")); - } else { - add(new JLabel("Java source files will NOT be included.")); - } - if (robotPackager.getPackagerOptionsPanel().getIncludeData().isSelected()) { - add(new JLabel("Data files will be included, if they exists.")); - } else { - add(new JLabel("Data source files will NOT be included.")); - } - add(Box.createVerticalStrut(20)); - add(new JLabel("The package will be saved in: " + robotPackager.getFilenamePanel().getFilenameField().getText())); - add(Box.createVerticalStrut(20)); - add(new JLabel("If all of the above is correct, click the Package button to start packaging.")); - add(new JPanel()); - - revalidate(); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/FilenamePanel.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/FilenamePanel.java deleted file mode 100644 index 4a9aceb..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/FilenamePanel.java +++ /dev/null @@ -1,269 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.packager; - - -import net.sf.robocode.io.FileUtil; -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.ui.dialog.WizardPanel; - -import javax.swing.*; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import javax.swing.text.Caret; -import java.awt.*; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.ComponentEvent; -import java.awt.event.ComponentListener; -import java.io.File; -import java.lang.reflect.InvocationTargetException; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -@SuppressWarnings("serial") -public class FilenamePanel extends WizardPanel { - private final RobotPackager robotPackager; - - private final EventHandler eventHandler = new EventHandler(); - private boolean robocodeErrorShown; - - private JButton browseButton; - private JTextField filenameField; - - private class EventHandler implements ActionListener, DocumentListener, ComponentListener { - public void insertUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void changedUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void removeUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void actionPerformed(ActionEvent e) { - if (e.getSource() == getBrowseButton()) { - showFileSelectDialog(); - } - } - - public void componentMoved(ComponentEvent e) {} - - public void componentResized(ComponentEvent e) {} - - public void componentHidden(ComponentEvent e) {} - - public void componentShown(ComponentEvent e) { - String fileName = FileUtil.getRobotsDir().getAbsolutePath() + File.separator; - File outgoingFile = new File(fileName); - - if (!outgoingFile.exists()) { - if (!outgoingFile.mkdirs()) { - Logger.logError("Cannot create: " + outgoingFile); - } - } - String jarName = "myrobots.jar"; - List selectedRobots = robotPackager.getRobotSelectionPanel().getSelectedRobots(); - - if (selectedRobots != null && selectedRobots.size() == 1) { - jarName = selectedRobots.get(0).getFullClassName() + "_" - + robotPackager.getPackagerOptionsPanel().getVersionField().getText() + ".jar"; - } - - getFilenameField().setText(fileName + jarName); - Caret caret = getFilenameField().getCaret(); - - caret.setDot(fileName.length()); - caret.moveDot(fileName.length() + jarName.length() - 4); - - getFilenameField().requestFocus(); - } - } - - public FilenamePanel(RobotPackager robotPackager) { - super(); - this.robotPackager = robotPackager; - initialize(); - } - - private void initialize() { - setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - addComponentListener(eventHandler); - - GridBagLayout layout = new GridBagLayout(); - - setLayout(layout); - GridBagConstraints c = new GridBagConstraints(); - - c.insets = new Insets(5, 5, 5, 5); - c.anchor = GridBagConstraints.NORTHWEST; - - c.fill = GridBagConstraints.HORIZONTAL; - c.gridwidth = 1; - c.weightx = 1; - - add(new JLabel("Please type in a .jar file to save this robot package to: "), c); - - c.gridy = 1; - add(getFilenameField(), c); - - c.fill = GridBagConstraints.NONE; - c.gridy = 2; - c.insets = new Insets(3, 3, 3, 3); - add(getBrowseButton(), c); - - c.fill = GridBagConstraints.VERTICAL; - c.weighty = 1; - c.gridy = 3; - add(new JPanel(), c); - } - - @Override - public boolean isReady() { - if (filenameField.getText() == null) { - return false; - } - int robocodeIndex = filenameField.getText().lastIndexOf(File.separatorChar); - - if (robocodeIndex > 0) { - if (filenameField.getText().substring(robocodeIndex + 1).indexOf("robocode") == 0) { - if (!robocodeErrorShown) { - robocodeErrorShown = true; - new Thread(new Runnable() { - public void run() { - JOptionPane.showMessageDialog(FilenamePanel.this, "Filename cannot begin with robocode"); - } - }).start(); - } - return false; - } - } - return (filenameField.getText().toLowerCase().indexOf(".jar") != 0); - } - - public static void main(String[] args) { - JFrame frame = new JFrame("options"); - - frame.setSize(new Dimension(500, 300)); - frame.getContentPane().add(new FilenamePanel(null)); - - try { - SwingUtilities.invokeAndWait(new ShowFrameWorker(frame)); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - - public JButton getBrowseButton() { - if (browseButton == null) { - browseButton = new JButton("Browse"); - browseButton.addActionListener(eventHandler); - } - return browseButton; - } - - public JTextField getFilenameField() { - if (filenameField == null) { - filenameField = new JTextField("(none selected)", 60); - filenameField.getDocument().addDocumentListener(eventHandler); - } - return filenameField; - } - - public void showFileSelectDialog() { - File f = new File("outgoing" + File.separatorChar); - - JFileChooser chooser = new JFileChooser(f); - - chooser.setCurrentDirectory(f); - - javax.swing.filechooser.FileFilter filter = new javax.swing.filechooser.FileFilter() { - @Override - public boolean accept(File pathname) { - if (pathname.isDirectory()) { - return true; - } - String fn = pathname.getName(); - int idx = fn.lastIndexOf('.'); - String extension = ""; - - if (idx >= 0) { - extension = fn.substring(idx); - } - return extension.equalsIgnoreCase(".jar"); - } - - @Override - public String getDescription() { - return "JAR files"; - } - }; - - chooser.setFileFilter(filter); - - boolean done = false; - - while (!done) { - done = true; - int rv = chooser.showSaveDialog(this); - String robotFileName; - - if (rv == JFileChooser.APPROVE_OPTION) { - robotFileName = chooser.getSelectedFile().getPath(); - if (robotFileName.toLowerCase().indexOf(".jar") < 0) { - robotFileName += ".jar"; - } - File outFile = new File(robotFileName); - - if (outFile.exists()) { - int ok = JOptionPane.showConfirmDialog(this, - robotFileName + " already exists. Are you sure you want to replace it?", "Warning", - JOptionPane.YES_NO_CANCEL_OPTION); - - if (ok == JOptionPane.NO_OPTION) { - done = false; - continue; - } - if (ok == JOptionPane.CANCEL_OPTION) { - return; - } - } - getFilenameField().setText(robotFileName); - fireStateChanged(); - } - } - } - - static class ShowFrameWorker implements Runnable { - final JFrame frame; - - public ShowFrameWorker(JFrame frame) { - this.frame = frame; - } - - public void run() { - if (frame != null) { - frame.setVisible(true); - } - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/PackagerOptionsPanel.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/PackagerOptionsPanel.java deleted file mode 100644 index c8ad5cb..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/PackagerOptionsPanel.java +++ /dev/null @@ -1,405 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.packager; - - -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.ui.dialog.WizardPanel; -import net.sf.robocode.ui.util.LimitedDocument; - -import javax.swing.*; -import javax.swing.event.DocumentEvent; -import javax.swing.event.DocumentListener; -import java.awt.*; -import java.awt.event.*; -import java.lang.reflect.InvocationTargetException; -import java.net.URL; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -@SuppressWarnings("serial") -public class PackagerOptionsPanel extends WizardPanel { - private final RobotPackager robotPackager; - - private final EventHandler eventHandler = new EventHandler(); - - private JCheckBox includeSource; - private JCheckBox includeData; - private JLabel authorLabel; - private JTextField authorField; - private JLabel descriptionLabel; - private JTextArea descriptionArea; - private JLabel versionLabel; - private JTextField versionField; - private JLabel versionHelpLabel; - private JLabel webpageLabel; - private JTextField webpageField; - private JLabel webpageHelpLabel; - - private List currentSelectedRobots; - - private class EventHandler implements ComponentListener, KeyListener, DocumentListener { - public void insertUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void changedUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void removeUpdate(DocumentEvent e) { - fireStateChanged(); - } - - public void componentMoved(ComponentEvent e) {} - - public void componentHidden(ComponentEvent e) {} - - public void componentShown(ComponentEvent e) { - List selectedRobots = robotPackager.getRobotSelectionPanel().getSelectedRobots(); - - // Make sure we don't reset content. Bug fix [3026856] - if (selectedRobots == null || selectedRobots.equals(currentSelectedRobots)) { - return; - } - currentSelectedRobots = selectedRobots; // Bug fix [3026856] - - if (selectedRobots.size() == 1) { - IRobotSpecItem robotSpecItem = selectedRobots.get(0); - - getIncludeSource().setSelected(robotSpecItem.getIncludeSource()); - - getIncludeData().setSelected(robotSpecItem.getIncludeData()); - - String ver = robotSpecItem.getVersion(); - if (ver == null || ver.length() == 0) { - getVersionHelpLabel().setVisible(false); - ver = "1.0"; - } else { - if (ver.length() == 10) { - ver = ver.substring(0, 9); - } - ver += "*"; - getVersionHelpLabel().setVisible(true); - } - getVersionField().setText(ver); - - String desc = robotSpecItem.getDescription(); - if (desc == null) { - desc = ""; - } - getDescriptionArea().setText(desc); - - String author = robotSpecItem.getAuthorName(); - if (author == null) { - author = ""; - } - getAuthorField().setText(author); - - URL url = robotSpecItem.getWebpage(); - String webPage = (url != null) ? url.toString() : ""; - getWebpageField().setText(webPage); - - String fullPackage = robotSpecItem.getFullPackage(); - - String text = ""; - if (fullPackage != null && fullPackage.indexOf(".") != -1) { - String htmlFileName = fullPackage.substring(0, fullPackage.lastIndexOf(".")) + ".html"; - - text = "(You may also leave this blank, and simply create the file: " + htmlFileName + ")"; - } - getWebpageHelpLabel().setText(text); - - getVersionLabel().setVisible(true); - getVersionField().setVisible(true); - getAuthorLabel().setVisible(true); - getAuthorField().setVisible(true); - getWebpageLabel().setVisible(true); - getWebpageField().setVisible(true); - getWebpageHelpLabel().setVisible(true); - getDescriptionLabel().setText( - "Please enter a short description of your robot (up to 3 lines of 72 chars each)."); - } else if (selectedRobots.size() > 1) { - getVersionLabel().setVisible(false); - getVersionField().setVisible(false); - getVersionHelpLabel().setVisible(false); - getAuthorLabel().setVisible(false); - getAuthorField().setVisible(false); - getWebpageLabel().setVisible(false); - getWebpageField().setVisible(false); - getWebpageHelpLabel().setVisible(false); - getDescriptionLabel().setText( - "Please enter a short description of this robot collection (up to 3 lines of 72 chars each)."); - if (getDescriptionArea().getText() == null || getDescriptionArea().getText().length() == 0) { - getDescriptionArea().setText("(Example)This robot comes from the ... robot collection\n"); - } - } - } - - public void componentResized(ComponentEvent e) {} - - public void keyPressed(KeyEvent e) {} - - public void keyReleased(KeyEvent e) {} - - public void keyTyped(KeyEvent e) {} - } - - public JPanel robotListPanel; - - public PackagerOptionsPanel(RobotPackager robotPackager) { - super(); - this.robotPackager = robotPackager; - initialize(); - } - - private void initialize() { - setBorder(BorderFactory.createEmptyBorder(10, 10, 10, 10)); - setLayout(new BoxLayout(this, BoxLayout.Y_AXIS)); - - JLabel label = new JLabel( - "It is up to you whether or not to include the source files when you distribute your robot."); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - label = new JLabel( - "If you include the source files, other people will be able to look at your code and learn from it."); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - getIncludeSource().setAlignmentX(Component.LEFT_ALIGNMENT); - add(getIncludeSource()); - - label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - label = new JLabel("You may include the source files too if they are available?"); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - getIncludeData().setAlignmentX(Component.LEFT_ALIGNMENT); - add(getIncludeData()); - - label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - add(getVersionLabel()); - - JPanel versionPanel = new JPanel(); - versionPanel.setLayout(new FlowLayout(FlowLayout.LEFT, 0, 0)); - versionPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - getVersionField().setAlignmentX(Component.LEFT_ALIGNMENT); - getVersionField().setMaximumSize(getVersionField().getPreferredSize()); - versionPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, getVersionField().getPreferredSize().height)); - versionPanel.add(getVersionField()); - versionPanel.add(getVersionHelpLabel()); - add(versionPanel); - - label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - add(getDescriptionLabel()); - - JScrollPane scrollPane = new JScrollPane(getDescriptionArea(), ScrollPaneConstants.VERTICAL_SCROLLBAR_NEVER, - ScrollPaneConstants.HORIZONTAL_SCROLLBAR_ALWAYS); - - scrollPane.setMaximumSize(scrollPane.getPreferredSize()); - scrollPane.setMinimumSize(new Dimension(100, scrollPane.getPreferredSize().height)); - scrollPane.setAlignmentX(Component.LEFT_ALIGNMENT); - add(scrollPane); - - label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - add(getAuthorLabel()); - - getAuthorField().setAlignmentX(Component.LEFT_ALIGNMENT); - getAuthorField().setMaximumSize(getAuthorField().getPreferredSize()); - add(getAuthorField()); - - label = new JLabel(" "); - label.setAlignmentX(Component.LEFT_ALIGNMENT); - add(label); - - add(getWebpageLabel()); - - getWebpageField().setAlignmentX(Component.LEFT_ALIGNMENT); - getWebpageField().setMaximumSize(getWebpageField().getPreferredSize()); - add(getWebpageField()); - - getWebpageHelpLabel().setAlignmentX(Component.LEFT_ALIGNMENT); - add(getWebpageHelpLabel()); - - JPanel panel = new JPanel(); - - panel.setAlignmentX(Component.LEFT_ALIGNMENT); - add(panel); - addComponentListener(eventHandler); - } - - @Override - public boolean isReady() { - if (getVersionLabel().isVisible()) { - String text = getVersionField().getText(); - - if (text.length() == 0 || !text.matches("([a-zA-Z0-9.])*[a-zA-Z0-9]+")) { - return false; - } - } - return getDescriptionArea().getText().length() != 0; - } - - public static void main(String[] args) { - JFrame frame = new JFrame("options"); - - frame.setSize(new Dimension(500, 300)); - frame.getContentPane().add(new PackagerOptionsPanel(null)); - - frame.addWindowListener(new WindowAdapter() { - @Override - public void windowClosing(WindowEvent e) { - e.getWindow().dispose(); - } - - @Override - public void windowClosed(WindowEvent e) { - System.exit(0); - } - }); - - try { - SwingUtilities.invokeAndWait(new PackAndShowFrameWorker(frame)); - } catch (InterruptedException e) { - // Immediately reasserts the exception by interrupting the caller thread itself - Thread.currentThread().interrupt(); - - e.printStackTrace(); - } catch (InvocationTargetException e) { - e.printStackTrace(); - } - } - - public JCheckBox getIncludeSource() { - if (includeSource == null) { - includeSource = new JCheckBox("Include source files", true); - } - return includeSource; - } - - public JCheckBox getIncludeData() { - if (includeData == null) { - includeData = new JCheckBox("Include data files", true); - } - return includeData; - } - - private JLabel getAuthorLabel() { - if (authorLabel == null) { - authorLabel = new JLabel("Please enter your name. (optional)"); - authorLabel.setAlignmentX(Component.LEFT_ALIGNMENT); - } - return authorLabel; - } - - public JTextField getAuthorField() { - if (authorField == null) { - authorField = new JTextField(40); - } - return authorField; - } - - public JLabel getDescriptionLabel() { - if (descriptionLabel == null) { - descriptionLabel = new JLabel(""); - descriptionLabel.setAlignmentX(Component.LEFT_ALIGNMENT); - } - return descriptionLabel; - } - - public JTextArea getDescriptionArea() { - if (descriptionArea == null) { - LimitedDocument doc = new LimitedDocument(3, 72); - - descriptionArea = new JTextArea(doc, null, 3, 72); - doc.addDocumentListener(eventHandler); - } - return descriptionArea; - } - - private JLabel getVersionLabel() { - if (versionLabel == null) { - versionLabel = new JLabel( - "Please enter a version number for this robot (up to 10 word chars: letters, digits, dots, but no spaces)."); - versionLabel.setAlignmentX(Component.LEFT_ALIGNMENT); - } - return versionLabel; - } - - public JTextField getVersionField() { - if (versionField == null) { - LimitedDocument doc = new LimitedDocument(1, 10); - - versionField = new JTextField(doc, null, 10); - doc.addDocumentListener(eventHandler); - } - return versionField; - } - - public JLabel getVersionHelpLabel() { - if (versionHelpLabel == null) { - versionHelpLabel = new JLabel("<-- Make sure to delete the asterisk and type in a new version number"); - } - return versionHelpLabel; - } - - public JLabel getWebpageLabel() { - if (webpageLabel == null) { - webpageLabel = new JLabel("Please enter a URL for your robot's webpage. (optional)"); - webpageLabel.setAlignmentX(Component.LEFT_ALIGNMENT); - } - return webpageLabel; - } - - public JTextField getWebpageField() { - if (webpageField == null) { - webpageField = new JTextField(40); - } - return webpageField; - } - - public JLabel getWebpageHelpLabel() { - if (webpageHelpLabel == null) { - webpageHelpLabel = new JLabel(""); - } - return webpageHelpLabel; - } - - static class PackAndShowFrameWorker implements Runnable { - final JFrame frame; - - public PackAndShowFrameWorker(JFrame frame) { - this.frame = frame; - } - - public void run() { - if (frame != null) { - frame.pack(); - frame.setVisible(true); - } - } - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/RobotPackager.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/RobotPackager.java deleted file mode 100644 index 4dd5214..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/packager/RobotPackager.java +++ /dev/null @@ -1,233 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.packager; - - -import net.sf.robocode.io.Logger; -import net.sf.robocode.repository.IRobotSpecItem; -import net.sf.robocode.repository.IRepositoryManager; -import net.sf.robocode.repository.RobotProperties; -import net.sf.robocode.ui.IWindowManager; -import net.sf.robocode.ui.dialog.*; -import static net.sf.robocode.ui.util.ShortcutUtil.MENU_SHORTCUT_KEY_MASK; - -import javax.swing.*; - -import java.awt.BorderLayout; -import java.awt.event.ActionEvent; -import java.awt.event.ActionListener; -import java.awt.event.KeyEvent; -import java.io.File; -import java.net.MalformedURLException; -import java.net.URL; -import java.util.List; - - -/** - * @author Mathew A. Nelson (original) - * @author Matthew Reeder (contributor) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - */ -@SuppressWarnings("serial") -public class RobotPackager extends JDialog implements WizardListener { - - private final int minRobots = 1; - private final int maxRobots = 1; // 250; - - private JPanel robotPackagerContentPane; - private WizardCardPanel wizardPanel; - private WizardController buttonsPanel; - private FilenamePanel filenamePanel; - private ConfirmPanel confirmPanel; - private RobotSelectionPanel robotSelectionPanel; - private PackagerOptionsPanel packagerOptionsPanel; - - private final IRepositoryManager repositoryManager; - private final IWindowManager windowManager; - - private final EventHandler eventHandler = new EventHandler(); - - private class EventHandler implements ActionListener { - public void actionPerformed(ActionEvent e) { - if (e.getActionCommand().equals("Refresh")) { - getRobotSelectionPanel().refreshRobotList(true); - } - } - } - - public RobotPackager(IRepositoryManager repositoryManager, IWindowManager windowManager) { - super(windowManager.getRobocodeFrame()); - this.repositoryManager = repositoryManager; - this.windowManager = windowManager; - initialize(); - } - - public void cancelButtonActionPerformed() { - dispose(); - } - - /** - * Return the buttonsPanel - * - * @return JButton - */ - private WizardController getButtonsPanel() { - if (buttonsPanel == null) { - buttonsPanel = getWizardPanel().getWizardController(); - } - return buttonsPanel; - } - - /** - * Return the buttonsPanel - * - * @return JButton - */ - private ConfirmPanel getConfirmPanel() { - if (confirmPanel == null) { - confirmPanel = new ConfirmPanel(this); - } - return confirmPanel; - } - - /** - * Return the optionsPanel - * - * @return robocode.packager.PackagerOptionsPanel - */ - protected FilenamePanel getFilenamePanel() { - if (filenamePanel == null) { - filenamePanel = new FilenamePanel(this); - } - return filenamePanel; - } - - /** - * Return the optionsPanel - * - * @return robocode.packager.PackagerOptionsPanel - */ - protected PackagerOptionsPanel getPackagerOptionsPanel() { - if (packagerOptionsPanel == null) { - packagerOptionsPanel = new PackagerOptionsPanel(this); - } - return packagerOptionsPanel; - } - - /** - * Return the newBattleDialogContentPane - * - * @return JPanel - */ - private JPanel getRobotPackagerContentPane() { - if (robotPackagerContentPane == null) { - robotPackagerContentPane = new JPanel(); - robotPackagerContentPane.setLayout(new BorderLayout()); - robotPackagerContentPane.add(getButtonsPanel(), BorderLayout.SOUTH); - robotPackagerContentPane.add(getWizardPanel(), BorderLayout.CENTER); - getWizardPanel().getWizardController().setFinishButtonTextAndMnemonic("Package!", 'P', 0); - robotPackagerContentPane.registerKeyboardAction(eventHandler, "Refresh", - KeyStroke.getKeyStroke(KeyEvent.VK_R, MENU_SHORTCUT_KEY_MASK), - JComponent.WHEN_ANCESTOR_OF_FOCUSED_COMPONENT); - robotPackagerContentPane.registerKeyboardAction(eventHandler, "Refresh", - KeyStroke.getKeyStroke(KeyEvent.VK_R, MENU_SHORTCUT_KEY_MASK), JComponent.WHEN_FOCUSED); - } - return robotPackagerContentPane; - } - - /** - * Return the Page property value. - * - * @return JPanel - */ - public RobotSelectionPanel getRobotSelectionPanel() { - if (robotSelectionPanel == null) { - robotSelectionPanel = net.sf.robocode.core.Container.createComponent(RobotSelectionPanel.class); - robotSelectionPanel.setup(minRobots, maxRobots, false, "Select the robot or team you would like to package.", /* true */ - false, - false, false/* true */, true, false, true, null); - } - return robotSelectionPanel; - } - - /** - * Return the tabbedPane. - * - * @return JTabbedPane - */ - private WizardCardPanel getWizardPanel() { - if (wizardPanel == null) { - wizardPanel = new WizardCardPanel(this); - wizardPanel.add(getRobotSelectionPanel(), "Select robot"); - wizardPanel.add(getPackagerOptionsPanel(), "Select options"); - wizardPanel.add(getFilenamePanel(), "Select filename"); - wizardPanel.add(getConfirmPanel(), "Confirm"); - } - return wizardPanel; - } - - private void initialize() { - setDefaultCloseOperation(WindowConstants.DISPOSE_ON_CLOSE); - setTitle("Robot Packager"); - setContentPane(getRobotPackagerContentPane()); - } - - public void finishButtonActionPerformed() { - String jarFilename = getFilenamePanel().getFilenameField().getText(); - File jarFile = new File(jarFilename); - - if (jarFile.exists()) { - int ok = JOptionPane.showConfirmDialog(this, - jarFilename + " already exists. Are you sure you want to replace it?", "Warning", - JOptionPane.YES_NO_CANCEL_OPTION); - - if (ok == JOptionPane.NO_OPTION || ok == JOptionPane.CANCEL_OPTION) { - Logger.logMessage("Cancelled by user."); - return; - } - Logger.logMessage("Overwriting " + jarFilename); - } - - String webPageFieldString = getPackagerOptionsPanel().getWebpageField().getText(); - URL webPage = null; - - if (webPageFieldString.length() > 0) { - try { - webPage = new URL(webPageFieldString); - } catch (MalformedURLException e) { - try { - webPage = new URL("http://" + webPageFieldString); - getPackagerOptionsPanel().getWebpageField().setText(webPage.toString()); - } catch (MalformedURLException ignored) {} - } - } - boolean includeSource = getPackagerOptionsPanel().getIncludeSource().isSelected(); - boolean includeData = getPackagerOptionsPanel().getIncludeData().isSelected(); - String version = getPackagerOptionsPanel().getVersionField().getText(); - String author = getPackagerOptionsPanel().getAuthorField().getText(); - String desc = getPackagerOptionsPanel().getDescriptionArea().getText(); - List robots = getRobotSelectionPanel().getSelectedRobots(); - - RobotProperties props = new RobotProperties(); - props.setIncludeSource(includeSource); - props.setIncludeData(includeData); - props.setVersion(version); - props.setAuthor(author); - props.setDescription(desc); - props.setWebPage(webPage); - - String outputText = repositoryManager.createPackage(jarFile, robots, props); - - ConsoleDialog dialog = new ConsoleDialog(windowManager.getRobocodeFrame(), "Packaging results", false); - dialog.setText(outputText); - dialog.pack(); - WindowUtil.packCenterShow(this, dialog); - dispose(); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/util/LimitedClassnameDocument.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/util/LimitedClassnameDocument.java deleted file mode 100644 index be2b543..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/util/LimitedClassnameDocument.java +++ /dev/null @@ -1,52 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.util; - - -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; - - -/** - * @author Mathew A. Nelson (original) - */ -@SuppressWarnings("serial") -public class LimitedClassnameDocument extends LimitedDocument { - - public LimitedClassnameDocument() { - super(); - } - - public LimitedClassnameDocument(int maxRows, int maxCols) { - super(maxRows, maxCols); - } - - @Override - public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { - if (offs == 0 && str.length() > 0) { - if (!Character.isJavaIdentifierStart(str.charAt(0))) { - java.awt.Toolkit.getDefaultToolkit().beep(); - return; - } - } else { - for (int i = 0; i < str.length(); i++) { - if (!Character.isJavaIdentifierPart(str.charAt(i))) { - java.awt.Toolkit.getDefaultToolkit().beep(); - return; - } - } - } - if (offs == 0) { - if (!Character.isUpperCase(str.charAt(0))) { - str = str.substring(0, 1).toUpperCase() + str.substring(1); - } - } - - super.insertString(offs, str, a); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/util/LimitedDocument.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/util/LimitedDocument.java deleted file mode 100644 index 5d64e37..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/util/LimitedDocument.java +++ /dev/null @@ -1,103 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.util; - - -import javax.swing.text.AttributeSet; -import javax.swing.text.BadLocationException; -import javax.swing.text.Element; -import javax.swing.text.PlainDocument; -import java.awt.*; - - -/** - * @author Mathew A. Nelson (original) - */ -@SuppressWarnings("serial") -public class LimitedDocument extends PlainDocument { - int maxRows = Integer.MAX_VALUE; - int maxCols = Integer.MAX_VALUE; - - public LimitedDocument() { - super(); - } - - public LimitedDocument(int maxRows, int maxCols) { - super(); - this.maxRows = maxRows; - this.maxCols = maxCols; - } - - @Override - public void insertString(int offs, String str, AttributeSet a) throws BadLocationException { - Element rootElement = getDefaultRootElement(); - int i = str.indexOf("\n"); - int newlines = 0; - - while (i < str.length() && i >= 0) { - newlines++; - i = str.indexOf("\n", i + 1); - } - - int currentLines = rootElement.getElementCount(); - - if (newlines > 0 && currentLines + newlines > maxRows) { - Toolkit.getDefaultToolkit().beep(); - return; - } - - int lineIndex = rootElement.getElementIndex(offs); - boolean done = false; - - int carry = rootElement.getElement(lineIndex).getEndOffset() - offs - 1; - int lineStart = 0; - - while (!done) { - int lineEnd = str.indexOf("\n", lineStart); - - if (lineEnd == -1 || lineEnd == str.length()) { - if (lineStart == 0) { - carry = 0; - lineEnd = str.length(); - } else { - lineEnd = str.length() + carry; - } - done = true; - } - int lineLen = lineEnd - lineStart; - // Increment for last line... - int currentLen; - - if (!done && lineStart > 0) { - currentLen = 0; - } else { - if (done && lineStart > 0) { - lineIndex++; - } - Element currentLine = rootElement.getElement(lineIndex); - - if (currentLine != null) { - currentLen = currentLine.getEndOffset() - currentLine.getStartOffset(); - } else { - currentLen = 1; - } - if (lineStart == 0) { - currentLen -= carry; - } - } - if (lineLen + currentLen > maxCols + 1) { - Toolkit.getDefaultToolkit().beep(); - return; - } - - lineStart = lineEnd + 1; - } - - super.insertString(offs, str, a); - } -} diff --git a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/util/ShortcutUtil.java b/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/util/ShortcutUtil.java deleted file mode 100644 index 16f5af5..0000000 --- a/workspace_robo/robocode.ui/src/main/java/net/sf/robocode/ui/util/ShortcutUtil.java +++ /dev/null @@ -1,62 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -package net.sf.robocode.ui.util; - - -import java.awt.*; -import java.awt.event.InputEvent; - - -/** - * Utility for handling shortcut keys. - * - * @author Flemming N. Larsen (original) - */ -public class ShortcutUtil { - - /** - * The menu shortcut key mask. - */ - public final static int MENU_SHORTCUT_KEY_MASK = Toolkit.getDefaultToolkit().getMenuShortcutKeyMask(); - - /** - * Returns the text for the shortcut modifier key. - * - * @return the text for the shortcut modifier key. - */ - public static String getModifierKeyText() { - - boolean isMac = (System.getProperty("os.name").startsWith("Mac")); - - String text = ""; - - if ((MENU_SHORTCUT_KEY_MASK & InputEvent.SHIFT_MASK) == InputEvent.SHIFT_MASK) { - text = "Shift"; - } - if ((MENU_SHORTCUT_KEY_MASK & InputEvent.CTRL_MASK) == InputEvent.CTRL_MASK) { - if (text.length() > 0) { - text += '+'; - } - text = "Ctrl"; - } - if ((MENU_SHORTCUT_KEY_MASK & InputEvent.ALT_MASK) == InputEvent.ALT_MASK) { - if (text.length() > 0) { - text += '+'; - } - text = isMac ? "Opt" : "Alt"; - } - if ((MENU_SHORTCUT_KEY_MASK & InputEvent.META_MASK) == InputEvent.META_MASK) { - if (text.length() > 0) { - text += '+'; - } - text = isMac ? "Cmd" : "Meta"; - } - - return text; - } -} diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/html/about.html b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/html/about.html deleted file mode 100644 index 84d226f..0000000 --- a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/html/about.html +++ /dev/null @@ -1,135 +0,0 @@ - - - - - - - - - - -
-  Robocode version {$robocode-version} - - -
-  © Copyright 2001-2016 Robocode contributors. All rights reserved. -
- - - -
- -Original Author: Mathew A. Nelson. -     -Original Graphics: Garett S. Hourihan. - - - -
- -Running on Java {$java-version} by {$java-vendor}  |   -Download  |   -Java 6 API documentation
- - - - - -
- -ReadMe - |  -License - |  -Home Page - |  -Project Home - |  -Versions - |  -News - |  -RoboWiki - |  -Robocode Repository - |  -Robocode Developers -
-Download - |  -Getting started - |  -Java API - |  -.NET API - |  -FAQ - |  -Google Group - |  -Help Forum - |  -Bug Reports - |  -Feature Requests - -

Main Contributors

-Mathew A. Nelson: Original developer (2001-2005)
-Flemming N. Larsen: Administrator, developer, integrator, lots of features (2005-2016)
-Pavel Savara: Administrator, developer, integrator, robot interfaces, refactorings, .NET plugin (2008-2011)
- -

Contributors

-Aaron Rotenberg: Robot Cache Cleaner utility
-Albert Perez: RoboRumble@Home client
-Alexander Schultz: Reporting lots of bugs and good solutions for fixing these
-Ascander Jr: Graphics for background tiles
-Christian D. Schnell: Codesize 1.0 utility
-Cubic Creative: Design and ideas for the JuniorRobot class
-Dan Lynn: The Robocode Repository that is the central place for storing your robots and also find other robots
-Endre Palatinus, Eniko Nagy, Attila Csizofszki and Laszlo Vigh: Score percentage in results/rankings
-Jerome Lavigne: Added "Smart Battles" to MeleeRumble, developer and admin of the RoboRumble server
-Joachim Hofer: Fixing problem with wrong results in RoboRumble
-Joshua Galecki: Added the RateControlRobot
-Julian Kent: Nano precision timing of allowed robot time
-Luis Crespo: Sound engine, single-step debugging, ranking panel
-Matthew Reeder: Editor enhancements, keyboard shortcuts, HyperThreading bugfixes
-Nathaniel Troutman: Fixing memory leaks
-Patrick Cupka, Julian Kent, Nat Pavasant, and "Positive": Redesigned robot movement method
Robert D. Maupin: Optimizations with collections and improved CPU constant benchmark
-Ruben Moreno Montoliu: Added paths with buttons to Developement Options
-Stefan Westen: onPaint method from RobocodeSG
-Titus Chen: Bugfixes for robot teleportation, bad wall collision detection, team ranking, replay scores and robot color flickering
-Tuan Anh Nguyen: Interactive_v2 sample robot - - - -
- -Thanks goes to every contributor as well to all users reporting bugs and suggesting new features for Robocode. - \ No newline at end of file diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/html/transparent.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/html/transparent.png deleted file mode 100644 index ce0ea77..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/html/transparent.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/icons/robocode-icon.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/icons/robocode-icon.png deleted file mode 100644 index b82402a..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/icons/robocode-icon.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/.cvsignore b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/.cvsignore deleted file mode 100644 index 085e8ba..0000000 --- a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Thumbs.db diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/body.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/body.png deleted file mode 100644 index d6423e2..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/body.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/.cvsignore b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/.cvsignore deleted file mode 100644 index 085e8ba..0000000 --- a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Thumbs.db diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-1.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-1.png deleted file mode 100644 index 61ac8ef..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-1.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-10.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-10.png deleted file mode 100644 index ca933a4..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-10.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-11.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-11.png deleted file mode 100644 index 736ffaf..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-11.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-12.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-12.png deleted file mode 100644 index 6d9f09d..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-12.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-13.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-13.png deleted file mode 100644 index f3afcb8..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-13.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-14.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-14.png deleted file mode 100644 index 4da1cc7..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-14.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-15.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-15.png deleted file mode 100644 index 8301645..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-15.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-16.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-16.png deleted file mode 100644 index 7bfa886..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-16.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-17.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-17.png deleted file mode 100644 index b63bc9a..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-17.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-2.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-2.png deleted file mode 100644 index 4a5abcc..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-2.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-3.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-3.png deleted file mode 100644 index ea053bd..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-3.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-4.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-4.png deleted file mode 100644 index 410627f..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-4.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-5.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-5.png deleted file mode 100644 index 3a13984..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-5.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-6.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-6.png deleted file mode 100644 index faf33e7..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-6.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-7.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-7.png deleted file mode 100644 index b89815d..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-7.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-8.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-8.png deleted file mode 100644 index 1b8f8ab..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-8.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-9.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-9.png deleted file mode 100644 index 25e83b9..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion1-9.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-1.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-1.png deleted file mode 100644 index 480df02..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-1.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-10.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-10.png deleted file mode 100644 index 11183ee..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-10.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-11.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-11.png deleted file mode 100644 index 443f05f..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-11.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-12.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-12.png deleted file mode 100644 index eab21ec..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-12.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-13.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-13.png deleted file mode 100644 index 8046463..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-13.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-14.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-14.png deleted file mode 100644 index 30cb78b..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-14.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-15.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-15.png deleted file mode 100644 index d01ebb7..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-15.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-16.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-16.png deleted file mode 100644 index c879e83..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-16.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-17.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-17.png deleted file mode 100644 index 28a3d65..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-17.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-18.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-18.png deleted file mode 100644 index 03333bd..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-18.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-19.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-19.png deleted file mode 100644 index 36ac235..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-19.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-2.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-2.png deleted file mode 100644 index 8455a93..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-2.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-20.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-20.png deleted file mode 100644 index 244324d..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-20.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-21.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-21.png deleted file mode 100644 index b694fb7..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-21.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-22.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-22.png deleted file mode 100644 index 1b2d721..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-22.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-23.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-23.png deleted file mode 100644 index c510b4f..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-23.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-24.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-24.png deleted file mode 100644 index 904a49d..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-24.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-25.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-25.png deleted file mode 100644 index 2b3abbf..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-25.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-26.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-26.png deleted file mode 100644 index 8ea2597..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-26.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-27.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-27.png deleted file mode 100644 index 6709f40..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-27.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-28.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-28.png deleted file mode 100644 index f2e2a80..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-28.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-29.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-29.png deleted file mode 100644 index 2f65762..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-29.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-3.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-3.png deleted file mode 100644 index 836636a..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-3.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-30.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-30.png deleted file mode 100644 index 2e0d9b1..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-30.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-31.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-31.png deleted file mode 100644 index bc98120..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-31.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-32.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-32.png deleted file mode 100644 index fc22f0d..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-32.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-33.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-33.png deleted file mode 100644 index 69275c6..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-33.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-34.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-34.png deleted file mode 100644 index 190cb40..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-34.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-35.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-35.png deleted file mode 100644 index 2d0ce7b..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-35.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-36.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-36.png deleted file mode 100644 index 31c873a..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-36.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-37.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-37.png deleted file mode 100644 index ff22d4f..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-37.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-38.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-38.png deleted file mode 100644 index 5bf8bd9..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-38.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-39.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-39.png deleted file mode 100644 index 932ff3c..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-39.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-4.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-4.png deleted file mode 100644 index e41c63b..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-4.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-40.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-40.png deleted file mode 100644 index b25365e..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-40.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-41.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-41.png deleted file mode 100644 index 4ade6dd..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-41.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-42.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-42.png deleted file mode 100644 index 0768366..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-42.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-43.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-43.png deleted file mode 100644 index 52c9327..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-43.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-44.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-44.png deleted file mode 100644 index 4251d58..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-44.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-45.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-45.png deleted file mode 100644 index cc4093b..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-45.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-46.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-46.png deleted file mode 100644 index 77d56d1..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-46.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-47.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-47.png deleted file mode 100644 index 2074752..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-47.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-48.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-48.png deleted file mode 100644 index 2518748..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-48.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-49.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-49.png deleted file mode 100644 index 175d74b..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-49.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-5.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-5.png deleted file mode 100644 index 72c8282..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-5.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-50.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-50.png deleted file mode 100644 index c626514..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-50.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-51.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-51.png deleted file mode 100644 index 4bf3a5f..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-51.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-52.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-52.png deleted file mode 100644 index 6bb9c7c..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-52.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-53.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-53.png deleted file mode 100644 index bb59a6c..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-53.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-54.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-54.png deleted file mode 100644 index 6a4d9e2..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-54.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-55.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-55.png deleted file mode 100644 index de6471c..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-55.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-56.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-56.png deleted file mode 100644 index 6eef566..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-56.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-57.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-57.png deleted file mode 100644 index 78ce12a..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-57.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-58.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-58.png deleted file mode 100644 index 41ecd2e..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-58.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-59.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-59.png deleted file mode 100644 index a8f230f..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-59.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-6.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-6.png deleted file mode 100644 index d39c246..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-6.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-60.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-60.png deleted file mode 100644 index 7de79a4..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-60.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-61.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-61.png deleted file mode 100644 index 91e0356..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-61.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-62.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-62.png deleted file mode 100644 index bb5a706..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-62.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-63.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-63.png deleted file mode 100644 index 21311d1..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-63.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-64.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-64.png deleted file mode 100644 index e5ad72e..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-64.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-65.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-65.png deleted file mode 100644 index 52b6c5c..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-65.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-66.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-66.png deleted file mode 100644 index 906f942..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-66.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-67.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-67.png deleted file mode 100644 index 2bdb611..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-67.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-68.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-68.png deleted file mode 100644 index 9d32427..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-68.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-69.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-69.png deleted file mode 100644 index af0e59b..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-69.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-7.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-7.png deleted file mode 100644 index f2b7f04..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-7.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-70.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-70.png deleted file mode 100644 index 44b0af3..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-70.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-71.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-71.png deleted file mode 100644 index 714ceb0..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-71.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-8.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-8.png deleted file mode 100644 index 4cf48c6..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-8.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-9.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-9.png deleted file mode 100644 index e06e3a8..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/explosion/explosion2-9.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/.cvsignore b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/.cvsignore deleted file mode 100644 index 085e8ba..0000000 --- a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/.cvsignore +++ /dev/null @@ -1 +0,0 @@ -Thumbs.db diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_0.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_0.png deleted file mode 100644 index 7ddb683..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_0.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_1.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_1.png deleted file mode 100644 index 5d683a2..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_1.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_2.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_2.png deleted file mode 100644 index ed9c206..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_2.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_3.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_3.png deleted file mode 100644 index b290b82..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_3.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_4.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_4.png deleted file mode 100644 index b5f1141..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/blue_metal/blue_metal_4.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/explode_debris.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/explode_debris.png deleted file mode 100644 index 314f151..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/ground/explode_debris.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/radar.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/radar.png deleted file mode 100644 index 29453c3..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/radar.png and /dev/null differ diff --git a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/turret.png b/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/turret.png deleted file mode 100644 index 354febb..0000000 Binary files a/workspace_robo/robocode.ui/src/main/resources/net/sf/robocode/ui/images/turret.png and /dev/null differ diff --git a/workspace_robo/super-pom/.project b/workspace_robo/super-pom/.project deleted file mode 100644 index e92ba39..0000000 --- a/workspace_robo/super-pom/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - super-pom - - - - - - - - diff --git a/workspace_robo/super-pom/pom.xml b/workspace_robo/super-pom/pom.xml deleted file mode 100644 index 3a29487..0000000 --- a/workspace_robo/super-pom/pom.xml +++ /dev/null @@ -1,179 +0,0 @@ - - - 4.0.0 - net.sf.robocode - super-pom - Robocode Super POM - ${robocode.version} - pom - - Robocode - http://robocode.sf.net - - - cp1252 - 1.9.2.5 - 1.9.2.5 - - - - - net.sf.robocode - Robocode Release Repository - http://robocode.sourceforge.net/maven2/ - - - - - net.sf.robocode - Robocode Plugin Repository - http://robocode.sourceforge.net/maven2 - - - - http://robocode.sourceforge.net/maven2 - - false - net.sf.robocode-upload - robocode release repository - sftp://fnl,robocode@web.sourceforge.net/home/groups/r/ro/robocode/htdocs/maven2 - - - - - - - org.apache.maven.plugins - maven-assembly-plugin - 2.3 - - true - - - - org.apache.maven.plugins - maven-clean-plugin - 2.5 - - - org.apache.maven.plugins - maven-compiler-plugin - 2.5.1 - - 1.6 - 1.6 - 8859_1 - true - - - - org.apache.maven.plugins - maven-dependency-plugin - 2.5.1 - - - org.apache.maven.plugins - maven-deploy-plugin - 2.7 - - true - - - - org.apache.maven.plugins - maven-eclipse-plugin - 2.9 - - - org.apache.maven.plugins - maven-install-plugin - 2.4 - - - org.apache.maven.plugins - maven-jar-plugin - 2.4 - - - false - - - - - org.apache.maven.plugins - maven-javadoc-plugin - 2.9 - - - org.apache.maven.plugins - maven-resources-plugin - 2.6 - - UTF-8 - - - - org.apache.maven.plugins - maven-surefire-plugin - 2.12.4 - - - - - - org.apache.maven.plugins - maven-compiler-plugin - - - org.apache.maven.plugins - maven-resources-plugin - - - org.apache.maven.plugins - maven-surefire-plugin - - - - - src/main/resources - false - - **/_svn/** - **/.svn/** - **/.git/** - - - - src/test/resources - false - - **/_svn/** - **/.svn/** - **/.git/** - - - - src/main/java - false - - **/*.java - **/_svn/** - **/.svn/** - **/.git/** - - - - - - - java8 - - [1.8,) - - - -Xdoclint:none - - - - diff --git a/workspace_robo/super-pom/robocode-license-header.txt b/workspace_robo/super-pom/robocode-license-header.txt deleted file mode 100644 index ae134b9..0000000 --- a/workspace_robo/super-pom/robocode-license-header.txt +++ /dev/null @@ -1,5 +0,0 @@ -Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -All rights reserved. This program and the accompanying materials -are made available under the terms of the Eclipse Public License v1.0 -which accompanies this distribution, and is available at -http://robocode.sourceforge.net/license/epl-v10.html \ No newline at end of file diff --git a/workspace_robo/tools/.gitignore b/workspace_robo/tools/.gitignore deleted file mode 100644 index a65b417..0000000 --- a/workspace_robo/tools/.gitignore +++ /dev/null @@ -1 +0,0 @@ -lib diff --git a/workspace_robo/tools/.project b/workspace_robo/tools/.project deleted file mode 100644 index d48fc19..0000000 --- a/workspace_robo/tools/.project +++ /dev/null @@ -1,11 +0,0 @@ - - - tools - - - - - - - - diff --git a/workspace_robo/tools/bin/ant.bat b/workspace_robo/tools/bin/ant.bat deleted file mode 100644 index 6d57c81..0000000 --- a/workspace_robo/tools/bin/ant.bat +++ /dev/null @@ -1,226 +0,0 @@ -@echo off - -REM Licensed to the Apache Software Foundation (ASF) under one or more -REM contributor license agreements. See the NOTICE file distributed with -REM this work for additional information regarding copyright ownership. -REM The ASF licenses this file to You under the Apache License, Version 2.0 -REM (the "License"); you may not use this file except in compliance with -REM the License. You may obtain a copy of the License at -REM -REM http://www.apache.org/licenses/LICENSE-2.0 -REM -REM Unless required by applicable law or agreed to in writing, software -REM distributed under the License is distributed on an "AS IS" BASIS, -REM WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. -REM See the License for the specific language governing permissions and -REM limitations under the License. - -REM This is an inordinately troublesome piece of code, particularly because it -REM tries to work on both Win9x and WinNT-based systems. If we could abandon '9x -REM support, things would be much easier, but sadly, it is not yet time. -REM Be cautious about editing this, and only add WinNT specific stuff in code that -REM only runs on WinNT. - -if "%HOME%"=="" goto homeDrivePathPre -if exist "%HOME%\antrc_pre.bat" call "%HOME%\antrc_pre.bat" - -:homeDrivePathPre -if "%HOMEDRIVE%%HOMEPATH%"=="" goto userProfilePre -if "%HOMEDRIVE%%HOMEPATH%"=="%HOME%" goto userProfilePre -if exist "%HOMEDRIVE%%HOMEPATH%\antrc_pre.bat" call "%HOMEDRIVE%%HOMEPATH%\antrc_pre.bat" - -:userProfilePre -if "%USERPROFILE%"=="" goto alpha -if "%USERPROFILE%"=="%HOME%" goto alpha -if "%USERPROFILE%"=="%HOMEDRIVE%%HOMEPATH%" goto alpha -if exist "%USERPROFILE%\antrc_pre.bat" call "%USERPROFILE%\antrc_pre.bat" - -:alpha - -if "%OS%"=="Windows_NT" @setlocal -if "%OS%"=="WINNT" @setlocal - -if "%ANT_HOME%"=="" goto setDefaultAntHome - -:stripAntHome -if not _%ANT_HOME:~-1%==_\ goto checkClasspath -set ANT_HOME=%ANT_HOME:~0,-1% -goto stripAntHome - -:setDefaultAntHome -rem %~dp0 is expanded pathname of the current script under NT -set ANT_HOME=%~dp0.. - -:checkClasspath -set _USE_CLASSPATH=yes -rem CLASSPATH must not be used if it is equal to "" -if "%CLASSPATH%"=="""" set _USE_CLASSPATH=no -if "%CLASSPATH%"=="" set _USE_CLASSPATH=no - -rem Slurp the command line arguments. This loop allows for an unlimited number -rem of arguments (up to the command line limit, anyway). -set ANT_CMD_LINE_ARGS=%1 -if ""%1""=="""" goto doneStart -shift -:setupArgs -if ""%1""=="""" goto doneStart -if ""%1""==""-noclasspath"" goto clearclasspath -set ANT_CMD_LINE_ARGS=%ANT_CMD_LINE_ARGS% %1 -shift -goto setupArgs - -rem here is there is a -noclasspath in the options -:clearclasspath -set _USE_CLASSPATH=no -shift -goto setupArgs - -rem This label provides a place for the argument list loop to break out -rem and for NT handling to skip to. - -:doneStart - -if _USE_CLASSPATH==no goto findAntHome - -:stripClasspath -if not _%CLASSPATH:~-1%==_\ goto findAntHome -set CLASSPATH=%CLASSPATH:~0,-1% -goto stripClasspath - -:findAntHome -rem find ANT_HOME if it does not exist due to either an invalid value passed -rem by the user or the %0 problem on Windows 9x -if exist "%ANT_HOME%\lib\ant.jar" goto checkJava - -rem check for ant in Program Files -if not exist "%ProgramFiles%\ant" goto checkSystemDrive -set ANT_HOME=%ProgramFiles%\ant -goto checkJava - -:checkSystemDrive -rem check for ant in root directory of system drive -if not exist %SystemDrive%\ant\lib\ant.jar goto checkCDrive -set ANT_HOME=%SystemDrive%\ant -goto checkJava - -:checkCDrive -rem check for ant in C:\ant for Win9X users -if not exist C:\ant\lib\ant.jar goto noAntHome -set ANT_HOME=C:\ant -goto checkJava - -:noAntHome -echo ANT_HOME is set incorrectly or ant could not be located. Please set ANT_HOME. -goto end - -:checkJava -set _JAVACMD=%JAVACMD% - -if "%JAVA_HOME%" == "" goto noJavaHome -if not exist "%JAVA_HOME%\bin\java.exe" goto noJavaHome -if "%_JAVACMD%" == "" set _JAVACMD=%JAVA_HOME%\bin\java.exe -goto checkJikes - -:noJavaHome -if "%_JAVACMD%" == "" set _JAVACMD=java.exe - -:checkJikes -if not "%JIKESPATH%"=="" goto runAntWithJikes - -:runAnt -if "%_USE_CLASSPATH%"=="no" goto runAntNoClasspath -:runAntWithClasspath -"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS% -rem Check the error code of the Ant build -if not "%OS%"=="Windows_NT" goto onError -set ANT_ERROR=%ERRORLEVEL% -goto end - -:runAntNoClasspath -"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% -rem Check the error code of the Ant build -if not "%OS%"=="Windows_NT" goto onError -set ANT_ERROR=%ERRORLEVEL% -goto end - -:runAntWithJikes - -if not _%JIKESPATH:~-1%==_\ goto checkJikesAndClasspath -set JIKESPATH=%JIKESPATH:~0,-1% -goto runAntWithJikes - -:checkJikesAndClasspath - -if "%_USE_CLASSPATH%"=="no" goto runAntWithJikesNoClasspath - -:runAntWithJikesAndClasspath -"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% -cp "%CLASSPATH%" %ANT_CMD_LINE_ARGS% -rem Check the error code of the Ant build -if not "%OS%"=="Windows_NT" goto onError -set ANT_ERROR=%ERRORLEVEL% -goto end - -:runAntWithJikesNoClasspath -"%_JAVACMD%" %ANT_OPTS% -classpath "%ANT_HOME%\lib\ant-launcher.jar" "-Dant.home=%ANT_HOME%" "-Djikes.class.path=%JIKESPATH%" org.apache.tools.ant.launch.Launcher %ANT_ARGS% %ANT_CMD_LINE_ARGS% -rem Check the error code of the Ant build -if not "%OS%"=="Windows_NT" goto onError -set ANT_ERROR=%ERRORLEVEL% -goto end - -:onError -rem Windows 9x way of checking the error code. It matches via brute force. -for %%i in (1 10 100) do set err%%i= -for %%i in (0 1 2) do if errorlevel %%i00 set err100=%%i -if %err100%==2 goto onError200 -if %err100%==0 set err100= -for %%i in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %err100%%%i0 set err10=%%i -if "%err100%"=="" if %err10%==0 set err10= -:onError1 -for %%i in (0 1 2 3 4 5 6 7 8 9) do if errorlevel %err100%%err10%%%i set err1=%%i -goto onErrorEnd -:onError200 -for %%i in (0 1 2 3 4 5) do if errorlevel 2%%i0 set err10=%%i -if err10==5 for %%i in (0 1 2 3 4 5) do if errorlevel 25%%i set err1=%%i -if not err10==5 goto onError1 -:onErrorEnd -set ANT_ERROR=%err100%%err10%%err1% -for %%i in (1 10 100) do set err%%i= - -:end -rem bug ID 32069: resetting an undefined env variable changes the errorlevel. -if not "%_JAVACMD%"=="" set _JAVACMD= -if not "%_ANT_CMD_LINE_ARGS%"=="" set ANT_CMD_LINE_ARGS= - -if "%ANT_ERROR%"=="0" goto mainEnd - -rem Set the return code if we are not in NT. We can only set -rem a value of 1, but it's better than nothing. -if not "%OS%"=="Windows_NT" echo 1 > nul | choice /n /c:1 - -rem Set the ERRORLEVEL if we are running NT. -if "%OS%"=="Windows_NT" color 00 - -goto omega - -:mainEnd - -rem If there were no errors, we run the post script. -if "%OS%"=="Windows_NT" @endlocal -if "%OS%"=="WINNT" @endlocal - -if "%HOME%"=="" goto homeDrivePathPost -if exist "%HOME%\antrc_post.bat" call "%HOME%\antrc_post.bat" - -:homeDrivePathPost -if "%HOMEDRIVE%%HOMEPATH%"=="" goto userProfilePost -if "%HOMEDRIVE%%HOMEPATH%"=="%HOME%" goto userProfilePost -if exist "%HOMEDRIVE%%HOMEPATH%\antrc_post.bat" call "%HOMEDRIVE%%HOMEPATH%\antrc_post.bat" - -:userProfilePost -if "%USERPROFILE%"=="" goto omega -if "%USERPROFILE%"=="%HOME%" goto omega -if "%USERPROFILE%"=="%HOMEDRIVE%%HOMEPATH%" goto omega -if exist "%USERPROFILE%\antrc_post.bat" call "%USERPROFILE%\antrc_post.bat" - -:omega - diff --git a/workspace_robo/tools/bin/ant.sh b/workspace_robo/tools/bin/ant.sh deleted file mode 100644 index 0727ea1..0000000 --- a/workspace_robo/tools/bin/ant.sh +++ /dev/null @@ -1,94 +0,0 @@ -#! /bin/sh - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -case "`uname`" in - CYGWIN*) cygwin=true ;; - Darwin*) darwin=true ;; -esac - -#Find the necessary resources -ANT_HOME=. - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD=$JAVA_HOME/jre/sh/java - else - JAVACMD=$JAVA_HOME/bin/java - fi - else - JAVACMD=java - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." - echo " We cannot execute $JAVACMD" - exit -fi - -if [ -n "$CLASSPATH" ] ; then - LOCALCLASSPATH=$CLASSPATH -fi - -# add in the dependency .jar files -DIRLIBS=${ANT_HOME}/build-lib/*.jar -for i in ${DIRLIBS} -do - # if the directory is empty, then it will return the input string - # this is stupid, so case for it - if [ "$i" != "${DIRLIBS}" ] ; then - if [ -z "$LOCALCLASSPATH" ] ; then - LOCALCLASSPATH=$i - else - LOCALCLASSPATH="$i":$LOCALCLASSPATH - fi - fi -done - -if [ -n "$JAVA_HOME" ] ; then - if [ -f "$JAVA_HOME/lib/tools.jar" ] ; then - LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/tools.jar - fi - - if [ -f "$JAVA_HOME/lib/classes.zip" ] ; then - LOCALCLASSPATH=$LOCALCLASSPATH:$JAVA_HOME/lib/classes.zip - fi - - # OSX hack to make Ant work with jikes - if $darwin ; then - OSXHACK="/System/Library/Frameworks/JavaVM.framework/Versions/CurrentJDK/Classes" - if [ -d ${OSXHACK} ] ; then - for i in ${OSXHACK}/*.jar - do - JIKESPATH=$JIKESPATH:$i - done - fi - fi - -else - echo "Warning: JAVA_HOME environment variable is not set." - echo " If build fails because sun.* classes could not be found" - echo " you will need to set the JAVA_HOME environment variable" - echo " to the installation directory of java." -fi - -# supply JIKESPATH to Ant as jikes.class.path -if [ -n "$JIKESPATH" ] ; then - if [ -n "$ANT_OPTS" ] ; then - ANT_OPTS="$ANT_OPTS -Djikes.class.path=$JIKESPATH" - else - ANT_OPTS=-Djikes.class.path=$JIKESPATH - fi -fi - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - ANT_HOME=`cygpath --path --windows "$ANT_HOME"` - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - LOCALCLASSPATH=`cygpath --path --windows "$LOCALCLASSPATH"` -fi -$JAVACMD -classpath "$LOCALCLASSPATH" -Dant.home="${ANT_HOME}" $ANT_OPTS org.apache.tools.ant.Main -e "$@" diff --git a/workspace_robo/tools/bin/m2.conf b/workspace_robo/tools/bin/m2.conf deleted file mode 100644 index cc046fb..0000000 --- a/workspace_robo/tools/bin/m2.conf +++ /dev/null @@ -1,4 +0,0 @@ -main is org.apache.maven.cli.MavenCli from plexus.core - -[plexus.core] -load tools/lib/*.jar diff --git a/workspace_robo/tools/bin/mvn.bat b/workspace_robo/tools/bin/mvn.bat deleted file mode 100644 index 8fd1f4c..0000000 --- a/workspace_robo/tools/bin/mvn.bat +++ /dev/null @@ -1,191 +0,0 @@ -@REM ---------------------------------------------------------------------------- -@REM Licensed to the Apache Software Foundation (ASF) under one -@REM or more contributor license agreements. See the NOTICE file -@REM distributed with this work for additional information -@REM regarding copyright ownership. The ASF licenses this file -@REM to you under the Apache License, Version 2.0 (the -@REM "License"); you may not use this file except in compliance -@REM with the License. You may obtain a copy of the License at -@REM -@REM http://www.apache.org/licenses/LICENSE-2.0 -@REM -@REM Unless required by applicable law or agreed to in writing, -@REM software distributed under the License is distributed on an -@REM "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -@REM KIND, either express or implied. See the License for the -@REM specific language governing permissions and limitations -@REM under the License. -@REM ---------------------------------------------------------------------------- - -@REM ---------------------------------------------------------------------------- -@REM Maven2 Start Up Batch script -@REM -@REM Required ENV vars: -@REM JAVA_HOME - location of a JDK home dir -@REM -@REM Optional ENV vars -@REM M2_HOME - location of maven2's installed home dir -@REM MAVEN_BATCH_ECHO - set to 'on' to enable the echoing of the batch commands -@REM MAVEN_BATCH_PAUSE - set to 'on' to wait for a key stroke before ending -@REM MAVEN_OPTS - parameters passed to the Java VM when running Maven -@REM e.g. to debug Maven itself, use -@REM set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -@REM ---------------------------------------------------------------------------- - -@REM Begin all REM lines with '@' in case MAVEN_BATCH_ECHO is 'on' -@echo off -@REM enable echoing my setting MAVEN_BATCH_ECHO to 'on' -@if "%MAVEN_BATCH_ECHO%" == "on" echo %MAVEN_BATCH_ECHO% - -@REM set %HOME% to equivalent of $HOME -if "%HOME%" == "" (set HOME=%HOMEDRIVE%%HOMEPATH%) - -@REM Execute a user defined script before this one -if exist "%HOME%\mavenrc_pre.bat" call "%HOME%\mavenrc_pre.bat" - -set ERROR_CODE=0 - -@REM set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" @setlocal -if "%OS%"=="WINNT" @setlocal - -@REM ==== START VALIDATION ==== -if not "%JAVA_HOME%" == "" goto OkJHome - -echo. -echo ERROR: JAVA_HOME not found in your environment. -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation -echo. -goto error - -:OkJHome -if exist "%JAVA_HOME%\bin\java.exe" goto chkMHome - -echo. -echo ERROR: JAVA_HOME is set to an invalid directory. -echo JAVA_HOME = %JAVA_HOME% -echo Please set the JAVA_HOME variable in your environment to match the -echo location of your Java installation -echo. -goto error - -:chkMHome -if not "%M2_HOME%"=="" goto valMHome - -if "%OS%"=="Windows_NT" SET M2_HOME=%~dp0 -if "%OS%"=="Windows_NT" set M2_HOME=%M2_HOME:~0,-5% -if "%OS%"=="WINNT" SET M2_HOME=%~dp0.. -if not "%M2_HOME%"=="" goto valMHome - -echo. -echo ERROR: M2_HOME not found in your environment. -echo Please set the M2_HOME variable in your environment to match the -echo location of the Maven installation -echo. -goto error - -:valMHome - -:stripMHome -if not _%M2_HOME:~-1%==_\ goto checkMBat -set M2_HOME=%M2_HOME:~0,-1% -goto stripMHome - -:checkMBat -if exist "%M2_HOME%\bin\mvn.bat" goto init - -echo. -echo ERROR: M2_HOME is set to an invalid directory. -echo M2_HOME = %M2_HOME% -echo Please set the M2_HOME variable in your environment to match the -echo location of the Maven installation -echo. -goto error -@REM ==== END VALIDATION ==== - -:init -@REM Decide how to startup depending on the version of windows - -@REM -- Windows NT with Novell Login -if "%OS%"=="WINNT" goto WinNTNovell - -@REM -- Win98ME -if NOT "%OS%"=="Windows_NT" goto Win9xArg - -:WinNTNovell - -@REM -- 4NT shell -if "%@eval[2+2]" == "4" goto 4NTArgs - -@REM -- Regular WinNT shell -set MAVEN_CMD_LINE_ARGS=%* -goto endInit - -@REM The 4NT Shell from jp software -:4NTArgs -set MAVEN_CMD_LINE_ARGS=%$ -goto endInit - -:Win9xArg -@REM Slurp the command line arguments. This loop allows for an unlimited number -@REM of agruments (up to the command line limit, anyway). -set MAVEN_CMD_LINE_ARGS= -:Win9xApp -if %1a==a goto endInit -set MAVEN_CMD_LINE_ARGS=%MAVEN_CMD_LINE_ARGS% %1 -shift -goto Win9xApp - -@REM Reaching here means variables are defined and arguments have been captured -:endInit -SET MAVEN_JAVA_EXE="%JAVA_HOME%\bin\java.exe" - -@REM -- 4NT shell -if "%@eval[2+2]" == "4" goto 4NTCWJars - -@REM -- Regular WinNT shell -for %%i in ("%M2_HOME%"\lib\classworlds-*) do set CLASSWORLDS_JAR="%%~fi" -for %%i in ("%M2_HOME%"\lib\maven-*-uber.jar) do set MAVENUBER_JAR="%%~fi" - -goto runm2 - -@REM The 4NT Shell from jp software -:4NTCWJars -for %%i in ("%M2_HOME%\lib\classworlds-*") do set CLASSWORLDS_JAR="%%i" -goto runm2 - -@REM Start MAVEN2 -:runm2 -%MAVEN_JAVA_EXE% %MAVEN_OPTS% -classpath %CLASSWORLDS_JAR%;%MAVENUBER_JAR% "-Dclassworlds.conf=%M2_HOME%\bin\m2.conf" "-Dmaven.home=%M2_HOME%" org.codehaus.classworlds.Launcher %MAVEN_CMD_LINE_ARGS% -if ERRORLEVEL 1 goto error -goto end - -:error -if "%OS%"=="Windows_NT" @endlocal -if "%OS%"=="WINNT" @endlocal -set ERROR_CODE=1 - -:end -@REM set local scope for the variables with windows NT shell -if "%OS%"=="Windows_NT" goto endNT -if "%OS%"=="WINNT" goto endNT - -@REM For old DOS remove the set variables from ENV - we assume they were not set -@REM before we started - at least we don't leave any baggage around -set MAVEN_JAVA_EXE= -set MAVEN_CMD_LINE_ARGS= -goto postExec - -:endNT -@endlocal & set ERROR_CODE=%ERROR_CODE% - -:postExec -if exist "%HOME%\mavenrc_post.bat" call "%HOME%\mavenrc_post.bat" -@REM pause the batch file if MAVEN_BATCH_PAUSE is set to 'on' -if "%MAVEN_BATCH_PAUSE%" == "on" pause - -if "%MAVEN_TERMINATE_CMD%" == "on" exit %ERROR_CODE% - -exit /B %ERROR_CODE% - diff --git a/workspace_robo/tools/bin/mvn.sh b/workspace_robo/tools/bin/mvn.sh deleted file mode 100644 index 502d7db..0000000 --- a/workspace_robo/tools/bin/mvn.sh +++ /dev/null @@ -1,162 +0,0 @@ -#!/bin/sh -# ---------------------------------------------------------------------------- -# Licensed to the Apache Software Foundation (ASF) under one -# or more contributor license agreements. See the NOTICE file -# distributed with this work for additional information -# regarding copyright ownership. The ASF licenses this file -# to you under the Apache License, Version 2.0 (the -# "License"); you may not use this file except in compliance -# with the License. You may obtain a copy of the License at -# -# http://www.apache.org/licenses/LICENSE-2.0 -# -# Unless required by applicable law or agreed to in writing, -# software distributed under the License is distributed on an -# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY -# KIND, either express or implied. See the License for the -# specific language governing permissions and limitations -# under the License. -# ---------------------------------------------------------------------------- - -# ---------------------------------------------------------------------------- -# Maven2 Start Up Batch script -# -# Required ENV vars: -# ------------------ -# JAVA_HOME - location of a JDK home dir -# -# Optional ENV vars -# ----------------- -# M2_HOME - location of maven2's installed home dir -# MAVEN_OPTS - parameters passed to the Java VM when running Maven -# e.g. to debug Maven itself, use -# set MAVEN_OPTS=-Xdebug -Xnoagent -Djava.compiler=NONE -Xrunjdwp:transport=dt_socket,server=y,suspend=y,address=8000 -# ---------------------------------------------------------------------------- - -QUOTED_ARGS="" -while [ "$1" != "" ] ; do - - QUOTED_ARGS="$QUOTED_ARGS \"$1\"" - shift - -done - -if [ -f /etc/mavenrc ] ; then - . /etc/mavenrc -fi - -if [ -f "$HOME/.mavenrc" ] ; then - . "$HOME/.mavenrc" -fi - -# OS specific support. $var _must_ be set to either true or false. -cygwin=false; -darwin=false; -mingw=false -case "`uname`" in - CYGWIN*) cygwin=true ;; - MINGW*) mingw=true;; - Darwin*) darwin=true - if [ -z "$JAVA_VERSION" ] ; then - JAVA_VERSION="CurrentJDK" - else - echo "Using Java version: $JAVA_VERSION" - fi - if [ -z "$JAVA_HOME" ] ; then - JAVA_HOME=/System/Library/Frameworks/JavaVM.framework/Versions/${JAVA_VERSION}/Home - fi - ;; -esac - -if [ -z "$JAVA_HOME" ] ; then - if [ -r /etc/gentoo-release ] ; then - JAVA_HOME=`java-config --jre-home` - fi -fi - -if [ -z "$M2_HOME" ] ; then - ## resolve links - $0 may be a link to maven's home - PRG="$0" - - # need this for relative symlinks - while [ -h "$PRG" ] ; do - ls=`ls -ld "$PRG"` - link=`expr "$ls" : '.*-> \(.*\)$'` - if expr "$link" : '/.*' > /dev/null; then - PRG="$link" - else - PRG="`dirname "$PRG"`/$link" - fi - done - - saveddir=`pwd` - - M2_HOME=`dirname "$PRG"`/.. - - # make it fully qualified - M2_HOME=`cd "$M2_HOME" && pwd` - - cd "$saveddir" - # echo Using m2 at $M2_HOME -fi - -# For Cygwin, ensure paths are in UNIX format before anything is touched -if $cygwin ; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --unix "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --unix "$JAVA_HOME"` - [ -n "$CLASSPATH" ] && - CLASSPATH=`cygpath --path --unix "$CLASSPATH"` -fi - -# For Migwn, ensure paths are in UNIX format before anything is touched -if $mingw ; then - [ -n "$M2_HOME" ] && - M2_HOME="`(cd "$M2_HOME"; pwd)`" - [ -n "$JAVA_HOME" ] && - JAVA_HOME="`(cd "$JAVA_HOME"; pwd)`" - # TODO classpath? -fi - -if [ -z "$JAVACMD" ] ; then - if [ -n "$JAVA_HOME" ] ; then - if [ -x "$JAVA_HOME/jre/sh/java" ] ; then - # IBM's JDK on AIX uses strange locations for the executables - JAVACMD="$JAVA_HOME/jre/sh/java" - else - JAVACMD="$JAVA_HOME/bin/java" - fi - else - JAVACMD="`which java`" - fi -fi - -if [ ! -x "$JAVACMD" ] ; then - echo "Error: JAVA_HOME is not defined correctly." - echo " We cannot execute $JAVACMD" - exit 1 -fi - -if [ -z "$JAVA_HOME" ] ; then - echo "Warning: JAVA_HOME environment variable is not set." -fi - -CLASSWORLDS_LAUNCHER=org.codehaus.classworlds.Launcher - -# For Cygwin, switch paths to Windows format before running java -if $cygwin; then - [ -n "$M2_HOME" ] && - M2_HOME=`cygpath --path --windows "$M2_HOME"` - [ -n "$JAVA_HOME" ] && - JAVA_HOME=`cygpath --path --windows "$JAVA_HOME"` - [ -n "$HOME" ] && - HOME=`cygpath --path --windows "$HOME"` -fi - -exec "$JAVACMD" \ - $MAVEN_OPTS \ - -classpath $PWD/tools/lib/classworlds-1.1.jar:$PWD/tools/lib/maven-2.2.1-uber.jar \ - "-Dclassworlds.conf=$PWD/tools/bin/m2.conf" \ - ${CLASSWORLDS_LAUNCHER} $QUOTED_ARGS - diff --git a/workspace_robo/tools/debugall/all.iml b/workspace_robo/tools/debugall/all.iml deleted file mode 100644 index c46da8f..0000000 --- a/workspace_robo/tools/debugall/all.iml +++ /dev/null @@ -1,33 +0,0 @@ - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - diff --git a/workspace_robo/tools/jacobe/.gitignore b/workspace_robo/tools/jacobe/.gitignore deleted file mode 100644 index e560d3e..0000000 --- a/workspace_robo/tools/jacobe/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/jacobe-ant-task.zip diff --git a/workspace_robo/tools/jacobe/ReadMe.txt b/workspace_robo/tools/jacobe/ReadMe.txt deleted file mode 100644 index a645e5b..0000000 --- a/workspace_robo/tools/jacobe/ReadMe.txt +++ /dev/null @@ -1,57 +0,0 @@ -==== - Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - All rights reserved. This program and the accompanying materials - are made available under the terms of the Eclipse Public License v1.0 - which accompanies this distribution, and is available at - http://robocode.sourceforge.net/license/epl-v10.html -==== - -Author: Flemming N. Larsen: - -The Jacobe Code Beautifier is used as code beautifier for Robocode. -You can read about it and download it from here: - -http://www.tiobe.com/index.php/content/products/jacobe/Jacobe.html - -Jacobe is quite good for Java as it follows the Java code conventions from Oracle: - -http://www.oracle.com/technetwork/java/codeconv-138413.html - -Jacobe can be integrated with Eclipse by using the Eclipse plugin for Jacobe. -The plugin can be downloaded from the same page used when downloading Jacobe -under the "Plug-ins" section. - -You can install the Jacobe plugin into Eclipse simply by unpacking the Jacobe -plugin to the root directory of Eclipse (the plugins directory must be -"overwritten" with the Jacobe plugin). - -When the Jacobe plugin has been put into the root directory of Eclipse, you -must restart Eclipse, if you had it running while putting the plugin into the -Eclipse directory. Otherwise you'll not be able to use Jacobe yet. - -I attached the robocode.cfg file, which is used for beautifying the Robocode -sources with Jacobe. You should put this file into the directory where -you have installed Jacobe, i.e. just together the sun.cfg file. - -In Eclipse (when you have added your plugin, and can see the purple bug in -the toolbar) you select "Preferences.." from the Window menu. On the -Preferences window you expand the Java (in the tree) and click Jacobe. - -Browse and select your Jacobe executable. Browse and select the -robocode.cfg file. All checkmarks should be cleared, except for "overwrite -original files". Otherwise backup files are created. Now you are ready -to code beautify following the Robocode Jacobe configuration. - -You can also code beautify the sources of Robocode by using the target named -"jacobe" in the build.xml file provided in this directory. Here you'll -need to download and install the Jacobe Ant Task: - -http://www.tiobe.com/content/products/jacobe/jacobe-ant-task.zip - -You should copy the jacode.jar file inside the jacobe-ant-task.zip file -into this folder, and also add the home folder where the Jacode executable -is located into your PATH environment variable. - -You can read more about the Jacobe Ant task here: - -http://www.tiobe.com/index.php/content/products/jacobe/jacobe_task_doc.html \ No newline at end of file diff --git a/workspace_robo/tools/jacobe/robocode.cfg b/workspace_robo/tools/jacobe/robocode.cfg deleted file mode 100644 index a8c916c..0000000 --- a/workspace_robo/tools/jacobe/robocode.cfg +++ /dev/null @@ -1,301 +0,0 @@ -// Jacobe configuration file for the Sun code conventions for Java -// $Id: sun.cfg,v 1.94 2006/05/31 09:29:01 stappers Exp $ -// reference: http://java.sun.com/docs/codeconv/ -// (c) 2000-2006 Tiobe Software BV -- All rights reserved -// support@jacobe.com, www.jacobe.com, Eindhoven, The Netherlands - - -// INDENTATION -// ----------- - -//--indent=4 ---indenttab=1 ---tablen=4 -//--unindentjumplabel - - -// LINE LENGTH -// ----------- - ---wrap=120 - - -// WRAPPING LINES -// -------------- - -//--wrapinfixoplineterm=1 ---wraplineterminfixop=1 ---indentcontinuation=2 -//--continuationindent=4 -//--wraplinetermcomma=1 ---wrapcommalineterm=1 ---wraparrayinitopenbracelineterm=1 ---wrapmethodcallopenparenlineterm=1 -//--wrapassoplineterm=1 - - -// COMMENTS -// -------- - ---opencommentspace=1 -//--opencommentlineterm=1 ---indentcomment=1 -//--commentstarspace=1 - -// JAVADOC -// ------- -// The rules below are only available in Jacobe Professional - ---javadocstartlineterm=1 ---linetermendjavadoc=1 ---javadocdescr ---javadocdescrlineterm=2 ---javadocauthor ---javadocauthorlineterm=1 ---javadocversion ---javadocversionlineterm=2 ---javadocparam ---javadocparamorder ---javadocparamlineterm=1 ---javadocreturn ---javadocreturnlineterm=1 ---javadocthrows ---javadocthrowsorder ---javadocthrowslineterm=1 ---javadocorder ---javadoctagspacearg=1 - - -// DECLARATIONS AND STATEMENTS -// --------------------------- - ---colonlineterm=1 ---spaceopenbrace=1 ---closebracelineterm=1 ---openbracespace=1 ---openbracespaceclosebrace=0 ---openbracelinetermclosebrace=0 ---openparenspacecloseparen=0 ---linetermopenbracket=0 ---indentbraces=0 ---indentblock=1 -//--dimopenbracketspace=0 -//--dimspaceclosebracket=0 -//--indexopenbracketspace=0 -//--indexspaceclosebracket=0 ---openbracketspaceclosebracket=0 - - -// DECLARATIONS -// ------------ - ---decllineterm=1 ---modifierslineterm=0 ---modifiersspace=1 -//--typespace=1 ---classspace=1 ---classlineterm=0 ---classlinetermopenbrace=0 ---classopenbracelineterm=1 ---classlinetermclosebrace=1 ---spaceextends=1 ---extendsspace=1 ---linetermextends=0 ---extendslineterm=0 -//--linetermimplements=0 -//--implementslineterm=0 -//--linetermthrows=0 ---methodlinetermopenbrace=0 ---methodopenbracelineterm=1 ---methodlinetermclosebrace=1 -//--arrayinitlinetermopenbrace=0 -//--arrayinitopenbracelineterm=0 -//--arrayinitlinetermclosebrace=0 -//--arrayinitclosebracelineterm=0 -//--arrayinitopenbracespace=0 -//--arrayinitspaceclosebrace=0 ---returntypelineterm=0 -//--typelineterm=0 -//--paramtypelineterm=0 -//--fortypelineterm=0 -//--declarraytoarraytype -//--linetermclass=1 -//--linetermconstructor=1 ---closebracelinetermopenbrace=1 ---importlineterm=0 ---modifierlineterm=0 -//--seplineterm=0 -//--paramopenparenlineterm=0 -//--paramlinetermcloseparen=0 -//--paramlinetermopenparen=0 -//--paramcloseparenlineterm=0 -//--paramspaceopenparen=0 ---enumcommalineterm=1 - - -// SIMPLE STATEMENTS -// ----------------- - ---statlineterm=1 ---methodcallspaceopenparen=0 ---methodcalllinetermopenparen=0 ---dotlineterm=0 ---linetermdot=0 ---linetermsep=0 ---lineterminfixop=0 ---infixoplineterm=0 ---prefixoplineterm=0 ---linetermpostfixop=0 ---linetermcomma=0 ---commalineterm=0 ---openparenlineterm=0 ---linetermcloseparen=0 ---assoplineterm=0 ---linetermassop=0 - - -// COMPOUND STATEMENTS -// ------------------- - ---blocklinetermopenbrace=0 ---blockopenbracelineterm=1 ---blocklinetermclosebrace=1 ---insertbraces ---blockstatlinetermopenbrace=0 - - -// IF STATEMENTS -// ------------- - ---spaceelse=1 ---closebracelinetermelse=0 -//--semicolonlinetermelse=1 ---elselinetermif=0 - - -// FOR STATEMENTS -// -------------- - ---forstatlineterm=0 - - -// DO-WHILE STATEMENTS -// ------------------- - ---closebracelinetermdowhile=0 ---semicolonlinetermdowhile=1 - - -// SWITCH STATEMENTS -// ----------------- - ---blanklinescase=1 ---indentcase=0 -//--insertbracescasestats - - -// TRY-CATCH STATEMENTS -// -------------------- - ---spacecatch=1 ---linetermcatch=0 ---spacefinally=1 ---linetermfinally=0 - - -// WHITE SPACE -// ----------- - -//--lineterm - - -// BLANK LINES -// ----------- - -//--blanklinescompilationunit=0 ---methodblanklines=1 ---declblanklinesstat=0 ---statblanklinesdecl=0 ---blanklinescomment=1 ---sectionblanklines=2 ---classblanklines=2 -//--enumconstantblanklinesdecl=1 - - -// SPACES -// ------ - -//--keywordspace=1 ---keywordspaceopenparen=1 ---keywordlinetermopenparen=0 ---methodnamespace=0 ---spacecomma=0 ---commaspace=1 ---spacesemicolon=0 ---semicolonspace=1 ---spacecolon=0 ---colonspace=1 ---assignspace=1 ---spaceassign=1 ---dotspace=0 ---spacedot=0 ---prefixopspace=0 ---infixopspace=1 ---spaceinfixop=1 ---spacepostfixop=0 ---spaceopenbracket=0 ---castspace=1 ---castopenparenspace=0 ---castspacecloseparen=0 -//--castopenparenlineterm=0 -//--castlinetermcloseparen=0 -//--castlinetermopenparen=0 -//--castcloseparenlineterm=0 -//--castspaceopenparen=0 -//--castcloseparenspace=0 -//--statopenparenlineterm=0 -//--statlinetermcloseparen=0 -//--statcloseparenspace=0 -//--statcloseparenlineterm=0 -//--castcloseparenspacegroupopenparen=1 ---statopenparenspace=0 ---statspacecloseparen=0 ---groupopenparenspace=0 ---groupspacecloseparen=0 -//--groupspaceopenparen=0 -//--groupcloseparenspace=0 -//--groupopenparenlineterm=0 -//--grouplinetermcloseparen=0 -//--grouplinetermopenparen=0 -//--groupcloseparenlineterm=0 ---methodopenparenspace=0 ---methodspacecloseparen=0 -//--methodopenparenlineterm=0 -//--methodlinetermcloseparen=0 -//--methodcloseparenspace=0 -//--methodcloseparenlineterm=0 -//--horspaceslineterm - -// ANNOTATIONS -// ----------- - -//--annotationatspace=0 -//--annotationatlineterm=0 -//--annotationspaceopenparen=0 -//--annotationlinetermopenparen=0 -//--annotationopenparenspace=0 -//--annotationopenparenlineterm=0 -//--annotationspacecloseparen=0 -//--annotationlinetermcloseparen=0 -//--annotationcloseparenspace=0 -//--annotationcloseparenlineterm=0 -//--annotationspaceopenbrace=0 -//--annotationlinetermopenbrace=0 -//--annotationopenbracespace=0 -//--annotationopenbracelineterm=0 -//--annotationspaceclosebrace=0 -//--annotationlinetermclosebrace=0 -//--annotationclosebracespace=0 -//--annotationclosebracelineterm=0 -//--annotationspace=1 -//--annotationlineterm=1 diff --git a/workspace_robo/tools/licenses/ant-LICENSE.txt b/workspace_robo/tools/licenses/ant-LICENSE.txt deleted file mode 100644 index cdf6ff8..0000000 --- a/workspace_robo/tools/licenses/ant-LICENSE.txt +++ /dev/null @@ -1,272 +0,0 @@ -/* - * Apache License - * Version 2.0, January 2004 - * http://www.apache.org/licenses/ - * - * TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - * - * 1. Definitions. - * - * "License" shall mean the terms and conditions for use, reproduction, - * and distribution as defined by Sections 1 through 9 of this document. - * - * "Licensor" shall mean the copyright owner or entity authorized by - * the copyright owner that is granting the License. - * - * "Legal Entity" shall mean the union of the acting entity and all - * other entities that control, are controlled by, or are under common - * control with that entity. For the purposes of this definition, - * "control" means (i) the power, direct or indirect, to cause the - * direction or management of such entity, whether by contract or - * otherwise, or (ii) ownership of fifty percent (50%) or more of the - * outstanding shares, or (iii) beneficial ownership of such entity. - * - * "You" (or "Your") shall mean an individual or Legal Entity - * exercising permissions granted by this License. - * - * "Source" form shall mean the preferred form for making modifications, - * including but not limited to software source code, documentation - * source, and configuration files. - * - * "Object" form shall mean any form resulting from mechanical - * transformation or translation of a Source form, including but - * not limited to compiled object code, generated documentation, - * and conversions to other media types. - * - * "Work" shall mean the work of authorship, whether in Source or - * Object form, made available under the License, as indicated by a - * copyright notice that is included in or attached to the work - * (an example is provided in the Appendix below). - * - * "Derivative Works" shall mean any work, whether in Source or Object - * form, that is based on (or derived from) the Work and for which the - * editorial revisions, annotations, elaborations, or other modifications - * represent, as a whole, an original work of authorship. For the purposes - * of this License, Derivative Works shall not include works that remain - * separable from, or merely link (or bind by name) to the interfaces of, - * the Work and Derivative Works thereof. - * - * "Contribution" shall mean any work of authorship, including - * the original version of the Work and any modifications or additions - * to that Work or Derivative Works thereof, that is intentionally - * submitted to Licensor for inclusion in the Work by the copyright owner - * or by an individual or Legal Entity authorized to submit on behalf of - * the copyright owner. For the purposes of this definition, "submitted" - * means any form of electronic, verbal, or written communication sent - * to the Licensor or its representatives, including but not limited to - * communication on electronic mailing lists, source code control systems, - * and issue tracking systems that are managed by, or on behalf of, the - * Licensor for the purpose of discussing and improving the Work, but - * excluding communication that is conspicuously marked or otherwise - * designated in writing by the copyright owner as "Not a Contribution." - * - * "Contributor" shall mean Licensor and any individual or Legal Entity - * on behalf of whom a Contribution has been received by Licensor and - * subsequently incorporated within the Work. - * - * 2. Grant of Copyright License. Subject to the terms and conditions of - * this License, each Contributor hereby grants to You a perpetual, - * worldwide, non-exclusive, no-charge, royalty-free, irrevocable - * copyright license to reproduce, prepare Derivative Works of, - * publicly display, publicly perform, sublicense, and distribute the - * Work and such Derivative Works in Source or Object form. - * - * 3. Grant of Patent License. Subject to the terms and conditions of - * this License, each Contributor hereby grants to You a perpetual, - * worldwide, non-exclusive, no-charge, royalty-free, irrevocable - * (except as stated in this section) patent license to make, have made, - * use, offer to sell, sell, import, and otherwise transfer the Work, - * where such license applies only to those patent claims licensable - * by such Contributor that are necessarily infringed by their - * Contribution(s) alone or by combination of their Contribution(s) - * with the Work to which such Contribution(s) was submitted. If You - * institute patent litigation against any entity (including a - * cross-claim or counterclaim in a lawsuit) alleging that the Work - * or a Contribution incorporated within the Work constitutes direct - * or contributory patent infringement, then any patent licenses - * granted to You under this License for that Work shall terminate - * as of the date such litigation is filed. - * - * 4. Redistribution. You may reproduce and distribute copies of the - * Work or Derivative Works thereof in any medium, with or without - * modifications, and in Source or Object form, provided that You - * meet the following conditions: - * - * (a) You must give any other recipients of the Work or - * Derivative Works a copy of this License; and - * - * (b) You must cause any modified files to carry prominent notices - * stating that You changed the files; and - * - * (c) You must retain, in the Source form of any Derivative Works - * that You distribute, all copyright, patent, trademark, and - * attribution notices from the Source form of the Work, - * excluding those notices that do not pertain to any part of - * the Derivative Works; and - * - * (d) If the Work includes a "NOTICE" text file as part of its - * distribution, then any Derivative Works that You distribute must - * include a readable copy of the attribution notices contained - * within such NOTICE file, excluding those notices that do not - * pertain to any part of the Derivative Works, in at least one - * of the following places: within a NOTICE text file distributed - * as part of the Derivative Works; within the Source form or - * documentation, if provided along with the Derivative Works; or, - * within a display generated by the Derivative Works, if and - * wherever such third-party notices normally appear. The contents - * of the NOTICE file are for informational purposes only and - * do not modify the License. You may add Your own attribution - * notices within Derivative Works that You distribute, alongside - * or as an addendum to the NOTICE text from the Work, provided - * that such additional attribution notices cannot be construed - * as modifying the License. - * - * You may add Your own copyright statement to Your modifications and - * may provide additional or different license terms and conditions - * for use, reproduction, or distribution of Your modifications, or - * for any such Derivative Works as a whole, provided Your use, - * reproduction, and distribution of the Work otherwise complies with - * the conditions stated in this License. - * - * 5. Submission of Contributions. Unless You explicitly state otherwise, - * any Contribution intentionally submitted for inclusion in the Work - * by You to the Licensor shall be under the terms and conditions of - * this License, without any additional terms or conditions. - * Notwithstanding the above, nothing herein shall supersede or modify - * the terms of any separate license agreement you may have executed - * with Licensor regarding such Contributions. - * - * 6. Trademarks. This License does not grant permission to use the trade - * names, trademarks, service marks, or product names of the Licensor, - * except as required for reasonable and customary use in describing the - * origin of the Work and reproducing the content of the NOTICE file. - * - * 7. Disclaimer of Warranty. Unless required by applicable law or - * agreed to in writing, Licensor provides the Work (and each - * Contributor provides its Contributions) on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - * implied, including, without limitation, any warranties or conditions - * of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - * PARTICULAR PURPOSE. You are solely responsible for determining the - * appropriateness of using or redistributing the Work and assume any - * risks associated with Your exercise of permissions under this License. - * - * 8. Limitation of Liability. In no event and under no legal theory, - * whether in tort (including negligence), contract, or otherwise, - * unless required by applicable law (such as deliberate and grossly - * negligent acts) or agreed to in writing, shall any Contributor be - * liable to You for damages, including any direct, indirect, special, - * incidental, or consequential damages of any character arising as a - * result of this License or out of the use or inability to use the - * Work (including but not limited to damages for loss of goodwill, - * work stoppage, computer failure or malfunction, or any and all - * other commercial damages or losses), even if such Contributor - * has been advised of the possibility of such damages. - * - * 9. Accepting Warranty or Additional Liability. While redistributing - * the Work or Derivative Works thereof, You may choose to offer, - * and charge a fee for, acceptance of support, warranty, indemnity, - * or other liability obligations and/or rights consistent with this - * License. However, in accepting such obligations, You may act only - * on Your own behalf and on Your sole responsibility, not on behalf - * of any other Contributor, and only if You agree to indemnify, - * defend, and hold each Contributor harmless for any liability - * incurred by, or claims asserted against, such Contributor by reason - * of your accepting any such warranty or additional liability. - * - * END OF TERMS AND CONDITIONS - * - * APPENDIX: How to apply the Apache License to your work. - * - * To apply the Apache License to your work, attach the following - * boilerplate notice, with the fields enclosed by brackets "[]" - * replaced with your own identifying information. (Don't include - * the brackets!) The text should be enclosed in the appropriate - * comment syntax for the file format. We also recommend that a - * file or class name and description of purpose be included on the - * same "printed page" as the copyright notice for easier - * identification within third-party archives. - * - * Copyright [yyyy] [name of copyright owner] - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -W3C® SOFTWARE NOTICE AND LICENSE -http://www.w3.org/Consortium/Legal/2002/copyright-software-20021231 - -This work (and included software, documentation such as READMEs, or other -related items) is being provided by the copyright holders under the following -license. By obtaining, using and/or copying this work, you (the licensee) agree -that you have read, understood, and will comply with the following terms and -conditions. - -Permission to copy, modify, and distribute this software and its documentation, -with or without modification, for any purpose and without fee or royalty is -hereby granted, provided that you include the following on ALL copies of the -software and documentation or portions thereof, including modifications: - - 1. The full text of this NOTICE in a location viewable to users of the - redistributed or derivative work. - 2. Any pre-existing intellectual property disclaimers, notices, or terms - and conditions. If none exist, the W3C Software Short Notice should be - included (hypertext is preferred, text is permitted) within the body - of any redistributed or derivative code. - 3. Notice of any changes or modifications to the files, including the date - changes were made. (We recommend you provide URIs to the location from - which the code is derived.) - -THIS SOFTWARE AND DOCUMENTATION IS PROVIDED "AS IS," AND COPYRIGHT HOLDERS MAKE -NO REPRESENTATIONS OR WARRANTIES, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED -TO, WARRANTIES OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE OR THAT -THE USE OF THE SOFTWARE OR DOCUMENTATION WILL NOT INFRINGE ANY THIRD PARTY -PATENTS, COPYRIGHTS, TRADEMARKS OR OTHER RIGHTS. - -COPYRIGHT HOLDERS WILL NOT BE LIABLE FOR ANY DIRECT, INDIRECT, SPECIAL OR -CONSEQUENTIAL DAMAGES ARISING OUT OF ANY USE OF THE SOFTWARE OR DOCUMENTATION. - -The name and trademarks of copyright holders may NOT be used in advertising or -publicity pertaining to the software without specific, written prior permission. -Title to copyright in this software and any associated documentation will at -all times remain with copyright holders. - -____________________________________ - -This formulation of W3C's notice and license became active on December 31 2002. -This version removes the copyright ownership notice such that this license can -be used with materials other than those owned by the W3C, reflects that ERCIM -is now a host of the W3C, includes references to this specific dated version of -the license, and removes the ambiguous grant of "use". Otherwise, this version -is the same as the previous version and is written so as to preserve the Free -Software Foundation's assessment of GPL compatibility and OSI's certification -under the Open Source Definition. Please see our Copyright FAQ for common -questions about using materials from our site, including specific terms and -conditions for packages like libwww, Amaya, and Jigsaw. Other questions about -this notice can be directed to site-policy@w3.org. - -Joseph Reagle - -This license came from: http://www.megginson.com/SAX/copying.html - However please note future versions of SAX may be covered - under http://saxproject.org/?selected=pd - -SAX2 is Free! - -I hereby abandon any property rights to SAX 2.0 (the Simple API for -XML), and release all of the SAX 2.0 source code, compiled code, and -documentation contained in this distribution into the Public Domain. -SAX comes with NO WARRANTY or guarantee of fitness for any -purpose. - -David Megginson, david@megginson.com -2000-05-05 diff --git a/workspace_robo/tools/licenses/ant-NOTICE.txt b/workspace_robo/tools/licenses/ant-NOTICE.txt deleted file mode 100644 index 4c88cc6..0000000 --- a/workspace_robo/tools/licenses/ant-NOTICE.txt +++ /dev/null @@ -1,26 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Ant distribution. == - ========================================================================= - - Apache Ant - Copyright 1999-2008 The Apache Software Foundation - - This product includes software developed by - The Apache Software Foundation (http://www.apache.org/). - - This product includes also software developed by : - - the W3C consortium (http://www.w3c.org) , - - the SAX project (http://www.saxproject.org) - - The task is based on code Copyright (c) 2002, Landmark - Graphics Corp that has been kindly donated to the Apache Software - Foundation. - - Portions of this software were originally based on the following: - - software copyright (c) 1999, IBM Corporation., http://www.ibm.com. - - software copyright (c) 1999, Sun Microsystems., http://www.sun.com. - - voluntary contributions made by Paul Eng on behalf of the - Apache Software Foundation that were originally developed at iClick, Inc., - software copyright (c) 1999. diff --git a/workspace_robo/tools/licenses/mvn-LICENSE.txt b/workspace_robo/tools/licenses/mvn-LICENSE.txt deleted file mode 100644 index d645695..0000000 --- a/workspace_robo/tools/licenses/mvn-LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/workspace_robo/tools/licenses/mvn-NOTICE.txt b/workspace_robo/tools/licenses/mvn-NOTICE.txt deleted file mode 100644 index ee40ae9..0000000 --- a/workspace_robo/tools/licenses/mvn-NOTICE.txt +++ /dev/null @@ -1,11 +0,0 @@ - ========================================================================= - == NOTICE file corresponding to the section 4 d of == - == the Apache License, Version 2.0, == - == in this case for the Apache Maven distribution. == - ========================================================================= - -This product includes software developed by -The Apache Software Foundation (http://www.apache.org/). - -This product includes software (Plexus and Classworlds) developed by -The Codehaus Foundation (http://www.codehaus.org/). diff --git a/workspace_robo/tools/loadTools.cmd b/workspace_robo/tools/loadTools.cmd deleted file mode 100644 index b2926f2..0000000 --- a/workspace_robo/tools/loadTools.cmd +++ /dev/null @@ -1,19 +0,0 @@ -@REM -@REM Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -@REM All rights reserved. This program and the accompanying materials -@REM are made available under the terms of the Eclipse Public License v1.0 -@REM which accompanies this distribution, and is available at -@REM http://robocode.sourceforge.net/license/epl-v10.html -@REM - -@echo off - -if not exist "%~dp0\lib" ( - mkdir "%~dp0\lib" -) - -if not exist "%~dp0\loader\Loader.class" ( - javac "%~dp0\loader\Loader.java" -) - -java -cp "%~dp0/loader" Loader http://robocode.sourceforge.net/tools/libs/ "%~dp0/lib/" ant.jar ant-contrib-0.6.jar ant-launcher.jar jacobe.jar junit.jar classworlds-1.1.jar maven-2.2.1-uber.jar \ No newline at end of file diff --git a/workspace_robo/tools/loadTools.sh b/workspace_robo/tools/loadTools.sh deleted file mode 100644 index 00d595e..0000000 --- a/workspace_robo/tools/loadTools.sh +++ /dev/null @@ -1,21 +0,0 @@ -#!/bin/bash -# -# Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors -# All rights reserved. This program and the accompanying materials -# are made available under the terms of the Eclipse Public License v1.0 -# which accompanies this distribution, and is available at -# http://robocode.sourceforge.net/license/epl-v10.html -# - - -dp0=${0%/*} - -if [ ! -d "$dp0/lib" ]; then - mkdir "$dp0/lib" -fi - -if [ ! -e "$dp0/loader/Loader.class" ]; then - javac "$dp0/loader/Loader.java" -fi - -java -cp "$dp0/loader" Loader http://robocode.sourceforge.net/tools/libs/ "$dp0/lib/" ant.jar ant-contrib-0.6.jar ant-launcher.jar jacobe.jar junit.jar classworlds-1.1.jar maven-2.2.1-uber.jar diff --git a/workspace_robo/tools/loader/Loader.java b/workspace_robo/tools/loader/Loader.java deleted file mode 100644 index b5e0488..0000000 --- a/workspace_robo/tools/loader/Loader.java +++ /dev/null @@ -1,54 +0,0 @@ -/** - * Copyright (c) 2001-2016 Mathew A. Nelson and Robocode contributors - * All rights reserved. This program and the accompanying materials - * are made available under the terms of the Eclipse Public License v1.0 - * which accompanies this distribution, and is available at - * http://robocode.sourceforge.net/license/epl-v10.html - */ -import java.io.FileOutputStream; -import java.io.IOException; -import java.io.InputStream; -import java.net.URL; -import java.net.URLConnection; - - -/** - * @author Pavel Savara (original) - */ -public class Loader { - public static void main(String[] args) throws IOException { - for (int i = 2; i < args.length; i++) { - System.out.print("Downloading " + args[0] + args[i] + " to " + args[1] + " [..."); - downloadFile(args[0], args[1], args[i]); - System.out.println("...] done"); - } - } - - private static void downloadFile(String libraries, String directory, String file) throws IOException { - URL url = new URL(libraries + file); - final URLConnection con = url.openConnection(); - InputStream is = null; - FileOutputStream fos = null; - - try { - is = con.getInputStream(); - fos = new FileOutputStream(directory + file); - do { - final int b = is.read(); - - if (b == -1) { - break; - } else { - fos.write(b); - } - } while (true); - } finally { - if (fos != null) { - fos.close(); - } - if (is != null) { - is.close(); - } - } - } -} diff --git a/workspace_robo/versions.md b/workspace_robo/versions.md deleted file mode 100644 index 4363a97..0000000 --- a/workspace_robo/versions.md +++ /dev/null @@ -1,3082 +0,0 @@ -## Version 1.9.2.5 (30-Dec-2015) - -### Bug fixes -* [Bug-378][]: robocode.robocodeGL.system.GLRenderer ClassNotFoundException. -* [Bug-380][]: Yet another historical bot related bug. -* Robot Editor: Source files were set to modified (starred) as soon as they were loaded. The modification state remained, even when no changes were made to the source file or when undoing all changes. Therefore the editor would always bring up a dialog with a warning, that the source file needed to be saved before closing the editor. - -### Change -* [Req-160][]: Fixed width font in console. Some systems did not used monospaced font in console windows. - -## Version 1.9.2.4 (20-Nov-2014) - -### Bug fixes -* [Req-159][]: Fix overkilled garbage collection on static fields. - * Robocode garbage collected practically any static field on a robot to prevent memory leaks (see [Bug-244][]). -* [Bug-375][]: Wrong width and height returned for .NET robots. - * The .NET API return 40 instead of 36 with the Width and Height properties. - -### Changes -* Upgraded Eclipse Compiler for Java (ECJ) to version 4.4. -* Upgraded jni4net to version 0.8.7.0. - -### Other -* Got rid of various issues (e.g. license headers) with the source files of Robocode in order to create a Debian distribution of Robocode. - * Thanks goes to Markus Koschany for all the help and support to make this possible. - -## Version 1.9.2.3 (15-Sep-2014) -* [Bug-374][]: Wrong size report for minirumble in v1.9.2.2. - -## Version 1.9.2.2 (03-Sep-2014) -* [Bug-373][]: Wrong robot size calculation in version 1.9.0 - 1.9.2. - -## Version 1.9.2.1 (21-May-2014) - -### Bug fixes -* [Bug-371][]: High cpu usage on editor. -* [Bug-372][]: Cannot load battle file when ``-DNOSECURITY=true`` is enabled - ``java.lang.IllegalAccessError``. - -## Version 1.9.2.0 (23-Apr-2014) - -### New feature -* Initial positions and headings added to the Control API. - * A new constructor has been added to the ``BattleSpecification`` for the ``RobocodeEngine`` so that it is possible to set the initial position and heading of each participant robot. This new constructor takes an additional parameter named ``initialSetups`` that is an array of ``RobotSetup`` instances. - * The ``RobotSetup`` is a new class introduced with this version that contains the initial position and heading for an individual robot. - -### Bug fixes -* [Bug-370][]: Robot Packager cannot find robot .properties file in development path. -* Fixed issue with the Robot Editor, where the caret position was not updated fast enough when typing very fast. - -## Version 1.9.1.0 (22-Mar-2014) - -### Bug fixes -* [Bug-366][]: Receiving enemy's real name on HitByBulletEvent. - * The previous fix was not correct for the owner and victim for the HitByBulletEvent and HitBulletEvent. -* [Bug-368][]: Issues with sentries - * All listed issues have been fixed. - * A bullet from a sentry robot will not be able to hit another bullet within the "safe zone" any more, but will still be able to hit another bullet within the sentry border area. - * When sentry robots are present on the battle field, the initial random positions will be located within the safe zone. This avoids robots from being punished by sentry robots from the start of the battle, as the robot did not enter the sentry border by itself. -* [Bug-369][]: RoboRumble: NoClassDefFoundError for CodeSizeCalculator. -* The missing property ``robocode.battle.sentryBorderSize`` has now been added to the .battle file format. -* Fixed the twinduel.sh file which was using a invalid file name for the configuration file. -* Added desktop files for FreeBSD. - -### New features -* Due to one of the ideas in [Bug-368][], a new method ``getNumSentries()`` for Java and a ``NumSentries`` read-only property for .NET was added to the ``Robot`` and ``RobotStatus`` classes, and to the ``IBasicRobotPeer`` interface as well. - -### Changes -* Upgraded Eclipse Compiler for Java (ECJ) to version 4.3.1. - -## Version 1.9.0.0 (16-Feb-2014) The Border Sentry Robot Release - -### Bug fixes -* [Bug-364][]: Robot Packager does not include the robot data dir in the .jar file. - * The Robot packager has now been extended with an option to include data files too when packaging a robot. -* [Bug-366][]: Receiving enemy's real name on HitByBulletEvent. -* Fixed various issues with the Robot Editor, e.g. letters written in the wrong error when typing text fast. -* Fixed issue when loading a robot jar file with no package (default package), which was found by Daniel Yeung, who also had a fix for it. :-) - -### New features -* *BorderSentry interface*: Added a new robot type (the BorderSentry) that allows you to implement border sentry robots, which are robots that guards the walls of the battlefield against "wall-crawlers" and "corner" robots. - * The Border Sentry robot is dedicated to Liam Noonan from Limerick Institute of Technology and the Robocode Ireland event in general. :-) - * The inspiration for this type of robot comes from the TV series named [Robot Wars](http://www.ukgameshows.com/ukgs/Robot_Wars). - * Note that border sentry robots... - * have 400 additional energy points meaning that a border sentry robot starts with 500 energy points! - * only appear at the borders of the battlefield, when a new round is started defined by the "border sentry size", which is a game rules that can be adjusted similar to other game rules. The default border sentry size is 100 units. - * can only make damage to other robot types within the *sentry border*, but not to robots in the "safe zone", which is the area inside the sentry border. - * can receive damage from other robots. But robots will not gain energy points from the border sentry robots (due to Mathew Nelson's excellent point regarding using sentry robots as "Energy Batteries" ;-) ). - * does not receive scores in the Ranking Panel nor Battle Results, even though you can see its score, like ramming damage, bullet damage etc. The goal for the border sentry robot is to be a referee, but not a player that can win or loose the battle. - * A new method names ``getSentryBorderSize()`` has been added to the Robot classes that returns the size / attack range from the edge of the borders, where BorderSentry robots are able to hit other robot types. - * A new method named ``isSentryRobot()`` has been added to the ``ScannedRobotEvent`` event class. - * When there is only one regular robot left on the battle field with one or more border sentry robots, the round is automatically ended. - * A new sample robot has been added named ``samplesentry.BorderGuard``. Try it out against your robot(s) or e.g. ``sample.Corners`` and ``sample.Walls``. - * An additional option has been added to the View Options in the Preferences to enable and disable the visual appearance of the sentry border, which is painted in transparent red (danger zone). -* [Req-156][]: Codesize added to properties file. - * The Robot Packager now adds a new property named ``robot.codesize`` which will be set to the value calculated by the built-in Codesize tool when compiling the robot and/or team. The Codesize value is the effective code size measured in bytes which is used by e.g. the RoboRumble to categorize robots into MicroBot, MiniBot and MegaBot etc. -* Improved the names of the menu items on the Robot menu. - -## Version 1.8.3.0 (04-Oct-2013) The Editor Theme Release - -### Bug fixes -* [Bug-363][]: No Last Survivor Bonus being given. -* The ``getWidth()`` and ``getHeight()`` methods on the Robot class have always returned 40, even though a robot is 36x36 pixels in size. - * Hence, ``getWidth()`` and ``getHeight()`` have been changed to return the correct width and height, which is 36. -* Fixed Robot Editor issues: - * ``NullPointerException`` occurring with a new source file that was not saved before being compiled. - * Issue where the caret position was set to the end of a source file when reading it into the editor. - -### Changes -* [Req-121][]: Issues with editor font. - * A new Editor Theme Configurator has been added the allows changing the font, text colors and styles for the Robocode Editor. - * Two built-in themes have been provided for Robocode: - * Robocode White Theme - * Robocode Black Theme - * When selecting a theme, Robocode will automatically use this theme the next time Robocode is started. - * When changing a theme, a new custom theme can be created and saved. Note that it is possible to overwrite existing themes. - * Editor themes are stored within the /theme/editor directory as theme property files, which makes it possible to modify these in a normal text editor, but also share the themes. - * The Editor Theme Configurator is available from the Robot Editor menu under View -> Change Editor Theme. -* The line numbers area in the Robocode Editor has been improved as well: - * The background and text colors for the line numbers can be changed. - * Line numbers are now right aligned + extra space has been added to the right. -* The Find & Replace dialog has got a better layout. - -## Version 1.8.2.0 (22-Jun-2013) - -### Bug fixes -* [Bug-357][]: Tab characters are inserted in the last line of a robot source file when opening it. - * This bug was only partially fixed with version 1.8.1.0. -* [Bug-358][]: Robot in default package cannot write to files. Should at least get a warning. -* [Bug-361][]: Problem in the text editor related with the .java file modification. -* [Bug-362][]: Rumble client does not remove participants in wrong codesize group. - * Thanks goes to Julian Kent ("Skilgannon") for providing a solution for this. :-) - -### Changes -* Improved the UI regarding Battle Rules: - * All Battle Rules have been assembled into one single Rules tab. - * Number of Round has been moved from the New Battle dialog to the Rules tab. - * Improved the visualization of the battle field size. - * Added input validation to text fields. -* [Req-64][]: Change default battle settings like e.g. "Number of Rounds". - * When the battle rules are changed in the user interface, Robocode will remember these as the user's default settings. - * A new Restore Defaults button has been added to get the game default settings back. -* Source code editor is now always maximized when opening and robot file or creating a new one. - -## Version 1.8.1.0 (24-Mar-2013) - -### Bug fixes -* [Bug-335][]/[Bug-336][]: Skipped turns ... issues. -* [Bug-349][]: Instances of RobocodeEngine don't seem to be independent - memory leak and performance decrease. -* [Bug-350][]: Bullet id from battle record XML file is sometimes -1 causing a NumberFormatException. -* [Bug-351][]: Robot.onBattleEnded(BattleEndedEvent) provides wrong scores. -* [Bug-352][]: Results from BattleCompletedEvent.getIndexedResults() are always sorted. -* [Bug-353][]: RobocodeEngine.setVisible() can cause a NullPointerException. -* [Bug-354][]: Replaying an XML record can cause an ArrayIndexOutOfBoundsException. -* [Bug-355][]: Priority battles not accepted for mini/micro/nano rumbles. -* [Bug-356][]: Update Roborumble URLs from Darkcanuck to LiteRumble. -* [Bug-357][]: Tab characters are inserted in the last line of a robot source file when opening it. - -## Version 1.8.0.0 (30-Jan-2013) - -### Bug fix -* [Bug-346][]: Cannot extract sources from robot packages. -* [Bug-348][]: .NET: UnauthorizedAccessException in AppDomainShell.Dispose(). - -### Changes -* Robocode has been updated to Java 6, and hence this will be the new minimum requirement for running Robocode from this version. -* The icon for Robocode was upgraded to a 256x256 pixel resolution. -* Added the new properties ``-DlogMessagesEnabled=true|false`` and ``-DlogErrorsEnabled=true|false`` for enabling and disabling log messages and log errors. - * The robocode.control.RobocodeEngine has got two similar methods: ``setLogMessagesEnabled(boolean)`` and ``setLogErrorsEnabled(boolean)`` - -## Version 1.7.4.4 (21-Nov-2012) - -### Bug fix -* [Bug-347][]: /bin/sh^M bad interpreter. - * All .sh and .command files contained the Windows ^M characters so these files could not be executed. - -## Version 1.7.4.3 (17-Nov-2012) - -### Bug Fixes -* [Bug-344][]: BattleAdaptor missing in ``robocode.control.events``. -* [Bug-345][]: Graphics still being rendered when minimized. -* [Bug-333][]: .NET runs release dll not debug dll so can't debug. - * Implemented a work-around so that the local robot repository is rebuild when removing a development path. - -### Changes -* Robocode sources are now put on [GitHub](https://github.com/robo-code/robocode). -* Upgraded the .NET plug-in to use Visual Studio Express 2010. -* The versions.txt has been changed to versions.md: - * The versions.txt was converted into [Markdown][] syntax in order to make it easier to convert into e.g. HTML, and because GitHub will automatically translate it into HTML when viewing this file in a browser. - * Thus, this file has been renamed from 'versions.txt' into 'versions.md'. - * The web page with the new versions.md can be viewed [here](https://github.com/robo-code/robocode/blob/master/versions.md). - * In addition, links to all reported bugs and feature requests have been inserted into versions.md so it is easy to browse to the reports and requests to find more details. - -## Version 1.7.4.2 (16-Aug-2012) - -### Bug Fixes -* [Bug-338][]: "Accept-Encoding: gzip" not in Roborumble HTTP Headers. -* [Bug-339][]: All Text Missing. - * Reverting fix for [Bug-332][] ("Use OpenGL backend under linux"), which caused too much trouble. -* [Bug-340][]: Robocode crash on window resize (linux-opengl). - * Reverting fix for [Bug-332][] ("Use OpenGL backend under linux"), which caused too much trouble. -* [Bug-341][]: InteractiveRobots gets error "After the event was added...". -* [Bug-342][]: New bots not given priority. - -### Changes -* The built-in [RoboRumble][] client is now able to decompress "gzip" and "deflate" content with HTTP connections with RoboRumble servers that supports it. - -## Version 1.7.4.1 (02-Jul-2012) - -### Bug Fixes -* [Bug-337][]: Hangups with New Editor in 1.7.4.0. - * Notice, that the editor can still be quite slow with large source files. Work is still in progress to speed it up. - * Several other minor bug fixes with the new editor, like e.g. undoing and redoing tab indentation. - -## Version 1.7.4.0 (07-Jun-2012) - -### Bug Fixes -* [Bug-332][]: Use OpenGL backend under linux. - * The ``-Dsun.java2d.opengl=True`` property has been set up per default in the "robocode.sh" file in order to enable OpenGL hardware acceleration per default for Linux and Solaris. -* [Bug-334][]: Snapshot API never shows bullets in "HIT_WALL" status. -* [Bug-328][]: Issue with the robocode.dll + \# chars in the path for a dll. - * This applies to the .NET plug-in. - -### New Features -* [Req-147][]: The snapshot API is ambiguous for bullets shot by teams. - * Two new methods have been added: - * [IRobotSnapshot.getRobotIndex()][] that returns a unique id between all robots participating in a battle. - * [IRobotSnapshot.getTeamIndex()][] that returns a unique id between all participating robots or -1 if a robot is not a member of a team. - * The existing [IRobotSnapshot.getContestantIndex()][] will return the team id if it is not -1, otherwise the robot id is returned. - -### Changes -* The Robocode Editor (source code editor) has been completely replaced by a new and improved editor. Expect some bugs! - -## Version 1.7.3.6 (29-Apr-2012) - -### Bug Fixes -* [Bug-331][]: RoboRumble client has infinite timeout. - * Default *connection timeout*, *read timeout* and *session timeout* have been set to 10 seconds. - -### New Features -* A new config file has been added for [RoboRumble][] in the roborumble directory in the robocode directory named "roborumble.properties". - * With this config file it is possible to configure the *connection timeout*, *read timeout* and *session timeout* used when downloading robots and uploading results. -* [Req-144]: Mac ... start with icon and name. - -### Changes -* Upgraded Eclipse Compiler for Java (ECJ) to version 3.7.2. - -## Version 1.7.3.5 (11-Mar-2012) - -### Bug Fixes -* [Bug-326][]: Package of team fails to load in team battles. -* Fixed minor issue where the Robot Packager tells that a NanoBot can be 250 bytes and a MiniBot 750 bytes, when these must be lesser than 250 and 750 bytes. - -## Version 1.7.3.4 (04-Dec-2011) - -### Bug Fixes -* [Bug-323][]: Robocode can't find the ECJ (Eclipse Compiler for Java) -* [Bug-319][]: Package name allows bad chars. - * This issue was not fixed entirely. Corrected text regarding use of lower-case letters in package name. -* Bug: Changes to the rendering options did not take effect immediately for the battle view. - -### New Features -* [Req-134][]: Calculate codesize after compile in editor. - -### Changes -* Upgraded Eclipse Compiler for Java (ECJ) to version 3.7.1. - -## Version 1.7.3.3 (05-Nov-2011) - -### Bug Fixes -* [Bug-311][]: ``out.write(int)`` uses up allocated printing quickly. -* [Bug-315][]: Unable to change drawing color in .NET (C\#). -* [Bug-318][]: Installer throws ``NumberFormatException`` on Linux 3.0. -* [Bug-319][]: Package name allows bad chars. -* [Bug-320][]: "About" window colors are awful. - -### Changes -* The layout of the About Box has been completely redesigned. -* If running on Java 1.6 or newer, OS/system based font antialiasing will be enabled. -* Upgraded to Maven 2.2.1 used for building Robocode. - * Cleaned up the build, improved the speed, and got rid of issue with building and testing every twice. -* Upgraded Eclipse Compiler for Java (ECJ) to version 3.7. -* Upgraded jni4net (Java <-> .NET bridge) to version 0.8.6.0. - -## Version 1.7.3.2 (23-Aug-2011) - -### Bug Fixes -* [Bug-313][]: Robocode .NET does not work on Java 7. -* [Bug-312][]: Enabling Paint Freezes Robocode. -* Fixed problem with XML serialization of just killed robot. -* Fixed bug in temporary record cleanup. - -### New Features -* Implemented deserialization of XML with short tags. - * The command line argument ``-replay`` now supports zipped XML. - -### Changes -* Various optimizations to let [RoboRumble][] start up and run faster. - * E.g. sound module and image loading is disabled when running the rumble. -* Imroved XML deserialization. -* [Patch-1][]: Improved priority battle handling. - * Patch by Jerome Lavigne ("Darkcanuck") - Improved priority battle handling in [RoboRumble][]. - * This change will help improve the efficiency of the [RoboRumble][] system and allow battles to be distributed more evenly + fix some inconsistent console output. - * Improves [RoboRumble][] client-side processing of priority battles received from the rumble server. Specifically: - 1. Priority battles will be discarded for bots that the client knows are no longer in the participants list (the client is aware of bot removals before the server is). - 2. Duplicate priority battles received from the server will be discarded (the server does not maintain state of which battles are sent to specific clients, so duplicates can be common). -* Upgraded to jni4net 0.8.5.1 (fixes [Bug-313][] above). - -## Version 1.7.3.1 (28-Jul-2011) - -### Bug Fixes -* [Bug-302][]: Hide enemy name implementation bug. -* [Bug-303][]: ``bullet.equals`` semantic has been change in 1.7.3.0 version. -* [Bug-304][]: ``setColor(null)`` causes NPE. -* [Bug-305][]: TeamRumble priority battles bug. -* [Bug-306][]: Rumble sh scripts for launching do not handle spaces in path. -* [Bug-307][]: Console output cannot handle non-ascii names. -* [Bug-308][]: ``ConcurrentModificationException`` in ``URLJarCollector``. -* [Bug-309][]: robot in development generates * into filename. -* [Bug-310][]: Interface Robot skips turns at end of round. -* Bug: ``BulletHitEvent.getBullet().getVictim()`` always returned null. - -### New Features -* [Req-135][]: Twin Duel configuration files. - * Twin Duel configuration files for the [RoboRumble][] client are now included. - -### Changes -* The Robot Editor is now saving and loading source files in UTF-8 (Unicode). -* Upgraded to use jni4net v0.8.4. - -## Version 1.7.3.0 (20-May-2011) - -### Bug Fixes -* [Bug-301][]: ``getTurnRateRadians`` incorrect for negative velocity. -* Fixed issues with unit-testing and building Robocode on Linux. - -## Version 1.7.3.0 Beta (26-Mar-2011) - -### Bug Fixes -* [Bug-222][]: Some of sound not working. - * The gunshot sound was not working. -* [Bug-297][]: x,y coords between ``BulletHitEvent`` & ``HitByBulletEvent`` differ. -* [Bug-299][]: Custom events no longer firing after clearing event queue. -* Fixed typo in the documentation with valid range of values for the battlefield width and height. - * Thanks goes to Tamás Balog for pointing this out. - -### New Features -* Added "Enable auto recording" option to the Common Options, which automatically generates a zipped XML record for every battle. - * Works only when "Enable replay recording" is enabled (is automatically set when enabling auto recording). -* [Req-124][]: Ability to save the properties file for robots in dev. path. -* [Req-129][]: ``Rules.getBulletSpeed``. - * It is about keeping the bullet power within 0.1 - 3.0, even when input is lesser or greater than this valid range. -* [Req-128][]: In battle name hiding. - * A general solution has been provided. A new game rule, "hide enemy names", can be enabled or disabled. - -### Changes -* Upgraded to use jni4net v0.8.3. - -## Version 1.7.2.2 (04-Nov-2010) - -### Bug Fixes -* Fixed "3 * PI / 4 means West" in the Robot API, which should be "3 * PI / 2 means West". - * Thanks goes to Gottl Johannes for pointing this out. - -## Version 1.7.2.2 Beta (02-Oct-2010) - -### Bug Fixes -* [Bug-290][]: Development Options remove wrong item. -* [Bug-291][]: JavaDoc missing ``_Robot`` and similar -* [Bug-292][]: Robot PrintStream doesn't handle write in a portable fashion. -* [Bug-293][]: Wrong headings with the JuniorRobot. - * Thanks goes to Mr. Kschan for finding and providing a fix for this bug. :-) - -### New sample robots -* Tuan Anh Nguyen provided a modified version of the interactive sample robot named ``Interactive_v2``, which use absolute movement (up, left, down, right) on the screen that can be easier to control than the original ``Interactive`` sample robot. - * Both Interactive robots now use both the arrow keys and the W, A, S, D key for moving the robot. -* Sample robots have been written for the \#F language which are put in the "/samples/SampleFs" directory. - * These \#F sample robots are available with the .NET plug-in and comes along with Visual Studio project files. - -### New Features -* Implemented Robocode .NET Control API plug-in (robocode.control.dll) with documentation. -* [Req-115][]: Installed package should contain readme file. - * Added ReadMe.txt (using Markdown syntax) and ReadMe.html. - * The ReadMe is available from the Help menu. -* [Req-118][]: Enable/disable development paths. - * Check boxes for each of the entries in has been added to the Preferences -> Development Options. -* [Req-119][]: Provide JuniorRobot template for inexperienced users - -### Changes -* Robocode has been upgraded to use jni4net v0.8 with CLR 4.0 support. -* It is not necessary to specify ``-Dsun.io.useCanonCaches=false`` anymore with the startup scripts for Robocode and [RoboRumble][] as this property is now automatically set internally when running Robocode under Windows. - * Hence, this property has been removed from all .bat, .sh, and .command files for Robocode. -* Robocode will not notify about Beta versions anymore per default. - * However, a new option in the Common Options (under Preferences) makes it possible to enable/disable notifications about new Beta versions. -* The tabs for the "Common" and "Development Options" in the Preferences window are now the first tabs. - -## Version 1.7.2.1 (05-Aug-2010) - -### Bug Fixes -* [Bug-283][]: Possible for robot to kill other robot threads. -* [Bug-287][]: Zipped robots data files are not extracted. -* [Bug-284][]: Robot Packager doesn't package source file in Eclipse proj. -* [Bug-215][]: Missed onRobotDeath events. - * Thanks goes to ForNeVeR for finding and solving this bug. -* [Bug-282][]: Cannot see robot with no package in New Battle dialog. -* [Bug-285][]: Robot Packaging Wizard doesn't save value for Next & Back. -* [Bug-286][]: ``ClassNotFoundException at RobotClassLoader.java:271``. -* [Bug-288][]: "skipped" turns at start with ``-Ddebug=true``. -* [Bug-289][]: Exclude filters not working. -* Bug: Sometimes the compiler window was hanging for several seconds, even though the compiler had finished compiling. - -### Changes -* The Robot Packing Wizard will now only allow word characters (letters, digits, dots, *but not spaces*) with the version field. -* Added ``robocode.annotation.SafeStatic``, which can be used to suppress warnings in the robot console for a robot that uses a static Robot reference on a field. - * Note that this means that your robot will need to clean the static field, when a new round is started. - * This annotation was suggested by Nat Pavasant: - - @SafeStatic - private static AdvancedRobot robot; -* Added syntax highlightning on Java annotations for the Robot Editor. - -## Version 1.7.2.1 Beta (19-Jun-2010) - -### Bug Fixes -* [Bug-231][]: Lockup on start if too many bots in robots dir (cont'd). - * Additional fixes were made. -* Fixed some issues with the robot repository when file URLs contains spaces, where robots were sometimes disappearing from the repository. - -### Changes -* [Req-99][]: Move away from Jikes towards ECJ. - * Jikes 1.22 has been replaced with the Eclipse Compiler for Java (ECJ) 3.5.2. - -## Version 1.7.2.0 (28-May-2010) The ".NET robots are now supported" release - -### Bug Fixes -* Bug: Robots were disabled when skipping 30 skipping non-consecutive turns (or 120 turns when performing I/O operations). - * Now, Robocode is only disabling robots when the robot skips 30 consecutive turns, which is the original behavior, and which has been broken since version 1.6.1.4. -* [Bug-275][]: Duplicate version numbers prevents uploading. -* [Bug-276][]: ``tzu.TheArtOfWar 1.2`` gets ``NullPointerExceptions``. -* [Bug-278][]: Attempting to install robocode over an existing install NPEs. -* [Bug-281][]: The robocode.command is missing the execute permissions bit. -* [Bug-277][]: Problems with ``Graphics2D.fill/draw(Shape)``. -* [Bug-280][]: NPE when uploading results. -* [Bug-274][]: "Ignoring" messages in rumble are duplicated. -* [Bug-269][]: Minor visual bug - Currently selected robot gets covered. -* Bug: A security exception was thrown with development robots trying to access their data directory. - -### Changes -* Robocode will now only install batch files relevant to the hosting system, e.g., .bat files are not installed under Unix/Linux/Mac OS X, and .sh files are not installed under Windows. -* Furthermore, .command files are only installed under Mac OS X, and has now the execution permission bit set (due to [Bug-281][]). -* Robocode will now write out a warning in the robot console when a robot is detected that uses static references to a robot, i.e. static fields that are declared as e.g. a ``Robot``, ``AdvancedRobot``, ``TeamRobot`` etc. (typically references to the robot itself). - * A static reference to a robot can cause unwanted behavior with the robot accessing these. Hence, it is strongly recommended that static robot references in a robot class or within its helper classes are changed into non-static references and that the robot is recompiled afterwards. - * In every round, Robocode is creating new instances of the individual robot, meaning that static references to former ``Robot`` objects points to "dead" ``Robot`` objects that are not used anymore in the game, and which cannot be garbage collected during the battle when there is static references to these. - -## Version 1.7.2.0 Beta 3 (29-Apr-2010) The ".NET robots are now supported" release -Thanks goes to Alex Schultz for keep finding bugs, but also helping out solving these. :-) - -### Bug Fixes -* [Bug-271][]: Battle engine consumes more CPU power over time. -* [Bug-267][]: Strange issue first time running roborumble in 1.7.2.0 Beta2. -* [Bug-272][]: ``isTeammate()`` sometimes returns false with teammates. -* [Bug-263][]: Cannot extract downloaded robot for editing in Robot Editor. -* [Bug-270][]: Strange thread exceptions with kid.DeltaSquad in 1.7. -* [Bug-228][]: ``Krabb.sliNk.GarmTeam 0.9v`` locks up in new beta. -* [Bug-265][]: Occasionally losing the bit of text in the robot console. -* [Bug-255][]: ``java.lang.Error: Interrupted attempt to aquire read lock``. -* Bug: Teams with versions could not be found in a development path. -* Bug: Files in ``/robots/.data`` or ``/robots/.robotcache`` directory were put into an underscore sub-directory. -* Bug: The "Kill Robot" button in the robot console windows was often disabled. - -### Changes -* The robot console now uses a rolling buffer so when the number of lines in the robot console exceeds the max number of lines (500), the oldest lines are removed, and ``^^^ TEXT TRUNCATED ^^^`` is written in the top. - * Previously half of the text was truncated when the max number of lines was reached. - -## Version 1.7.2.0 Beta 2 (14-Mar-2010) The ".NET robots are now supported" release - -### Bug Fixes -* [Bug-254][]: Roborumble doesn't upload with ``EXECUTE=NOT``. -* [Bug-257][]: Team RoboRumble uploading is broken. -* [Bug-262][]: TeamRumble: Cannot find robot in nested .jar files. -* [Bug-244][]: Robot static data isn't being GCed after battle. - * Additional fixes were made to solve this issue. -* [Bug-258][]: ``isTeammate()`` called on null gives ``NullPointerException``. -* [Bug-260][]: ``ArrayIndexOutOfBoundsException`` when starting team battle. -* [Bug-250][]: Installer installs ``AutoExtract$1.class``. -* [Bug-252][]: ``yk.JahRoslav 1.1`` throws ``WinException``. -* [Bug-259][]: ``jlm.javaDisturbance`` loses substantial score in 1.7.2 Beta. -* [Bug-261][]: (.NET) condition tested on concurrently modified collection. - -### License Change -* We have changed license from Common Public License (CPL) v1.0 into Eclipse Puplic License (EPL) v1.0. - -## Version 1.7.2.0 Beta (15-Feb-2010) The ".NET robots are now supported" release - -### Bug Fixes -* [Bug-244][]: Robot static data isn't being GCed after battle. -* [Bug-245][]: Removing directories from "development options" doesn't work. -* [Bug-247][]: Version ordering is somewhat strange with letters. -* [Bug-243][]: Robot console text sometimes disappears. -* [Bug-240][]: ``morbid.MorbidPriest_1.0`` fails to load. -* Bug in ``RobotClassLoader`` causing ``ClassNotFoundException`` for some robots during robot class load. -* Fixed a ``NullPointerException`` occuring when Robocode is (re)loading the robot repository after a developer path has been removed. - -### New Features -* .NET Robocode plug-in. - * It is now possible to code robots in .NET and let them engage in Robocode battles. :-) -* [Req-101][]: ``onRoundEnded()``. - * It is now possible for robots to get notified when a round has ended. - * The ``onRoundEnded()`` event handler receives a new ``RoundEndedEvent`` that contains information about the number of turns in the round and total turns in the whole battle when the event occurred. - * The ``robocode.control.RoundEndedEvent`` in the Control API has been extended with a new method named ``getTotalTurns()`` similar to the new ``robocode.RoundEndedEvent`` for the Robot API. -* [Req-114][]: RateControlRobot vs. TeamRobot. - * The ``RateControlRobot`` is now a ``TeamRobot`` meaning that it can participate in team battles. -* [Req-113][]: Skipped turn events. - * Added ``getSkippedTurn()`` method on the ``SkippedTurnEvent`` class, which returns the turn that was skipped. - * The ``SkippedTurnEvent.getTime()`` returns the time when the ``SkippedTurnEvent`` was processed by the robot, which is always later when the robot is skipping turns. - * The message ``SYSTEM: you skipped turn`` has been improved, so it will tell which turn that was skipped like ``SYSTEM: john.Doh skipped turn 43``. -* [Req-80][]: Screenshot of battleview. - * Press Ctrl+T on Windows and Linux, and Command+T for Mac OS in order to take a screenshot of the battle view. - * The screenshot will be saved in the Robocode folder named "screenshots", and the filename will be a timestamp for when the screenshot was taken. -* [Req-89][]: Launch Robocode from .br (battle record) files. - * Robocode is now able to launch from from .battle (battle specification) and .br (battle record) files in Windows. -* [Req-86][]: Rankings should be visible when Robocode is minimized. - * A new View Option has been implemented to preventing speedup when minimized. - * This new View Option can now be set in the Preferences by putting a check mark into "Prevent speedup when minimized". -* [Req-93][]: Rename ``/robots/.robotcache`` to ``/robots/.data``. - -### Changes -* Browser support has been improved for Mac OS, Unix and Linux, which in most cases did not work properly. - * In previous versions of Robocode, the browser.sh was used to start up the user's preferred browser. The browser.sh file is not being used anymore. Hence, this file can safely be removed from your Robocode installation dir. - * Now, Robocode will start up a browser under Mac OS, Unix and Linux with no use of scripts. -* The Development Options dialog in the Preferences has been improved: - * Changed from using single interval selection to multi selection interval. - * Adding an existing path is ignored. - * The list of path is automatically sorted. - -## Version 1.7.1.6 (06-Jan-2010) - -### Bug Fixes -* [Bug-237][]: OS X 10.6: Cannot run Robocode from robocode.sh. - * It must be run from the new robocode.command file instead. -* [Bug-238][]: OS X 10.6: The editor cannot see the JD - * It must be run from the new robocode.command file instead. -* The ``onDeathEvent(DeathEvent)`` method was called too late, when a new round was about to start. Not when the robot has died. -* [Bug-231][]: Lockup on start if too many bots in robots dir (cont'd) - * Additional fix was made to locate multiple robots under the same package. -* Changed the robot painting so that everything that goes into the painting buffer is always painted, and remaining painting operations exceeding the buffer capacity are always dropped. - * Previously, only the last painting operations exceeding the painting buffer were executed. - -### New Features -* The amount of used memory and total memory is now shown in the title bar of Robocode. - * This is useful to see how much memory your robots are consuming. - -### Changes -* If the robot paints too much between actions, an improved error message is written out in the robot console. - * But from this version of Robocode this message is only written out once. -* A ``SecurityException`` is now thrown if a robot exceeds its max. data file quota, meaning that it uses more than 200.000 bytes its data files in total. - -## Version 1.7.1.6 Beta (10-Dec-2009) - -### Bug Fixes -* [Bug-236][]: Robot Editor doesn't accept packagename with dot (.) in it. -* [Bug-234][]: Source is not included. - * Additional fix was made for this issue. -* [Bug-231][]: Lockup on start if too many bots in robots dir (cont'd) - -### Requests -* [Req-92][]: Scrollable properties. - * All console windows including the Robot Console and Properties are now scrollable, and all have the same look. - -### Changes -* It is now possible to add paths to robot project inside an Eclipse workspace under the Development Options in the Preferences. - * Robocode will read the .classpath file in the project in order to locate both class files, properties files, and java files. - * This means that the Robot Packager is now able to include your source files when you use Eclipse, and it supports multiple source paths. - * **Note:** Robocode does not support linked sources or include and exclude filters. -* Changed the messages given when creating a new robot with the Robot Editor regarding robot name and package name. - -## Version 1.7.1.5 (11-Nov-2009) - -### Bug Fixes -* ``RobocodeFileOutputStream.getName()`` always returned ``null`` instead of the filename. -* Robots listed in e.g. the New Battle window was sorted like: 1.1.1, 1.1.10y, 1.1.2, 1.1.10 (alpha-numerical). - * But version numbers with an ending letter like in "1.1.10y" like in the versions just listed, were not placed in the correct order. - * Notice that 1.1.10y is between 1.1.1 and 1.1.2. This bug has been fixed so the versions in the example now will be sorted correctly like: 1.1.1, 1.1.2, 1.1.10, 1.1.10y. - -## Version 1.7.1.5 Beta (14-Oct-2009) - -### Bug Fixes -* [Bug-232][]: ``Graphics2D.getTransform()`` throws NPE. -* [Bug-233][]: "Teleport" - * occurred when robot's distance remaining was very large. -* [Bug-234][]: Source is not included. - * ``robot.java.source.included`` was not set in the robot.properties file. - -## Version 1.7.1.4 (25-Sep-2009) - -### Bug Fixes -* [Bug-226][]: ``java.io.FileNotFoundException`` in ``RobotFileSystemManager.init``. -* [Bug-227][]: Can't load ``Katana 1.0`` or ``DrussGT 1.3.1wilo``. -* [Bug-230][]: Lockup on start if too many bots in robots dir. -* [Bug-229][]: ``IllegalArgumentException`` on painting in some robots? -* Fixed ``NullPointerException`` that could occur with the ``-battle`` command-line option. - -### Changes - -#### Banning -* The previous 1.7.x.x versions have been very strict so that robots that could not be loaded, started, skipped too many turns etc. would be disallowed to participate in battles. - * With the bug fix for [Bug-227][] above this policy has been changed so robots are only "banned" if they cause a security violation or they could not be loaded or started (meaning that they will not be allowed to run). - * In addition, ALL security violations are always written out in both the main console and robot's console. A message will be written out in the main console like ``xxx has caused a security violation. This robot has been banned and will not be allowed to participate in battles``. - -#### Painting -* With the bug fix for [Bug-229][] a change was made so a robot will now receive this message in its console window, if it is painting too much between actions: - - SYSTEM: This robot is painting too much between actions. Max. capacity has been reached. -* Notice that a robot is not allowed to perform an unlimited amount of paint operations for two reasons: - 1. It takes up a lot of memory as the painting operations are recorded in a buffer before being processed, and potentially this buffer must be recorded to a file (for replays). - * A robot is allowed to use up to a maximum of 64 KiB per paint action. An average painting operation like e.g. ``fillRect(x, y, width, height)`` takes up 15 bytes, meaning that more than 4000 painting operations should be possible per paint action, which is a lot. - 2. It takes a lot of CPU cycles to process the painting buffer to the display making the painting slow if the buffer is too large. -* It is possible to remove the limit for the robots painting buffer by using the existing command-line option: ``-Ddebug=true``. - -## Version 1.7.1.4 Beta (26-Aug-2009) -This version is dedicated for the [RoboRumble][] community where many issues seen with the RoboRumble client have been solved. - -Thank you all for reporting as many known issues as possible, and also help out solving these - especially with the issue seen with the robot movement that had a big impact on the scores and rankings! :-) - -A big thanks goes to Patrick Cupka ("Voidious"), Julian Kent ("Skilgannon"), "Positive" and Nat Pavasant ("Nat") for their combined work with developing and testing the new and improved robot movement regarding acceleration and deceleration rules ([Bug-214][]). :-) - -### Bug Fixes -* [Bug-214][]: Accel/decel rules introduced in 1.7.1.3 causes trouble. -* [Bug-215][]: Missed onRobotDeath events. -* [Bug-212][]: Team jar files reported as corrupted. -* [Bug-208][]: Does not extract .properties files into bot data dirs. - * The previous fix for this issue did not work properly as the file sizes were truncated to 0 bytes. -* [Bug-216][]: Sometimes too few results for robots are displayed. -* [Bug-213][]: ``NullPointerException`` when setting classpath directory. -* [Bug-209][]: [Codesize] Invalid entry point in codesize-1.1.jar. - * Previous fix was not working properly. -* [Bug-218][]: Robocode enters infinite loop with the Restart button. -* Bug: The RateControlRobot (Beta) returned rates in radians instead of degrees with the methods: ``getTurnRate()``, ``getGunRotationRate()``, and ``getRadarRotationRate()``. - -### Changes for RoboRumble -* Updated the PARTICIPANTSURL in the roborumble.txt, meleerumble.txt, and teamrumble.txt. - -## Version 1.7.1.3 (08-Jul-2009) - -### Bug Fixes -* [Bug-210][]: Bullet and Ram Damage Bonuses are wrong. -* [Bug-208][]: Does not extract .properties files into bot data dirs. -* [Bug-207][]: Access denied ``javax.swing`` ``-DNOSECURITY=true``. -* [Bug-209][]: [Codesize] Invalid entry point in codesize-1.1.jar. -* Bug: Sometimes the "Show results when battle(s) ends" in the Common Options was disabled when running the RobocodeEngine, even though the setting had been enabled earlier. -* A ``NullPointerException`` occurred when closing the Preferences window, when no sound device is present in the system. - -### Changes -* The default font on the ``Graphics`` context when using ``onPaint(Graphics2D)`` or ``getGraphics()`` has been changed to the "Dialog" font. - -## Version 1.7.1.3 Beta (08-Jun-2009) - -### Bug Fixes -* ``AdvancedRobot.setMaxTurnRate()`` did not work properly since version 1.5.4. -* [Bug-205][]: Wrong survival scores sent by rumble client. -* [Bug-206][]: Funny behaviors with robot graphics/painting. - -### New RateControlRobot (Beta) -* Joshua Galecki has provided a new robot type, the ``RateControlRobot``, which is an extension of the ``AdvancedRobot``. -* The ``RateControlRobot`` class has been created in an attempt to allow more realistic robots. - * That is, many real/physical robots are given commands in terms of rates ("move forward one meter per second"). Hence, the ``RateControlRobot`` helps simulating a real robot. -* With this release, we ask the community for feedback and we will announce it as stable in one of next major releases. So please report issues or change requests etc. for this new robot type. - -### Changes for RoboRumble -* Added validation of each of the participant lines of the participant list. - * If a participant line is invalid due to e.g. wrong format/syntax or bad URL, then an error message is written out and the participant is ignored. -* The format of the lines in the participant lines is the same as usual. - * Accepted lines must follow this format: ``,(|)``, where must match the regular expression ``[\\w\\.]+[ ][\\w\\.-]+``, the must be a HTTP URL pointing at the robot .jar file, and the must be a number. The and are mutual exclusive. - * Example of accepted lines: - - johndoe.SomeRobot 1.0,http://somewhere.com/SomeRobot\_1\_0.jar - johndoe.SomeRobot 1.0,321 - -* Removed the info message "Trying to download " from the console output. - -### Other changes -* The Development Options has become more usable, as Ruben Moreno Montoliu has added a list of paths and buttons for adding and removing directories, full resizable. -* Updated the Javadoc with a note for the ``setAdjustXX()`` robot methods, which are ignored when turning with infinite values. - -## Version 1.7.1.2 (25-May-2009) - -### Bug Fixes -* [Bug-199][]: FontMetrics StackOverflowError. -* [Bug-200][]: ``Graphics2D.setFont()`` has no effect. -* [Bug-201][]: ``setMaxVelocity(lower than current) + reverse`` direction bug. -* [Bug-196][]: Wrong file path used for development bots. - * Refixed. -* [Bug-202][]: Installer says to run robocode.jar. -* [Bug-204][]: Nanobot rumble not sending melee or team parameters. - * Thanks goes to Jerome Lavigne ("Darkcanuck") for this fix. -* Fixed three bugs introduced with the Beta version found using new test units: - * One bug where the speed would immediately drop to max. velocity when calling ``setMaxVelocity()`` - disregarding the acceleration and deceleration rules. - * Another bug where the turn rate was a bit wrong when moving back and turning left in the same time. - * A third bug where the robot continued to move backwards when it should have stopped due to ``setAhead(0)`` or ``setBack(0)``. - -## Version 1.7.1.2 Beta (08-May-2009) - -### Bug Fixes -* [Bug-139][]: Bug in RobotPeer.updateMovement? - * Robocode was not moving 100% according to it's own rules. Now it is. -* [Bug-192][]: Fair Play! - * With two identical robots in a battle against each other, the first robots was much more likely to win, which was not fair. -* [Bug-195][]: Client tries to remove all participants. - * When RoboRumble, TeamRumble, and/or MeleeRumble downloaded the participants list and did not receive a ``HTTP_OK`` or an empty list, the participants list was emptied. This caused problems with the RoboRumble server. -* [Bug-196][]: Wrong file path used for development bots. - Added option ``-DALWAYSUSECACHEFORDATA`` for anyone who liked it better. -* [Bug-197][]: Melee rumble doesn't use "smart battles". - * Thanks goes to Jerome Lavigne ("Darkcanuck") for this fix. - * Smart battles are also known as "priority battles". -* Fixed several ``ArrayOutOfBoundsExceptions`` occurring when starting a battle with fewer robots than a battle just played with more robots. - -### Changes for RoboRumble -* The participants URL for RoboRumble, MeleeRumble, and TeamRumble have been updated to use the participant lists from the new RoboWiki: - * [RoboRumble](http://robowiki.net/wiki/RoboRumble/Participants). - * [MeleeRumble](http://robowiki.net/wiki/RoboRumble/Participants/Melee). - * [TeamRumble](http://robowiki.net/wiki/RoboRumble/Participants/Teams). - -### Other changes -* Updated the Help menu to point at the new RoboWiki regarding the Online Help and FAQ. -* RobocodeEngine control class: Added additional ``runBattle()`` method where it is possible to specify the initial positions of the robots when starting a battle. -* The about box was updated, where contributors are now written in bold and in a green color. - -## Version 1.7.1.1 (10-Apr-2009) -With this release we have focused on eliminating as many problems seen with [RoboRumble][] as possible. Hence, this version should hopefully prove stable as the new RoboRumble client. - -### Bug Fixes for RoboRumble -* [Bug-188][]: Meleerumble using 2 bots instead of 10. - * Now the ``MELEEBOTS`` (number of robots that participate in a melee battle) works as expected. -* [Bug-193][]: TeamRumble uploading result for Robot instead of team. -* [Bug-187][]: Not enough java memory allocated in launch scripts. - * The launch scripts for RoboRumble and TeamRumble were changed so it is allowed to use up to 512 MB heap memory, and MeleeRumble is allowed to use up to 1024 MB. -* [Bug-191][]: ``EOFException`` during repository rebuild. - * Exception is now reported in a simplified way. -* [Bug-194][]: JarJar multi-registration. - * RoboRumble was not reusing the same RobocodeEngine instance. - -### Other bug fixes -* [Bug-169][]: ``pe.SandboxDT_3.02`` stopped working in 1.6.2 and later version. - * We had broken semantics of ``getTeammates()`` to return empty array when there is no team. -* [Bug-189][]: API - cannot subclass Event in 1.7.1. -* [Bug-190][]: Errors with some robot classes when rebuilding database. -* [Bug-185][]: Webpage button lay over robot description. -* [Bug-186][]: Rounds number do not saved between run. - -### JuniorRobot changes -* Bug - The event variables ``scannedXX`` and ``hitXX`` on the JuniorRobot was not reset to -1 (or -99) when nothing was scanned or hit. -* [Req-90][]: Prevent JuniorRobot to be unresponsive. -* **Change:** JuniorRobot will now automatically scan for enemies when it is not moving. - -## Version 1.7.1 (24-Mar-2009) - -### Bug Fixes -* [Bug-176][]: Editor UNDO does delete the line when no undo left. -* [Bug-180][]: Editor: Find (set cursor position). -* [Bug-182][]: roborumble.sh and teamrumble.sh are broken. -* [Bug-183][]: ``NullPointerException`` in ``BattlesRunner.runBattlesImpl``. -* [Bug-184][]: Custom event priority broken. - -### Changes -* The New Battle dialog is now larger per default. -* The layout of the View Options and Sound Options tab in the Preferences has been improved. - * An error dialog is shown when the input field for the desired TPS is out of range. - -## Version 1.7.1 Beta 2 (11-Mar-2009) - -### Bug Fixes -* [Bug-178][]: Typing to find bot no longer works. -* [Bug-181][]: API: Typo in Documentation ``onBulletMissed(BulletMissedEvent)``. -* [Bug-179][]: Event.setTime() method should not be hidden. - * Put back ``setTime()`` method of ``Event``, the security is now handled other way instead of hiding the field. -* Fixed the problem with loading team robots from nested .jar files. -* On Ubuntu (Linux) the "Default window size" did not work properly. - -### Internal Changes -* On SUN's JVM enabled caching of .jar files opened thru ``URLConnection``. - * Solved problem with closing such files by implementing ``URLJarCollector``. - -## Version 1.7.1 Beta (01-Mar-2009) -With this release we give BIG thanks to Nat Pavasant who have put in great effort in testing and finding as many bugs in Robocode as possible. He has been a great help with testing especially [RoboRumble][] functionality. - -Currently, there is one known issue, which will be fixed with the next Beta or in the final release of version 1.7.1. This is critical for e.g. the TeamRumble, so please notice the known issue below. - -### Known issue -* With this version Robocode cannot handle team packages containing robot .jar files, i.e. robot packages. - -### Bug Fixes -* [Bug-166][]: Bots referencing ``robocode.robocodeGL`` broken. -* [Bug-168][]: Bots inconviently stop working if they go over time limit. -* [Bug-172][]: Robot console fails to display some deaths/wins. -* [Bug-174][]: Robot console is sometimes empty. -* [Bug-173][]: Robot packager can be activated once per running. -* [Bug-175][]: Development robots cause problems with data files. -* [Bug-171][]: A battleview size exceed 800x600 filled with black. -* [Bug-165][]: ``NullPointerException`` when using ``-battle`` option from cmd-line. -* [Bug-170][]: Robot Colors don't stick between rounds. -* [Bug-177][]: Open battle menu dialog is not loading robots. -* Bug: The command line usage of Robocode was not printed out at all when using the ``-?`` or ``-help`` option. - -### New Features -* Added ``getCurrentWorkingDir()`` + ``getRobotsDir()`` to the ``robocode.control.RobocodeEngine``. -* [Req-86][]: Rankings should be visible when Robocode is minimized. - * This feature has been added and it is possible to control the behavior from Common Options in the Preferences with the "Don't hide Rankings when main window is minimized", which is enabled per default. -* [Req-88][]: Command Line option for saving a battle record file. - * Two new command line options have been added for Robocode, i.e. ``-record `` and ``-recordXML ``. - * The ``-record option`` records the battle as a binary and zipped battle record. Here I propose that the specified filename should is something like record.br. - * The ``-recordXML`` does the same as the -record option, but saves the battle record as an XML file. Here I suggest that you use a filename like record.br.xml. -* [Req-49][]: Speedup time required for rebuilding robot database. - -### RoboRumble Changes -* Changed the link for [http://rumble.fervir.com/rumble](http://rumble.fervir.com/rumble) into [http://darkcanuck.net/rumble](http://darkcanuck.net/rumble) as the RoboRumble server fervir is down and with unstable ranking. - * The current ranking at Darkcanuck's server is alive. Almost all clients are point to Darkcanuck's now. Hence, it is updated now. -* [Req-82][]: Launch upload result in separate thread. - * Results from the [RoboRumble][] client is now uploaded in a seperate thread. -* [Req-84][]: Added append option in copy method (``FileTransfer`` class). - -### Internal Changes -* The robot repository has been updated. It is no longer extracting .jar files. - * It also remembers last timestamp on file so detection of the changes is really fast. Only data files are extracted now. - * Data files for non-packed robots were moved to .robotcache as well. -* VersionManager is now able to detect if the Robocode version was upgraded since last run. -* Blocking security issue with relative path in ``getDataFile()`` method. -* Improved security in RobotClassLoader. -* Reimplemented RobotPackager. -* ``BulletSnapshot`` has now method ``getBulletId()`` which gives identity of bullet for UI. - -## Version 1.7.0.2 (16-Feb-2009) - -### Bug Fix -* The fix for [Bug-164][] (Compiler Classpath Suggestion) backfired, as the entire text field in the window with the compiler properties would now be quoted. - * Hence, the compiler would not be able to compile, and it was not possible to change the compiler preferences from the GUI. - -## Version 1.7.0.1 (14-Feb-2009) - -### Bug Fixes -* [Bug-163][]: Spaces or native names in name of robocode directory. - * Some users experienced problems with starting Robocode. Hence, all startup batch and shell files for Windows, Linux, Mac OS X etc. have been corrected. -* [Bug-164][]: Compiler Classpath Suggestion. - * When running Robocode in a folder with spaces, the compiler classpath was not quoted. Hence, the compiler would not work. - -## Version 1.7 (11-Feb-2009) - -### Bug Fixes -* [Bug-160][]: Battle Results screen displaying old results. - * The results where not updated on the Battle Results windows between battles. -* [Bug-161][]: Robot disabled by any other than losing energy can recover. - * Robots disabled due to bad behaviour could regain energy by hitting another robot by a bullet after it had been disabled. - * Now this is only possible when the robot has disabled itself by using all its energy, and will be able recover energy by hitting an enemy, which is allowed. -* [Bug-162][]: Team battle. - * Robots like ``abc.Shadow 3.83``, ``davidalves.Phoenix 1.02``, and ``kawigi.micro.Shiz 1.1``, ``kawigi.micro.ShizPair 1.1`` caused a ``NullPointerException`` and would not show up on the battle window. - -## Version 1.7 Beta 2 (26-Jan-2009) - -### Bug Fixes -* [Bug-158][]: Ubuntu throws ``NullPointerException`` in main. - * This bug occurred when trying to startup Robocode. -* [Bug-159][]: Installation fail on windows if directory contain space. - -### Changes -* Improved the version checking for new Robocode versions available for download. - -## Version 1.7 Beta (19-Jan-2009) -* This version represents a completely new infrastructure of Robocode making it easier to extend and maintain for the future. It does not contain New Features compared to the previous version of Robocode, but focus on working the same way as the previous versions despite of all the restructurings. - -### Bug Fixes -* [Bug-156][]: Spammy output on robot console windows. - -### Internal Changes -* Robocode was modularized using the dependency injection framework PicoContainer. - * This work includes introduction of many interfaces to existing components. -* Introduced Maven2 as build setup where the whole directory layout is based on the standard Maven structure. -* Rewritten the ``RobotClassLoader`` so it is able to load .jar file in the future. -* Rewritten security layer to use ``AccessController`` and ``CodeSource`` for detection of trusted code. -* Redesigned ``RobocodeProperties`` to ``SettingsManager`` and introduced ``ISettingsListener``. -* Implemented ``RbSerializer`` to be able to implement IPC (Inter-Process Communication) in future. - * This should make it possible to extend Robocode for more platforms like e.g. Microsoft .NET. -* Redesigned ``RepositoryManager`` and nearby to hide implementation details. -* Moved all implementation of Robocode to the package ``net.sf.robocode``. - * The old package ``robocode`` is now "used only" for API to outer world in order to keep backwards compability. - -## Version 1.6.2 (04-Jan-2009) - -### Bug Fixes -* [Bug-154][]: Robot name missing when replaying XML record. -* [Bug-153][]: Junior Robot ``turnAheadRight`` bug. - * When a JuniorRobot was calling ``turnAheadRight()``, ``turnAheadLeft()``, ``turnBackRight()``, or ``turnBackLeft()``, the following exception occurred causing the robot to be terminated: - - java.lang.ClassCastException: robocode.peer.proxies.StandardRobotProxy -* [Bug-151][]: Exception when changing between ``Robot`` to ``AdvancedRobot``. - * When a robot was changed from a ``Robot`` into an ``AdvancedRobot`` and recompiled, the game would cast a ``ClassCastException`` if a battle was started or restarted including that particular robot. - * However, this bug did not occur with new battles where the list of robots was refreshed (by pressing Ctrl+R). - -## Version 1.6.2 Beta 4 (22-Dec-2008) - -### Bug Fixes -* Fixed open battle dialog, which was not loading. -* Fixed recorder NPE. -* Fixed serialization problems of scan arc (``Arc2D``). -* Fixed problem with reloading robot repository on each next battle dialog. - -## Version 1.6.2 Beta 3 (18-Dec-2008) - -### Changes -* Published new battle events and battle snapshots in the Control API, i.e. in the ``robocode.control`` package. -* Added missing Javadocs (HTML documentation) to public Robocode API classes. - -### Bug Fixes -* The current scoring (not the total scoring) was calculated wrong from version 1.6.1. - * The current Ramming Kill Bonus was set to current bullet kill bonus, which gave wrong ranking in the Ranking Panel. -* [Bug-148][]: Wrong bullet power. - * Wrong bullet power could be reported back from ``Bullet.getPower()``, which could be ``> Rules.MAX_BULLET_POWER`` or ``< Rules.MIN_BULLET_POWER``. -* [Bug-147][]: gunHeat is negative. - * gunHeat could be negative, which should never occur. -* [Bug-149][]: Replay exception. - * An ``ArrayIndexOutOfBoundsException`` occurred in some situations. -* Fixed problem with ``RobocodeEngine.setVisible(true)``, where the ``RobocodeEngine`` would hang forever. - -## Version 1.6.2 Beta 2 (07-Dec-2008) - -### Bug Fixes -* Fixed problem with Bullet identity. -* Battle cleanup concurrency issue. -* Fixed problem with robots without package. -* AWT AppContext cleanup. -* Fixed versions comparison problem. - -### Changes -* Mostly cleanup of code and documentation. -* Improved compatibility with RobocodeJGAP. -* Development robot version names were visible in the robot repository. - -## Version 1.6.2 Beta (25-Nov-2008) - -### Bug Fixes -* [Req-78][]: Visual debugging without cpu penalty. - * Now Robocode gives a robot unlimited time when painting is enabled on UI (in the robot dialog) for that robot. -* Robocode will not load non-valid robots from repository anymore. -* Fixed placement of the robot dialogs (aka. robot console windows). -* Exception on robot's ``Condition`` doesn't break further processing now. -* [Bug-146][]: Spammy output when running roborumble. - * Output from RoboRumble was spammy when outputting log after the first battle. -* ``java.lang.IllegalArgumentException: Line unsupported: interface Clip supporting format`` could occur when starting Robocode. -* [Bug-81][]: Replay recording does not record paintings. - -### New Features -* [Req-24][]: Recording of battles. (fully implemented) - * Battle recording and replay: Saving to binary and xml file. -* [Req-63][]: Replay should store debug graphics. - * Robot painting and debug properties are now being recorded, but robot painting is not exported to xml. - * Recording is slowing down the game and eats memory and disk space. Hence, you need to enable it in options, as it is disabled per default. -* New command line option ``-replay`` for replaying a battle record. -* New dialog for battle console and battle turn snapshots. -* Robot dialog: New tab-page with robot properties. -* The robot API has been extended with a new ``setDebugProperty()`` method. - * See the ``sample.PaintingRobot`` robot for example of usage. -* [Req-31][]: Redirecting Robot output, running without GUI. - * The ``robocode.control`` package has been improved so that the ``RobocodeEngine`` is able to return much more detailed information about was is going on inside the battle for each turn, round, and battle thru a new ``IBattleListener`` interface. - * With the new ``RobocodeEngine`` it is possible to a detailed snapshot of the game state, e.g. the states of all robots and bullets, and also get the messages sent to the robot console etc. -* [Req-77][]: Better "lifebar" display. - * Robot buttons on the Battle View is now showing the amount of energy and score as two coloured bars within the robot button. - -### Changes -* Redesigned ``RobotPeer`` and ``Battle``. - * Now we send messages between threads instead of synchronizing individual properties. - * Code here is much more readable now. -* Most synchronization is now interlocked. -* Event manager, priority and dispatch of events refactored. -* The methods ``setPriority()`` and ``setTime()`` on the ``Event`` classes are no longer part of the Robot API. - * These methods were used internally by the game. - * Events are final classes now. -* More unit tests were added. -* ``Graphics2DProxy`` optimized. -* Interactive robots are better detected to not waste time of non-interactive robots. -* Team messages are deserialized on receiver robot thread. -* Got rid of robot loader thread. - * Now Robocode is loading on robot's thread, where we got more security. -* Introduced new interfaces for code components. -* Robot threads have ``NORM_PRIORITY - 1``, AWT UI have ``NORM_PRIORITY + 2``. -* [Req-75][]: Add client version to POST data sent to server. - * We now upload the [RoboRumble][] client version when uploading results to the RoboRumble server. -* Robots which are "wrong behaving" are removed from the robot repository and are not given another chance to run. - * This goes for skipped turns, for unstoppable robots and for robots with class loading troubles. -* Changed the formatting of this versions.txt file in order to improve readability. - -## Version 1.6.1.4 (14-Nov-2008) - -### Bug Fixes -* Loosing robots were not receiving ``onBattleEnded(BattleEndedEvent)`` events. -* A new security issue fix for robots that were able to execute code thru the Event Dispatch Thread (EDT). - * **Robots that try to access the EDT will be disabled!** -* [Bug-144][]: drawArc does not work as expected. - * Both ``drawArc()`` and ``fillArc()`` are now using the Robocode coordinate and angle system. -* [Bug-143][]: Blank console window when compiling. - * Some systems still had this issue, so a new fix has been applied. - -### New feature -* [Req-65][]: Score % display. - * The results and current rankings (during a battle) is now showing the score as percentage(s) in parenthesis right beside the score points like e.g. '7875 (12%)' for the total score in the results and '21 / 2900 (7 / 14%)' with the current rankings. - * Thanks goes to Endre Palatinus, Eniko Nagy, Attila Csizofszki and Laszlo Vigh for this contribution! - -### Changes -* The command-line option ``EXPERIMENTAL`` (= ``true`` or ``false``) allowing access to the robot interface peer is now working for the ``RobocodeEngine`` class also. - -## Version 1.6.1.3 (24-Oct-2008) - -### Bug Fixes -* [Bug-143][]: Blank console window when compiling. - * This bug was introduced in 1.6.1.2. - * When trying to compile a robot that would give a compiler error, the output console window for the compiler could be blank on Windows system and/or hang. - * Now the compiler error is output correctly as in previous versions. -* [Bug-137][]: Roborumble ``ITERATE`` broken. - * When running RoboRumble with ``ITERATE=YES``, ``DOWNLOAD=YES``, and ``RUNONLY=SERVER``, the ratings were only read once, not per iteration. - * This bug fix removes a very old bug and the need of using a batch file as workaround in order to do the loop with updated ratings. -* [Bug-141][]: The ``-DROBOTPATH=`` option does not work. -* [Bug-142][]: Broken .sh files. - * An misplaced colon character was included in the teamrumble.sh file. -* Fixed issue with first time access to a robot's data directory after startup, where the robot was not allowed to write to it's own file. - -### Changes -* [Bug-130][]: Various usability issues. - * The list of available robots in the 'New Battle' dialog is now automatically refreshed before it is being shown, when a new robot has been compiled or a robot has been removed. - * The 'Save' and 'Save As' in the File menu of the Robot Editor is now enabled and disabled depending if there is anything to save or not. - -## Version 1.6.1.2 (12-Sep-2008) - -### Bug Fixes -* RoboRumble: Sometimes results were given to the wrong robots, which gave a problem with the robot rankings in the RoboRumble, TeamRumble and MeleeRumble. - * Thanks goes to Joachim Hofer ("Qohnil") for fixing this issue! :-) -* RoboRumble: Robots that read their data file got the following error message: - - Preventing unknown thread from access: (java.io.FilePermission... -* ``ArrayOutOfBoundsException`` could occur when accessing the ``Graphics2D`` object returned by the ``getGraphics()`` method on the ``Robot```classes. -* The ``draw(Shape)`` method on the ``Graphics2D`` object returned by the ``getGraphics()`` method could not draw lines. -* The ``onMousePressed()`` event was called twice instead of only one time per mouse press. - -## Version 1.6.1.1 (28-Aug-2008) - -### Bug Fixes -* Issues with the scoring. - * Sometimes the robots were ranked incorrectly compared to their total scores given in the battle results. -* When disabling the security (``-DNOSECURITY=true``) it would not be possible to run any battles as the following error would occur: - - RobocodeFileOutputStream.threadManager cannot be null! -* [Bug-135][]: ``-battle`` broken. - * When using a battle file, the battles were not displayed one the GUI. -* [Bug-134][]: Robot problem after Options->Clean robot cache. - * Robots that tried to access their data file, like e.g. ``sample.SittingDuck`` got a ``AccessControlException``. -* [Bug-131][]: Sometimes the compiler window hangs. - * This bug only occurred when the compiler gave compilation errors. -* ``IllegalArgumentException`` occurred when calling ``setStroke()`` or ``setComposite()`` on the ``Graphics2D`` object returned by the new ``getGraphics()`` method on the Robot. - -### Changes -* The intro battle will only be shown if a battle file has not been specified using the ``-battle`` command-line argument and Robocode is being run for the first time since installation. - * Previously, the intro battle was always shown even though a battle file had been specified. - -## Version 1.6.1 (17-Aug-2008) - -### Bug Fixes -* [Bug-125][]: TimeoutExceptions occur when debugging in Eclipse. - -### Changes - -#### New Methods -* Added ``getGraphics()`` to ``Robot`` and ``IBasicRobotPeer``. - * A robot is now able to paint itself at any time, and not only using the ``onPaint()`` event handler. -* Added ``getStatusEvents()`` to ``AdvancedRobot`` and ``IAdvancedRobotPeer``. - * A robot is now able to handle status events in the middle of an event handler. - -#### New Event -* [Req-66][]: "onBattleIEnd(*)" Event. - * The the ``onBattleEnded()`` event handler is provided through the new ``IBasicEvents2`` class. - * The new event ``BattleEndedEvent`` has been added. - * When this event occur the new event handler ``onBattleEnded()`` will be called on the robot, i.e. when the battle is ended. - * When reading the ``BattleEndedEvent`` it is possible to read out the results of the battle of the individual robot or team. - * In addition, it is possible to check if the battle was aborted by the game or user. - * The battle results will only be available if the battle is not aborted (where the results does not count). - -#### Paint Events -* Paint events are now put in the robot event queue, meaning that the robots will pay CPU time when their ``onPaint()`` event handler is called. -* Added the ``PaintEvent``, which makes it possible to set the event priority of paint events using the ``AdvancedRobot.setEventPriority()``. - -#### Mouse and Keyboard Events -* Mouse and keyboard events have added as new pulic classes and put into the robot event queue. - * The robots will pay CPU time when their ``onMouseXX()`` and ``onKeyXX()`` event handlers are called. - -#### Package Name -* [Req-70][]: Longer package name allowed. - * The max. length of a robot's full package name has been extended from 16 to 32 characters. - * The Robocode Repository is able to handle this (verified with Dan Lynn). - -#### New TPS Slider -* The TPS slider has been redesigned to be more exponential, so it covers battle in slow speed (1-30 TPS), higher speed (30 - 120 TPS), and fast speed (120 - 1000 TPS). -* If you set the slider to max. TPS the game will run as fast as possible. - * This feature already existed in earlier versions. -* If you set the slider to minimum (0 TPS) the game will pause. - * This is a new feature. - -#### The FPS (Frames Per Second) -* The max. FPS is now fixed to be max. 50 FPS allowing the TPS (turns per second) to be even faster. - -#### New Title Bar -* The title on the Robocode window is now showing the current turn in a battle, and is updated every half second. -* The layout of the information shown in the title has been improved a bit. - -#### Dialogs -* The About box, New Battle Dialog, Preferences Dialog, Ranking Dialog, and the Compiler Preferences Dialog are now modal. -* It is now possible to close the New Battle and Results Dialog by pressing the Esc key. - -#### Ranking Panel -* The menu item for the Ranking Panel is now hidden when replaying a battle. - * The Ranking Panel is now being hidden if it is visible, when a battle is being replayed. - * The reason for hiding the Ranking Panel is that the replay feature does not support displaying the current rankings during the replay, i.e. the current scores are not recorded. - -#### Command-line Options -* Added the new ``-DPARALLEL`` option (set to ``true`` or ``false``), which allows robots to run in parallel intended to take advantage of more CPU's available in the system. - * This option may speedup battles with multiple CPU time consuming robots. However, the time measuring is not per robot. -* Added the new ``-DRANDOMSEED`` option (set to a random seed value), which enables the new repeatable and deterministic random generator. - * The benefit of using this option to make it easier to test and debug your robots, as your robots will appear in the exactly same positions, when you rerun a battle. -* The ``-DPARALLEL`` and ``-DRANDOMSEED`` option has no effect when running RoboRumble, MeleeRumble, and TeamRumble. - -#### New Random Generator -* Added a new deterministic and repeatable random generator is used by the game and overrides the random generator used throughout the whole virtual Java machine. - * Methods like e.g. ``Math.random()`` will be using the exactly the same deterministic random generator enforced by Robocode. -* The new random generator will only be deterministic, if the ``-DRANDOMSEED`` option is enabled, i.e. when ``-DRANDOMSEED=12345678`` (or another value). Otherwise the the battles will run truly randomized. - -#### System Logging -* The system log output has now been split, so logged errors are sent to ``System.err`` and logged messages are sent to ``System.out``. - * This makes it possible to filter out messages from errors when reading out the logs from Robocode. -* The system log also includes a full stack trace when errors are logged, making it easier to determine where an error has occurred. - -#### Various Usability Issues -* [Bug-130][]: Various usability issues. - * Added "Enable all" and "Disable all" button in the View Options of the Preferences. - * When the TPS slider is set to 0, the game is paused, and the Pause/Resume button set to paused mode. - * When the TPS is 0 and the Pause/Resume button is pressed, the game will resume at 1 TPS, and the TPS slider will now move to 1. - * In the New Battle window, the focus is now kept in the list of available robots when one of the two 'Add' buttons has been pressed. - * Previously the focus was lost, and you had to reselect robots in the list of available robots in order to add more robots. - * Multiple robots can now be added to a battle by using the arrow keys with e.g. the Alt+A. - * Rearranged the order of menu items here and there, and also improved the name of some menus. - -## Version 1.6.0.1 (03-Jun-2008) - -### Bug Fixes -* [Req-74][]: Option for enabling/disabling robot timeouts. - * It was not possible anymore to debug robots from Eclipse as ``TimeoutExceptions`` occurred when trying to resume from a breakpoint. - * Now, Robocode must be started by adding the option ``-Ddebug=true`` to the VM arguments when debugging Robocode from Eclipse (or any other IDE). - * The documentation (Wiki) about how to debug robots using Eclipse using the ``-Ddebug=true`` option will be updated. -* Fixed missing internal robot proxy layer introduced in Robocode 1.6.0. - -## Version 1.6.0 (01-May-2008) - -### Bug Fixes -* The CPU constant was not calculated the first time Robocode was started up. -* [Bug-123][]: Compiler fails to build due to CR/LF in scripts. - * Removed ^M characters from the buildJikes.sh file so that the Jikes compiler can be built under *nix based system like Linux and Mac OS X. -* Fixed a security issue where robots could access the internals of the Robocode game thru the AWT Event Queue. - * Robots that try to access the AWT Event Queue will now be disabled due to "bad behaviour". - -### New Robot Interfaces -* A new package named ``robocode.robotinterfaces`` has been introduced, which contains pure Java robot interfaces for basic, advanced, interactive, junior and team robots. - * See the Robocode Javadocs (HTML) documentation for more details about these new interfaces [here](http://robocode.sourceforge.net/docs/robocode/robocode/robotinterfaces/package-summary.html). -* The main purpose of the new robot interfaces is to make it possible for robot developers to create new robot types with their own API, but also to create robots using other programming languages, which requires used of interfaces instead of classes. -* The robot interfaces obeys the rules within Robocode, so it is not possible to create new game rules. However, it is possible to create new robot types with other methods names etc. (new API) based on the new robot interfaces. Also note that is is possible to create your own robots based directly on the robot interfaces. -* See the new '/robots/sampleex' directory for some examples of how to use these new interfaces in Java. -* The introduction of the new robot interfaces required a great deal of changes and cleanup of the internal structures of Robocode, but for the better (future). -* A new command line option has been made for Robocode named ``EXPERIMENTAL``, which must be set to ``true`` in order to allow the robots to access the internal robot peer with the robot interfaces for performing robot operations. - * When this flag is not set, you'll get a SecurityException in your robot if it is inherited from a robot interface. - * This option must be set in the robocode.bat or robocode.sh like ``-DEXPERIMENTAL=true``. - * **Note** that this experimental option might be removed in the future so that robots are always allowed to access the robot peer from the new robot interfaces. -* Most work with the robot interfaces was performed by Pavel Savara that has joined the development of Robocode, who have done a tremendous job with the new robot interfaces. - -### Other Changes -* Added a "Make all bullets white" option to the Rendering Options. -* When this option is enabled, all bullets on the battle field will be painted in white. - * Use this options when you need to see all bullets on the battle field, i.e. when bullet colors are almost invisible. That is, some robots might try make the bullets "invisible" to cheat the observer. - * Thanks goes to [Robocode Ireland](http://robocode.ie/) for holding a turnament showing that this option was crusial when battles are shown on a big screen for a large audience. -* Lots of the Javadoc (HTML) documentation for the Robocode APIs were updated. - -## Version 1.5.4 (15-Feb-2008) - -### Bug Fixes -* [Req-62][]: Fix for massive turn skipping when cpu constant < granularity. - * The CPU constant was way too little compared to version 1.4.9. - * This is a critical bug when Robocode is used for competitions like the [RoboRumble][]. - * Now the CPU calculation has been improved by using a heavy math benchmark that have been adopted from Robert D. Maupin ("Chase-san"). -* The method for determining if a robot has exceeded it's CPU time limit has been improved to use nano second precision (using ``System.nanoTime()``), to get rid of an issue with millisecond granularity that is too coarse. - * This method was created by Julian Kent ("Skilgannon"). - -## Version 1.5.3 (30-Jan-2008) - -### Bug Fixes -* [Bug-122][]: Not all shortcut keys work on MacOS. -* Some of the mnemonics on the menus on the Help menu did not work correctly. -* ``NullPointerException`` occurred when clicking a robot button on the right side of the battle view, when no battle was running. - -### Changes -* Keyboard shortcuts have been replaced to comply with OSes where the function keys (F1 - F12) are not available or have a specific purpose, and thus should not be overridden. - * The F5 shortcut key for refreshing the list of available robots in the New Battle, Robot Packager, Robot Extractor, and Team Creator window has been changed to 'modifier key' + R, i.e. Ctrl+R on Windows and Linux, and Command+R for Mac OS. - * The F6 shortcut key for 'Compile' has been changed to 'modifier key' + B, i.e. Ctrl+B on Windows and Linux, and Command+B for Mac OS. - * The F3 shortcut key for 'Find Next' has been changed to 'modifier key' + G, i.e. Ctrl+G on Windows and Linux, and Command+G for Mac OS. -* When a robot or team is being packaged an UUID is added in the .properties and/or .team files in the newly generated robot or team archive file (robot/team .jar file). - * The UUID is a unique identifier for the robot or team, which is generated every time a robot or team package is being created or overwritten. -* This feature has been made to support New Features provided in Robocode Repository, which is currently being updated. - -## Version 1.5.2 (08-Jan-2008) - -### Bug Fix -* On some systems Robocode would not start up when trying to run robocode.bat or robocode.sh. - -## Version 1.5.1 (12-Dec-2007) - -### Bug Fix -* Fixed security flaw with the Event Dispatch Thread, where robots could use the ``SwingUtilities.invokeLater()`` for running any code they should like to. - * Thanks goes to John Cleland who reported this security flaw and provided some very good examples of robots that could do some nasty cheats/hacks. - -## Version 1.5 (05-Dec-2007) - -### Bug Fixes -* [Bug-115][]: AWTException with RoboRumble on OS X. -* [Bug-97][]: Exception when packaging robots. - -### Changes -* [Req-58][]: HitRobotEvent - damage. - * Redundant ``HitRobotEvents`` are no longer occurring when Robocode is performing collision detection between two robots. - * Previously, if a collision occurred between a stationary robot (i.e. not moving) and another robot that was moving, then two ``HitRobotEvents`` would first be sent to each robot based on the stationary robot - even though no damage was done. Next, two ``HitRobotEvents`` would be sent to each robot based on the robot that was moving, which **was** causing damage. - * Now ``HitRobotEvents`` will only occur when damage is done to each robot. No ``HitRobotEvents`` will be ever be sent when no damage is done. That is, when a stationary robot is "colliding" with another robot. -* [Req-57][]: Events processed in chronological order. - * The events in the robot event queue are now sorted in chronological order so that events that occurred before newer events gets processed first. - * Previously, the event queue was ordered based on the event priorities so that the events with the highest priorities were processed first. - * This could cause some problems with robots with skipped turns, as their event queue would potentially contain events from different time frames. - * Now it is perfectly safe for robots to assume that events occurring before other event are processed first. - * Events occurring in the same time frame is still sorted based on their priorities so that the events with higher priorities are processed before events with lower priorities. -* [Req-53][]: More control over the event queue. - * The priority of the ``DeathEvent`` was changed from the reserved priority 100 to -1 in order to allow robots to process all pending events before they die. - * Previously, robots were not able to process all events when it died as the ``DeathEvent`` was having the highest possible priority. - * Now, when the ``DeathEvent`` has the lowest priority, meaning that this event will be the last event left on the robot's event queue before it dies. That is, all events in the event queue have already been processed when reaching the ``DeathEvent``. -* [Req-60][]: Enhanced CPU constant calculation. - * The CPU constant is now measured in nanoseconds rather than milliseconds. - * Using New Features introduced of Java 5.0 that provides more precise timing and also offer better granularity of timings. -* [Req-64][]: Change default battle settings like e.g. "Number of Rounds". - * The "Number of Rounds" value on the New Battle Dialog is now saved and restored when the game is restarted, i.e. Robocode remember Number of Rounds you used the last time. -* Improved the output of the command line usage of Robocode when called from the command line with the ``-?`` or ``-help`` option. - -### New Features -* [Req-54][]: All input received from events. - * The Robot class has got a new ``onStatus(StatusEvent e)`` method. - * This event handler is automatically called for each turn of a battle, which contain a complete snapshot of the current robot state at that specific time/turn. - * This new method makes it possible to map a specific robot class field value to a specific time. -* [Req-56][]: Robots Cache Cleaner. - * Added the Robot Cache Cleaner tool created by Aaron Rotenberg ("AaronR"). - * This tool is used for cleaning the cache files of the robots, which is very useful with the [RoboRumble][] client, where most problems with the robot repository can be solved by cleaning the robot cache files. - * This tool is activation by selecting "Clean Robot Cache" in the Options menu or by running the tool from a command line (standing in the robocode home directory): - - java -cp ./libs/robocode.jar;./libs/cachecleaner.jar ar.robocode.cachecleaner.CacheCleaner - -## Version 1.4.9 (07-Nov-2007) - -### Bug Fixes -* [Bug-120][]: The renderering is slower on Vista than XP? -* [Bug-116][]: Exclude filter removes bots from the RoboRumble. - * [RoboRumble][] participants excluded with the ``EXCLUDE`` filter were removed from the ratings, which is not the intension. - * In addition, if trailing white-spaces occurred with the comma-separated list for the ``EXCLUDE`` filter, the filter did not filter out participants correctly. - * With the release of 1.4.8 this bug was claimed to be fixed, but unfortunately the bug fix was missing in the build of the 1.4.8 release. -* Corrected bug seen with the ``JuniorRobot``, when first calling ``turnAheadLeft(100,90)`` and then ``turnRight(90)`` right after this call, where the robot turn quickly to the left, but slowly to the right. -* The calculation of the possible frame rate (FPS) was calculated incorrectly. - * This caused Robocode to run with lower FPS (when rendering battles on the GUI) compared to what is possible with the available hardware. - * With this bug fix, Robocode will render the battles even faster than before in most cases. - -### Changes -* When a new CPU constant is being calculated it will now take the system time granularity (OS dependent) into account. - * Previously, if the CPU constant was less than the time millis granularity, then skipped turns could occur on robots when the CPU constant < system time millis granularity. - -## Version 1.4.8 (25-Oct-2007) - -### Bug Fixes -* [Bug-114][]: Wait Interrupted Message. - * With Robocode 1.4.7 a minor bug was introduced so that the robot console printed out "Wait interrupted" when a round was completed. -* [Bug-117][]: Sound card is being dodgey/not detected by OS causes error. -* [Bug-118][]: Battles fail when executing with Eclipse debugger. - * When debugging robots or the Robocode game itself within Eclipse on Windows, the Java VM was crashing with an "Access Violation". - -## Version 1.4.7 (09-Oct-2007) - -### Bug Fixes -* [Bug-112][]: Forcing stop: no score will be generated. - * Some robots did not receive any score even though they won the battle. - * The cause of this bug was due to Robocode that did not always detect if the robot's thread(s) had been properly terminated. - * Thanks goes to Eric Simonton, David Alves, and Aaron Rotenberg ("AaronR") for help solving this issue! -* Teams located in the '/robots/.robotcache' directory were still put into the robot.database file. - * Thus, teams located in the .robotcache directory were incorrectly shown in the New Battle dialog. -* [Bug-110][]: Partial match recording replay. - * "Ghost" rounds: When stopping a battle while recording was enabled and then replaying the recorded battle, Robocode would show the last rounds of the battle even though no recording occurred for these rounds. -* [Bug-113][]: ``-battle`` option runs at full speed. - * When using the ``-battle`` option Robocode would run at full speed, i.e. the TPS set to maximum, even though the GUI was enabled with a predefined TPS. - * Now, the TPS is only set to maximum when the ``-nodisplay`` option is being used. -* [Bug-111][]: Wasted time at end of each round. - * Robocode was wasting time on trying to wake up robots that were dead. - * Robocode was blocked for the amount of milliseconds defined by the CPU constant when a robot was killed in a battle, as Robocode was waiting for the dead robot to wake up for exactly this amount of time. -* [Bug-85][]: No window position in-bounding. - * When starting Robocode, saved window locations (x and y coordinate) of a window might not fit into any of the available screens/displays (e.g. virtual desktop). - * Robocode will now center windows into the current screen displayed. - -### Robocode Changes -* The Stop button is now only enabled when a battle is running and will will be disabled after the battle has ended. - -### RoboRumble Changes -* The configurations files roborumble.txt, meleerumble.txt, and teamrumble.txt have been improved: - * All properties are now documented and have been grouped more logically. - * The ``BATTLESPERBOT`` property has been raised to 2000 for the RoboRumble and MeleeRumble. -* [Req-55][]: Exclude Filter for RoboRumble. - * An exclude filter has now been added, which makes it possible to exclude participants that causes trouble somehow. - * The exclude filter is controlled using the new ``EXCLUDE`` property, which takes a comma-separate list of participants where the wildcards * and ? can be used - * Excluded participants are not added to the participants file, and will not be downloaded or take part in battles. - -## Version 1.4.6 (25-Sep-2007) - -### Bug Fixes -* [Bug-107][]: Bullet hit locations reported inaccurately. - * The coordinates of a ``Bullet`` from a bullet event like ``HitByBulletEvent()`` was not correct as the coordinates of the bullets would follow the bullet explosion on the robot it has hit. - * Now the coordinates of the ``Bullet`` will not change when it hits a robot or another bullet, even though the coordinates of the bullet explosion will change internally (for painting the explosion). - * This means that the coordinates of a bullet received from a bullet event will actually be on the real bullet line. - * The initial explosion painting on a robot has also changed so it shows exactly where the bullet has hit the robot. -* When Robocode cleaned up the robot database a ``NullPointerException`` could occur if the robot database was pointing to a missing file. -* [Bug-108][]: It is possible to restart a battle without any robots. - * The Restart button was enabled when no battles had previously been started. -* [Bug-106][]: Incorrect repaint of paused battlefield. - * The areas of the battle field was repainted with the black background together with the Robocode logo when the game was paused and the battle window was repainted. Hence, it was not possible to see the current state of the game on the battle field. -* [Bug-98][]: When minimized doesn't show actual tps. - * When the Robocode window was minimized the actual TPS and FPS were not shown. -* When installing new versions of Robocode on top of an existing Robocode installation, the About window did not have the right height. - -### Changes -* The color of each bullet is now independent on the current color set with the ``setBulletColor()`` method. - * Previously, all bullets were instantly changing their colors when ``setBulletColor()`` was called. - * Now, the color of the bullet will stick to the bullet color set when the bullet was fired. -* Improved the "Check for new version", so that is able to differ between release type as alpha, beta, and final release types. - -## Version 1.4.5 (17-Sep-2007) The "Fair Play" release - -### Bug Fixes -* [Bug-104][]: Reproducable scoring bug. - * Unfair play: Two robots with the same code (but different names) would get different scores instead of a 50-50 split. - * Robots listed before other robots in a battle would gain a minor benefit compared to the other robots. This was in particular the case if they killed each other at the same time. Then the robot listed first would get a "half turn" advantage over the other robot. - * Now, the ordering does not matter anymore, as when ever the robots are checked one at a time in sequence, then they will be checked in random order. -* [Bug-103][]: ConcurrentModificationException. - * ``ConcurrentModificationException`` could still occur when called one of the ``getXXEvent`` methods with an ``AdvancedRobot``. - * Now all ``getXXEvent`` methods like e.g. ``getAllEvents()`` are all synchronized directly with the internal event queue of the robot before reading out the events. -* [Bug-105][]: ``testingCondition`` flag not reset. - * Test Condition flag of a robot was not reset between rounds. - * If the robot thread was disabled while testing a condition for a custom event all following rounds will trigger an exception: - - robocode.exception.RobotException: You cannot take action inside Condition.test(). You should handleonCustomEvent instead. - -* [Bug-101][]: "Keyboard lockup" with interactive robots. - * The sample robot named ``sample.Interactive`` has been changed for Robocode 1.4.5 so it continues moving forward or back when the UP or DOWN arrow key is being pressed down. Previously, the robot would only move 50 pixel when pressing down the UP or down arrow key, which was not intuitive compared to the behaviour with traditional first person shooter games. Thus, this looked like a bug. -* [Bug-87][]: Round indicator incorrect. - * Again, the title of Robocode was incorrectly showing round N+1 of N when a battle was ended. -* Memory leaks occurring during a round due to missing cleanup of bullets have been removed. - * Note that _ALL_ bullets were actually cleaned up, when ending the battle (containing one or several rounds). - * One good side-effect of this bug fix is that the game is speeded up, especially when running in minimized mode, as the game does not have to perform unnecessary calculations on bullets that is not visible on the battle field anymore. - -### Changes -* The sample robot named ``sample.Interactive`` has been changed so it continues moving forward or back when the UP or DOWN arrow key is being pressed down. - * Previously, the robot would only move 50 pixel when pressing down the UP or down arrow key, which was not intuitive compared to the behaviour with traditional first person shooter games. Thus, this looked like a bug. - -## Version 1.4.4 (09-Sep-2007) - -### Bug Fixes -* With version 1.4.3 a bug was introduced so that ``battleAborted()`` was called in the ``robocode.control.RobocodeListener`` when the battle was not aborted, i.e. when a battle completes successfully. - * This bug caused Robocode clients as e.g. RoboRumble to hang! -* Removed Windows end-of-line characters from the .sh files for RoboRumble. - -### Change -* Robocode now throws a ``NullPointerException`` if the condition parameter has been set to null when calling ``addCustomEvent()`` or ``removeCustomEvent()`` on an ``AdvancedRobot``. - -## Version 1.4.3 (07-Sep-2007) - -### Bug Fixes -* [Bug-95][]: OutOfMemory: Robots are Being Left on the Stack. - * Major bug fixes was done by Nathaniel Troutman to get rid of large memory leaks, especially when creating and destroying ``robocode.control.RobocodeEngine`` instances many times. - * Most of the memory leaks were caused by circular references between internal classes/objects in Robocode. Now, these such circular references are cleaned up. -* The configuration files for RoboRumble was completely missing under the /roborumble folder, i.e. the meleerumble.txt, roborumble.txt, and teamrumble.txt. -* [Bug-94][]: Inconsistent Behavoir of ``RobocodeEngine.setVisible()``. - * This fix was done by Nathaniel Troutman. - * When invoking the RobocodeEngine to directly run a battle(s) and calling ``RobocodeEngine.setVisible(true)``, and then later call ``RobocodeEngine.setVisible(false)`` the results dialog would still show up at the end of a battle. -* [Bug-96][]: Initializing Label even when no display. - * Did another fix where a dummy AWT (GUI) component was created even though the GUI was disabled causing problems when trying to run e.g. RoboRumble remotely without the GUI enabled. -* [Req-52][]: The 'New Battle' window sometimes is spamed with .robotcache. - * Sometimes the "New Batle" window would show robot classes that reside in the .robotcache folder under the /robots folder. This occurred when the robot database was (re)builded, e.g. if the robot.database file was missing. -* [Bug-99][]: Clicking on a bottom area results in ``ClassCastException``. - * When running battles including the MyFirstJunior and the pressing the mouse button outside of the battle field a ``ClassCastException`` would occur. -* [Bug-100][]: Double-clicking "restart". - * When double-clicking the Restart button for the battle window the UI could lock up completely trying to play all battles, and it would not be possible to stop the battle. - -## Version 1.4.2 (26-Aug-2007) - -### Bug Fixes -* [Bug-92][]: RoboRumble tries to connect with GUI. - * RoboRumble was invoking AWT (GUI) stuff when running, which caused problems on systems without support graphical display or running [RoboRumble][] remotely behind a firewall. -* [Bug-102][]: Bots can hold memory after being destroyed. - * When running ``robocode.control.RobocodeEngine`` it caused memory leaks each time a new instance of the ``RobocodeEngine`` was created, even though the object was completely destroyed. -* [Bug-93][]: ``onPaint(Graphics2D g)`` called prematurely. - * The ``onPaint()`` method was invoked just before the robot got the chance of updating it's internal world model. - * Now the battle view is updated as the first thing right after the robots have updated their internal model. -* [Bug-71][]: RobocodeEngine becomes slower the more battles that are run. - * The Robocode engine was halted with spurious exceptions when an exception occurred inside an ``onPaint()`` method in a robot, i.e. when the robot itself causes an exception inside ``onPaint()``. - * Now, whenever an exception occurs inside the ``onPaint()`` method of a robot, the exception is now being catched by Robocode and printed out in the robot console. - * Due to this bug exception handlers have now been added to all ``onKeyXX`` and ``onMouseXX`` events, where the exceptions are now printed out to the robot console. -* A ``ConcurrentModificationException`` bug did still occur with the internal ``EventQueue`` of a robot. - -## Version 1.4.1 (19-Aug-2007) - -### Bug Fix -* [Bug-91][]: ``ConcurrentModificationException``. - * A couple of ``ConcurrentModificationException`` bugs were introduced with version 1.4, which are now fixed. - * Thank goes to Helge Rhodin ("Krabb") for help with solving the bug! - -## Version 1.4 (14-Aug-2007) The "Junior Robot" release - -### Bug Fixes -* [Bug-88][]: Scorch layer. - * I changed the behaviour of the scorch marks + plus a lot more. -* Static fields on robots were not cleaned up anymore after each battle has ended. -* [Bug-90][]: Limit per round, not turn. - * When printing to ``out`` in ``onScannedRobot()`` event before a ``scan()`` call, the the logging to out would stop with an system error that to much is printed out. - -### Changes - -#### Added JuniorRobot -* The ``JuniorRobot`` class is simpler to use than the ``Robot`` class and has a simplified model, in purpose of teaching programming skills to inexperienced in programming students. - * This new robot type has been designed by Nutch Poovarawan / Cubic Creative team. -* Added ``sample.MyFirstJuniorRobot``. - * This robot is very similar to ``MyFirstRobot``, but tracks it's scanned enemy better. - -#### GUI: Changed Menu Shortcut Key -* Robocode forced the use of the Ctrl key to be used as menu shortcut key. - * Now Robocode ask the Java VM what menu shortcut key to use. -* This change means that Mac OS X users should now use the Command key instead of the control key. - * Thanks goes to Nutch Poovarawan for the tip of how to do this! :-) - -#### Improved Battle View a bit -* A red border is now painted around the battlefield when the battleview's height and/or width is larger than the battlefield. -* Explosions are painted outside the battlefield, when the battleview is larger than the battlefield. -* The text for the Robot names and scores are now "clipped" to the width and height of the battleview instead of the battlefield. - -#### Added "Recalculate CPU constant" to the Options Menu -* [Req-50][]: Recalculate CPU Constant. - * This makes it possible to force recalculation of the CPU constant. - -#### RoboRumble Changes -* Redundant RoboRumble config files are now removed from the /config folder. -* Changed ``UPLOAD=NOT`` to ``UPLOAD=YES`` as default, i.e. the results are now automatically uploaded to the RoboRumble server. - -## Version 1.3.5 (04-Jul-2007) The "Fast renderings" release - -### Bug Fixes -* [Bug-87][]: Round indicator incorrect. - * The title was displaying "Playing round N+1 of N" when the battle has ended. -* [Bug-86][]: Using UI removes focus from interactive bots. - * Key events are now received even though the battle view does not have the focus. - -### Changes - -#### Faster Rendering -* The battle rendering is now 30-50% faster due to image buffering (but uses more memory). -* A new "Buffer images" option under the Rendering Options can be enabled/disabled on the fly while playing a battle. - * By default, "Buffer images" is enabled which makes the rendering faster, but which also uses additional memory. -* Due to the faster renderings, explosion debris is now enabled by default. - -#### Controlling Robocode -* The container classes in the robocode.control package are now Serializable, which makes it easy to load and store, battle specifications, results etc., but also to send these over the network. - -## Version 1.3.4 (27-Jun-2007) The "Interactive" release - -### Bug Fixes -* [Bug-84][]: Preferences page problem on machine w/out sound card. - * ``NullPointerException`` occurred when trying to open the Sound Options page from the Preferences when no sound card (or actually audio mixer) is present in the system. - -### New Features -* The Robot class has now been extended with keyboard and mouse events/methods: - * ``onKeyTyped(KeyEvent)`` - * ``onKeyPressed(KeyEvent)`` - * ``onKeyReleased(KeyEvent)`` - * ``onMouseMoved(MouseEvent)`` - * ``onMouseClicked(MouseEvent)`` - * ``onMousePressed(MouseEvent)`` - * ``onMouseReleased(MouseEvent)`` - * ``onMouseEntered(MouseEvent)`` - * ``onMouseExited(MouseEvent)`` - * ``onMouseDragged(MouseEvent)`` - * ``onMouseWheelMoved(MouseEvent)`` - - These New Features adds a new dimension to the game, i.e. you could make robots that must be controlled entirely manual, semi-automized robots, or press various key for changing between various robot strategies, e.g. when debugging. - - Thus, it is now possible to create robots where multiple human players battle against each other, or compete against existing legacy robots. - -### New Sample Robot -* A new sample robot named "Interactive" has been added to demonstrate how to control a robot using keyboard and mouse events only. -* This robot is controlled by the arrow keys and/or the mouse wheel, and let the gun point towards the current coordinate of the mouse pointer used for aiming. Mouse buttons are used for firing bullets with various fire power. - -### Minor Changes -* The background Robocode logo has been changed into green and the Robocode slogan "Build the best, destroy the rest" was added. - -## Version 1.3.3 (22-Jun-2007) - -### Bug Fixes -* [Bug-82][]: Undo comment does not change font color of code. - * Wrong colors when undoing and redoing multiline comment in the Robot Editor -* When a battle was stopped a new battle could start before the previous battle was closed down. -* When restarting a battle while it was paused caused strange behaviour with new battles, and the "Next Turn" button stopped working. -* [Bug-83][]: Ranking Panel Does not update number of competitors. - * In some situations the Rankings Panel did not show the results for all robots. - * This could be seen if first playing a battle with only 2 robots, and then start a new battle with more robots. In this case, only the rankings for the top 2 robots were shown. - -### Changes -* The Rankings Panel and Results Dialog are now automatically packed to fit the table containing the rankings/results. - -## Version 1.3.2 (09-Jun-2007) - -### Bug Fixes -* The ``sample.SittingDuck`` would not start when no GUI is enabled. -* The Look and Feel is not set if the GUI is disabled. -* The robocode.sh ignored command line arguments (e.g. under Linux and Mac). -* [Bug-80][]: Results file is empty with the command line. - * When setting the ``-result`` parameter from the command line the results file was empty. - -### Changes -* When specifying the ``-battle`` parameter the .battle extension and battle directory can be omitted. - * Hence you can write ``-battle sample`` instead of ``-battle battles/sample.battle``. - * If a specified battle file does not exist Robocode will now exit with an error. -* If you specify the ``-results`` parameter the last results will now always be printed out, i.e. with and without the GUI enabled. Otherwise, if the GUI is not enabled (by setting the ``-nodisplay`` parameter) then the last results will be printed out to system out. - -## Version 1.3.1 (30-May-2007) - -### Bug Fixes -* When loading a battle, the robots specified in the battle file were not selected on the battle dialog. -* When the intro battle has finished the battle settings are now reset to the default battle settings. - * This fixes the issue were the fixed robot starting positions are still used in new battles and where the "Number of Rounds" was set to 1 instead of 10. -* [Bug-79][]: Output displayed in bursts. - * The output in the robot console windows were written out in bulks instead of immediately. -* Bugs fixed in RoboRumble which could cause a ``IllegalThreadStateException``. - -### Changes -* Robocode will now print out an error message and just proceed if problems arise with trying to set the Look and Feel (LAF) to the system LAF. -* [Req-44][]: Restart tweak. - * When stopping or restarting a battle, the battle will now stop immediately instead of continuing for a while showing robot explosions when the robots are being terminated due to the stop. -* [Req-45][]: Reset compiler cancel button. - * Added confirm dialog when trying to reset the compiler preferences from the Compiler -> Options -> Reset Compiler in the Robocode Editor in order to prevent the compiler preferences to be reset by accident. - -### New Features -* Added link to Java 5.0 Documentation in the Help menu. - -## Version 1.3 (17-May-2007) Now featuring the RoboRumble client - -### Bug Fixes -* [Bug-78][]: Robots are disabled with no timer or countdown. -* [Bug-74][]: Java FilePermission error during startup. - * The Event Dispatch Thread was denied access by the Robocode Security Manager. -* [Bug-75][]: ``getTeammates()`` problem. - * Changed back the ``TeamRobot.getTeammates()`` to return ``null`` if no teammates are available. - * This rollback was done in order to keep compatibility with robots developed for older versions of Robocode. -* [Bug-72][]: The game won't play sounds on 2nd launch. - * No sounds were played (when enabled) when Robocode was launched the second time. -* [Bug-73][]: Sound don't work. -* [Bug-76][]: Unique error. - * Lots of synchronizations issues and potential ``ConcurrentModificationExceptions`` have been fixed. -* [Bug-70][]: Version 1.2.6A incompatible with Roboleague. - * The bug causes this exception: - - Exception in thread "Thread-4" java.lang.NoSuchMethodError: robocode.control.RobotResults.getRamDamageBonus() -* [Bug-69][]: Robot causes Null Pointer Exception. - * Fixed ``NullPointerException`` occurred when a robot is forced to stop. -* When using ``robocode.control.RobocodeEngine`` it was not possible to play team battles. Instead an ``ArrayOutOfBoundsException`` occurred. -* ``robocode.control.RobotResults.getRamDamage()`` incorrectly returned a double instead of an integer. - * This bug caused problems with running Robocode on RoboLeague. -* The "Enable replay recording" got set if it was not set after running Robocode without the robocode.properties file the first time. -* ``NullPointerException`` could occur when using ``robocode.control.RobocodeEngine`` and the GUI was not enabled. -* The text field for the filename in the robot packager was way too high. -* In RoboRumble, the codesize of some robots were incorrectly calculated to be 0 bytes, and hence these robots was not able to participate in [RoboRumble][] battles. -* This was due to the codesize tool, which could not analyze .jar files inside .jars. - -### Changes - -#### RoboRumble Client is now built-in -* [Req-39][]: Support for RR@Home - * RoboRumble@Home client, originally developed by Albert Prez, is now built-in. - * [RoboRumble][] is the ultimate collaborative effort to have a live, up-to-date ranking of bots. - * It uses the power of available robocoder's computers to distribute the effort of running battles and building the rankings. - * For more information about RoboRumble@Home you should read its [home page](http://robowiki.net/wiki/RoboRumble). - * The version of the RoboRumble client included in Robocode is an updated version of the original one that can run with the current version of Robocode and which has been ported to Java 5. - * Configuration files has been updated, and are available in the 'roborumble' folder. - * Issues with downloading robots from the Robocode Repository site has been fixed. - * Special thanks goes to Gert Heijenk ("GrubbmGait") who did a tremendous job with lots of alpha testing regarding the new RoboRumble@Home built into Robocode! :-D - -#### Codesize -* [Req-38][]: Codesize. - * The codesize tool by Christian D. Schnell has been added to support the built-in [RoboRumle][] plus a new feature for getting the codesize and robot codesize class (MiniBot, MegaBot etc.) when a robot is being packaged. - * This tool has now been taken over by Flemming N. Larsen (agreed with Christian) and updated to version 1.1, which can handle files > 2KB, and also analyse .jar files inside .jar files. - -#### Start Positions -* [Req-36][]: Initial Placement. - * Added feature that allows specifying the initial start positions of the robots on the battlefield. - * By specifying positions by setting ``robocode.battle.initialPositions`` in a .battle using this format ``(x1,y1,heading1),(x2,y2,heading2),(?,?,?)`` you can specify the initial location and heading for each robot specified with ``robocode.battle.selectedRobots``. - * One example is: - - (50,50,90),(100,100,?),? - - * This means that: - 1. the 1st robot starts at (50,50) with a heading of 90 degrees, - 2. the 2nd robot starts at (100,100,?) with a random heading, - 3. the 3rd (and last) robot starts at a random position with a random heading. - - * See the battle/intro.battle for an example of how to use this option. - -#### Robot and Control API -* Added a new method called ``getNameAndVersion()`` to the ``robocode.control.RobotSpecification``. - * This method was added to better support [RoboRumble][] and similar ranking programs. -* Changed the ``TeamRobot.broadcastMessage()`` so it does not throw an ``IOException`` when the robot is not in a team. - -#### Improved File Structure -* The file structure of Robocode has been slightly improved. -* All .jar files including robocode.jar are now located in the libs folder. -* The robot.database and .robotcache files has been moved to the robots folder. -* All RoboRumble related files are located in the roborumble folder. - -## Version 1.2.6A (11-Mar-2007) - -### Bug Fixes -* A ``NullPointerException`` occurred if the battle view was not initialized. -* This bug made it impossible to control Robocode via the ``robocode.control`` package when attempting to show the battle window. - -### Changes -* [Req-37][]: Running Score Window. - * The Ranking Panel and Battle Results are now windows instead of dialoges. - * This means that the Ranking Panel and Battle Results will still be visible when the game is running in minimized mode. - -## Version 1.2.6 (06-Mar-2007) - -### Bug Fixes -* [Bug-66][]: Crash: starting a new round while et.Predator 1.8 is playing. - * With some robots, a ``java.lang.NoClassDefFoundError`` occurred when Robocode tried to cleanup the static fields occupied by the robot when the battles are over. -* [Bug-67][]: Some issues with MessageEvent + priority. - * These 4 issues were fixed: - 1. In the Robocode API -> AdvancedRobot -> setEventPriority there is information about all event priorities except MessageEvent priority. - 2. You can call ``getEventPriority("MessageEvent")``, but when you call ``setEventPriority("MessageEvent", someValue)`` you gets a ``"SYSTEM: Unknown event class: MessageEvent"`` message and the priority doesn't change. (using ``TeamRobot``). - 3. ``getEventPriority("MessageEvent")`` returns 80, so (if it is true) it "collides" with ``CustomEvent`` priority which is also 80 by default. This way you can't assume which event will be called first basing on its priority. - 4. Unlike it is done for other events, there is no ``getMessageEvents()`` function. -* [Bug-68][]: Preferences not saved. - * The rendering options was not set correctly when loading these between battle sessions. -* When using the ``RobocodeEngine.setVisible(true)`` the Robocode window was shown with the wrong size and without the native Look & Feel. - -### Changes - -#### New TeamRobot Method -* Added missing ``getMessageEvents()`` to the ``TeamRobot``. - -#### Default Event Priorities -* The changes were made as some events "shared" the same default priority, making it hard to tell which event would occur before the other. -* ``BulletHitBulletEvent`` priority was changed from 50 to 55. - * Previously, both ``BulletHitEvents`` and ``BulletHitBulletEvents`` used priority = 50. -* ``MessageEvent`` priority was changed from 80 to 75. - * Previously, both ``CustomEvents`` and ``MessageEvents`` used priority = 80. -* The Ranking Panel has been enhanced. - -#### Ranking Panel -* Now the Ranking Panel contains the same columns as the Battle Results. -* Both the current scores and total scores are shown together where it makes sense. -* The column names of both the Ranking Panel and Battle Results have been improved. - -#### New Pause/Debug Button -* [Req-35][]: Pause Button. - * A Pause/Debug button has been added to the Robot Console window. - * This is handy if you want to pause the game when only your robot's console window is open when the game is minimized. - -#### Battle Window -* The Pause/Debug button on the Battle Window has been changed into a toggle button. -* The "Next Turn" button is now always visible, but not alvays enabled. - -#### Documentation -* The documentation of the Robocode API (Javadoc) has been improved a lot. - -#### Installer -* The Installer is now checking is the user is running Java 5.0 or newer. -* If the Java version is older than 5.0, then an error message will display telling the user to install at least JRE 5.0 or JDK 5.0, and the installation is terminated. - -#### robocode.sh -* robocode.sh has been updated. - * Armin Voetter has contributed with an improved version of robocode.sh so that the script resolves the path to Robocode by itself. - -## Version 1.2.5A (19-Feb-2007) - -### Bug Fix -* On some systems Robocode could not start up due to a ``NullPointerException`` in the internal sound manager/cache. - -## Version 1.2.5 (18-Feb-2007) - -### Bug Fixes -* [Bug-65][]: Cannot run robocode after installation. -* [Bug-63][]: BulletHitBullet only destroys one bullet. - * When two bullets collided, one of the bullets was not destroyed, but continued. -* [Bug-64][]: Exception when referencing length of an array of ``String``. - * ``TeamRobot.getTeammates()`` returned ``null`` instead of an empty array when no teammates are available. -* [Bug-62][]: Memory "Leak". - * Memory leak could occur on robots using large objects on static fields. - * Robocode now clean all static object fields that are not final after each battle, but not between rounds. That is, the static fields are now garbage collected. -* Some ``ConcurrentModificationException`` issues were removed. - -#### Changes - -### Sound Effects (SFX) -* The sound effects in Robocode can now be changed. - * This is done by specifying the file for each sound effect using the ``file.sfx.xxx`` property keys in the robocode.properties file, e.g. the ``file.sfx.gunshot`` for setting the sound effect for gunshot. - - * ``robocode.file.sfx.gunshot``: the sound of a gun shot. - * ``robocode.file.sfx.robotCollision``: the sound of a robot colliding with another robot. - * ``robocode.file.sfx.wallCollision``: the sound of a robot hitting the wall. - * ``robocode.file.sfx.robotDeath``: the sound of a robot dying, i.e. exploding. - * ``robocode.file.sfx.bulletHitsRobot``: the sound of a bullet hitting a robot. - * ``robocode.file.sfx.bulletHitsBullet``: the sound of a bullet colliding with another bullet. - -* The supported sound formats can be found [here](http://java.sun.com/j2se/1.5.0/docs/guide/sound/). - -#### Music Support -* Robocode now supports music. -* By specifying the file for each music file using these properties in the robocode.properties file for setting: - - * ``file.music.theme``: the startup theme music. - * ``file.music.background``: background music during battles. - * ``file.music.endOfBattle``: the "end of battle" music when a battle is over. - -* The supported music formats can be found [here](http://java.sun.com/j2se/1.5.0/docs/guide/sound/). - -#### Misc. -* The column names in the Battle Results window have been improved. -* Keys in the robocode.properties file (the configuration file) are now automatically sorted when saved. -* Previously the keys were put in random order each time the property file was saved. - -## Version 1.2.4 (25-Jan-2007) - -### Bug Fixes -* [Bug-60][]: ``ConcurrentModificationException`` when extracting robots. - * This exception sometimes occurred when robots were imported when Robocode was starting up. -* [Bug-59][]: Issue when setting the priority of a ``BulletHitBulletEvent``. - * Added methods for setting and getting the priority of ``BulletHitBulletEvent`` that was missing completely in Robocode?! -* Removed ``IndexOutOfBoundsException`` when replaying battles. -* Explosion debrise was shown in the lower left corner (0,0) when starting battles and battle ground is set to visible. -* [Bug-61][]: Hang when checking for new version with no Internet access. - * Robocode could hang when checking for a new version when no Internet connection was available. - * Now a 5 second timeout has been added to prevent Robocode from hanging. - -### Changes - -#### Robots Die Faster -* [Req-33][]: Making robots die quicker (graphically). - * Robocode stops painting the battlefield and playing sounds when a battle is ended after 35 turns. - * However, the robots still have 120 turns until they are really killed like Robocode is used to, but the battle continues like if it was running in minimized mode (fast). - -#### Options -* The common options for enabling replay recording has been changed to disabled per default. - * When running lots of battles in a row with replay recording enabled Robocode runs out of memory, which causes problems when running tournaments. -* Added "View Explosion Debris" option in the View Options. - * Explosion debris is diabled per default as this feature can slow down the game with 25% - 50% when viewing battles. - -#### Javadocs -* [Req-34][]: Provide javadoc for robocode.util.Utils and robocode.control. - * Javadocs have been provided for: - * The ``robocode.util.Utils`` class providing angle normalizing methods. - * The ``robocode.control`` package used for controlling Robocode externally. - -#### Files -* Fixed incosistency with .jar files located in the robot folder. -* Robot packages (.jar files) is now only extracted from the root of the robots folder. -* In previous Robocode versions when starting up Robocode without a robot.database file and .robotcache directory, Robocode would extract Robot packages from the root of the robot folder and also the sub folders. When running Robocode the first time without these files, robots from the sub folders were shown (if available), but not the following times when Robocode was started up. - * This fix was done by Robert D. Maupin ("Chase-san"). - -## Version 1.2.3B (14-Jan-2007) - -### Bug Fixes -* [Bug-58][]: ``NullPointerException`` during replay. - * Titus Chen made a bug fix for a ``NullPointerException`` that caused a replay to stop. - * This occurred when "Pan" was enabled for the mixer in the Sound Options during a replay. -* When using robocode databases ("robot.database") created with version 1.2.3 and earlier version in version 1.2.3A, Robocode crashed in the startup with a ``ClassCastException``. - -## Version 1.2.3A (12-Jan-2007) - -### Bug Fix -* [Bug-57][]: ``ConcurrentModificationException``. - * Removed a ``ConcurrentModificationException`` that occurred when processing robot events. - -### Changes -* Robert D. Maupin ("Chase-san") replaced all old type Java containers like ``Vector``, ``Hashtable``, ``Enumeration`` with the newer and faster types like ``ArrayList``, ``HashMap``, and ``Set``. - * This improves the performance a bit, especially when running in "minimized" mode. - -## Version 1.2.3 (10-Jan-2007) - -### Bug Fixes -* Removed ``NullPointerException`` when trying to restart the initial intro battle. -* [Bug-54][]: Flickering when constantly changing colors. - * Titus Chen made a fix for this fix, which occurred when the max. amount of robot colors (i.e. 256) was exceeded. -* [Bug-55][]: Incorrect score after replay. - * Thanks goes to Titus Chen for reporting this issue + providing a fix for this issue. -* Minor bug fix in the Extract Results dialog, where an empty line was following each line of text. - -### Changes - -#### Added Replay Feature -* A new "Replay" button has been added to the toolbar at the buttom of the battle screen. - * The replay feature makes it possible to replay a battle. -* In a comming version of Robocode, it will be possible to load and save replays. -* [Req-24][]: Recording of battles. (partially implemented) - * Added "Enable replay recording" option to the Common Options for enabling and disabling replay recording as replay recording eats lots of memory. - * When the replay recording is disabled, the "Replay" button will not be available. - -#### Improved the security manager -* Robots are not allowed to access any internal Robocode packages anymore, except for the ``robocode.util`` package in order to let legacy robots access the ``robocode.util.Utils`` class, e.g. for calling ``normalRelativeAngle()`` etc. - -#### New hotkey -* Hotkey added for exiting Robocode quickly. - * It is now possible to exit from Robocode by pressing Alt+F4 in the main window of Robocode. Note that the main window must be active. - -## Version 1.2.2 (14-Dec-2006) - -### Bug Fixes -* [Bug-52][]: Extra hit wall events. - * Extra ``HitWallEvents`` were occuring. - * Thanks goes to Titus Chen for reporting this issue + providing a fix for this issue. -* [Bug-53][]: Teams not always ranked correctly. - * Thanks goes to Titus Chen for reporting this issue + providing a fix for this issue as well. -* In addition, the ranking scores and final battle results have been made consistent. -* The radar scan arc was not painted correctly if the radar was moving towards left. -* Sometimes ``ArrayIndexOutOfBoundsExceptions`` occurred when adding and/or removing robots in the robots folder. - -### Changes -* [Req-30][]: UI Control for adjusting the TPS quickly. - * Added TPS slider to the toolbar on the battle window so the TPS can be changed quickly. -* [Req-32][]: Bullet size. - * Bullet sizes has been improved. - * Very small bullets will always be visible, even on large 5000x5000 battle fields. -* Removed the "Allow robots to change colors repeatedly" from the View Options. - * This option did not have any affect as the current rendering engine always allows robots to change colors repeatedly. - -## Version 1.2.1A (26-Nov-2006) - -### Bug Fixes -* [Bug-51][]: Hit wall problems. - * Hitting wall with an exact angle of 0, 90, 180 or 270 degrees caused a robot to disappear from the battlefield (could be seen with the sample robots Corner and Wall). - * Thanks goes to Titus Chen for reporting this issue + providing a fix for this issue. - -## Version 1.2.1 (24-Nov-2006) - -### Bug Fixes -* [Bug-50][]: Bottom-left corner anomaly. - * The check for wall collision did not work properly in some situations due to rounding problems with float vs double precision. -* [Bug-49][]: Robot gets stuck off-screen. -* [Bug-48][]: ``isMyFault()`` returns ``false`` despite moving toward the robot. - * ``HitRobotEvent.isMyFault()`` returned ``false`` despite the fact that the robot was moving toward the robot it collided with. - * This was the case when ``distanceRemaining == 0`` even though this could occur on purpose if the move was set to ``distanceRemaining``. -* [Bug-47][]: Teleportation in version 1.2. - * Teleportation when hitting wall and ``abs(sin(heading)) > 0.00001`` or ``abs(cos(heading)) > 0.00001``. -* [Bug-46][]: Gun Method returns too soon. - * The ``turnGun(double)`` method returned before the gun rotation had returned. -* [Bug-41][]: More bad bullet collision detections. - * Bad bullet collision detection algorithm was replaced with [Paul Bourke's 2D line intersection algorithm](http://paulbourke.net/geometry/lineline2d/). - -## Version 1.2 (05-Nov-2006) - -### Bug Fixes -* [Bug-24][]: Robots hangs when running looong battles (and pausing). - * This issue which was not really fixed in 1.1.5. -* [Bug-37][]: Bad bullet collision detection. -* [Bug-42][]: "Number of rounds" box is not tall enough on Gnome/Linux. - * Some text fields in e.g. the "New Battle" were not tall enough to show their content on for e.g. Gnome/Linux. -* [Bug-43][]: Layout is bad for Gnome/Linux. - * It was hard to read the text on the buttons on the Rendering Options. The text was cut off. - -### Changes - -#### Security option -* [Req-21][]: Option for accessing external .jars - * The ``NOSECURITY`` option has been extended so it is now possible to access 3rd party jar files. - * If you want to access other jars in your robot you'll have to disable the security in Robocode by setting the ``NOSECURITY`` option to true, i.e. adding ``-DNOSECURITY=true`` in robocode.bat (under Windows) or robocode.sh (under Mac and Linux). - * You'll also have to add the jar file to your ``CLASSPATH`` or put it into the /lib/ext folder of your Java Runtime Environment (JRE), if adding it to the ``CLASSPATH`` does not work. - -#### Results can be saved in CSV File -* [Req-25][]: Save battle results to file. - * Results can now be saved in the Comma Separated Value (CSV) File Format. - * A "Save" button has been added to the battle results dialog. - -#### Battle Results / Ranking panel -* The rank and name of the robots in the battle results dialog and in ranking panel has been splitted up into two independent colums, i.e "Rank" and "Name". - * This was necessary in order to save the rank and name independently in a file. - -#### Browser -* [Req-26][]: Invoke default browser from Help. - * The default browser under Windows is now used when browsing e.g. the Online Help. - * The browser.bat file has been removed as there is no need for it anymore. - -## Version 1.1.5 (22-Oct-2006) - -### Bug Fixes -* [Bug-40][]: Half of ``BulletHitBulletEvents`` are created improperly. - * Fixed ``BulletHitBulletEvents`` where half of them referred to the wrong bullet. -* [Bug-39][]: Final results not always ranked correctly. -* [Bug-36][]: License text in installer has wierd image at the buttom. - * Updated the Common Public License to the original version. - -### Change -* The Ranking Panel total score is now updated on the fly. - -## Version 1.1.4B (19-Oct-2006) - -### Bug Fixes -* [Bug-24][]: Robots hangs when running looong battles (and pausing). -* [Bug-34][]: Getting ``null`` on ``getName()``. - * The ``getName()`` on ``ScannedRobotEvent`` returned ``null``. -* [Bug-35][]: robocode.sh contains invalid ^M character. - * Fixed the robocode.sh (Unix) file which contained a ^M (Microsoft DOS/Windows character), which caused this file to be unusable for starting Robocode. - -## Version 1.1.4A (15-Oct-2006) - -### Bug Fixes -* [Bug-33][]: Sound is cut off after a round or two. - * The sounds were cut off after first round. -* [Bug-31][]: Ranking Panel does not save its size and position. - * The Ranking Panel position and size was not saved in the window.properties file. -* [Bug-30][]: ``ad.Quest`` robot causes ``ConcurrentModificationException``. - * This exception occurred in the robot event queue. -* Periodic ``NullPointerException`` removed from battle view. - -## Version 1.1.4 (14-Oct-2006) - -### Bug Fixes -* The Battle View was not updated on the primary monitor display on a dual monitor system. -* [Bug-28][]: Enabling sound makes Robocode crash. - * When enabling sounds on-the-fly where it was originally disabled, Robocode crashed/halted with a ``NullPointerException``. -* [Bug-29][]: Runtime exception when opening new battle. - * Removed a ``NullPointerException`` occurring when opening a battle the first time with a new version of Robocode. -* [Bug-21][]: Replace function generates extra tab. - * When inserting text by 'copy and paste' or 'search and replace' into the Editor, extra tabs were sometimes added. -* [Req-19][]: Possible to install Robocode on Windows Vista. - * Robocode icons has been updated. -* Lots of internal optimizations of Robocode has been made to speed up the game. - -### Changes - -#### Ranking Panel -* Ranking Panel added to the Options menu. - * Thanks goes to Luis Crespo for this new feature. -* This panel shows the current robot rankings during battles. - -#### Single-step Debugging -* It is now possible to do single-step debugging in Robocode. - * Thanks goes to Luis Crespo for this new feature. - * The "Pause" button has been extended into "Pause/Debug", and a "Next Turn" button is available to perform one turn at a time, which is vital for single-step debugging. -* A new ``Rules`` class was added containing helper methods and constants for Robocode rules. - -#### Common Options -* [Req-23][]: Preference to allow disabling of the scorecard pop-up. - * Common Options has been added that currently contains "Show results when battle(s) ends", which is used for enabling or disabling showing the results dialog when the battle(s) ends. - -## Version 1.1.3 (20-Sep-2006) The "Java 5 and Sound" release - -### Bug Fixes -* [Bug-25][]: Wrong score for 1st place results in some battles. - * Wrong 1st place scores for robots, which got 1 point for winning and also 1 point for the death of an enemy robot, and hence got 2 points instead of just 1 point for the 1st place. -* [Req-18][]: Better notification about new Robocode versions. - * Improved the notification about new available Robocode versions. -* [Bug-19][]: Confused updater. - * Now Robocode will only give a notification about a new available version if the version number is greater than the version retrieved from the robocode.jar file. - * The check interval has been changed from 10 days into 5 days. -* [Bug-26][]: Battlefield graphics is not always updated. - -### Changes - -#### Moved to Java 5.0 -* The minimum requirement for Robocode is from now on Java 5 (1.5.0). - * You must have at least a JRE 5.0 (1.5.0) or JDK 5.0. - * Robocode has also been tested with the upcomming Java 6 (1.6.0) where it seems to run just fine. - -#### Sound Effects added -* [Req-15][]: Optional sound effects. - * Sounds have been added to Robocode along with Sound Options. - * Thanks goes to Luis Crespo for this cool new feature. - * You are able to change between available mixers (on your system). - * Panning is supported, so that explosions in e.g. the left side of the screen is louder in the left speaker. - * Volume is supported, so that e.g. a bullet with more power makes more noise. - * **Note:** Some mixers performs better, but might not support volume and/or panning. - * A new command line option, ``-nosound``, has been added in order to turn off sound support. - * This feature should prove useful on systems without sound support. - -#### New Methods for Setting Colors -* The ``setColors(bodyColor, gunColor, radarColor)`` has been reintroduced. -* The ``setColors(bodyColor, gunColor, radarColor, bulletColor, scanColor)`` has been added. -* The ``setAllColor(color)`` has been added. - -#### Misc. -* [Req-17][]: New splashscreen picture. - * The Robocode logo on the splash screen and battle view is now rendered using Java2D. - * The layout of the Developer Options was improved a bit. - -## Version 1.1.2 (20-Aug-2006) The "Robocode is now TPS centric instead of FPS centric" release - -### Bug Fixes -* [Bug-22][]: Bad buildJikes.sh in 1.1.1 - * The ``buildJikes.sh`` contained the ^M (DOS return-carrige characters), which do not belong in a Unix/Linux file. ;-) -* The radar color was sometimes painted with too much lumination (white). - -### Changes - -#### TPS centric instead of FPS centric -* [Req-12][]: Faster framerates / Turns per second. - * Robocode is no longer FPS (Frames Per Second) centric, meaning that 1 turn (time unit) = 1 frame. - * Robocode is now TPS (Turns Per Second) centric, meaning that 1 turn is not necessarily equal to 1 frame anymore. - * You specify how many turns you want to compute every second (desired TPS), and Robocode will render as many frames as possible depending on the TPS. - * If the TPS is higher than the FPS, some turns are not rendered. However, this does not mean that turns are skipped. - * The higher TPS, the lower the FPS will get. - * The better graphics hardware acceleration the higher TPS and FPS. - * Replaced the ``-fps`` (Frames Per Second) command line option with the ``-tps`` (Turns Per Second) option. - * Now there is an option to display both the TPS and FPS in the titlebar in the View Options. - -#### Rendering Options -* Added Rendering Options to the Preferences. -* It now possible to change the settings for Antialiasing, Text Antialiasing, Rendering Method, and number of rendering buffers. - -#### Explosion rendering -* [Req-11][]: Explosion on robots dependent on bullet energy. - * Explosions are no longer pre-scaled in 6 fixed sizes, but instead scaled real-time using Java2D. - * The explosion sizes are now more precise depending on bullet damage, and the memory usage for the explosions has been brought down by not using pre-scaled explosion images. - * This fixed the painting of explosions on the iMac, where explosions were painted as filled circles with version 1.1 and 1.1.1. - * Bullets are now painted as filled energy balls with a size that depends on the bullet energy. -* [Req-13][]: Bullets are sometimes too small. - * The size (circle area) is calculated so that: - * A bullet with power = 0.1 (minimum power) uses 1 pixel. - * A bullet with power = 3 (maximum power) uses 30 pixels. - * In addition, explosions when a bullet hits a robot or another bullet are also depending on the bullet energy. - -#### New Option -* Added the option "Visible Explosions" in the View Options to the Preferences. -* This option makes it possible to enable and disable the painting of explosions. - -#### Setting Robot Colors -* The ``setColors(bodyColor, gunColor, radarColor)`` method is now deprecated. - * Replaced by ``setBodyColor()``, ``setRadarColor()``, and ``setScanColor()``. -* [Req-10][]: Coloring of bullets and scan arcs. - * Added ``setBulletColor()`` for changing the bullet color, and ``setScanColor()`` for changing the scan color (used for drawing scan arcs). - -#### Improved Sample Robots -* [Req-20][]: Robot templates must be updated regarding deprecated methods. - * All sample robots has been updated. - * Deprecated methods are replaced by current methods. - * Colors has been added to each robot, except for MyFirstRobot, which should be kept as simple as possible. - -#### Added Restart Button -* [Req-14][]: Restart Button. - * Restart button has been added in order to restart a battle. - -#### New "No Display" Option -* [Req-4][]: Prevent API from loading unused features. - * No graphical components are loaded anymore when Robocode is run from the command line with the ``-nodisplay`` option. - * This feature has been added in order to run Robocode on Unix-like systems that don't have X installed on them or for running Robocode as a kind of server, e.g. for [RoboRumble][]. - -#### Added Browse Button -* [Req-16][]: Browse button in Development Options. - -#### Keyboard Mnemonics -* Changed some keyboard mnemonics in the View Options in the Preferences. - -## Version 1.1.1 (06-Jul-2006) - -### Bug Fixes -* [Bug-16][]: Too many skipped turn because of CPU speed detection. - * Robots than ran fine under v1.0.6 were skipping turns like crazy under v1.0.7. - * The CPU speed detection has been changed to accept 50 times as many clock cycles than with with v1.0.7. -* [Bug-6][]: Text-Output Errors. - * Robot text-output error has been fixed according to the solution provided by Matt (msj(at)sysmatrix(dot)net). -* [Bug-15][]: "Visible ground" option is not saved. - * The state of the "View option" was not loaded correctly, and hence always set to enabled everytime Robocode was restarted. -* [Bug-11][]: A bug at ``updateMovement()`` in ``RobotPeer.java``. - * The ``updateMovement()`` that checked for ``distanceRemaining > 1`` instead of ``distanceRemaining > 0`` when slowing down. -* [Bug-14][]: Radar color is wrong. - * The radar was not colored correctly due to a bug in the coloring filter. -* [Bug-17][]: Robot editor's window list retains old windows. - * The Robocode editor's window menu did not remove closed windows properly when muliple windows were opened in the editor. -* [Bug-12][]: Autoextract hangs on Mac 10.3.9. -* [Bug-13][]: Compiling may fail - Mac 10.3.9. - * Issues with installing and compiling under Mac 10.3.9 were fixed. -* [Bug-18][]: Blank console in battles between two bots. -* [Req-2][]: Keep window size of "New battle" window. - * The window position and sizes were not loaded properly from the windows.properties file. - * The battle window is no longer reset every time a new battle is started, and the window size and position is now saved into the windows.properties file. -* Various part of Robocode did not work properly if installed into a folder containing spaces, e.g. compiling and viewing the API documentation did not work. - -### Changes - -#### 1200x1200 Battle Field -* [Req-3][]: More precise battlefieldsize configuration. - * Added 1200x1200 battle field size as one of the standard sizes, and set the size step to 100. - * This feature was added to accommodate [RoboRumble][]. - -#### Robot Colors -* The robot colors are now painted using a true HSL color model. -* The change to use the HSL color model fixed the bug regarding none or wrong coloring. -* Also, the lumination of the robot colors has been changed. - -#### Robocode SG Support -* [Req-7][]: Graphical "debug" facilities like with RobocodeGL. - * Added a checkbox to enable Robocode SG painting in the robot console. - * The "Debug paint" button in the robot console has been renamed to "Paint". -* [Req-8][]: Debug Graphics - SG Option. - * The "Paint" button enables painting in general, and by trickering "Robocode SG", the robot (debug) painting will be rendered as Robocode SG does it. - -#### Command line / batch files -* Added the ``-Xmx512M`` option to the batch files extending the max. memory heap size to 512 MB. -* Added the ``-Dsun.io.useCanonCaches=false`` which fixes some ``SecurityException`` issues on robots that read from files, and also fixed the installing and compiling problem under Mac 10.3.9. - -## Version 1.1 (14-Jun-2006) The "Continuation" release - -### Bug Fixes -* [Bug-1][] and [Req-1][]: Multiple or hyperthreading CPUs (most P4s) hangs Robocode. -* [Bug-5][]: Robot compile error under jdk1.5. - * The Jikes compiler has been updated to version 1.22. -* [Bug-7][]: Window won't repaint itself, window flickers in battle mode. -* [Bug-9][]: Screen flickers using Sun JDK1.5.0 in Linux. -* [Bug-8][]: Opening of the Robocode API help. - * Help menu updated. -* [Bug-9][]: Screen flickers using Sun JDK1.5.0 in Linux. -* [Bug-10][]: Eclipse compile problem (Java 1.5) in ``RobocodeClassLoader``. -* Links in Help menu fixed, so you are able to browse the API etc. - * Updated with links for "RoboWiki", "Yahoo Group: Robocode", and "Robocode Repository". -* [Req-5][]: Keyboard Navigation. - * Hotkeys have been added to every button, menu, and menu option. - -### Changes -* Added feature for Debug Painting. -* By implementing the ``Robot.onPaint(Graphics2D g)`` method of your robot(s), graphics of your choice will be rendered when enabling "Debug Paint" on the console window for that robot. -* [Req-6][]: Editor Improvements. - * New "Edit" menu containing: "Undo", "Redo", "Cut", "Copy", "Paste", "Delete", "Find...", "Find next", "Replace", "Select All". - * New "Window" menu containing "Close" and "Close All" options, entries for each open window (up to 9), "More Windows" option where you can get all open windows. - * Added undo/redo stack. - * Added linenumbers. -* New rendering engine based on Java2D: - * Graphics is drawn faster as Java2D make use of hardware acceleration. - * Robot colors are now painting using the HSB color model. - * Graphics is resized when the battle window is resized. - * Added "Visible ground" option in "View Options" which will paint background tiles and explosion debrises. -* The battlefield is always centered in the battle window. - -## Robocode was release as Open Source on SourceForge - -## Development was taken over by Flemming N. Larsen - -## Version 1.0.7 (18-Feb-2005) -* Released as Open Source under Common Public License. -* New explosion graphics. -* Fixed a few bugs. - * No longer possible to teleport when hitting walls ([Bug-3][]). - * Docs fixed and regenerated ([Bug-4][]). - * Fire assistance removed from ``AdvancedRobot`` ([Bug-2][]). -* Now requires Java 1.4. -* New system for calculating CPU speed. - -## Version 1.0.6 (17-Jul-2002) -* Robots that perform file I/O will be allowed 240 skipped turns in a row before being stopped. - * Other robots will still be allowed 30 in a row. -* Fixed issue with Linux where window frames were outside screen. -* Fixed reset compiler option in editor (broken in 1.0.5). - -## Version 1.0.5 (15-Jul-2002) -* Updated dialogs for: Packager, Extractor, Team Creator, Compile Options. - * So they don't hide behind main window. -* Fixed bug where New Battle dialog would hang on some systems. - -## Version 1.0.4 (15-Jul-2002) -* Raised max ``setXX`` calls before disable to 10,000. -* Moved ``setXX`` and ``getXX`` warnings to only print when max is hit. - * Previously at 300 and 3000, respectively. -* Fixed bug in ``clearAllEvents``. -* Updated Jikes compiler to version 1.16. - -## Version 1.0.3 (28-Jun-2002) -* Added ``setFire(double)`` and ``setFireBullet(double)`` methods to ``AdvancedRobot``. -* Added ``getDataQuotaAvailable()`` call to ``AdvancedRobot``. -* Fixed bug: Robots taking action in ``Condition.test()``. -* Implemented better method for stopping misbehaving robots. - * Basically, to help fix mistakes such as: - - bad: while (getGunHeat() != 0) {} - good: while (getGunHeat() != 0) { doNothing(); } - - * Robots will be disabled after 10000 calls to ``getXX`` methods with no action. - * Robots will be disabled after 1000 calls to ``setXX`` methods with no action. - * Only ``getXX`` and ``setXX`` in the robot itself counts (``event.getXX`` does not). - -## Version 1.0.2 (21-Jun-2002) -* Increased default filesystem quota to 200000 bytes. -* Droid leaders now start with 220 energy. -* Fixed bug that allowed robots to read other robots' data directories. -* Fixed bug that allowed invalid robot version strings. -* Fixed two bugs that allowed robots to exceed filesystem quota. - -## Version 1.0.1 (23-Apr-2002) -* Team robots will always show in the robot selection dialog. -* Robots in .jar files without a .properties file will not show. -* The extension ".jar.zip" is now supported for cases where the browser renames .jar files. - -## Version 1.0 (05-Apr-2002) -* New online help integrated. - * http://robocode.alphaworks.ibm.com/help/index.html. - * includes instructions for using Eclipse to build a Robot. -* ``onWin()`` is now called the moment you are the last surviving robot. - * You can now do victory dances in ``onWin``. - * Tracker and TrackFire updated to reflect this. -* Context assist will now work inside Eclipse. -* Fixed bug: ``getTeammates()`` returning ``null`` for last teammate. -* Fixed a few other small bugs. - -## Version 0.99.4 (24-Mar-2002) -* Fixed scanning bug (missing scan events with small scanarcs). -* Added "Import downloaded robot" tool. -* Renamed "Packager" to "Package robot for upload". -* Added "Extract downloaded robot for editing" to Robot Editor -* Added "Press F5 to refresh" label to robot selection dialog. -* Added small battle demo when new version detected. - -## Version 0.99.3 (21-Mar-2002) -* Fixed velocity bug. - * Movement is now more optimized. - * No more '1 2 0 -1 0 1 2 0' velocities. -* Fixed ``maxVelocity`` bug. - * ``setMaxVelocity`` can no longer be used to instantly stop. -* Fixed first turn bug (``getTime`` returing 0 twice). -* New, more accurate CPU benchmark. (Updated Linpack benchmark). - * Should fix '1ms per turn' bug on Win9X systems. - -## Version 0.99.2 (13-Mar-2002) -* Added a development path to support external IDEs such as [Eclipse](http://eclipse.org). - * Found in Options->Preferences. - * Simply add the path to your robot project. - * As usual, robots will be loaded from disk at the start of each battle. -* Improved support for RoboLeague. -* Documented ``robocode.control`` package (http://robocode.alphaworks.ibm.com/docs/control). -* Fixed bug: ``sendMessage`` causing ``StringIndexOutOfBounds``. - -## Version 0.99.1 (11-Mar-2002) -* Fixed bug: Some messages were delayed. -* Fixed bug: Broken RoboLeague interoperability. -* Fixed bug: ``getSender()`` did not show version or duplicates. -* Fixed bug: RobotPackager not packaging teams correctly under Java2 1.3. - -## Version 0.99 (05-Mar-2002) The "TEAMS" release -* Introducing: Teams! - * See ``sampleteam.MyFirstTeam`` for an example. - * Teams may consist of 2 to 10 robots. - * To use teams, first create one or more TeamRobots, then create a Team. - * TeamRobots will not show up in the New Battle dialog by default. You can change this behavior in Options->Preferences. - * To create a team, select Robot->Team->Create Team. - * You can add regular robots to a team, but they will not be able to communicate. - * The *first* robot you add to a team becomes the "team leader". Team leaders start with 200 energy. (They are superheroes) When team leaders die, all other members of the team lose 30 energy. Protect your leader! - * Team scoring is cumulative, but similar to normal scoring: Teams receive 50 points for each surviving team member every time an enemy dies. Teams receive ``10 * numEnemies`` points for each surviving teammate upon winning. Damage bonuses are for all damage dealt by that team Firsts, Seconds, Thirds are based on last surviving team member. - * Teammates can damage each other. - * Teams can be packaged like regular robots. - * Teammates without a version will receive the team version [enclosed in square brackets]. - * Team messages are limited to 32K per message. -* Introducing: Droids. - * Droids are robots without radar or scanning ability. - * simply add "implements Droid" to a TeamRobot to create a droid. - * Droids start with 120 energy (due to weight savings on the radar). - * Droids do not show up in the New Battle dialog by default. You can change this behavior in Options->Preferences. - * The API is unchanged, but scanning will not work. - * See ``sampleteam.MyFirstDroid`` for an example. -* Added new class: TeamRobot. - * See Javadocs for details. - * Adds messaging capability to robots. -* Added new class: ``MessageEvent`` -* Added new interface: ``Droid`` -* Fixed bug: Duplicate robots sometimes showed up in robot selection dialog. -* Fixed bug: Default Window Size not working for some battles. - -## Version 0.98.3: (08-Feb-2002) The "Everything but teams and it took too long" release -* ``setColors()`` now accepts any color (previously it had to be a default color). - * Only works in the first round. - * Only the first 16 robots in a battle will get their Reqed colors. -* Robots may now extend or use classes that are not in their package. - * This allows for utility classes, when they are in the robots tree. - * If you do not wish others to extend your robot, declare your robot class final. - * If you do not with others to use classes from your package, do not declare them public. - * All referenced classes will be packaged with the robot packager. -* Robots in the robotcache directory that do not have a .properties file will not show up in the robot selection dialog (done in order to support extended robots, above). -* You may now delete files in your data directory. -* Robocode will now always run at full speed when minimized. -* New Battle Dialog "Finish" button renamed to "Start Battle". -* New Battle Dialog "Start Battle" button Reqs focus when enabled. -* Robocode FAQ linked from help menu. -* Robocode now supports RoboLeague by Christian Schnell. - * http://user.cs.tu-berlin.de/~lulli/roboleague/. -* Fixed bug: Default thread priority was low. -* Fixed bug: Robots had access to peer. -* Fixed bug: Survival seconds reported as Survival firsts. -* Fixed bug: Robots did not always receive all ``onRobotDeath`` events. -* Fixed bug: ``getTime`` returning last round's end time at start of rounds. -* Editor 'Open File' now defaults to the last opened directory (per session). -* Fixed minor editor bug when parsing for classname. -* Fixed bug: Robocode will no longer try to save the size/position of a maximized window. -* Fixed bug: Bullets hitting each other immediately with fast gun cooling rate. -* Fixed bug: Incorrect number of rounds reported when stop pressed. -* Fixed bug: Incorrect number of "seconds" and "thirds" displayed. - -## Version 0.98.2 (28-Nov-2001) The "Screaming FPS" release -* Speed up performance when minimized. -* New license includes academic use. -* Fixed bug: disappearing energy/name strings. - -## Version 0.98.1 (27-Nov-2001) The "Ok, NOW it's starting to feel real" release -* Fixed bug clearing scaled battles. -* Robot consoles changed back to white on dark gray. -* Fixed bug with case sensitivity in editor's suggested filename. -* Other minor tweaks and bug fixes. -* Updated Tracker and RamFire (no ``setInterruptible``). -* Added commentary and dates to this file. -* Added link to this file from help menu. - -## Version 0.98 (27-Nov-2001) The "It's starting to feel real" release -* Added ``setColors(Color robotColor, Color gunColor, Color radarColor)`` to Robot. - * By default, robots are the default blue. - * Call this in your run method (no more than once per round) to set your robot's colors. - * Accepts any ``System`` default colors, i.e. ``Color.red``. -* Robots are now instantiated each round. - * You no longer need to re-initialize all your variables at the beginning of ``run()``. - * ** Only static variables are persistent across rounds **. -* Graphics optimizations. - * No more rotating images at the start of each battle. - * Far more memory efficient. -* New model for CPU time. - * Robocode now uses the [Linpack benchmark](http://www.netlib.org/benchmark/linpackjava/). - * Used to determine how much time each robot is allowed for processing. -* Threading changes. - * Robocode is now threadsafe (as far as I know, anyway). - * Robot threads execute sequentially. - * No more "busy wait" enhances performance, especially on large battles. -* Minimized optimizations. - * When minimized, Robocode will not do any drawing. - * FPS can really crank up (when set in options-preferences). -* Minor graphic changes (The gun is slightly further forward). -* New class hierarchy, in order to clean up the javadocs. - * added ``_Robot`` and ``_AdvancedRobot``. - * These hold deprecated methods and system-related things. - * added ``_AdvancedRadiansRobot`` to clean up the ``AdvancedRobot`` docs. - * You should still extend either ``Robot`` or ``AdvancedRobot``. -* Battles may now consist of 1-256 robots. - * A warning confirmation will appear for > 24 robots. - * A confirmation will appear for 1 robot. -* Robots will now appear as they are loaded. -* So large battles won't appear "hung". -* Consoles persist between battles (although they are cleared). -* Console threading is more efficient. -* Console scrolling is crisper (bug fixed). -* Console now has an unlimited size, once opened. - * There is an 8K circular buffer before it is opened. -* ``setInterruptible()`` moved to ``AdvancedRobot``. - * Deprecated version in ``Robot`` does nothing. - * Note: Balancing of the ``Robot`` class still needs work. -* Skipping turns may happen more often, but is not as big a deal as it used to be. - * with the exception of your first turn. - * You will only lose events if you skip 2 in a row. - * You will not be stopped unless you skip 60 turns in a row. - * Skipped turns can be caused by loading classes from disk, writing files, etc. If this becomes a problem, I will preload all classes. -* Fixed bug with compiler when filename has a space. -* Fixed bug with getting ``BulletMissed`` and ``BulletHit`` events for same bullet. -* Fixed bug with editor locking up reading some files. -* Another round of major code organization. -* Again, probably more minor items that I already forgot about. :) -* (Later additions... such as:) - * Invalid insert bug in editor - * Copy/Paste from console. - -## Version 0.97.4 (18-Nov-2001) The "finally, a single installer!" release -* Completely reworked install process. -* There is no longer a setup.exe installer. -* Jikes is now packaged with Robocode as the default compiler. - * you may use javac if you prefer, and you have it. -* API docs now link to the Java API. -* Fixed bug: Editor did not close files after saving. -* Fixed bug: Unable to deselect "display robot names". -* Fixed bug: Shared static vars between instances of the same robot. -* Fixed a few graphics glitches. -* Minor doc updates. - -## Version 0.97.3 (05-Nov-2001) The "hourly release" release :) -* Fixed ``NullPointerException`` when loading robots with no package. -* Added ``robocode.robot.filesystem.quota`` property to robocode.properties. - * This is a temporary solution, which sets the default filesystem quota for robots. - * Example: ``robocode.robot.filesystem.quota=200000`` for 200k. -* Fixed bug in editor that caused it to suggest an unreasonable filename. - -## Version 0.97.2 (04-Nov-2001) -* Fixed bug that caused some robots to be stopped by the game. -* Battles/Rounds start faster (back to 0.96.2 speed). -* More lenient on CPU use. - * You have roughly 4 whole seconds before your first move. - * You have roughly ``50 + (1000 / fps)`` milliseconds to process each frame. - * This is more than twice what the entire game itself gets. :) - * Failure to take action in that amount of time results in a SkippedTurnEvent. - * You will be removed from the round if you skip 30 turns in a round. - * Un-deprecated ``onSkippedTurn`` and ``SkippedTurnEvent``. - * No reasonable robot should ever receive a ``SkippedTurnEvent``... but now it's there just in case. - -## Version 0.97.1 (03-Nov-2001) -* Abstract classes now work properly in the selection dialog and robot database. -* Fixed a few Javadoc bugs. -* Fixed pause/resume bug. -* Javadocs have deprecated calls again. - -## Version 0.97 (02-Nov-2001) The "painful but worth it" release -* I probably missed a few things in this list. :) -* Introducing the Robot Packager. - * Select your robot, type in a few details, and let it figure out the rest. - * Saves details in a .properties file (see details below). - * Builds a .jar for you. - * Save this .jar in your robots directory (not a subdirectory, for now). - * You may distribute this jar as a standalone robot. -* .properties files. - * Not required unless you are packaging your robot. - * Built automatically by the packager. - * Includes: - * Robot version - * Short description - * Optional author name - * Optional webpage - * Robocode version - * Flag for source included -* .jar files, and the robotcache. - * Simply put a robot .jar file in your robots directory. - * It will be extracted to the "robotcache". - * Jar filename is the unique key for the robotcache. - * Do not edit files in the robotcache, they may be overwritten. Copy them to your robots directory if you like. This will be a feature in a future version of Robocode. -* Robot Database. - * Built and maintained for you. - * Allows Robocode to remember which .class files are robots, and which not. - * Press F5 in the robot selection dialog to refresh the database. -* Robot Selection dialog. - * Divided up into packages. - * Shows robot details (from .properties) if they exist. -* .html files. - * Create a .html file if you like... see ``sample.SittingDuck``. - * Linked from robot selection dialog. -* Major scoring changes. - * 50 points every time an enemy dies while you are alive. - * (10 * numOthers) points if you are the sole survivor - * 1 point for each point of damage you do with bullets. - * 2 points for each point of damage you do by ramming (see Ramming changes, below). - * ``bonus .2 * damage`` done to a specific enemy, if you kill that robot, or - * ``bonus .3 * damage`` done to a specific enemy, if you kill by ramming. -* Ramming changes. - * Damage increased (from .4 to .6). - * Only generates score if you are moving toward the enemy. - * If you are ramming, and run out of energy, you will now be disabled instead of killed. -* "Life" replaced with "Energy". - * A more sensible name. - * All ``getLife()`` calls deprecated and replaced with ``getEnergy()``. -* Added ``getEnergy()`` to ``HitRobotEvent`` (I can't believe it wasn't there before!). -* Only ``Robots`` and ``AdvancedRobots`` will show in the New Battle dialog. - * Fixes known bug listed below at the end of 0.96 changes. -* Custom events are now be cleared at the start of each round. - * However, since many robots rely on them still existing, Robocode will currently re-add any custom events that were created at the beginning of the first round, for all remaining rounds. This is a temporary solution for backwards compatibility, and will cause a warning message in your console. -* You may now print to ``System.out``. - * Will automatically redirect output to your console. -* Robot Editor now supports creating normal Java files. -* Added line number display to Robot Editor -* ``MoveCompleteCondition`` bug fixed. -* ``getTurnRemaining()``, ``getGunTurnRemaining()``, ``getRadarTurnRemaining()`` now return degrees. -* ``getTurnRemainingRadians()``, ``getGunTurnRemainingRadians()``, ``getRadarTurnRemainingRadians()`` added. -* Added ``setAdjustRadarForRobotTurn(boolean)``. - * By default, set to the value of ``setAdjustRadarForGunTurn`` for backwards compatibility. -* Windows now remember their last position. - * This is based on the preferred size of the window, so that different battlefield sizes may have different window position and sizes. - * This is stored in the file "window.properties" which you can safely delete to reset. -* Added "Default Window Size" to Options menu. - * Resizes the window to optimal (even better than before). -* Command-line parameters to run a battle. - * ``robocode -battle battles\sample.battle -results out.txt -fps 250 -minimize``. - * Results will go to ``System.out`` if you do not specify a results file. - * All other Robocode output goes to ``System.err``. -* "Activity" is now defined as loss of 10 energy in the battle. - * Inactivity Time is now the number of frames in which 10 energy must be lost. - * This does not include loss due to inactivity itself, or hitting walls. - * Prevents robots stopping the inactivity timer by calling ``fire(.1)`` every 15 seconds. -* Compiler uses ``-g`` option for debugging. - * This *may* help those users trying to use advanced debuggers. -* Much improved "waiting for robots to start". -* More lenient on "robot has not performed any actions". -* Various javadoc fixes. -* Minor updates to template files. - -## Version 0.96.2 (09-Oct-2001) -* Fixed bug in movement that allowed robots to exceed ``maxVelocity``. - -## Version 0.96.1 -* Added automatic version checking. -* Added ``getVelocity()`` to ``Robot``. -* Fixed minor bug in editor (caused the "do" in "doNothing" to highlight). -* ``WinException`` and ``DeathException`` now extend ``Error`` instead of ``RuntimeException``. - * So you won't catch them by mistake with: ``catch (Exception e)``. - * You still don't want to catch them, or you'll get no score. -* Fixed minor API doc bugs. -* Added a warning when you are calling the ``setXX`` methods too many times (300). - * has no effect on whether the game stops you or not, it simply helps to explain why. before taking an action. -* Replaced BrowserControl with BrowserLauncher, from http://www.stanford.edu/~ejalbert/software/BrowserLauncher. - * Should work on more systems. -* Synchronized ``tick()``. - * Two threads cannot take action at the same time. - * This entire area needs work. -* FPS no longer displayed when Swing doublebuffering is on. -* Added ``getHeadingRadians()`` to ``Bullet``. -* Fixed ``getHeading()`` in ``Bullet`` to return degrees. - -## Version 0.96 (05-Oct-2001) The "Robocode is now my life" release -* Renamed "Battles" to "Rounds" -- a single battle consists of multiple rounds. -* Commented and updated all sample robots. -* All sample robots are now in package "sample". -* If the old samples exist, Robocode will ask you if it may delete them, when you first run it. -* Only Target, Crazy, Spinbot are still AdvancedRobots. - * Target must be for the custom event. - * Crazy and Spinbot call setTurn methods. -* SittingDuck is now an AdvancedRobot. - * SittingDuck writes to the filesystem. -* Help system now uses system browser. Hopefully. Let me know of any issues. -* API Help menu item copied to RobocodeEditor, and uses the local copy. -* Robots may now use,extend,or inherit external classes, as long as they are in the same root package. - * You must be in a package to use this feature. -* Added call: ``getDataDirectory()`` to ``AdvancedRobot`` -- returns ``java.io.File`` representing your data directory. -* Added call: ``getDataFile(String filename)`` to ``AdvancedRobot`` -- returns ``java.io.File`` representing a file in your data directory. -* AdvancedRobots may now read files that are in the same directory (or subdirectory) as their root package. - * It is recommended that you only read from your data directory. - * You may not read another robot's data directory. - * If you extend another robot, and it calls ``getDataDirectory``, it will get YOUR data directory. - * If you extend another robot, and manually try to read it's data directory, it will fail. -* Added classes: ``RobocodeFileOutputStream`` and ``RobocodeFileWriter``. -* AdvancedRobots may now write files to their data directory. - * You must use ``RobocodeFileOutputStream`` or ``RobocodeFileWriter``. - * Any other output stream will fail. - * You may wrapper them with other output streams. - * Example: ``PrintStream out1 = new PrintStream(new RobocodeFileOutputStream(getDataFile("my.dat")));`` - * There is a quota of 100K. -* Fixed scoring bug (as exhibited by ``rk.Rotator``). -* Fixed threads stuck in wait condition when new battle selected. -* Fixed threads stuck in ``onWin`` or ``onDeath`` events. -* Fixed threads not taking action. -* Fixed leftover threads. -* Fixed a half dozen other thread issues. -* Limited \# of worker threads a robot may have to 5. -* Limited ``print``/``println`` calls to ``out``, to 100 per turn. -* Robots now run in their own ``ThreadGroup``. (You can no longer can see other robot's threads). -* Robots now have their own ``Classloader``. (static variable ``messages`` will no longer work). -* Fixed ``NullPointerException`` in ``RobocodeOutputStream``. -* ``WinEvents`` or ``DeathEvents`` will now be the only thing in the event queue. -* Reworked event handler system, should be more robust. -* Tweaked event priorities. New default priorities are: - * ``BulletHitBulletEvent``: 50. -* Valid priorities are 0 to 99 (100 is reserved). -* Added new method ``setInterruptible(boolean)`` to ``Robot``. - * Can only be used while handling an event. - * Always resets to false when the event ends. - * Causes event handler to restart from the top, if the same event (or another event of the same priority) is generated while in the event handler following this call. - * This will only happen if you take an action inside an event handler, that causes the same event handler to be called. - * This makes it possible for Robots to turn and move like AdvancedRobots... - * This has no effect on events of higher priority. -* Calling ``scan()`` inside of ``onScannedRobot()`` can now restart ``onScannedRobot``. - * internally calls ``setInterruptible(true)`` for itself. - * See ``sample.Corners`` for example. -* Robots of class ``Robot`` no longer take damage from hitting a wall. -* Robots of class ``AdvancedRobot`` take more damage from hitting a wall. -* Added ``isMyFault()`` to ``HitRobotEvent``. - * Returns ``true`` if you caused the event by moving toward the other robot. -* Revamped robot to robot collisions. - * Your movement will be marked complete if you are moving toward the other robot. - * You will not be stopped if you are moving away from the other robot. - * Collisions now cause more damage, but are easier to escape from. - * This means robots without ``onHitRobot`` handlers still have a chance... - * An event is generated every time one robot hits another. - * If you are moving toward the other robot, you will get ``onHitRobotEvent`` with ``isMyFault() = true``. - * If another robot is moving toward you, you will get an ``onHitRobotEvent`` with ``isMyFault() = false``. - * If you are moving toward each other, you will get two events, with the ``isMyFault() = true``, first. -* Damage from robot to robot collisions is now a constant 0.4. -* Added ``getBearing()`` to ``onHitByBullet``. -* Added a ``Bullet`` object. - * encapsulates owner, victim, power, velocity, X, and Y. -* Bullet hitting bullet generates ``BulletHitBulletEvent`` - methods include ``getBullet()`` and ``getHitBullet()``. - * added ``getBullet()`` to ``HitByBulletEvent``, ``BulletHitEvent``, ``BulletMissedEvent``. -* Added ``fireBullet()``, which is exactly like ``fire()``, but returns a ``Bullet`` object. - * I could not simply add a bullet return to fire, because it broke *all* existing robot .class files. -* You can now select from the results dialog. -* Fixed path for open/save battles on non-Windows systems. -* Fixed slashscreen for some systems. -* Fixed minor API doc bugs. -* Updated many API docs. -* Renamed and reorganized many internal classes. -* Fixed bug with allowed package names (now allows digits). -* Windows installer now defaults to c:\. -* Added ``getGunHeat()`` to ``Robot``. - * When gunHeat is 0, you can fire. - * ``gunHeat`` goes up by ``(1 + firePower / 5)`` when you fire. - * This is unchanged from the v0.95. -* Added ``getGunCoolingRate()`` to ``Robot``. -* Deprecated ``getGunCharge()``. - * Use ``getGunHeat()`` instead. -* Deprecated ``endTurn()``. - * It will still work for now, but you should replace calls to to it with ``execute()``. -* Removed ``onSkippedTurn``. - * Your robot will simply be stopped instead. - * The results dialog will report "not deterministic". - * Not deterministic means that a battle started with the exact same conditions and starting positions, may not end up with the same results. (Ok, so far, you can't test that...) :) - * Added ``getWaitCount()`` and ``getMaxWaitCount()`` to ``AdvancedRobot``. -* Deprecated ``SkippedTurnEvent``. - * Well, it's no longer used. -* Deprecated all ``getRobotXX`` methods. - * Replaced with ``getXX`` methods. -* Deprecated all ``getXXDegrees`` and ``setXXDegrees`` methods. - * Just use the ``getXX`` and ``setXX`` methods. -* Compiler will always show output, and uses the ``-deprecation`` flag. - * so you can see that you're using a deprecated call. - * I would like to remove all deprecated calls in the next version. -* Known bug: New battle dialog not smart enough to differentiate between Robots classes and other classes. - * You will be able to put other classes into a battle. - * They will sit there and do nothing. - -## Version 0.95 (09-Sep-2001) "The /. release" -* Completely rewrote all windows and dialogs to use LayoutManagers. -* Linux support vastly improved (although fps still not great). -* Improved framerate calculation (should be smoother on most systems). -* Robot exceptions now all go to robot's console. -* Fixed bug in initialization - radar turn. -* Hitting a wall no longer resets inactivity counter. -* Better pause functionality (fixed bugs). -* Known bug: Help system still not using external browser. -* Smarter dialog locations. - -## Version 0.94 (09-Aug-2001) -* Fixed a few bugs so Linux version would run. -* Known bug: Linux version does not run well. - -## Version 0.93 (23-Apr-2001) -* Completely redone graphics for tanks, guns, radar. -* Firepower adjusted. Higher-power bullets now move slightly slower and fire slightly slower. -* Gun must 'charge up' before firing. This avoids the "lucky shot" syndrome at the beginning of a battle. -* Added ``execute()`` method for ``AdvancedRobots``. Better name for 'endTurn'. -* Optimized drawing of explosion graphics. -* Added buttons for selecting battle size. -* Bullets can now hit each other (not perfect yet). -* Updated security manager to work with jdk1.4. -* Revised bounding box for new graphics. The graphics should no longer have a 5-pixel blank area. -* Optimized scanning code. -* Added 'color mask' to determine which parts of image should be recolored. -* Replaced splashscreen and icons. -* Java-based help, API, check new version. -* Robot menu (disabled). -* Changed ``fireDelay`` mechanism to be ``gunCharge``. Still in progress. -* Renamed to Robocode. -* Added Buttons for framerate. -* Added Buttons for battle size. - -## Version 0.92 (Mar-2001) -* Added ``getTime()`` method to ``Robots``. -* Added ``getFireDelay()`` method to ``Robots``. -* Added explosions. - -## Version 0.91 (Mar-2001) -* Fixed bug in ``waitFor()`` so that automatic scanning will not repeatedly generate events when the condition is ``true``. -* Fixed bugs in Tracker sample robot. -* Fixed display issues with view scan arc option. - -## Version 0.9 (Mar-2001) -* Completely reworked ``scan()`` to use a sweep as the radar moves. If the radar is not moving, the scan will be a straight line. -* Added fire assistance to regular ``Robot`` classes (not ``AdvancedRobots``). - * If you fire at a robot you see during ``scan()``, and gun/radar are together, and you ``fire()`` before doing anything else, you will fire at its center. - -## Version 0.8 (Feb-2001) -* Initial release. - * Robocode brought to IBM. - -## Version 0.1 (Sep-2000) -* Development started as late-night project. - - - - -[RoboRumble]: http://robowiki.net/wiki/RoboRumble (RoboWiki - RoboRumble) -[Markdown]: http://daringfireball.net/projects/markdown/syntax (Markdown syntax) - -[IRobotSnapshot.getContestantIndex()]: http://robocode.sourceforge.net/docs/robocode/robocode/control/snapshot/IRobotSnapshot.html#getContestantIndex() (robocode.control.snapshot.IRobotSnapshot.getContestantIndex()) -[IRobotSnapshot.getRobotIndex()]: http://robocode.sourceforge.net/docs/robocode/robocode/control/snapshot/IRobotSnapshot.html#getRobotIndex() (robocode.control.snapshot.IRobotSnapshot.getRobotIndex()) -[IRobotSnapshot.getTeamIndex()]: http://robocode.sourceforge.net/docs/robocode/robocode/control/snapshot/IRobotSnapshot.html#getTeamIndex() (robocode.control.snapshot.IRobotSnapshot.getTeamIndex()) - -[Patch-1]: http://sourceforge.net/p/robocode/patches/1/ (#1 Improved priority battle handling) - -[Bug-1]: http://sourceforge.net/p/robocode/bugs/1/ (Multiple or hyperthreading CPUs (most P4s) hangs Robocode) -[Bug-2]: http://sourceforge.net/p/robocode/bugs/2/ (Remove firing assistance for AdvancedRobo) -[Bug-3]: http://sourceforge.net/p/robocode/bugs/3/ (Teleportation of robot can happen (rare)) -[Bug-4]: http://sourceforge.net/p/robocode/bugs/4/ (#4 API Doc incorrect) -[Bug-5]: http://sourceforge.net/p/robocode/bugs/5/ (Robot compile error under jdk1.5) -[Bug-6]: http://sourceforge.net/p/robocode/bugs/6/ (Text-Output Errors) -[Bug-7]: http://sourceforge.net/p/robocode/bugs/7/ (Window won't repaint itself, window flickers in battle mode) -[Bug-8]: http://sourceforge.net/p/robocode/bugs/8/ (Opening of the Robocode API help) -[Bug-9]: http://sourceforge.net/p/robocode/bugs/9/ (Screen flickers using Sun JDK1.5.0 in Linux) -[Bug-10]: http://sourceforge.net/p/robocode/bugs/10/ (Eclipse compile problem (Java 1.5) in RobocodeClassLoader) -[Bug-11]: http://sourceforge.net/p/robocode/bugs/11/ (A bug at updateMovement() in RobotPeer.jav) -[Bug-12]: http://sourceforge.net/p/robocode/bugs/12/ (Autoextract hangs on Mac 10.3.9) -[Bug-13]: http://sourceforge.net/p/robocode/bugs/13/ (Compiling may fail - Mac 10.3.9) -[Bug-14]: http://sourceforge.net/p/robocode/bugs/14/ (Radar color is wrong) -[Bug-15]: http://sourceforge.net/p/robocode/bugs/15/ ("Visible ground" option is not saved) -[Bug-16]: http://sourceforge.net/p/robocode/bugs/16/ (Too many skipped turn because of CPU speed detection) -[Bug-17]: http://sourceforge.net/p/robocode/bugs/17/ (Robot editor's window list retains old windows) -[Bug-18]: http://sourceforge.net/p/robocode/bugs/18/ (Blank console in battles between two bots) -[Bug-19]: http://sourceforge.net/p/robocode/bugs/19/ (Confused updater) -[Bug-21]: http://sourceforge.net/p/robocode/bugs/21/ (Replace function generates extra tab) -[Bug-22]: http://sourceforge.net/p/robocode/bugs/22/ (Bad buildJikes.sh in 1.1.) -[Bug-24]: http://sourceforge.net/p/robocode/bugs/24/ (Robots hangs when running looong battles (and pausing)) -[Bug-25]: http://sourceforge.net/p/robocode/bugs/25/ (Wrong score for 1st place results in some battles) -[Bug-26]: http://sourceforge.net/p/robocode/bugs/26/ (Battlefield graphics is not always updated) -[Bug-28]: http://sourceforge.net/p/robocode/bugs/28/ (Enabling sound makes Robocode crash) -[Bug-29]: http://sourceforge.net/p/robocode/bugs/29/ (Runtime exception when opening new battle) -[Bug-30]: http://sourceforge.net/p/robocode/bugs/30/ (ad.Quest robot causes ConcurrentModificationException) -[Bug-31]: http://sourceforge.net/p/robocode/bugs/31/ (Ranking Panel does not save its size and position) -[Bug-33]: http://sourceforge.net/p/robocode/bugs/33/ (Sound is cut off after a round or two) -[Bug-34]: http://sourceforge.net/p/robocode/bugs/34/ (Getting null on getName()) -[Bug-35]: http://sourceforge.net/p/robocode/bugs/35/ (robocode.sh contains invalid ^M character) -[Bug-36]: http://sourceforge.net/p/robocode/bugs/36/ (License text in installer has wierd image at the buttom) -[Bug-37]: http://sourceforge.net/p/robocode/bugs/37/ (Bad bullet collision detection) -[Bug-39]: http://sourceforge.net/p/robocode/bugs/39/ (Final results not always ranked correctly) -[Bug-40]: http://sourceforge.net/p/robocode/bugs/40/ (Half of BulletHitBulletEvents are created improperly) -[Bug-41]: http://sourceforge.net/p/robocode/bugs/41/ (More bad bullet collision detections) -[Bug-42]: http://sourceforge.net/p/robocode/bugs/42/ ("Number of rounds" box is not tall enough on Gnome/Linux) -[Bug-43]: http://sourceforge.net/p/robocode/bugs/43/ (Layout is bad for Gnome/Linux) -[Bug-46]: http://sourceforge.net/p/robocode/bugs/46/ (Gun Method returns too soon) -[Bug-47]: http://sourceforge.net/p/robocode/bugs/47/ (Teleportation in version 1.2) -[Bug-48]: http://sourceforge.net/p/robocode/bugs/48/ (isMyFault() returns false despite moving toward the robot) -[Bug-49]: http://sourceforge.net/p/robocode/bugs/49/ (Robot gets stuck off-screen) -[Bug-50]: http://sourceforge.net/p/robocode/bugs/50/ (Bottom-left corner anomaly) -[Bug-51]: http://sourceforge.net/p/robocode/bugs/51/ (Hit wall problems) -[Bug-52]: http://sourceforge.net/p/robocode/bugs/52/ (Extra hit wall events) -[Bug-53]: http://sourceforge.net/p/robocode/bugs/53/ (Teams not always ranked correctly) -[Bug-54]: http://sourceforge.net/p/robocode/bugs/54/ (Flickering when constantly changing colors) -[Bug-55]: http://sourceforge.net/p/robocode/bugs/55/ (Incorrect score after replay) -[Bug-57]: http://sourceforge.net/p/robocode/bugs/57/ (ConcurrentModificationException) -[Bug-58]: http://sourceforge.net/p/robocode/bugs/58/ (NullPointerException during replay) -[Bug-59]: http://sourceforge.net/p/robocode/bugs/59/ (Issue when setting the priority of a BulletHitBulletEvent) -[Bug-60]: http://sourceforge.net/p/robocode/bugs/60/ (ConcurrentModificationException when extracting robots) -[Bug-61]: http://sourceforge.net/p/robocode/bugs/61/ (Hang when checking for new version with no Internet access) -[Bug-62]: http://sourceforge.net/p/robocode/bugs/62/ (Memory "Leak") -[Bug-63]: http://sourceforge.net/p/robocode/bugs/63/ (BulletHitBullet only destroys one bullet) -[Bug-64]: http://sourceforge.net/p/robocode/bugs/64/ (Exception when referencing length of an array of String) -[Bug-65]: http://sourceforge.net/p/robocode/bugs/65/ (Cannot run robocode after installation) -[Bug-66]: http://sourceforge.net/p/robocode/bugs/66/ (Crash: starting a new round while et.Predator 1.8 is playing) -[Bug-67]: http://sourceforge.net/p/robocode/bugs/67/ (Some issues with MessageEvent + priority) -[Bug-68]: http://sourceforge.net/p/robocode/bugs/68/ (Preferences not saved) -[Bug-69]: http://sourceforge.net/p/robocode/bugs/69/ (Robot causes Null Pointer Exception) -[Bug-70]: http://sourceforge.net/p/robocode/bugs/70/ (Version 1.2.6A incompatible with Roboleague) -[Bug-71]: http://sourceforge.net/p/robocode/bugs/71/ (RobocodeEngine becomes slower the more battles that are run) -[Bug-72]: http://sourceforge.net/p/robocode/bugs/72/ (The game won't play sounds on 2nd launch) -[Bug-73]: http://sourceforge.net/p/robocode/bugs/73/ (Sound don't work) -[Bug-74]: http://sourceforge.net/p/robocode/bugs/74/ (Java FilePermission error during startup) -[Bug-75]: http://sourceforge.net/p/robocode/bugs/75/ (getTeammates() problem) -[Bug-76]: http://sourceforge.net/p/robocode/bugs/76/ (Unique error) -[Bug-78]: http://sourceforge.net/p/robocode/bugs/78/ (Robots are disabled with no timer or countdown) -[Bug-79]: http://sourceforge.net/p/robocode/bugs/79/ (Output displayed in bursts) -[Bug-80]: http://sourceforge.net/p/robocode/bugs/80/ (Results file is empty with the command line) -[Bug-81]: http://sourceforge.net/p/robocode/bugs/80/ (Replay recording does not record paintings) -[Bug-82]: http://sourceforge.net/p/robocode/bugs/82/ (Undo comment does not change font color of code) -[Bug-83]: http://sourceforge.net/p/robocode/bugs/83/ (Ranking Panel Does not update number of competitors) -[Bug-84]: http://sourceforge.net/p/robocode/bugs/84/ (Preferences page problem on machine w/out sound card) -[Bug-85]: http://sourceforge.net/p/robocode/bugs/85/ (No window position in-bounding) -[Bug-86]: http://sourceforge.net/p/robocode/bugs/86/ (Using UI removes focus from interactive bots) -[Bug-87]: http://sourceforge.net/p/robocode/bugs/87/ (Round indicator incorrect) -[Bug-88]: http://sourceforge.net/p/robocode/bugs/88/ (Scorch layer) -[Bug-90]: http://sourceforge.net/p/robocode/bugs/90/ (Limit per round, not turn) -[Bug-91]: http://sourceforge.net/p/robocode/bugs/91/ (ConcurrentModificationException) -[Bug-92]: http://sourceforge.net/p/robocode/bugs/92/ (RoboRumble tries to connect with GUI) -[Bug-93]: http://sourceforge.net/p/robocode/bugs/93/ (onPaint(Graphics2D g) called prematurely) -[Bug-94]: http://sourceforge.net/p/robocode/bugs/94/ (Inconsistent Behavoir of RobocodeEngine.setVisible()) -[Bug-95]: http://sourceforge.net/p/robocode/bugs/95/ (OutOfMemory: Robots are Being Left on the Stack) -[Bug-96]: http://sourceforge.net/p/robocode/bugs/96/ (Initializing Label even when no display) -[Bug-97]: http://sourceforge.net/p/robocode/bugs/97/ (Exception when packaging robots) -[Bug-98]: http://sourceforge.net/p/robocode/bugs/98/ (When minimized doesn't show actual tps) -[Bug-99]: http://sourceforge.net/p/robocode/bugs/99/ (Clicking on a bottom area results in ClassCastException) -[Bug-100]: http://sourceforge.net/p/robocode/bugs/100/ (Double-clicking "restart") -[Bug-101]: http://sourceforge.net/p/robocode/bugs/101/ ("Keyboard lockup" with interactive robots) -[Bug-102]: http://sourceforge.net/p/robocode/bugs/102/ (Bots can hold memory after being destroyed) -[Bug-103]: http://sourceforge.net/p/robocode/bugs/103/ (ConcurrentModificationException) -[Bug-104]: http://sourceforge.net/p/robocode/bugs/104/ (Reproducable scoring bug) -[Bug-105]: http://sourceforge.net/p/robocode/bugs/105/ (testingCondition flag not reset) -[Bug-106]: http://sourceforge.net/p/robocode/bugs/106/ (Incorrect repaint of paused battlefield) -[Bug-107]: http://sourceforge.net/p/robocode/bugs/107/ (Bullet hit locations reported inaccurately) -[Bug-108]: http://sourceforge.net/p/robocode/bugs/108/ (It is possible to restart a battle without any robots) -[Bug-110]: http://sourceforge.net/p/robocode/bugs/110/ (Partial match recording replay) -[Bug-111]: http://sourceforge.net/p/robocode/bugs/111/ (Wasted time at end of each round) -[Bug-112]: http://sourceforge.net/p/robocode/bugs/112/ (Forcing stop: no score will be generated) -[Bug-113]: http://sourceforge.net/p/robocode/bugs/113/ (-battle option runs at full speed) -[Bug-114]: http://sourceforge.net/p/robocode/bugs/114/ (Wait Interrupted Message) -[Bug-115]: http://sourceforge.net/p/robocode/bugs/115/ (AWTException with RoboRumble on OS X) -[Bug-116]: http://sourceforge.net/p/robocode/bugs/116/ (Exclude filter removes bots from the RoboRumble) -[Bug-117]: http://sourceforge.net/p/robocode/bugs/117/ (Sound card is being dodgey/not detected by OS causes error) -[Bug-118]: http://sourceforge.net/p/robocode/bugs/118/ (Battles fail when executing with Eclipse debugger) -[Bug-120]: http://sourceforge.net/p/robocode/bugs/120/ (The renderering is slower on Vista than XP) -[Bug-122]: http://sourceforge.net/p/robocode/bugs/122/ (Not all shortcut keys work on MacOS) -[Bug-123]: http://sourceforge.net/p/robocode/bugs/123/ (Compiler fails to build due to CR/LF in scripts) -[Bug-125]: http://sourceforge.net/p/robocode/bugs/125/ (TimeoutExceptions occur when debugging in Eclipse) -[Bug-130]: http://sourceforge.net/p/robocode/bugs/130/ (Various usability issues) -[Bug-131]: http://sourceforge.net/p/robocode/bugs/131/ (Sometimes the compiler window hangs) -[Bug-134]: http://sourceforge.net/p/robocode/bugs/134/ (Robot problem after Options->Clean robot cache) -[Bug-135]: http://sourceforge.net/p/robocode/bugs/135/ (-battle broken) -[Bug-137]: http://sourceforge.net/p/robocode/bugs/137/ (Roborumble "ITERATE" broken) -[Bug-139]: http://sourceforge.net/p/robocode/bugs/139/ (Bug in RobotPeer.updateMovement?) -[Bug-141]: http://sourceforge.net/p/robocode/bugs/141/ (The -DROBOTPATH= option does not work) -[Bug-142]: http://sourceforge.net/p/robocode/bugs/142/ (Broken .sh files) -[Bug-143]: http://sourceforge.net/p/robocode/bugs/143/ (Blank console window when compiling) -[Bug-144]: http://sourceforge.net/p/robocode/bugs/144/ (drawArc does not work as expected) -[Bug-146]: http://sourceforge.net/p/robocode/bugs/146/ (Spammy output when running roborumble) -[Bug-147]: http://sourceforge.net/p/robocode/bugs/147/ (gunHeat is negative) -[Bug-148]: http://sourceforge.net/p/robocode/bugs/148/ (Wrong bullet power) -[Bug-149]: http://sourceforge.net/p/robocode/bugs/149/ (Replay exception) -[Bug-151]: http://sourceforge.net/p/robocode/bugs/151/ (Exception when changing between Robot to AdvancedRobot) -[Bug-153]: http://sourceforge.net/p/robocode/bugs/153/ (Junior Robot turnAheadRight bug) -[Bug-154]: http://sourceforge.net/p/robocode/bugs/154/ (Robot name missing when replaying XML record) -[Bug-156]: http://sourceforge.net/p/robocode/bugs/156/ (Spammy output on robot console windows) -[Bug-158]: http://sourceforge.net/p/robocode/bugs/158/ (Ubuntu throws NullPointerException in main) -[Bug-159]: http://sourceforge.net/p/robocode/bugs/159/ (Installation fail on windows if directory contain space) -[Bug-160]: http://sourceforge.net/p/robocode/bugs/160/ (Battle Results screen displaying old results) -[Bug-161]: http://sourceforge.net/p/robocode/bugs/161/ (Robot disabled by any other than losing energy can recover) -[Bug-162]: http://sourceforge.net/p/robocode/bugs/162/ (Team battle) -[Bug-163]: http://sourceforge.net/p/robocode/bugs/163/ (Spaces or native names in name of robocode directory) -[Bug-164]: http://sourceforge.net/p/robocode/bugs/164/ (Compiler Classpath Suggestion) -[Bug-165]: http://sourceforge.net/p/robocode/bugs/165/ (NullPointerException when using -battle option from cmd-line) -[Bug-166]: http://sourceforge.net/p/robocode/bugs/166/ (Bots referencing robocode.robocodeGL broken) -[Bug-168]: http://sourceforge.net/p/robocode/bugs/168/ (Bots inconviently stop working if they go over time limit) -[Bug-169]: http://sourceforge.net/p/robocode/bugs/169/ (pe.SandboxDT_3.02 stopped working in 1.6.2 and later version) -[Bug-170]: http://sourceforge.net/p/robocode/bugs/170/ (Robot Colors don't stick between rounds) -[Bug-171]: http://sourceforge.net/p/robocode/bugs/171/ (A battleview size exceed 800x600 filled with black) -[Bug-172]: http://sourceforge.net/p/robocode/bugs/172/ (Robot console fails to display some deaths/wins) -[Bug-173]: http://sourceforge.net/p/robocode/bugs/173/ (Robot packager can be activated once per running) -[Bug-174]: http://sourceforge.net/p/robocode/bugs/174/ (Robot console is sometimes empty) -[Bug-175]: http://sourceforge.net/p/robocode/bugs/175/ (Development robots cause problems with data files) -[Bug-177]: http://sourceforge.net/p/robocode/bugs/177/ (Open battle menu dialog is not loading robots) -[Bug-178]: http://sourceforge.net/p/robocode/bugs/178/ (Typing to find bot no longer works) -[Bug-179]: http://sourceforge.net/p/robocode/bugs/179/ (Event.setTime() method should not be hidden) -[Bug-181]: http://sourceforge.net/p/robocode/bugs/181/ (API: Typo in Documentation onBulletMissed(BulletMissedEvent)) -[Bug-176]: http://sourceforge.net/p/robocode/bugs/176/ (Editor UNDO does delete the line when no undo left) -[Bug-180]: http://sourceforge.net/p/robocode/bugs/180/ (Editor: Find (set cursor position)) -[Bug-182]: http://sourceforge.net/p/robocode/bugs/182/ (roborumble.sh and teamrumble.sh are broken) -[Bug-183]: http://sourceforge.net/p/robocode/bugs/183/ (NullPointerException in BattlesRunner.runBattlesImpl) -[Bug-184]: http://sourceforge.net/p/robocode/bugs/184/ (Custom event priority broken) -[Bug-185]: http://sourceforge.net/p/robocode/bugs/185/ (Webpage button lay over robot description) -[Bug-186]: http://sourceforge.net/p/robocode/bugs/186/ (Rounds number do not saved between run) -[Bug-187]: http://sourceforge.net/p/robocode/bugs/187/ (Not enough java memory allocated in launch scripts) -[Bug-188]: http://sourceforge.net/p/robocode/bugs/188/ (Meleerumble using 2 bots instead of 10) -[Bug-189]: http://sourceforge.net/p/robocode/bugs/189/ (API - cannot subclass Event in 1.7.1) -[Bug-190]: http://sourceforge.net/p/robocode/bugs/190/ (Errors with some robot classes when rebuilding database) -[Bug-191]: http://sourceforge.net/p/robocode/bugs/191/ (EOFException during repository rebuild) -[Bug-192]: http://sourceforge.net/p/robocode/bugs/192/ (Fair Play!) -[Bug-193]: http://sourceforge.net/p/robocode/bugs/193/ (TeamRumble uploading result for Robot instead of team) -[Bug-194]: http://sourceforge.net/p/robocode/bugs/194/ (JarJar multi-registration) -[Bug-195]: http://sourceforge.net/p/robocode/bugs/195/ (Client tries to remove all participants) -[Bug-196]: http://sourceforge.net/p/robocode/bugs/196/ (Wrong file path used for development bots) -[Bug-197]: http://sourceforge.net/p/robocode/bugs/197/ (Melee rumble doesn't use "smart battles") -[Bug-199]: http://sourceforge.net/p/robocode/bugs/199/ (FontMetrics StackOverflowError) -[Bug-200]: http://sourceforge.net/p/robocode/bugs/200/ (Graphics2D.setFont() has no effect) -[Bug-201]: http://sourceforge.net/p/robocode/bugs/201/ (setMaxVelocity(lower than current) + reverse direction bug) -[Bug-202]: http://sourceforge.net/p/robocode/bugs/202/ (Installer says to run robocode.jar) -[Bug-204]: http://sourceforge.net/p/robocode/bugs/204/ (Nanobot rumble not sending melee or team parameters) -[Bug-205]: http://sourceforge.net/p/robocode/bugs/205/ (Wrong survival scores sent by rumble client) -[Bug-206]: http://sourceforge.net/p/robocode/bugs/206/ (Funny behaviors with robot graphics/painting) -[Bug-207]: http://sourceforge.net/p/robocode/bugs/207/ (Access denied javax.swing -DNOSECURITY=true) -[Bug-208]: http://sourceforge.net/p/robocode/bugs/208/ (Does not extract .properties files into bot data dirs) -[Bug-209]: http://sourceforge.net/p/robocode/bugs/209/ ([Codesize] Invalid entry point in codesize-1.1.jar) -[Bug-210]: http://sourceforge.net/p/robocode/bugs/210/ (Bullet and Ram Damage Bonuses are wrong) -[Bug-212]: http://sourceforge.net/p/robocode/bugs/212/ (Team jar files reported as corrupted) -[Bug-213]: http://sourceforge.net/p/robocode/bugs/213/ (NullPointerException when setting classpath directory) -[Bug-214]: http://sourceforge.net/p/robocode/bugs/214/ (Accel/decel rules introduced in 1.7.1.3 causes trouble) -[Bug-215]: http://sourceforge.net/p/robocode/bugs/215/ (Missed onRobotDeath events) -[Bug-216]: http://sourceforge.net/p/robocode/bugs/216/ (Sometimes too few results for robots are displayed) -[Bug-218]: http://sourceforge.net/p/robocode/bugs/218/ (Robocode enters infinite loop with the Restart button) -[Bug-222]: http://sourceforge.net/p/robocode/bugs/222/ (Some of sound not working) -[Bug-226]: http://sourceforge.net/p/robocode/bugs/226/ (java.io.FileNotFoundException in RobotFileSystemManager.init) -[Bug-227]: http://sourceforge.net/p/robocode/bugs/227/ (Can't load Katana 1.0 or DrussGT 1.3.1wilo) -[Bug-228]: http://sourceforge.net/p/robocode/bugs/228/ (Krabb.sliNk.GarmTeam 0.9v locks up in new beta) -[Bug-229]: http://sourceforge.net/p/robocode/bugs/229/ (IllegalArgumentException on painting in some robots?) -[Bug-230]: http://sourceforge.net/p/robocode/bugs/230/ (Lockup on start if too many bots in robots dir) -[Bug-231]: http://sourceforge.net/p/robocode/bugs/231/ (Lockup on start if too many bots in robots dir (cont'd)) -[Bug-232]: http://sourceforge.net/p/robocode/bugs/232/ (Graphics2D.getTransform() throws NPE) -[Bug-233]: http://sourceforge.net/p/robocode/bugs/233/ ("Teleport") -[Bug-234]: http://sourceforge.net/p/robocode/bugs/234/ (Source is not included) -[Bug-236]: http://sourceforge.net/p/robocode/bugs/236/ (Robot Editor doesn't accept packagename with dot (.) in it) -[Bug-237]: http://sourceforge.net/p/robocode/bugs/237/ (OS X 10.6: Cannot run Robocode from robocode.sh) -[Bug-238]: http://sourceforge.net/p/robocode/bugs/238/ (OS X 10.6: The editor cannot see the JD) -[Bug-240]: http://sourceforge.net/p/robocode/bugs/240/ (morbid.MorbidPriest_1.0 fails to load) -[Bug-243]: http://sourceforge.net/p/robocode/bugs/243/ (Robot console text sometimes disappears) -[Bug-244]: http://sourceforge.net/p/robocode/bugs/244/ (Robot static data isn't being GCed after battle) -[Bug-245]: http://sourceforge.net/p/robocode/bugs/245/ (Removing directories from "development options" doesn't work) -[Bug-247]: http://sourceforge.net/p/robocode/bugs/247/ (Version ordering is somewhat strange with letters) -[Bug-250]: http://sourceforge.net/p/robocode/bugs/250/ (Installer installs AutoExtract$1.class) -[Bug-252]: http://sourceforge.net/p/robocode/bugs/252/ (yk.JahRoslav 1.1 throws WinException) -[Bug-254]: http://sourceforge.net/p/robocode/bugs/254/ (Roborumble doesn't upload with EXECUTE=NOT) -[Bug-255]: http://sourceforge.net/p/robocode/bugs/255/ (java.lang.Error: Interrupted attempt to aquire read lock) -[Bug-257]: http://sourceforge.net/p/robocode/bugs/257/ (Team RoboRumble uploading is broken) -[Bug-258]: http://sourceforge.net/p/robocode/bugs/258/ (isTeammate() called on null gives NullPointerException) -[Bug-259]: http://sourceforge.net/p/robocode/bugs/259/ (jlm.javaDisturbance loses substantial score in 1.7.2 Beta) -[Bug-260]: http://sourceforge.net/p/robocode/bugs/260/ (ArrayIndexOutOfBoundsException when starting team battle) -[Bug-261]: http://sourceforge.net/p/robocode/bugs/261/ ((.NET) condition tested on concurrently modified collection) -[Bug-262]: http://sourceforge.net/p/robocode/bugs/262/ (TeamRumble: Cannot find robot in nested .jar files) -[Bug-263]: http://sourceforge.net/p/robocode/bugs/263/ (Cannot extract downloaded robot for editing in Robot Editor) -[Bug-265]: http://sourceforge.net/p/robocode/bugs/265/ (Occasionally losing the bit of text in the robot console) -[Bug-267]: http://sourceforge.net/p/robocode/bugs/267/ (Strange issue first time running roborumble in 1.7.2.0 Beta2) -[Bug-269]: http://sourceforge.net/p/robocode/bugs/269/ (Minor visual bug - Currently selected robot gets covered) -[Bug-270]: http://sourceforge.net/p/robocode/bugs/270/ (Strange thread exceptions with kid.DeltaSquad in 1.7) -[Bug-271]: http://sourceforge.net/p/robocode/bugs/271/ (Battle engine consumes more CPU power over time) -[Bug-272]: http://sourceforge.net/p/robocode/bugs/272/ (isTeammate() sometimes returns false with teammates) -[Bug-274]: http://sourceforge.net/p/robocode/bugs/274/ ("Ignoring" messages in rumble are duplicated) -[Bug-275]: http://sourceforge.net/p/robocode/bugs/275/ (Duplicate version numbers prevents uploading) -[Bug-276]: http://sourceforge.net/p/robocode/bugs/276/ (tzu.TheArtOfWar 1.2 gets NullPointerExceptions) -[Bug-277]: http://sourceforge.net/p/robocode/bugs/277/ (Problems with Graphics2D.fill/draw(Shape)) -[Bug-278]: http://sourceforge.net/p/robocode/bugs/278/ (Attempting to install robocode over an existing install NPEs) -[Bug-280]: http://sourceforge.net/p/robocode/bugs/280/ (NPE when uploading results) -[Bug-281]: http://sourceforge.net/p/robocode/bugs/281/ (The robocode.command is missing the execute permissions bit) -[Bug-282]: http://sourceforge.net/p/robocode/bugs/282/ (Cannot see robot with no package in New Battle dialog) -[Bug-283]: http://sourceforge.net/p/robocode/bugs/283/ (Possible for robot to kill other robot threads) -[Bug-284]: http://sourceforge.net/p/robocode/bugs/284/ (Robot Packager doesn't package source file in Eclipse proj) -[Bug-285]: http://sourceforge.net/p/robocode/bugs/285/ (Robot Packaging Wizard doesn't save value for Next & Back) -[Bug-286]: http://sourceforge.net/p/robocode/bugs/286/ (ClassNotFoundException at RobotClassLoader.java:271) -[Bug-287]: http://sourceforge.net/p/robocode/bugs/287/ (Zipped robots data files are not extracted) -[Bug-288]: http://sourceforge.net/p/robocode/bugs/288/ ("skipped" turns at start with -Ddebug=true) -[Bug-289]: http://sourceforge.net/p/robocode/bugs/289/ (Exclude filters not working) -[Bug-290]: http://sourceforge.net/p/robocode/bugs/290/ (Development Options remove wrong item) -[Bug-291]: http://sourceforge.net/p/robocode/bugs/291/ (JavaDoc missing _Robot and similar) -[Bug-292]: http://sourceforge.net/p/robocode/bugs/292/ (Robot PrintStream doesn't handle write in a portable fashion) -[Bug-293]: http://sourceforge.net/p/robocode/bugs/293/ (Wrong headings with the JuniorRobot) -[Bug-297]: http://sourceforge.net/p/robocode/bugs/297/ (x,y coords between BulletHitEvent & HitByBulletEvent differ) -[Bug-299]: http://sourceforge.net/p/robocode/bugs/299/ (Custom events no longer firing after clearing event queue) -[Bug-301]: http://sourceforge.net/p/robocode/bugs/301/ (getTurnRateRadians incorrect for negative velocity) -[Bug-302]: http://sourceforge.net/p/robocode/bugs/302/ (Hide enemy name implementation bug) -[Bug-303]: http://sourceforge.net/p/robocode/bugs/303/ (bullet.equals semantic has been change in 1.7.3.0 version) -[Bug-304]: http://sourceforge.net/p/robocode/bugs/304/ (setColor(null) causes NPE) -[Bug-305]: http://sourceforge.net/p/robocode/bugs/305/ (TeamRumble priority battles bug) -[Bug-306]: http://sourceforge.net/p/robocode/bugs/306/ (Rumble sh scripts for launching do not handle spaces in path) -[Bug-307]: http://sourceforge.net/p/robocode/bugs/306/ (Console output cannot handle non-ascii names) -[Bug-308]: http://sourceforge.net/p/robocode/bugs/308/ (ConcurrentModificationException in URLJarCollector) -[Bug-309]: http://sourceforge.net/p/robocode/bugs/309/ (robot in development generates * into filename) -[Bug-310]: http://sourceforge.net/p/robocode/bugs/310/ (Interface Robot skips turns at end of round) -[Bug-311]: http://sourceforge.net/p/robocode/bugs/311/ (out.write(int) uses up allocated printing quickly) -[Bug-312]: http://sourceforge.net/p/robocode/bugs/312/ (Enabling Paint Freezes Robocode) -[Bug-313]: http://sourceforge.net/p/robocode/bugs/313/ (Robocode .NET does not work on Java 7) -[Bug-315]: http://sourceforge.net/p/robocode/bugs/315/ (Unable to change drawing color in .NET (C#)) -[Bug-318]: http://sourceforge.net/p/robocode/bugs/318/ (Installer throws NumberFormatException on Linux 3.0) -[Bug-319]: http://sourceforge.net/p/robocode/bugs/319/ (Package name allows bad chars) -[Bug-320]: http://sourceforge.net/p/robocode/bugs/320/ ("About" window colors are awful) -[Bug-323]: http://sourceforge.net/p/robocode/bugs/323/ (Robocode can't find the ECJ (Eclipse Compiler for Java)) -[Bug-326]: http://sourceforge.net/p/robocode/bugs/326/ (Package of team fails to load in team battles) -[Bug-328]: http://sourceforge.net/p/robocode/bugs/328/ (Issue with the robocode.dll + # chars in the path for a dll) -[Bug-331]: http://sourceforge.net/p/robocode/bugs/331/ (RoboRumble client has infinite timeout) -[Bug-332]: http://sourceforge.net/p/robocode/bugs/332/ (Use OpenGL backend under linux) -[Bug-333]: http://sourceforge.net/p/robocode/bugs/333/ (.NET runs release dll not debug dll so can't debug) -[Bug-334]: http://sourceforge.net/p/robocode/bugs/334/ (Snapshot API never shows bullets in "HIT_WALL" status) -[Bug-335]: http://sourceforge.net/p/robocode/bugs/335/ (Skipped turns ... issues) -[Bug-336]: http://sourceforge.net/p/robocode/bugs/336/ (Skipped turns ... issues) -[Bug-337]: http://sourceforge.net/p/robocode/bugs/337/ (Hangups with New Editor in 1.7.4.0) -[Bug-338]: http://sourceforge.net/p/robocode/bugs/338/ ("Accept-Encoding: gzip" not in Roborumble HTTP Headers) -[Bug-339]: http://sourceforge.net/p/robocode/bugs/339/ (All Text Missing) -[Bug-340]: http://sourceforge.net/p/robocode/bugs/340/ (Robocode crash on window resize (linux-opengl)) -[Bug-341]: http://sourceforge.net/p/robocode/bugs/341/ (InteractiveRobots gets error "After the event was added...") -[Bug-342]: http://sourceforge.net/p/robocode/bugs/342/ (New bots not given priority) -[Bug-344]: http://sourceforge.net/p/robocode/bugs/344/ (BattleAdaptor missing in robocode.control.events) -[Bug-345]: http://sourceforge.net/p/robocode/bugs/345/ (Graphics still being rendered when minimized) -[Bug-346]: http://sourceforge.net/p/robocode/bugs/346/ (Cannot extract sources from robot packages) -[Bug-347]: http://sourceforge.net/p/robocode/bugs/347/ (/bin/sh^M bad interpreter) -[Bug-348]: http://sourceforge.net/p/robocode/bugs/348/ (.NET: UnauthorizedAccessException in AppDomainShell.Dispose()) -[Bug-349]: http://sourceforge.net/p/robocode/bugs/349/ (Instances of RobocodeEngine don't seem to be independant - memory leak and performance decrease) -[Bug-350]: http://sourceforge.net/p/robocode/bugs/350/ (Bullet id from battle record XML file is sometimes -1 causing a NumberFormatException) -[Bug-351]: http://sourceforge.net/p/robocode/bugs/351/ (Robot.onBattleEnded(BattleEndedEvent) provides wrong scores) -[Bug-352]: http://sourceforge.net/p/robocode/bugs/352/ (Results from BattleCompletedEvent.getIndexedResults() are always sorted) -[Bug-353]: http://sourceforge.net/p/robocode/bugs/353/ (RobocodeEngine.setVisible() can cause a NullPointerException) -[Bug-354]: http://sourceforge.net/p/robocode/bugs/354/ (Replaying an XML record can cause an ArrayIndexOutOfBoundsException) -[Bug-355]: http://sourceforge.net/p/robocode/bugs/355/ (Priority battles not accepted for mini/micro/nano rumbles) -[Bug-356]: http://sourceforge.net/p/robocode/bugs/356/ (Update Roborumble URLs from Darkcanuck to LiteRumble) -[Bug-357]: http://sourceforge.net/p/robocode/bugs/357/ (Tab characters are inserted in the last line of a robot source file when opening it) -[Bug-358]: http://sourceforge.net/p/robocode/bugs/358/ (Robot in default package cannot write to files. Should at least get a warning) -[Bug-361]: http://sourceforge.net/p/robocode/bugs/361/ (Problem in the text editor related with the .java file modification) -[Bug-362]: http://sourceforge.net/p/robocode/bugs/362/ (Rumble client does not remove participants in wrong codesize group) -[Bug-363]: http://sourceforge.net/p/robocode/bugs/363/ (No Last Survivor Bonus being given) -[Bug-364]: http://sourceforge.net/p/robocode/bugs/364/ (Robot Packager does not include the robot data dir in the .jar file) -[Bug-366]: http://sourceforge.net/p/robocode/bugs/366/ (Receiving enemy's real name on HitByBulletEvent) -[Bug-368]: http://sourceforge.net/p/robocode/bugs/368/ (Issues with sentries) -[Bug-369]: http://sourceforge.net/p/robocode/bugs/369/ (RoboRumble: NoClassDefFoundError for CodeSizeCalculator) -[Bug-370]: http://sourceforge.net/p/robocode/bugs/370/ (Robot Packager cannot find robot .properties file in development path) -[Bug-371]: http://sourceforge.net/p/robocode/bugs/371/ (High cpu usage on editor) -[Bug-372]: http://sourceforge.net/p/robocode/bugs/372/ (Cannot load battle file when -DNOSECURITY=true is enabled - java.lang.IllegalAccessError) -[Bug-373]: http://sourceforge.net/p/robocode/bugs/373/ (Wrong robot size calculation in version 1.9.0 - 1.9.2) -[Bug-374]: http://sourceforge.net/p/robocode/bugs/374/ (Wrong size report for minirumble in v1.9.2.2) -[Bug-375]: http://sourceforge.net/p/robocode/bugs/375/ (Wrong width and height returned for .NET robots) -[Bug-378]: http://sourceforge.net/p/robocode/bugs/378/ (robocode.robocodeGL.system.GLRenderer ClassNotFoundException) -[Bug-380]: http://sourceforge.net/p/robocode/bugs/380/ (Yet another historical bot related bug) - -[Req-1]: http://sourceforge.net/p/robocode/feature-requests/1/ (Multiple or hyperthreading CPUs (most P4s) hangs Robocode) -[Req-2]: http://sourceforge.net/p/robocode/feature-requests/2/ (Keep window size of "New battle" window) -[Req-3]: http://sourceforge.net/p/robocode/feature-requests/3/ (More precise battlefieldsize configuration) -[Req-4]: http://sourceforge.net/p/robocode/feature-requests/4/ (Prevent API from loading unused features) -[Req-5]: http://sourceforge.net/p/robocode/feature-requests/5/ (Keyboard Navigation) -[Req-6]: http://sourceforge.net/p/robocode/feature-requests/6/ (Editor Improvements) -[Req-7]: http://sourceforge.net/p/robocode/feature-requests/7/ (Graphical "debug" facilities like with RobocodeGL) -[Req-8]: http://sourceforge.net/p/robocode/feature-requests/8/ (Debug Graphics - SG Option) -[Req-10]: http://sourceforge.net/p/robocode/feature-requests/10/ (Coloring of bullets and scan arcs) -[Req-11]: http://sourceforge.net/p/robocode/feature-requests/11/ (Explosion on robots dependent on bullet energy) -[Req-12]: http://sourceforge.net/p/robocode/feature-requests/12/ (Faster framerates / Turns per second) -[Req-13]: http://sourceforge.net/p/robocode/feature-requests/13/ (Bullets are sometimes too small) -[Req-14]: http://sourceforge.net/p/robocode/feature-requests/14/ (Restart Button) -[Req-15]: http://sourceforge.net/p/robocode/feature-requests/15/ (Optional sound effects) -[Req-16]: http://sourceforge.net/p/robocode/feature-requests/16/ (Browse button in Development Options) -[Req-17]: http://sourceforge.net/p/robocode/feature-requests/17/ (New splashscreen picture) -[Req-18]: http://sourceforge.net/p/robocode/feature-requests/18/ (Better notification about new Robocode versions) -[Req-19]: http://sourceforge.net/p/robocode/feature-requests/19/ (Possible to install Robocode on Windows Vista) -[Req-20]: http://sourceforge.net/p/robocode/feature-requests/20/ (Robot templates must be updated regarding deprecated methods) -[Req-21]: http://sourceforge.net/p/robocode/feature-requests/21/ (Option for accessing external .jars) -[Req-23]: http://sourceforge.net/p/robocode/feature-requests/23/ (Preference to allow disabling of the scorecard pop-up) -[Req-24]: http://sourceforge.net/p/robocode/feature-requests/24/ (Recording of battles) -[Req-25]: http://sourceforge.net/p/robocode/feature-requests/25/ (Save battle results to file) -[Req-26]: http://sourceforge.net/p/robocode/feature-requests/26/ (Invoke default browser from Help) -[Req-30]: http://sourceforge.net/p/robocode/feature-requests/30/ (UI Control for adjusting the TPS quickly) -[Req-31]: http://sourceforge.net/p/robocode/feature-requests/31/ (Redirecting Robot output, running without GUI) -[Req-32]: http://sourceforge.net/p/robocode/feature-requests/32/ (Bullet size) -[Req-33]: http://sourceforge.net/p/robocode/feature-requests/33/ (Making robots die quicker (graphically)) -[Req-34]: http://sourceforge.net/p/robocode/feature-requests/34/ (Provide javadoc for robocode.util.Utils and robocode.control) -[Req-35]: http://sourceforge.net/p/robocode/feature-requests/35/ (Pause Button) -[Req-36]: http://sourceforge.net/p/robocode/feature-requests/36/ (Initial Placement) -[Req-37]: http://sourceforge.net/p/robocode/feature-requests/37/ (Running Score Window) -[Req-38]: http://sourceforge.net/p/robocode/feature-requests/38/ (Codesize) -[Req-39]: http://sourceforge.net/p/robocode/feature-requests/39/ (Support for RR@Hom) -[Req-44]: http://sourceforge.net/p/robocode/feature-requests/44/ (Restart tweak) -[Req-45]: http://sourceforge.net/p/robocode/feature-requests/45/ (Reset compiler cancel button) -[Req-49]: http://sourceforge.net/p/robocode/feature-requests/49/ (Speedup time required for rebuilding robot database) -[Req-50]: http://sourceforge.net/p/robocode/feature-requests/50/ (Recalculate CPU Constant) -[Req-52]: http://sourceforge.net/p/robocode/feature-requests/52/ (The 'New Battle' window sometimes is spamed with .robotcache) -[Req-53]: http://sourceforge.net/p/robocode/feature-requests/53/ (More control over the event queue) -[Req-54]: http://sourceforge.net/p/robocode/feature-requests/54/ (All input received from events) -[Req-55]: http://sourceforge.net/p/robocode/feature-requests/55/ (Exclude Filter for RoboRumble) -[Req-56]: http://sourceforge.net/p/robocode/feature-requests/56/ (Robots Cache Cleaner) -[Req-57]: http://sourceforge.net/p/robocode/feature-requests/57/ (Events processed in chronological order) -[Req-58]: http://sourceforge.net/p/robocode/feature-requests/58/ (HitRobotEvent - damage) -[Req-60]: http://sourceforge.net/p/robocode/feature-requests/60/ (Enhanced CPU constant calculation) -[Req-62]: http://sourceforge.net/p/robocode/feature-requests/62/ (Fix for massive turn skipping when cpu constant < granularity) -[Req-63]: http://sourceforge.net/p/robocode/feature-requests/63/ (Replay should store debug graphics) -[Req-64]: http://sourceforge.net/p/robocode/feature-requests/64/ (Change default battle settings like e.g. "Number of Rounds") -[Req-65]: http://sourceforge.net/p/robocode/feature-requests/65/ (Score % display) -[Req-66]: http://sourceforge.net/p/robocode/feature-requests/66/ ("onBattleIEnd(*)" Event) -[Req-70]: http://sourceforge.net/p/robocode/feature-requests/70/ (Longer package name allowed) -[Req-74]: http://sourceforge.net/p/robocode/feature-requests/74/ (Option for enabling/disabling robot timeouts) -[Req-75]: http://sourceforge.net/p/robocode/feature-requests/75/ (Add client version to POST data sent to server) -[Req-77]: http://sourceforge.net/p/robocode/feature-requests/77/ (Better "lifebar" display) -[Req-78]: http://sourceforge.net/p/robocode/feature-requests/78/ (Visual debugging without cpu penalty) -[Req-80]: http://sourceforge.net/p/robocode/feature-requests/80/ (Screenshot of battleview) -[Req-82]: http://sourceforge.net/p/robocode/feature-requests/82/ (Launch upload result in separate thread) -[Req-84]: http://sourceforge.net/p/robocode/feature-requests/84/ (Added append option in copy method (FileTransfer class)) -[Req-86]: http://sourceforge.net/p/robocode/feature-requests/86/ (Rankings should be visible when Robocode is minimized) -[Req-88]: http://sourceforge.net/p/robocode/feature-requests/88/ (Command Line option for saving a battle record file) -[Req-89]: http://sourceforge.net/p/robocode/feature-requests/89/ (Launch Robocode from .br (battle record) files) -[Req-90]: http://sourceforge.net/p/robocode/feature-requests/90/ (Prevent JuniorRobot to be unresponsive) -[Req-92]: http://sourceforge.net/p/robocode/feature-requests/92/ (Scrollable properties) -[Req-93]: http://sourceforge.net/p/robocode/feature-requests/93/ (Rename /robots/.robotcache to /robots/.data) -[Req-99]: http://sourceforge.net/p/robocode/feature-requests/99/ (Move away from Jikes towards ECJ) -[Req-101]: http://sourceforge.net/p/robocode/feature-requests/101/ (onRoundEnded()) -[Req-113]: http://sourceforge.net/p/robocode/feature-requests/113/ (Skipped turn events) -[Req-114]: http://sourceforge.net/p/robocode/feature-requests/114/ (RateControlRobot vs. TeamRobot) -[Req-115]: http://sourceforge.net/p/robocode/feature-requests/115/ (Installed package should contain readme file) -[Req-118]: http://sourceforge.net/p/robocode/feature-requests/118/ (Enable/disable development paths) -[Req-121]: http://sourceforge.net/p/robocode/feature-requests/121/ (Issues with editor font) -[Req-124]: http://sourceforge.net/p/robocode/feature-requests/124/ (Ability to save the properties file for robots in dev. path) -[Req-128]: http://sourceforge.net/p/robocode/feature-requests/128/ (In battle name hiding) -[Req-129]: http://sourceforge.net/p/robocode/feature-requests/129/ (Rules.getBulletSpeed) -[Req-134]: http://sourceforge.net/p/robocode/feature-requests/134/ (Calculate codesize after compile in editor) -[Req-135]: http://sourceforge.net/p/robocode/feature-requests/135/ (Twin Duel configuration files) -[Req-144]: http://sourceforge.net/p/robocode/feature-requests/144/ (Mac ... start with icon and name) -[Req-156]: http://sourceforge.net/p/robocode/feature-requests/156/ (Codesize added to properties file) -[Req-159]: http://sourceforge.net/p/robocode/feature-requests/159/ (Fix overkilled garbage collection on static fields) -[Req-160]: http://sourceforge.net/p/robocode/feature-requests/160/ (Fixed width font in console) diff --git a/软件需求规格说明书.doc b/软件需求规格说明书.doc index d599a11..c8af5bb 100644 Binary files a/软件需求规格说明书.doc and b/软件需求规格说明书.doc differ

- * If you have not already, you should create a {@link Robot} first. - * - * @see - * robocode.sourceforge.net - * @see - * Building your first robot - * - * @see JuniorRobot - * @see Robot - * @see TeamRobot - * @see RateControlRobot - * @see Droid - * @see BorderSentry - * - * @author Mathew A. Nelson (original) - * @author Flemming N. Larsen (contributor) - * @author Robert D. Maupin (contributor) - * @author Pavel Savara (contributor) - */ -public class AdvancedRobot extends _AdvancedRadiansRobot implements IAdvancedRobot, IAdvancedEvents { - - /** - * Returns the distance remaining in the robot's current move measured in - * pixels. - *