5 Commits

Author SHA1 Message Date
b084e0a156 Asset folder is lower case 2020-10-23 09:15:42 +02:00
2241822b26 Loads Ivy 2020-10-23 09:15:14 +02:00
d63ee05b5d Added example.json to run with Cli 2020-07-25 03:08:08 +02:00
27c08eee39 Removed interfaces Asset. Refactoring 2020-07-25 01:12:53 +02:00
2443b984cf Added cli sub directory 2020-07-25 01:04:56 +02:00
15 changed files with 61 additions and 43 deletions

View File

@ -130,7 +130,7 @@
<delete file="${store.dir}/temp_final.jar"/>
</target>
<property name="ivy.install.version" value="2.1.0-rc2" />
<property name="ivy.install.version" value="2.5.0" />
<condition property="ivy.home" value="${env.IVY_HOME}">
<isset property="env.IVY_HOME" />
</condition>
@ -142,7 +142,7 @@
<mkdir dir="${ivy.jar.dir}"/>
<!-- download Ivy from web site so that it can be used even without any special installation -->
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
<get src="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
dest="${ivy.jar.file}" usetimestamp="true"/>
</target>

View File

@ -1,4 +1,4 @@
#Sat, 25 Jul 2020 00:02:41 +0200
#Sat, 25 Jul 2020 03:07:19 +0200
annotation.processing.enabled=true
annotation.processing.enabled.in.editor=false
annotation.processing.processors.list=

View File

@ -1,5 +1,5 @@
/*
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
* Copyright (c) 2020, tube
* All rights reserved.
*
* Redistribution and use in source and binary forms, with or without
@ -23,40 +23,32 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim.interfaces;
package opensesim.cli;
import java.util.HashMap;
import javax.swing.JPanel;
import opensesim.world.RealWorld;
import opensesim.util.idgenerator.IDGenerator;
import opensesim.util.idgenerator.Id;
import java.io.IOException;
import java.io.InputStream;
import java.util.Scanner;
import opensesim.world.GodWorld;
import opensesim.world.World;
/**
*
* @author 7u83 <7u83@mail.ru>
* @author tube
*/
public interface Asset extends Configurable {
public class Main {
static HashMap<Id, Asset> assetsById = new HashMap<>();
static HashMap<String, Asset> assetsBySymbol = new HashMap<>();
static IDGenerator assetIdGenerator = new IDGenerator();
public static void main(String[] args) throws IOException {
System.out.println("OpenSeSim Cli");
public String getSymbol();
InputStream is;
is = Main.class.getResourceAsStream(
"/opensesim/resources/files/example.json"
);
public Id getID();
// We have to bootstrap with a god world because
// there whould be no way to to initialize the world
GodWorld godworld = new GodWorld(is);
public Id setID(Id id);
public JPanel getEditGui();
/**
* Indicate if this asset can act as currency
*
* @return true if currency, false no.
*/
public boolean isCurrency();
public String getTypeName();
// public Asset(Id);
System.out.println("finished");
}
}

View File

@ -0,0 +1,10 @@
{
"version": 0.2,
"assets": [
{
"type": "opensesim.sesim.assets.FurtureAsset",
"symbol": "MSFT",
"name": "Hello"
}
]
}

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim.Assets;
package opensesim.sesim.assets;
import opensesim.world.AbstractAsset;
import opensesim.world.GodWorld;

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim.Assets;
package opensesim.sesim.assets;
import opensesim.world.AbstractAsset;
import opensesim.world.GodWorld;

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim.Assets;
package opensesim.sesim.assets;
import opensesim.world.AbstractAsset;
import opensesim.world.GodWorld;

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim.Assets;
package opensesim.sesim.assets;
import javax.swing.JPanel;
import opensesim.world.AbstractAsset;

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim.Assets;
package opensesim.sesim.assets;
/**
*

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim.Assets;
package opensesim.sesim.assets;
import opensesim.world.AbstractAsset;
import opensesim.world.GodWorld;

View File

@ -23,7 +23,7 @@
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
* POSSIBILITY OF SUCH DAMAGE.
*/
package opensesim.sesim.Assets;
package opensesim.sesim.assets;
import opensesim.world.AbstractAsset;
import opensesim.world.GodWorld;

View File

@ -25,6 +25,8 @@
*/
package opensesim.world;
import java.io.IOException;
import java.io.InputStream;
import java.lang.reflect.Constructor;
import java.lang.reflect.InvocationTargetException;
import java.util.Collection;
@ -32,6 +34,7 @@ import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Random;
import java.util.Scanner;
import java.util.Set;
import java.util.logging.Level;
import java.util.logging.Logger;
@ -74,8 +77,12 @@ public class GodWorld implements GetJson, World {
public static final String ASSET_SYMBOL = "symbol";
public static final String ASSET_TYPE = "type";
public static final String VERSION = "version";
}
public static double VERSION = 0.2;
/* HashSet<AbstractAsset> assetsById = new HashSet<>();
HashMap<String, AbstractAsset> assetsBySymbol = new HashMap<>();
@ -91,7 +98,16 @@ public class GodWorld implements GetJson, World {
*/
public GodWorld(JSONObject cfg) {
init(cfg, false);
}
public GodWorld(InputStream is) throws IOException{
String s = new Scanner(is, "UTF-8").useDelimiter("\\A").next();
JSONObject cfg = new JSONObject(s);
Double version = cfg.getDouble(GodWorld.JKEYS.VERSION);
if (version != GodWorld.VERSION) {
throw new IOException("File has wrong version.");
}
init(cfg,false);
}
public Scheduler getScheduler() {
@ -186,7 +202,7 @@ public class GodWorld implements GetJson, World {
cls = (Class<AbstractAsset>) Class.forName(class_name);
a = cls.getConstructor(GodWorld.class, JSONObject.class).newInstance(this, cfg);
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
Logger.getLogger(GodWorld.class.getName()).log(Level.SEVERE, null, ex);
Logger.getLogger(GodWorld.class.getName()).log(Level.SEVERE, class_name, ex);
return null;
}

View File

@ -26,8 +26,8 @@
package opensesim.world;
import java.util.Map;
import opensesim.sesim.Assets.CurrencyAsset;
import opensesim.sesim.Assets.DummyAsset;
import opensesim.sesim.assets.CurrencyAsset;
import opensesim.sesim.assets.DummyAsset;
import org.junit.After;
import org.junit.AfterClass;
import org.junit.Before;

View File

@ -26,7 +26,7 @@
package opensesim.world;
import java.util.Set;
import opensesim.sesim.Assets.CurrencyAsset;
import opensesim.sesim.assets.CurrencyAsset;
import opensesim.util.scheduler.EventListener;
import org.junit.After;
import org.junit.AfterClass;