Compare commits
No commits in common. "master" and "multiasset" have entirely different histories.
master
...
multiasset
@ -130,7 +130,7 @@
|
||||
<delete file="${store.dir}/temp_final.jar"/>
|
||||
</target>
|
||||
|
||||
<property name="ivy.install.version" value="2.5.0" />
|
||||
<property name="ivy.install.version" value="2.1.0-rc2" />
|
||||
<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="https://repo1.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
|
||||
<get src="http://repo2.maven.org/maven2/org/apache/ivy/ivy/${ivy.install.version}/ivy-${ivy.install.version}.jar"
|
||||
dest="${ivy.jar.file}" usetimestamp="true"/>
|
||||
</target>
|
||||
|
||||
|
@ -1,4 +1,4 @@
|
||||
#Sat, 25 Jul 2020 03:07:19 +0200
|
||||
#Sat, 25 Jul 2020 00:02:41 +0200
|
||||
annotation.processing.enabled=true
|
||||
annotation.processing.enabled.in.editor=false
|
||||
annotation.processing.processors.list=
|
||||
|
@ -1,10 +0,0 @@
|
||||
{
|
||||
"version": 0.2,
|
||||
"assets": [
|
||||
{
|
||||
"type": "opensesim.sesim.assets.StockAsset",
|
||||
"symbol": "MSFT",
|
||||
"name": "Microsoft"
|
||||
}
|
||||
]
|
||||
}
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
@ -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;
|
||||
|
||||
/**
|
||||
*
|
@ -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;
|
||||
@ -34,9 +34,9 @@ import org.json.JSONObject;
|
||||
*
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class StockAsset extends AbstractAsset{
|
||||
public class StockAssett extends AbstractAsset{
|
||||
|
||||
public StockAsset(GodWorld world, JSONObject cfg) {
|
||||
public StockAssett(GodWorld world, JSONObject cfg) {
|
||||
super(world, cfg);
|
||||
}
|
||||
|
@ -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;
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2020, tube
|
||||
* Copyright (c) 2018, 7u83 <7u83@mail.ru>
|
||||
* All rights reserved.
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
@ -23,32 +23,40 @@
|
||||
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*/
|
||||
package opensesim.cli;
|
||||
package opensesim.sesim.interfaces;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.io.InputStream;
|
||||
import java.util.Scanner;
|
||||
import opensesim.world.GodWorld;
|
||||
import opensesim.world.World;
|
||||
import java.util.HashMap;
|
||||
import javax.swing.JPanel;
|
||||
import opensesim.world.RealWorld;
|
||||
import opensesim.util.idgenerator.IDGenerator;
|
||||
import opensesim.util.idgenerator.Id;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author tube
|
||||
* @author 7u83 <7u83@mail.ru>
|
||||
*/
|
||||
public class Main {
|
||||
public interface Asset extends Configurable {
|
||||
|
||||
public static void main(String[] args) throws IOException {
|
||||
System.out.println("OpenSeSim Cli");
|
||||
static HashMap<Id, Asset> assetsById = new HashMap<>();
|
||||
static HashMap<String, Asset> assetsBySymbol = new HashMap<>();
|
||||
static IDGenerator assetIdGenerator = new IDGenerator();
|
||||
|
||||
InputStream is;
|
||||
is = Main.class.getResourceAsStream(
|
||||
"/opensesim/resources/files/example.json"
|
||||
);
|
||||
public String getSymbol();
|
||||
|
||||
// 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 getID();
|
||||
|
||||
System.out.println("finished");
|
||||
}
|
||||
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);
|
||||
}
|
@ -25,8 +25,6 @@
|
||||
*/
|
||||
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;
|
||||
@ -34,7 +32,6 @@ 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;
|
||||
@ -78,12 +75,8 @@ 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<>();
|
||||
*/
|
||||
@ -98,25 +91,9 @@ 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);
|
||||
}
|
||||
|
||||
private void init(JSONObject cfg, boolean mt) {
|
||||
// this.scheduler = new Scheduler();
|
||||
// this.scheduler.start();
|
||||
putJson(cfg);
|
||||
}
|
||||
|
||||
|
||||
public Scheduler getScheduler() {
|
||||
return scheduler;
|
||||
}
|
||||
@ -129,6 +106,11 @@ public class GodWorld implements GetJson, World {
|
||||
this(new JSONObject("{}"));
|
||||
}
|
||||
|
||||
private void init(JSONObject cfg, boolean mt) {
|
||||
this.scheduler = new Scheduler();
|
||||
this.scheduler.start();
|
||||
putJson(cfg);
|
||||
}
|
||||
|
||||
private void putJson(JSONObject cfg) {
|
||||
// Read assets
|
||||
@ -188,19 +170,11 @@ public class GodWorld implements GetJson, World {
|
||||
return cfg;
|
||||
}
|
||||
|
||||
/**
|
||||
* Create an asset from a JSON object
|
||||
*
|
||||
* @param cfg the JSON object to create the asset from
|
||||
* @return the created asset
|
||||
* @throws SeSimException
|
||||
*/
|
||||
public AbstractAsset createAsset(JSONObject cfg) throws SeSimException {
|
||||
AbstractAsset a;
|
||||
String class_name;
|
||||
Class<AbstractAsset> cls;
|
||||
|
||||
// get asset name
|
||||
try {
|
||||
class_name = cfg.getString(JKEYS.ASSET_TYPE);
|
||||
} catch (JSONException jex) {
|
||||
@ -208,14 +182,11 @@ public class GodWorld implements GetJson, World {
|
||||
return null;
|
||||
}
|
||||
|
||||
// create class from name
|
||||
try {
|
||||
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, class_name, ex);
|
||||
} catch (ClassNotFoundException | NoSuchMethodException | SecurityException | InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) {
|
||||
Logger.getLogger(GodWorld.class.getName()).log(Level.SEVERE, null, ex);
|
||||
return null;
|
||||
}
|
||||
|
||||
|
@ -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;
|
||||
|
@ -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;
|
||||
|
Loading…
Reference in New Issue
Block a user