repo_name
stringlengths
7
104
file_path
stringlengths
13
198
context
stringlengths
67
7.15k
import_statement
stringlengths
16
4.43k
code
stringlengths
40
6.98k
prompt
stringlengths
227
8.27k
next_line
stringlengths
8
795
wmr513/reactive
workflow/java/workflow/AMQPWorkflowConsumer.java
// Path: common/java/common/AMQPCommon.java // public class AMQPCommon { // // public static Channel connect() throws Exception { // ConnectionFactory factory = new ConnectionFactory(); // factory.setHost("127.0.0.1"); // factory.setPort(32768); // Connection conn = factory.newConnection(); // return conn.createChannel(); // } // // public static void close(Channel channel) throws Exception { // channel.close(); // channel.getConnection().close(); // } // // }
import com.rabbitmq.client.Channel; import com.rabbitmq.client.QueueingConsumer; import common.AMQPCommon;
package workflow; /** * Continuously consume messages every 2 seconds */ public class AMQPWorkflowConsumer { public void execute() throws Exception {
// Path: common/java/common/AMQPCommon.java // public class AMQPCommon { // // public static Channel connect() throws Exception { // ConnectionFactory factory = new ConnectionFactory(); // factory.setHost("127.0.0.1"); // factory.setPort(32768); // Connection conn = factory.newConnection(); // return conn.createChannel(); // } // // public static void close(Channel channel) throws Exception { // channel.close(); // channel.getConnection().close(); // } // // } // Path: workflow/java/workflow/AMQPWorkflowConsumer.java import com.rabbitmq.client.Channel; import com.rabbitmq.client.QueueingConsumer; import common.AMQPCommon; package workflow; /** * Continuously consume messages every 2 seconds */ public class AMQPWorkflowConsumer { public void execute() throws Exception {
Channel channel = AMQPCommon.connect();
wmr513/reactive
workflow/java/workflow/AMQPWorkflowProcessor.java
// Path: common/java/common/AMQPCommon.java // public class AMQPCommon { // // public static Channel connect() throws Exception { // ConnectionFactory factory = new ConnectionFactory(); // factory.setHost("127.0.0.1"); // factory.setPort(32768); // Connection conn = factory.newConnection(); // return conn.createChannel(); // } // // public static void close(Channel channel) throws Exception { // channel.close(); // channel.getConnection().close(); // } // // }
import com.rabbitmq.client.Channel; import com.rabbitmq.client.QueueingConsumer; import common.AMQPCommon;
package workflow; public class AMQPWorkflowProcessor { public void execute() throws Exception {
// Path: common/java/common/AMQPCommon.java // public class AMQPCommon { // // public static Channel connect() throws Exception { // ConnectionFactory factory = new ConnectionFactory(); // factory.setHost("127.0.0.1"); // factory.setPort(32768); // Connection conn = factory.newConnection(); // return conn.createChannel(); // } // // public static void close(Channel channel) throws Exception { // channel.close(); // channel.getConnection().close(); // } // // } // Path: workflow/java/workflow/AMQPWorkflowProcessor.java import com.rabbitmq.client.Channel; import com.rabbitmq.client.QueueingConsumer; import common.AMQPCommon; package workflow; public class AMQPWorkflowProcessor { public void execute() throws Exception {
Channel channel = AMQPCommon.connect();
wmr513/reactive
threaddelegate/java/threaddelegate/Dispatcher.java
// Path: common/java/common/AMQPCommon.java // public class AMQPCommon { // // public static Channel connect() throws Exception { // ConnectionFactory factory = new ConnectionFactory(); // factory.setHost("127.0.0.1"); // factory.setPort(32768); // Connection conn = factory.newConnection(); // return conn.createChannel(); // } // // public static void close(Channel channel) throws Exception { // channel.close(); // channel.getConnection().close(); // } // // }
import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import com.rabbitmq.client.Channel; import com.rabbitmq.client.QueueingConsumer; import common.AMQPCommon;
package threaddelegate; public class Dispatcher { //account, thread private Map<String, Long> allocationMap = new ConcurrentHashMap<String, Long>(); //thread id, number of messages processing private Map<Long, Long> processingCountMap = new ConcurrentHashMap<Long, Long>(); //Thread id, thread object private Map<Long, TradeProcessor> threadpool = new ConcurrentHashMap<Long, TradeProcessor>(); private boolean display = false; public void dispatchMessages() throws Exception {
// Path: common/java/common/AMQPCommon.java // public class AMQPCommon { // // public static Channel connect() throws Exception { // ConnectionFactory factory = new ConnectionFactory(); // factory.setHost("127.0.0.1"); // factory.setPort(32768); // Connection conn = factory.newConnection(); // return conn.createChannel(); // } // // public static void close(Channel channel) throws Exception { // channel.close(); // channel.getConnection().close(); // } // // } // Path: threaddelegate/java/threaddelegate/Dispatcher.java import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Map; import java.util.concurrent.ConcurrentHashMap; import com.rabbitmq.client.Channel; import com.rabbitmq.client.QueueingConsumer; import common.AMQPCommon; package threaddelegate; public class Dispatcher { //account, thread private Map<String, Long> allocationMap = new ConcurrentHashMap<String, Long>(); //thread id, number of messages processing private Map<Long, Long> processingCountMap = new ConcurrentHashMap<Long, Long>(); //Thread id, thread object private Map<Long, TradeProcessor> threadpool = new ConcurrentHashMap<Long, TradeProcessor>(); private boolean display = false; public void dispatchMessages() throws Exception {
Channel channel = AMQPCommon.connect();
wmr513/reactive
threshold/java/threshold/AMQPConfig.java
// Path: common/java/common/AMQPCommon.java // public class AMQPCommon { // // public static Channel connect() throws Exception { // ConnectionFactory factory = new ConnectionFactory(); // factory.setHost("127.0.0.1"); // factory.setPort(32768); // Connection conn = factory.newConnection(); // return conn.createChannel(); // } // // public static void close(Channel channel) throws Exception { // channel.close(); // channel.getConnection().close(); // } // // }
import com.rabbitmq.client.Channel; import com.rabbitmq.client.QueueingConsumer; import common.AMQPCommon;
package threshold; public class AMQPConfig { public void execute() throws Exception {
// Path: common/java/common/AMQPCommon.java // public class AMQPCommon { // // public static Channel connect() throws Exception { // ConnectionFactory factory = new ConnectionFactory(); // factory.setHost("127.0.0.1"); // factory.setPort(32768); // Connection conn = factory.newConnection(); // return conn.createChannel(); // } // // public static void close(Channel channel) throws Exception { // channel.close(); // channel.getConnection().close(); // } // // } // Path: threshold/java/threshold/AMQPConfig.java import com.rabbitmq.client.Channel; import com.rabbitmq.client.QueueingConsumer; import common.AMQPCommon; package threshold; public class AMQPConfig { public void execute() throws Exception {
Channel channel = AMQPCommon.connect();
thane98/3DSFE-Randomizer
randomizer/common/fs/model/Decompiler.java
// Path: randomizer/common/fs/data/ScriptSingleton.java // public class ScriptSingleton { // private static ScriptSingleton instance; // // private Hashtable<String, Byte[]> tags = new Hashtable<>(); // private Hashtable<Integer, Byte[]> subheaders = new Hashtable<>(); // // private ScriptSingleton() throws SAXException, IOException, ParserConfigurationException { // DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); // DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); // Document doc = dBuilder.parse(this.getClass().getResourceAsStream("Commands.xml")); // doc.getDocumentElement().normalize(); // NodeList nList = doc.getElementsByTagName("Command"); // for (int x = 0; x < nList.getLength(); x++) { // Node node = nList.item(x); // if (!node.getAttributes().getNamedItem("name").getNodeValue().equals("")) { // if (node.getAttributes().getNamedItem("tag").getNodeValue().equals("")) { // tags.put(node.getAttributes().getNamedItem("name").getNodeValue(), new Byte[0]); // } else { // String[] splitString = node.getAttributes().getNamedItem("tag").getNodeValue().split(","); // Byte[] bytes = new Byte[splitString.length]; // for (int y = 0; y < bytes.length; y++) { // bytes[y] = Byte.parseByte(splitString[y], 16); // } // tags.put(node.getAttributes().getNamedItem("name").getNodeValue(), bytes); // } // } // } // // doc = dBuilder.parse(this.getClass().getResourceAsStream("Subheaders.xml")); // doc.getDocumentElement().normalize(); // nList = doc.getElementsByTagName("Subheader"); // for (int x = 0; x < nList.getLength(); x++) { // Node node = nList.item(x); // if (!node.getAttributes().getNamedItem("id").getNodeValue().equals("")) { // int id = Integer.parseInt(node.getAttributes().getNamedItem("id").getNodeValue()); // String[] unparsedValues = node.getAttributes().getNamedItem("layout").getNodeValue().split(","); // Byte[] values = new Byte[unparsedValues.length]; // for (int y = 0; y < values.length; y++) // values[y] = Byte.parseByte(unparsedValues[y]); // subheaders.put(id, values); // } // } // } // // public static ScriptSingleton getInstance() throws Exception { // if (instance == null) // instance = new ScriptSingleton(); // return instance; // } // // public Hashtable<String, Byte[]> getTags() { // return tags; // } // // public Hashtable<Integer, Byte[]> getSubheaders() { // return subheaders; // } // } // // Path: randomizer/common/utils/ByteUtils.java // public class ByteUtils { // public static short toShort(byte[] encodedValues, int index) { // return (short) (((encodedValues[index + 1] & 0xff) << 8) + (encodedValues[index] & 0xff)); // } // // public static int toBigEndianShort(byte[] encodedValues, int index) { // return (((encodedValues[index] << 8) & 0xFF00) | (encodedValues[index + 1] & 0xFF)); // } // // public static int toInt(byte[] encodedValue, int index) { // int value = (encodedValue[index + 3] << (Byte.SIZE * 3)); // value |= (encodedValue[index + 2] & 0xFF) << (Byte.SIZE * 2); // value |= (encodedValue[index + 1] & 0xFF) << (Byte.SIZE); // value |= (encodedValue[index] & 0xFF); // return value; // } // // public static byte[] toByteArray(short value) { // byte[] ret = new byte[2]; // ret[0] = (byte) (value & 0xff); // ret[1] = (byte) ((value >> 8) & 0xff); // return ret; // } // // public static List<Byte> toByteList(byte[] arr) { // List<Byte> bytes = new ArrayList<>(); // for (byte b : arr) // bytes.add(b); // return bytes; // } // // public static byte[] toByteArray(int value) { // byte[] encodedValue = new byte[Integer.SIZE / Byte.SIZE]; // encodedValue[3] = (byte) (value >> (Byte.SIZE * 3)); // encodedValue[2] = (byte) (value >> (Byte.SIZE * 2)); // encodedValue[1] = (byte) (value >> Byte.SIZE); // encodedValue[0] = (byte) value; // return encodedValue; // } // // public static String getString(byte[] source, int index) throws UnsupportedEncodingException { // int end = index; // while (source[end] != 0) { // end++; // } // return new String(Arrays.copyOfRange(source, index, end), "shift-jis"); // } // // public static String toString(byte[] input) { // StringBuilder builder = new StringBuilder("["); // for(int x = 0; x < input.length; x++) { // builder.append("0x").append(Long.toHexString(input[x] & 0xFF)); // if(x != input.length - 1) // builder.append(", "); // } // return builder.append("]").toString(); // } // }
import randomizer.common.fs.data.ScriptSingleton; import randomizer.common.utils.ByteUtils; import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.List;
package randomizer.common.fs.model; public class Decompiler { private int ref; private List<String> result; private byte[] bytes; private String fileName; public Decompiler() {} public String decompile(Path path) throws Exception { this.fileName = path.toFile().getName(); List<Integer> headers = new ArrayList<>(); result = new ArrayList<>(); bytes = Files.readAllBytes(path);
// Path: randomizer/common/fs/data/ScriptSingleton.java // public class ScriptSingleton { // private static ScriptSingleton instance; // // private Hashtable<String, Byte[]> tags = new Hashtable<>(); // private Hashtable<Integer, Byte[]> subheaders = new Hashtable<>(); // // private ScriptSingleton() throws SAXException, IOException, ParserConfigurationException { // DocumentBuilderFactory dbFactory = DocumentBuilderFactory.newInstance(); // DocumentBuilder dBuilder = dbFactory.newDocumentBuilder(); // Document doc = dBuilder.parse(this.getClass().getResourceAsStream("Commands.xml")); // doc.getDocumentElement().normalize(); // NodeList nList = doc.getElementsByTagName("Command"); // for (int x = 0; x < nList.getLength(); x++) { // Node node = nList.item(x); // if (!node.getAttributes().getNamedItem("name").getNodeValue().equals("")) { // if (node.getAttributes().getNamedItem("tag").getNodeValue().equals("")) { // tags.put(node.getAttributes().getNamedItem("name").getNodeValue(), new Byte[0]); // } else { // String[] splitString = node.getAttributes().getNamedItem("tag").getNodeValue().split(","); // Byte[] bytes = new Byte[splitString.length]; // for (int y = 0; y < bytes.length; y++) { // bytes[y] = Byte.parseByte(splitString[y], 16); // } // tags.put(node.getAttributes().getNamedItem("name").getNodeValue(), bytes); // } // } // } // // doc = dBuilder.parse(this.getClass().getResourceAsStream("Subheaders.xml")); // doc.getDocumentElement().normalize(); // nList = doc.getElementsByTagName("Subheader"); // for (int x = 0; x < nList.getLength(); x++) { // Node node = nList.item(x); // if (!node.getAttributes().getNamedItem("id").getNodeValue().equals("")) { // int id = Integer.parseInt(node.getAttributes().getNamedItem("id").getNodeValue()); // String[] unparsedValues = node.getAttributes().getNamedItem("layout").getNodeValue().split(","); // Byte[] values = new Byte[unparsedValues.length]; // for (int y = 0; y < values.length; y++) // values[y] = Byte.parseByte(unparsedValues[y]); // subheaders.put(id, values); // } // } // } // // public static ScriptSingleton getInstance() throws Exception { // if (instance == null) // instance = new ScriptSingleton(); // return instance; // } // // public Hashtable<String, Byte[]> getTags() { // return tags; // } // // public Hashtable<Integer, Byte[]> getSubheaders() { // return subheaders; // } // } // // Path: randomizer/common/utils/ByteUtils.java // public class ByteUtils { // public static short toShort(byte[] encodedValues, int index) { // return (short) (((encodedValues[index + 1] & 0xff) << 8) + (encodedValues[index] & 0xff)); // } // // public static int toBigEndianShort(byte[] encodedValues, int index) { // return (((encodedValues[index] << 8) & 0xFF00) | (encodedValues[index + 1] & 0xFF)); // } // // public static int toInt(byte[] encodedValue, int index) { // int value = (encodedValue[index + 3] << (Byte.SIZE * 3)); // value |= (encodedValue[index + 2] & 0xFF) << (Byte.SIZE * 2); // value |= (encodedValue[index + 1] & 0xFF) << (Byte.SIZE); // value |= (encodedValue[index] & 0xFF); // return value; // } // // public static byte[] toByteArray(short value) { // byte[] ret = new byte[2]; // ret[0] = (byte) (value & 0xff); // ret[1] = (byte) ((value >> 8) & 0xff); // return ret; // } // // public static List<Byte> toByteList(byte[] arr) { // List<Byte> bytes = new ArrayList<>(); // for (byte b : arr) // bytes.add(b); // return bytes; // } // // public static byte[] toByteArray(int value) { // byte[] encodedValue = new byte[Integer.SIZE / Byte.SIZE]; // encodedValue[3] = (byte) (value >> (Byte.SIZE * 3)); // encodedValue[2] = (byte) (value >> (Byte.SIZE * 2)); // encodedValue[1] = (byte) (value >> Byte.SIZE); // encodedValue[0] = (byte) value; // return encodedValue; // } // // public static String getString(byte[] source, int index) throws UnsupportedEncodingException { // int end = index; // while (source[end] != 0) { // end++; // } // return new String(Arrays.copyOfRange(source, index, end), "shift-jis"); // } // // public static String toString(byte[] input) { // StringBuilder builder = new StringBuilder("["); // for(int x = 0; x < input.length; x++) { // builder.append("0x").append(Long.toHexString(input[x] & 0xFF)); // if(x != input.length - 1) // builder.append(", "); // } // return builder.append("]").toString(); // } // } // Path: randomizer/common/fs/model/Decompiler.java import randomizer.common.fs.data.ScriptSingleton; import randomizer.common.utils.ByteUtils; import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.Arrays; import java.util.List; package randomizer.common.fs.model; public class Decompiler { private int ref; private List<String> result; private byte[] bytes; private String fileName; public Decompiler() {} public String decompile(Path path) throws Exception { this.fileName = path.toFile().getName(); List<Integer> headers = new ArrayList<>(); result = new ArrayList<>(); bytes = Files.readAllBytes(path);
int pointerOffset = ByteUtils.toInt(bytes, 0x1C);
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AGui.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
package randomizer.awakening.singletons; public class AGui { private static transient AGui instance; private transient IntegerProperty baseStatPasses = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMin = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); private transient IntegerProperty growthMin = new SimpleIntegerProperty(); private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient boolean[] selectedCharacters = new boolean[ACharacters.getInstance()
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AGui.java import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; package randomizer.awakening.singletons; public class AGui { private static transient AGui instance; private transient IntegerProperty baseStatPasses = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMin = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); private transient IntegerProperty growthMin = new SimpleIntegerProperty(); private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient boolean[] selectedCharacters = new boolean[ACharacters.getInstance()
.getCharactersByType(CharacterType.FirstGen).size()];
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AGui.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
package randomizer.awakening.singletons; public class AGui { private static transient AGui instance; private transient IntegerProperty baseStatPasses = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMin = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); private transient IntegerProperty growthMin = new SimpleIntegerProperty(); private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient boolean[] selectedCharacters = new boolean[ACharacters.getInstance() .getCharactersByType(CharacterType.FirstGen).size()]; private boolean[] selectedJobs = new boolean[AJobs.getInstance().getJobs().size()]; private boolean[] selectedItems = new boolean[AItems.getInstance().getWeapons().size()]; private boolean[] selectedSkills = new boolean[ASkills.getInstance().getSkills().size()]; private boolean[] selectedOptions; private AGui() { try {
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AGui.java import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; package randomizer.awakening.singletons; public class AGui { private static transient AGui instance; private transient IntegerProperty baseStatPasses = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMin = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); private transient IntegerProperty growthMin = new SimpleIntegerProperty(); private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient boolean[] selectedCharacters = new boolean[ACharacters.getInstance() .getCharactersByType(CharacterType.FirstGen).size()]; private boolean[] selectedJobs = new boolean[AJobs.getInstance().getJobs().size()]; private boolean[] selectedItems = new boolean[AItems.getInstance().getWeapons().size()]; private boolean[] selectedSkills = new boolean[ASkills.getInstance().getSkills().size()]; private boolean[] selectedOptions; private AGui() { try {
BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AGui.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); private transient IntegerProperty growthMin = new SimpleIntegerProperty(); private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient boolean[] selectedCharacters = new boolean[ACharacters.getInstance() .getCharactersByType(CharacterType.FirstGen).size()]; private boolean[] selectedJobs = new boolean[AJobs.getInstance().getJobs().size()]; private boolean[] selectedItems = new boolean[AItems.getInstance().getWeapons().size()]; private boolean[] selectedSkills = new boolean[ASkills.getInstance().getSkills().size()]; private boolean[] selectedOptions; private AGui() { try { BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/text/AwakeningOptions.txt"))); options = new ArrayList<>(); String line; while((line = streamReader.readLine()) != null) { options.add(line); } } catch (IOException e) { e.printStackTrace(); } // Set up default selections.
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AGui.java import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); private transient IntegerProperty growthMin = new SimpleIntegerProperty(); private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient boolean[] selectedCharacters = new boolean[ACharacters.getInstance() .getCharactersByType(CharacterType.FirstGen).size()]; private boolean[] selectedJobs = new boolean[AJobs.getInstance().getJobs().size()]; private boolean[] selectedItems = new boolean[AItems.getInstance().getWeapons().size()]; private boolean[] selectedSkills = new boolean[ASkills.getInstance().getSkills().size()]; private boolean[] selectedOptions; private AGui() { try { BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/text/AwakeningOptions.txt"))); options = new ArrayList<>(); String line; while((line = streamReader.readLine()) != null) { options.add(line); } } catch (IOException e) { e.printStackTrace(); } // Set up default selections.
List<Skill> skills = ASkills.getInstance().getSkills();
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AGui.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
private boolean[] selectedItems = new boolean[AItems.getInstance().getWeapons().size()]; private boolean[] selectedSkills = new boolean[ASkills.getInstance().getSkills().size()]; private boolean[] selectedOptions; private AGui() { try { BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/text/AwakeningOptions.txt"))); options = new ArrayList<>(); String line; while((line = streamReader.readLine()) != null) { options.add(line); } } catch (IOException e) { e.printStackTrace(); } // Set up default selections. List<Skill> skills = ASkills.getInstance().getSkills(); selectedOptions = new boolean[options.size()]; for(int x = 0; x < selectedOptions.length; x++) { selectedOptions[x] = true; } for(int x = 0; x < selectedCharacters.length; x++) { selectedCharacters[x] = true; } for(int x = 0; x < selectedJobs.length; x++) { selectedJobs[x] = true; } for(int x = 0; x < skills.size(); x++) {
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AGui.java import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; private boolean[] selectedItems = new boolean[AItems.getInstance().getWeapons().size()]; private boolean[] selectedSkills = new boolean[ASkills.getInstance().getSkills().size()]; private boolean[] selectedOptions; private AGui() { try { BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/text/AwakeningOptions.txt"))); options = new ArrayList<>(); String line; while((line = streamReader.readLine()) != null) { options.add(line); } } catch (IOException e) { e.printStackTrace(); } // Set up default selections. List<Skill> skills = ASkills.getInstance().getSkills(); selectedOptions = new boolean[options.size()]; for(int x = 0; x < selectedOptions.length; x++) { selectedOptions[x] = true; } for(int x = 0; x < selectedCharacters.length; x++) { selectedCharacters[x] = true; } for(int x = 0; x < selectedJobs.length; x++) { selectedJobs[x] = true; } for(int x = 0; x < skills.size(); x++) {
selectedSkills[x] = skills.get(x).getType() != SkillType.Enemy;
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesJobs.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.fates.singletons; public class FatesJobs { private static FatesJobs instance;
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesJobs.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.fates.singletons; public class FatesJobs { private static FatesJobs instance;
private List<Job> jobs;
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesJobs.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.fates.singletons; public class FatesJobs { private static FatesJobs instance; private List<Job> jobs; private FatesJobs() { try { // Parse jobs from JSON. Type jobType = new TypeToken<List<Job>>() {}.getType(); Gson gson = new Gson();
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesJobs.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.fates.singletons; public class FatesJobs { private static FatesJobs instance; private List<Job> jobs; private FatesJobs() { try { // Parse jobs from JSON. Type jobType = new TypeToken<List<Job>>() {}.getType(); Gson gson = new Gson();
JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesJobs.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.fates.singletons; public class FatesJobs { private static FatesJobs instance; private List<Job> jobs; private FatesJobs() { try { // Parse jobs from JSON. Type jobType = new TypeToken<List<Job>>() {}.getType(); Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/FatesClasses.json"), "UTF-8"))); jobs = gson.fromJson(reader, jobType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static FatesJobs getInstance() { if (instance == null) instance = new FatesJobs(); return instance; } public List<Job> getMaleBaseClasses() { List<Job> current = new ArrayList<>(); boolean[] selectedJobs = FatesGui.getInstance().getSelectedJobs(); for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x);
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesJobs.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.fates.singletons; public class FatesJobs { private static FatesJobs instance; private List<Job> jobs; private FatesJobs() { try { // Parse jobs from JSON. Type jobType = new TypeToken<List<Job>>() {}.getType(); Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/FatesClasses.json"), "UTF-8"))); jobs = gson.fromJson(reader, jobType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static FatesJobs getInstance() { if (instance == null) instance = new FatesJobs(); return instance; } public List<Job> getMaleBaseClasses() { List<Job> current = new ArrayList<>(); boolean[] selectedJobs = FatesGui.getInstance().getSelectedJobs(); for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x);
if((j.getGender() == 0 || j.getGender() == 2) && j.getState() != JobState.Promoted && selectedJobs[x])
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesJobs.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
current.add(j); } return current; } public List<Job> getFemalePromotedClasses() { List<Job> current = new ArrayList<>(); boolean[] selectedJobs = FatesGui.getInstance().getSelectedJobs(); for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x); if((j.getGender() == 1 || j.getGender() == 2) && j.getState() != JobState.Base && selectedJobs[x]) current.add(j); } return current; } public List<Job> getEligibleJobs(boolean male, int maxLength) { if(maxLength < 1) throw new IllegalArgumentException("Violation of precondidition: " + "getEligibleJobs. maxLength must be greater than 0."); List<Job> eligible = new ArrayList<>(); List<Job> pool; if(male) pool = getMaleBaseClasses(); else pool = getFemaleBaseClasses(); try { for(Job j : pool) { if(j.getJid().getBytes("shift-jis").length <= maxLength && j.getItemType()
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesJobs.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; current.add(j); } return current; } public List<Job> getFemalePromotedClasses() { List<Job> current = new ArrayList<>(); boolean[] selectedJobs = FatesGui.getInstance().getSelectedJobs(); for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x); if((j.getGender() == 1 || j.getGender() == 2) && j.getState() != JobState.Base && selectedJobs[x]) current.add(j); } return current; } public List<Job> getEligibleJobs(boolean male, int maxLength) { if(maxLength < 1) throw new IllegalArgumentException("Violation of precondidition: " + "getEligibleJobs. maxLength must be greater than 0."); List<Job> eligible = new ArrayList<>(); List<Job> pool; if(male) pool = getMaleBaseClasses(); else pool = getFemaleBaseClasses(); try { for(Job j : pool) { if(j.getJid().getBytes("shift-jis").length <= maxLength && j.getItemType()
!= ItemType.Staves && j.getItemType() != ItemType.Beaststone)
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesJobs.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
public List<Job> getEligibleJobs(boolean male, int maxLength) { if(maxLength < 1) throw new IllegalArgumentException("Violation of precondidition: " + "getEligibleJobs. maxLength must be greater than 0."); List<Job> eligible = new ArrayList<>(); List<Job> pool; if(male) pool = getMaleBaseClasses(); else pool = getFemaleBaseClasses(); try { for(Job j : pool) { if(j.getJid().getBytes("shift-jis").length <= maxLength && j.getItemType() != ItemType.Staves && j.getItemType() != ItemType.Beaststone) eligible.add(j); } } catch(UnsupportedEncodingException e) { e.printStackTrace(); } return eligible; } public byte[] generateWeaponsRanks(Job j) { if(j == null) throw new IllegalArgumentException("Violation of precondidition: " + "generateItem. j must not be null."); byte[] weaponRanks = new byte[8]; if(j.getItemType() == ItemType.Swords) {
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesJobs.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; public List<Job> getEligibleJobs(boolean male, int maxLength) { if(maxLength < 1) throw new IllegalArgumentException("Violation of precondidition: " + "getEligibleJobs. maxLength must be greater than 0."); List<Job> eligible = new ArrayList<>(); List<Job> pool; if(male) pool = getMaleBaseClasses(); else pool = getFemaleBaseClasses(); try { for(Job j : pool) { if(j.getJid().getBytes("shift-jis").length <= maxLength && j.getItemType() != ItemType.Staves && j.getItemType() != ItemType.Beaststone) eligible.add(j); } } catch(UnsupportedEncodingException e) { e.printStackTrace(); } return eligible; } public byte[] generateWeaponsRanks(Job j) { if(j == null) throw new IllegalArgumentException("Violation of precondidition: " + "generateItem. j must not be null."); byte[] weaponRanks = new byte[8]; if(j.getItemType() == ItemType.Swords) {
weaponRanks[0] = (byte) WeaponRank.C.value();
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AItems.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random;
package randomizer.awakening.singletons; public class AItems { private static AItems instance;
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AItems.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random; package randomizer.awakening.singletons; public class AItems { private static AItems instance;
private List<FEItem> items;
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AItems.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random;
package randomizer.awakening.singletons; public class AItems { private static AItems instance; private List<FEItem> items; private AItems() { Type itemType = new TypeToken<List<FEItem>>() {}.getType(); try { Gson gson = new Gson();
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AItems.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random; package randomizer.awakening.singletons; public class AItems { private static AItems instance; private List<FEItem> items; private AItems() { Type itemType = new TypeToken<List<FEItem>>() {}.getType(); try { Gson gson = new Gson();
JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AItems.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random;
package randomizer.awakening.singletons; public class AItems { private static AItems instance; private List<FEItem> items; private AItems() { Type itemType = new TypeToken<List<FEItem>>() {}.getType(); try { Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/AwakeningItems.json"), "UTF-8"))); items = gson.fromJson(reader, itemType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static AItems getInstance() { if (instance == null) instance = new AItems(); return instance; } List<FEItem> getWeapons() { List<FEItem> weapons = new ArrayList<>(); for(FEItem i : items) {
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AItems.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random; package randomizer.awakening.singletons; public class AItems { private static AItems instance; private List<FEItem> items; private AItems() { Type itemType = new TypeToken<List<FEItem>>() {}.getType(); try { Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/AwakeningItems.json"), "UTF-8"))); items = gson.fromJson(reader, itemType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static AItems getInstance() { if (instance == null) instance = new AItems(); return instance; } List<FEItem> getWeapons() { List<FEItem> weapons = new ArrayList<>(); for(FEItem i : items) {
if(i.getType() != ItemType.Treasure)
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AItems.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random;
weapons.add(i); } return weapons; } public List<FEItem> getSelectedItems(ItemType type) { List<FEItem> selected = new ArrayList<>(); List<FEItem> weapons = getWeapons(); boolean[] selectedItems = AGui.getInstance().getSelectedItems(); for(int x = 0; x < weapons.size(); x++) { if(weapons.get(x).getType() == type && selectedItems[x]) selected.add(weapons.get(x)); } return selected; } public FEItem generateEligibleItem(ItemType type, int maxLength) { List<FEItem> eligible = new ArrayList<>(); try { for(FEItem i : getSelectedItems(type)) { if(i.getIid().getBytes("shift-jis").length <= maxLength) eligible.add(i); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Random random = new Random(); return eligible.get(random.nextInt(eligible.size())); }
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AItems.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random; weapons.add(i); } return weapons; } public List<FEItem> getSelectedItems(ItemType type) { List<FEItem> selected = new ArrayList<>(); List<FEItem> weapons = getWeapons(); boolean[] selectedItems = AGui.getInstance().getSelectedItems(); for(int x = 0; x < weapons.size(); x++) { if(weapons.get(x).getType() == type && selectedItems[x]) selected.add(weapons.get(x)); } return selected; } public FEItem generateEligibleItem(ItemType type, int maxLength) { List<FEItem> eligible = new ArrayList<>(); try { for(FEItem i : getSelectedItems(type)) { if(i.getIid().getBytes("shift-jis").length <= maxLength) eligible.add(i); } } catch (UnsupportedEncodingException e) { e.printStackTrace(); } Random random = new Random(); return eligible.get(random.nextInt(eligible.size())); }
public FEItem generateItem(Job j) {
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesItems.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random;
package randomizer.fates.singletons; public class FatesItems { private static FatesItems instance;
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesItems.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random; package randomizer.fates.singletons; public class FatesItems { private static FatesItems instance;
private List<FEItem> items;
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesItems.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random;
package randomizer.fates.singletons; public class FatesItems { private static FatesItems instance; private List<FEItem> items; private String[] playerIids = { "IID_青銅の剣", "IID_青銅の槍", "IID_青銅の斧", "IID_青銅の暗器", "IID_青銅の弓", "IID_ファイアー", "IID_ライブ", "IID_獣石", "IID_乱拳", "IID_岩塊" }; private FatesItems() { try { Type itemType = new TypeToken<List<FEItem>>() {}.getType(); Gson gson = new Gson();
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesItems.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random; package randomizer.fates.singletons; public class FatesItems { private static FatesItems instance; private List<FEItem> items; private String[] playerIids = { "IID_青銅の剣", "IID_青銅の槍", "IID_青銅の斧", "IID_青銅の暗器", "IID_青銅の弓", "IID_ファイアー", "IID_ライブ", "IID_獣石", "IID_乱拳", "IID_岩塊" }; private FatesItems() { try { Type itemType = new TypeToken<List<FEItem>>() {}.getType(); Gson gson = new Gson();
JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesItems.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random;
package randomizer.fates.singletons; public class FatesItems { private static FatesItems instance; private List<FEItem> items; private String[] playerIids = { "IID_青銅の剣", "IID_青銅の槍", "IID_青銅の斧", "IID_青銅の暗器", "IID_青銅の弓", "IID_ファイアー", "IID_ライブ", "IID_獣石", "IID_乱拳", "IID_岩塊" }; private FatesItems() { try { Type itemType = new TypeToken<List<FEItem>>() {}.getType(); Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/FatesItems.json"), "UTF-8"))); items = gson.fromJson(reader, itemType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static FatesItems getInstance() { if (instance == null) instance = new FatesItems(); return instance; } public List<FEItem> getWeapons() { List<FEItem> weapons = new ArrayList<>(); // TODO: Refactor getWeapons for(FEItem i : items) {
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesItems.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random; package randomizer.fates.singletons; public class FatesItems { private static FatesItems instance; private List<FEItem> items; private String[] playerIids = { "IID_青銅の剣", "IID_青銅の槍", "IID_青銅の斧", "IID_青銅の暗器", "IID_青銅の弓", "IID_ファイアー", "IID_ライブ", "IID_獣石", "IID_乱拳", "IID_岩塊" }; private FatesItems() { try { Type itemType = new TypeToken<List<FEItem>>() {}.getType(); Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/FatesItems.json"), "UTF-8"))); items = gson.fromJson(reader, itemType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static FatesItems getInstance() { if (instance == null) instance = new FatesItems(); return instance; } public List<FEItem> getWeapons() { List<FEItem> weapons = new ArrayList<>(); // TODO: Refactor getWeapons for(FEItem i : items) {
if(i.getType() != ItemType.Treasure)
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesItems.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random;
public static FatesItems getInstance() { if (instance == null) instance = new FatesItems(); return instance; } public List<FEItem> getWeapons() { List<FEItem> weapons = new ArrayList<>(); // TODO: Refactor getWeapons for(FEItem i : items) { if(i.getType() != ItemType.Treasure) weapons.add(i); } return weapons; } public List<FEItem> getSelectedItems(ItemType type) { if(type == null) throw new IllegalArgumentException("Violation of precondidition: " + "getSelectedItems. type must not be null."); List<FEItem> selected = new ArrayList<>(); List<FEItem> weapons = getWeapons(); boolean[] selectedItems = FatesGui.getInstance().getSelectedItems(); for(int x = 0; x < weapons.size(); x++) { if(weapons.get(x).getType() == type && selectedItems[x]) selected.add(weapons.get(x)); } return selected; }
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/structures/FEItem.java // public class FEItem { // private String iid; // private String name; // private ItemType type; // // public FEItem() { // // } // // public String getIid() { // return iid; // } // // public void setIid(String iid) { // this.iid = iid; // } // // public ItemType getType() { // return type; // } // // public void setType(ItemType type) { // this.type = type; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesItems.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.structures.FEItem; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; import java.util.Random; public static FatesItems getInstance() { if (instance == null) instance = new FatesItems(); return instance; } public List<FEItem> getWeapons() { List<FEItem> weapons = new ArrayList<>(); // TODO: Refactor getWeapons for(FEItem i : items) { if(i.getType() != ItemType.Treasure) weapons.add(i); } return weapons; } public List<FEItem> getSelectedItems(ItemType type) { if(type == null) throw new IllegalArgumentException("Violation of precondidition: " + "getSelectedItems. type must not be null."); List<FEItem> selected = new ArrayList<>(); List<FEItem> weapons = getWeapons(); boolean[] selectedItems = FatesGui.getInstance().getSelectedItems(); for(int x = 0; x < weapons.size(); x++) { if(weapons.get(x).getType() == type && selectedItems[x]) selected.add(weapons.get(x)); } return selected; }
public FEItem generateItem(Job j) {
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AJobs.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.awakening.singletons; public class AJobs { private static AJobs instance;
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AJobs.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.awakening.singletons; public class AJobs { private static AJobs instance;
private List<Job> jobs;
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AJobs.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.awakening.singletons; public class AJobs { private static AJobs instance; private List<Job> jobs; private AJobs() { Type jobType = new TypeToken<List<Job>>() {}.getType(); try { Gson gson = new Gson();
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AJobs.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.awakening.singletons; public class AJobs { private static AJobs instance; private List<Job> jobs; private AJobs() { Type jobType = new TypeToken<List<Job>>() {}.getType(); try { Gson gson = new Gson();
JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AJobs.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.awakening.singletons; public class AJobs { private static AJobs instance; private List<Job> jobs; private AJobs() { Type jobType = new TypeToken<List<Job>>() {}.getType(); try { Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/AwakeningClasses.json"), "UTF-8"))); jobs = gson.fromJson(reader, jobType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static AJobs getInstance() { if (instance == null) instance = new AJobs(); return instance; } public List<Job> getMaleBaseClasses() { List<Job> current = new ArrayList<>(); boolean[] selectedJobs = AGui.getInstance().getSelectedJobs(); for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x);
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AJobs.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.awakening.singletons; public class AJobs { private static AJobs instance; private List<Job> jobs; private AJobs() { Type jobType = new TypeToken<List<Job>>() {}.getType(); try { Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/AwakeningClasses.json"), "UTF-8"))); jobs = gson.fromJson(reader, jobType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static AJobs getInstance() { if (instance == null) instance = new AJobs(); return instance; } public List<Job> getMaleBaseClasses() { List<Job> current = new ArrayList<>(); boolean[] selectedJobs = AGui.getInstance().getSelectedJobs(); for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x);
if((j.getGender() == 0 || j.getGender() == 2) && j.getState() != JobState.Promoted && selectedJobs[x])
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AJobs.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
boolean[] selectedJobs = AGui.getInstance().getSelectedJobs(); for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x); if((j.getGender() == 0 || j.getGender() == 2) && j.getState() != JobState.Base && selectedJobs[x]) current.add(j); } return current; } public List<Job> getFemalePromotedClasses() { List<Job> current = new ArrayList<>(); boolean[] selectedJobs = AGui.getInstance().getSelectedJobs(); for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x); if((j.getGender() == 1 || j.getGender() == 2) && j.getState() != JobState.Base && selectedJobs[x]) current.add(j); } return current; } public List<Job> getEligibleJobs(boolean male, int maxLength) { List<Job> eligible = new ArrayList<>(); List<Job> pool; if(male) pool = getMaleBaseClasses(); else pool = getFemaleBaseClasses(); try { for(Job j : pool) { if(j.getJid().getBytes("shift-jis").length <= maxLength && j.getItemType()
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AJobs.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; boolean[] selectedJobs = AGui.getInstance().getSelectedJobs(); for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x); if((j.getGender() == 0 || j.getGender() == 2) && j.getState() != JobState.Base && selectedJobs[x]) current.add(j); } return current; } public List<Job> getFemalePromotedClasses() { List<Job> current = new ArrayList<>(); boolean[] selectedJobs = AGui.getInstance().getSelectedJobs(); for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x); if((j.getGender() == 1 || j.getGender() == 2) && j.getState() != JobState.Base && selectedJobs[x]) current.add(j); } return current; } public List<Job> getEligibleJobs(boolean male, int maxLength) { List<Job> eligible = new ArrayList<>(); List<Job> pool; if(male) pool = getMaleBaseClasses(); else pool = getFemaleBaseClasses(); try { for(Job j : pool) { if(j.getJid().getBytes("shift-jis").length <= maxLength && j.getItemType()
!= ItemType.Staves && j.getItemType() != ItemType.Beaststone)
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AJobs.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x); if((j.getGender() == 1 || j.getGender() == 2) && j.getState() != JobState.Base && selectedJobs[x]) current.add(j); } return current; } public List<Job> getEligibleJobs(boolean male, int maxLength) { List<Job> eligible = new ArrayList<>(); List<Job> pool; if(male) pool = getMaleBaseClasses(); else pool = getFemaleBaseClasses(); try { for(Job j : pool) { if(j.getJid().getBytes("shift-jis").length <= maxLength && j.getItemType() != ItemType.Staves && j.getItemType() != ItemType.Beaststone) eligible.add(j); } } catch(UnsupportedEncodingException e) { e.printStackTrace(); } return eligible; } public byte[] generateWeaponsRanks(Job j) { byte[] weaponRanks = new byte[5]; if(j.getItemType() == ItemType.Swords) {
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // // Path: randomizer/common/enums/WeaponRank.java // public enum WeaponRank { // None (0), // E (0x1), // D (0x15), // C (0x33), // B (0x60), // A (0xA1), // S (0xFB); // // private int value; // // WeaponRank(int value) { // this.value = value; // } // // public int value() { // return value; // } // } // // Path: randomizer/common/structures/Job.java // public class Job // { // private JobState state; // private String jid; // private String name; // private ItemType itemType; // private short tiedJob; // private short id; // private byte weaponRank; // private byte gender; // // private Skill[] skills; // // public Job() { // // } // // @Override public String toString() // { // return name; // } // // public JobState getState() { // return state; // } // // public void setState(JobState state) { // this.state = state; // } // // public String getJid() { // return jid; // } // // public void setJid(String jid) { // this.jid = jid; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public byte getWeaponRank() { // return weaponRank; // } // // public void setWeaponRank(byte weaponRank) { // this.weaponRank = weaponRank; // } // // public Short getTiedJob() { // return tiedJob; // } // // public void setTiedJob(Short tiedJob) { // this.tiedJob = tiedJob; // } // // public ItemType getItemType() { // return itemType; // } // // public void setItemType(ItemType weaponType) { // this.itemType = weaponType; // } // // public int getGender() { // return gender; // } // // public void setGender(byte gender) { // this.gender = gender; // } // // public Skill[] getSkills() { // return skills; // } // // public void setSkills(Skill[] skills) { // this.skills = skills; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/AJobs.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; import randomizer.common.enums.WeaponRank; import randomizer.common.structures.Job; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.io.UnsupportedEncodingException; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; for(int x = 0; x < jobs.size(); x++) { Job j = jobs.get(x); if((j.getGender() == 1 || j.getGender() == 2) && j.getState() != JobState.Base && selectedJobs[x]) current.add(j); } return current; } public List<Job> getEligibleJobs(boolean male, int maxLength) { List<Job> eligible = new ArrayList<>(); List<Job> pool; if(male) pool = getMaleBaseClasses(); else pool = getFemaleBaseClasses(); try { for(Job j : pool) { if(j.getJid().getBytes("shift-jis").length <= maxLength && j.getItemType() != ItemType.Staves && j.getItemType() != ItemType.Beaststone) eligible.add(j); } } catch(UnsupportedEncodingException e) { e.printStackTrace(); } return eligible; } public byte[] generateWeaponsRanks(Job j) { byte[] weaponRanks = new byte[5]; if(j.getItemType() == ItemType.Swords) {
weaponRanks[0] = (byte) WeaponRank.C.value();
thane98/3DSFE-Randomizer
randomizer/common/fs/model/ScriptCompiler.java
// Path: randomizer/common/utils/ByteUtils.java // public class ByteUtils { // public static short toShort(byte[] encodedValues, int index) { // return (short) (((encodedValues[index + 1] & 0xff) << 8) + (encodedValues[index] & 0xff)); // } // // public static int toBigEndianShort(byte[] encodedValues, int index) { // return (((encodedValues[index] << 8) & 0xFF00) | (encodedValues[index + 1] & 0xFF)); // } // // public static int toInt(byte[] encodedValue, int index) { // int value = (encodedValue[index + 3] << (Byte.SIZE * 3)); // value |= (encodedValue[index + 2] & 0xFF) << (Byte.SIZE * 2); // value |= (encodedValue[index + 1] & 0xFF) << (Byte.SIZE); // value |= (encodedValue[index] & 0xFF); // return value; // } // // public static byte[] toByteArray(short value) { // byte[] ret = new byte[2]; // ret[0] = (byte) (value & 0xff); // ret[1] = (byte) ((value >> 8) & 0xff); // return ret; // } // // public static List<Byte> toByteList(byte[] arr) { // List<Byte> bytes = new ArrayList<>(); // for (byte b : arr) // bytes.add(b); // return bytes; // } // // public static byte[] toByteArray(int value) { // byte[] encodedValue = new byte[Integer.SIZE / Byte.SIZE]; // encodedValue[3] = (byte) (value >> (Byte.SIZE * 3)); // encodedValue[2] = (byte) (value >> (Byte.SIZE * 2)); // encodedValue[1] = (byte) (value >> Byte.SIZE); // encodedValue[0] = (byte) value; // return encodedValue; // } // // public static String getString(byte[] source, int index) throws UnsupportedEncodingException { // int end = index; // while (source[end] != 0) { // end++; // } // return new String(Arrays.copyOfRange(source, index, end), "shift-jis"); // } // // public static String toString(byte[] input) { // StringBuilder builder = new StringBuilder("["); // for(int x = 0; x < input.length; x++) { // builder.append("0x").append(Long.toHexString(input[x] & 0xFF)); // if(x != input.length - 1) // builder.append(", "); // } // return builder.append("]").toString(); // } // }
import randomizer.common.utils.ByteUtils; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List;
public void compile(Path path, String input) throws Exception { String[] unsplitEvents = input.split("\\r?\\n\\r?\\n"); writeHeader(unsplitEvents.length); if(input.equals("")) { for(int x = 0; x < 4; x++) data.remove(data.size() - 1); finish(path); return; } for (String unsplitEvent : unsplitEvents) { CompiledEvent e = new CompiledEvent(); String[] temp = unsplitEvent.split("\\r?\\n"); e.setEventStart(lineNumbers); events.add(e); lineNumbers += temp.length + 1; e.setOffset(data.size()); e.compile(this, temp); for (int x = 0; x < 0x18; x++) data.add((byte) 0); e.setSubheaderOffset(data.size()); data.addAll(e.getSubheaderBytes()); e.setEventOffset(data.size()); data.addAll(e.getEventBytes()); if (events.indexOf(e) != unsplitEvents.length - 1) { while (data.size() % 4 != 0) data.add((byte) 0); }
// Path: randomizer/common/utils/ByteUtils.java // public class ByteUtils { // public static short toShort(byte[] encodedValues, int index) { // return (short) (((encodedValues[index + 1] & 0xff) << 8) + (encodedValues[index] & 0xff)); // } // // public static int toBigEndianShort(byte[] encodedValues, int index) { // return (((encodedValues[index] << 8) & 0xFF00) | (encodedValues[index + 1] & 0xFF)); // } // // public static int toInt(byte[] encodedValue, int index) { // int value = (encodedValue[index + 3] << (Byte.SIZE * 3)); // value |= (encodedValue[index + 2] & 0xFF) << (Byte.SIZE * 2); // value |= (encodedValue[index + 1] & 0xFF) << (Byte.SIZE); // value |= (encodedValue[index] & 0xFF); // return value; // } // // public static byte[] toByteArray(short value) { // byte[] ret = new byte[2]; // ret[0] = (byte) (value & 0xff); // ret[1] = (byte) ((value >> 8) & 0xff); // return ret; // } // // public static List<Byte> toByteList(byte[] arr) { // List<Byte> bytes = new ArrayList<>(); // for (byte b : arr) // bytes.add(b); // return bytes; // } // // public static byte[] toByteArray(int value) { // byte[] encodedValue = new byte[Integer.SIZE / Byte.SIZE]; // encodedValue[3] = (byte) (value >> (Byte.SIZE * 3)); // encodedValue[2] = (byte) (value >> (Byte.SIZE * 2)); // encodedValue[1] = (byte) (value >> Byte.SIZE); // encodedValue[0] = (byte) value; // return encodedValue; // } // // public static String getString(byte[] source, int index) throws UnsupportedEncodingException { // int end = index; // while (source[end] != 0) { // end++; // } // return new String(Arrays.copyOfRange(source, index, end), "shift-jis"); // } // // public static String toString(byte[] input) { // StringBuilder builder = new StringBuilder("["); // for(int x = 0; x < input.length; x++) { // builder.append("0x").append(Long.toHexString(input[x] & 0xFF)); // if(x != input.length - 1) // builder.append(", "); // } // return builder.append("]").toString(); // } // } // Path: randomizer/common/fs/model/ScriptCompiler.java import randomizer.common.utils.ByteUtils; import java.io.IOException; import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; import java.util.List; public void compile(Path path, String input) throws Exception { String[] unsplitEvents = input.split("\\r?\\n\\r?\\n"); writeHeader(unsplitEvents.length); if(input.equals("")) { for(int x = 0; x < 4; x++) data.remove(data.size() - 1); finish(path); return; } for (String unsplitEvent : unsplitEvents) { CompiledEvent e = new CompiledEvent(); String[] temp = unsplitEvent.split("\\r?\\n"); e.setEventStart(lineNumbers); events.add(e); lineNumbers += temp.length + 1; e.setOffset(data.size()); e.compile(this, temp); for (int x = 0; x < 0x18; x++) data.add((byte) 0); e.setSubheaderOffset(data.size()); data.addAll(e.getSubheaderBytes()); e.setEventOffset(data.size()); data.addAll(e.getEventBytes()); if (events.indexOf(e) != unsplitEvents.length - 1) { while (data.size() % 4 != 0) data.add((byte) 0); }
byte[] offsetBytes = ByteUtils.toByteArray(e.getOffset());
thane98/3DSFE-Randomizer
randomizer/common/structures/Skill.java
// Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // }
import randomizer.common.enums.SkillType;
package randomizer.common.structures; public class Skill { private String seid; private String name;
// Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // Path: randomizer/common/structures/Skill.java import randomizer.common.enums.SkillType; package randomizer.common.structures; public class Skill { private String seid; private String name;
private SkillType type;
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesSkills.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.fates.singletons; public class FatesSkills { private static FatesSkills instance;
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesSkills.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.fates.singletons; public class FatesSkills { private static FatesSkills instance;
private List<Skill> skills;
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesSkills.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.fates.singletons; public class FatesSkills { private static FatesSkills instance; private List<Skill> skills; private FatesSkills() { try { // Parse skills from JSON. Type skillType = new TypeToken<List<Skill>>() {}.getType(); Gson gson = new Gson();
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesSkills.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.fates.singletons; public class FatesSkills { private static FatesSkills instance; private List<Skill> skills; private FatesSkills() { try { // Parse skills from JSON. Type skillType = new TypeToken<List<Skill>>() {}.getType(); Gson gson = new Gson();
JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesSkills.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
.getResourceAsStream("data/json/FatesSkills.json"), "UTF-8"))); skills = gson.fromJson(reader, skillType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static FatesSkills getInstance() { if (instance == null) instance = new FatesSkills(); return instance; } public Skill getSkillById(int id) { if(id < 0) throw new IllegalArgumentException("Violation of precondidition: " + "getSkillById. id must not be negative."); for(Skill s : skills) { if(s.getId() == id) return s; } return null; } public List<Skill> getSelectedSkills() { boolean[] selected = FatesGui.getInstance().getSelectedSkills(); List<Skill> selectedSkills = new ArrayList<>(); for(int x = 0; x < skills.size(); x++) {
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesSkills.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; .getResourceAsStream("data/json/FatesSkills.json"), "UTF-8"))); skills = gson.fromJson(reader, skillType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static FatesSkills getInstance() { if (instance == null) instance = new FatesSkills(); return instance; } public Skill getSkillById(int id) { if(id < 0) throw new IllegalArgumentException("Violation of precondidition: " + "getSkillById. id must not be negative."); for(Skill s : skills) { if(s.getId() == id) return s; } return null; } public List<Skill> getSelectedSkills() { boolean[] selected = FatesGui.getInstance().getSelectedSkills(); List<Skill> selectedSkills = new ArrayList<>(); for(int x = 0; x < skills.size(); x++) {
if(skills.get(x).getType() == SkillType.Personal && !FatesGui.getInstance().getSelectedOptions()[10])
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesGui.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
package randomizer.fates.singletons; public class FatesGui { private static transient FatesGui instance; private transient IntegerProperty baseStatPasses = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMin = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); private transient IntegerProperty growthMin = new SimpleIntegerProperty(); private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient String[] paths = { "Birthright", "Conquest", "Revelation" }; private transient boolean[] selectedCharacters = new boolean[FatesCharacters.getInstance()
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesGui.java import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; package randomizer.fates.singletons; public class FatesGui { private static transient FatesGui instance; private transient IntegerProperty baseStatPasses = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMin = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); private transient IntegerProperty growthMin = new SimpleIntegerProperty(); private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient String[] paths = { "Birthright", "Conquest", "Revelation" }; private transient boolean[] selectedCharacters = new boolean[FatesCharacters.getInstance()
.getCharactersByType(CharacterType.NPC).size()];
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesGui.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
package randomizer.fates.singletons; public class FatesGui { private static transient FatesGui instance; private transient IntegerProperty baseStatPasses = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMin = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); private transient IntegerProperty growthMin = new SimpleIntegerProperty(); private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient String[] paths = { "Birthright", "Conquest", "Revelation" }; private transient boolean[] selectedCharacters = new boolean[FatesCharacters.getInstance() .getCharactersByType(CharacterType.NPC).size()]; private boolean[] selectedJobs = new boolean[FatesJobs.getInstance().getJobs().size()]; private boolean[] selectedItems = new boolean[FatesItems.getInstance().getWeapons().size()]; private boolean[] selectedSkills = new boolean[FatesSkills.getInstance().getSkills().size()]; private boolean[] selectedPaths = new boolean[paths.length]; private boolean[] selectedOptions; private FatesGui() { try { // Parse options.
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesGui.java import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; package randomizer.fates.singletons; public class FatesGui { private static transient FatesGui instance; private transient IntegerProperty baseStatPasses = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMin = new SimpleIntegerProperty(); private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); private transient IntegerProperty growthMin = new SimpleIntegerProperty(); private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient String[] paths = { "Birthright", "Conquest", "Revelation" }; private transient boolean[] selectedCharacters = new boolean[FatesCharacters.getInstance() .getCharactersByType(CharacterType.NPC).size()]; private boolean[] selectedJobs = new boolean[FatesJobs.getInstance().getJobs().size()]; private boolean[] selectedItems = new boolean[FatesItems.getInstance().getWeapons().size()]; private boolean[] selectedSkills = new boolean[FatesSkills.getInstance().getSkills().size()]; private boolean[] selectedPaths = new boolean[paths.length]; private boolean[] selectedOptions; private FatesGui() { try { // Parse options.
BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesGui.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient String[] paths = { "Birthright", "Conquest", "Revelation" }; private transient boolean[] selectedCharacters = new boolean[FatesCharacters.getInstance() .getCharactersByType(CharacterType.NPC).size()]; private boolean[] selectedJobs = new boolean[FatesJobs.getInstance().getJobs().size()]; private boolean[] selectedItems = new boolean[FatesItems.getInstance().getWeapons().size()]; private boolean[] selectedSkills = new boolean[FatesSkills.getInstance().getSkills().size()]; private boolean[] selectedPaths = new boolean[paths.length]; private boolean[] selectedOptions; private FatesGui() { try { // Parse options. BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/text/FatesOptions.txt"))); options = new ArrayList<>(); String line; while((line = streamReader.readLine()) != null) { options.add(line); } } catch (IOException e) { e.printStackTrace(); } // Set up default selections.
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesGui.java import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; private transient IntegerProperty growthMax = new SimpleIntegerProperty(); private transient IntegerProperty modPasses = new SimpleIntegerProperty(); private transient IntegerProperty modMin = new SimpleIntegerProperty(); private transient IntegerProperty modMax = new SimpleIntegerProperty(); private transient List<String> options; private transient String[] paths = { "Birthright", "Conquest", "Revelation" }; private transient boolean[] selectedCharacters = new boolean[FatesCharacters.getInstance() .getCharactersByType(CharacterType.NPC).size()]; private boolean[] selectedJobs = new boolean[FatesJobs.getInstance().getJobs().size()]; private boolean[] selectedItems = new boolean[FatesItems.getInstance().getWeapons().size()]; private boolean[] selectedSkills = new boolean[FatesSkills.getInstance().getSkills().size()]; private boolean[] selectedPaths = new boolean[paths.length]; private boolean[] selectedOptions; private FatesGui() { try { // Parse options. BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/text/FatesOptions.txt"))); options = new ArrayList<>(); String line; while((line = streamReader.readLine()) != null) { options.add(line); } } catch (IOException e) { e.printStackTrace(); } // Set up default selections.
List<Skill> skills = FatesSkills.getInstance().getSkills();
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesGui.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
private boolean[] selectedPaths = new boolean[paths.length]; private boolean[] selectedOptions; private FatesGui() { try { // Parse options. BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/text/FatesOptions.txt"))); options = new ArrayList<>(); String line; while((line = streamReader.readLine()) != null) { options.add(line); } } catch (IOException e) { e.printStackTrace(); } // Set up default selections. List<Skill> skills = FatesSkills.getInstance().getSkills(); selectedOptions = new boolean[options.size()]; for(int x = 0; x < selectedOptions.length; x++) { selectedOptions[x] = true; } for(int x = 0; x < selectedCharacters.length; x++) { selectedCharacters[x] = true; } for(int x = 0; x < selectedJobs.length; x++) { selectedJobs[x] = true; } for(int x = 0; x < skills.size(); x++) {
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/CharacterType.java // public enum CharacterType { // FirstGen, SecondGen, NPC, Player // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/fates/singletons/FatesGui.java import javafx.beans.property.IntegerProperty; import javafx.beans.property.SimpleIntegerProperty; import randomizer.Randomizer; import randomizer.common.enums.CharacterType; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.URISyntaxException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; private boolean[] selectedPaths = new boolean[paths.length]; private boolean[] selectedOptions; private FatesGui() { try { // Parse options. BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/text/FatesOptions.txt"))); options = new ArrayList<>(); String line; while((line = streamReader.readLine()) != null) { options.add(line); } } catch (IOException e) { e.printStackTrace(); } // Set up default selections. List<Skill> skills = FatesSkills.getInstance().getSkills(); selectedOptions = new boolean[options.size()]; for(int x = 0; x < selectedOptions.length; x++) { selectedOptions[x] = true; } for(int x = 0; x < selectedCharacters.length; x++) { selectedCharacters[x] = true; } for(int x = 0; x < selectedJobs.length; x++) { selectedJobs[x] = true; } for(int x = 0; x < skills.size(); x++) {
selectedSkills[x] = skills.get(x).getType() != SkillType.Enemy;
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/ASkills.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.awakening.singletons; public class ASkills { private static ASkills instance;
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/ASkills.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.awakening.singletons; public class ASkills { private static ASkills instance;
private List<Skill> skills;
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/ASkills.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.awakening.singletons; public class ASkills { private static ASkills instance; private List<Skill> skills; private ASkills() { Type skillType = new TypeToken<List<Skill>>() {}.getType(); try { Gson gson = new Gson();
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/ASkills.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.awakening.singletons; public class ASkills { private static ASkills instance; private List<Skill> skills; private ASkills() { Type skillType = new TypeToken<List<Skill>>() {}.getType(); try { Gson gson = new Gson();
JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/ASkills.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
Type skillType = new TypeToken<List<Skill>>() {}.getType(); try { Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/AwakeningSkills.json"), "UTF-8"))); skills = gson.fromJson(reader, skillType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static ASkills getInstance() { if (instance == null) instance = new ASkills(); return instance; } public Skill getSkillById(int id) { for(Skill s : skills) { if(s.getId() == id) return s; } return null; } public List<Skill> getSelectedSkills() { boolean[] selected = AGui.getInstance().getSelectedSkills(); List<Skill> selectedSkills = new ArrayList<>(); for(int x = 0; x < skills.size(); x++) {
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/SkillType.java // public enum SkillType // { // Basic, Enemy, DLC, Personal // } // // Path: randomizer/common/structures/Skill.java // public class Skill // { // private String seid; // private String name; // private SkillType type; // private short id; // // public Skill() { // // } // // @Override // public String toString() // { // return name; // } // // public String getSeid() { // return seid; // } // // public void setSeid(String seid) { // this.seid = seid; // } // // public SkillType getType() { // return type; // } // // public void setType(SkillType type) { // this.type = type; // } // // public short getId() { // return id; // } // // public void setId(short id) { // this.id = id; // } // // public String getName() { // return name; // } // // public void setName(String name) { // this.name = name; // } // } // Path: randomizer/awakening/singletons/ASkills.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.SkillType; import randomizer.common.structures.Skill; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; Type skillType = new TypeToken<List<Skill>>() {}.getType(); try { Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/AwakeningSkills.json"), "UTF-8"))); skills = gson.fromJson(reader, skillType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static ASkills getInstance() { if (instance == null) instance = new ASkills(); return instance; } public Skill getSkillById(int id) { for(Skill s : skills) { if(s.getId() == id) return s; } return null; } public List<Skill> getSelectedSkills() { boolean[] selected = AGui.getInstance().getSelectedSkills(); List<Skill> selectedSkills = new ArrayList<>(); for(int x = 0; x < skills.size(); x++) {
if(skills.get(x).getType() == SkillType.Personal && !AGui.getInstance().getSelectedOptions()[10])
thane98/3DSFE-Randomizer
randomizer/common/structures/Job.java
// Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // }
import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState;
package randomizer.common.structures; public class Job {
// Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // Path: randomizer/common/structures/Job.java import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; package randomizer.common.structures; public class Job {
private JobState state;
thane98/3DSFE-Randomizer
randomizer/common/structures/Job.java
// Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // }
import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState;
package randomizer.common.structures; public class Job { private JobState state; private String jid; private String name;
// Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // // Path: randomizer/common/enums/JobState.java // public enum JobState // { // Base, Promoted, SpecialPromote // } // Path: randomizer/common/structures/Job.java import randomizer.common.enums.ItemType; import randomizer.common.enums.JobState; package randomizer.common.structures; public class Job { private JobState state; private String jid; private String name;
private ItemType itemType;
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesChapters.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.fates.singletons; public class FatesChapters { private static FatesChapters instance;
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // } // Path: randomizer/fates/singletons/FatesChapters.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.fates.singletons; public class FatesChapters { private static FatesChapters instance;
private List<Chapter> chapters;
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesChapters.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.fates.singletons; public class FatesChapters { private static FatesChapters instance; private List<Chapter> chapters; private FatesChapters() { try { Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); Gson gson = new Gson();
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // } // Path: randomizer/fates/singletons/FatesChapters.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.fates.singletons; public class FatesChapters { private static FatesChapters instance; private List<Chapter> chapters; private FatesChapters() { try { Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); Gson gson = new Gson();
JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
thane98/3DSFE-Randomizer
randomizer/fates/singletons/FatesChapters.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.fates.singletons; public class FatesChapters { private static FatesChapters instance; private List<Chapter> chapters; private FatesChapters() { try { Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/FatesChapters.json"), "UTF-8"))); chapters = gson.fromJson(reader, chapterType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static FatesChapters getInstance() { if (instance == null) instance = new FatesChapters(); return instance; }
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // } // Path: randomizer/fates/singletons/FatesChapters.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.fates.singletons; public class FatesChapters { private static FatesChapters instance; private List<Chapter> chapters; private FatesChapters() { try { Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/FatesChapters.json"), "UTF-8"))); chapters = gson.fromJson(reader, chapterType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static FatesChapters getInstance() { if (instance == null) instance = new FatesChapters(); return instance; }
public List<Chapter> getChaptersByType(ChapterType type) {
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AChapters.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.awakening.singletons; public class AChapters { private static AChapters instance;
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // } // Path: randomizer/awakening/singletons/AChapters.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.awakening.singletons; public class AChapters { private static AChapters instance;
private List<Chapter> chapters;
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AChapters.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.awakening.singletons; public class AChapters { private static AChapters instance; private List<Chapter> chapters; private AChapters() { Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); try { Gson gson = new Gson();
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // } // Path: randomizer/awakening/singletons/AChapters.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.awakening.singletons; public class AChapters { private static AChapters instance; private List<Chapter> chapters; private AChapters() { Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); try { Gson gson = new Gson();
JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class
thane98/3DSFE-Randomizer
randomizer/awakening/singletons/AChapters.java
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // }
import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List;
package randomizer.awakening.singletons; public class AChapters { private static AChapters instance; private List<Chapter> chapters; private AChapters() { Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); try { Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8"))); chapters = gson.fromJson(reader, chapterType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static AChapters getInstance() { if (instance == null) instance = new AChapters(); return instance; }
// Path: randomizer/Randomizer.java // public class Randomizer extends Application { // public static void main(String[] args) { // launch(args); // } // // @Override // public void start(Stage primaryStage) { // try { // // Create and display the main stage. // Gui.getInstance().setMainStage(primaryStage); // Parent root = FXMLLoader.load(this.getClass().getResource("gui/fxml/Verification.fxml")); // Scene scene = new Scene(root, 320, 260); // scene.getStylesheets().add(getClass().getResource("gui/jmetro/JMetroLightTheme.css").toExternalForm()); // primaryStage.setScene(scene); // primaryStage.setResizable(false); // primaryStage.getIcons().add(new Image(this.getClass().getResourceAsStream("icon.png"))); // primaryStage.setTitle("Randomizer Verification"); // primaryStage.show(); // } catch (Exception e) { // e.printStackTrace(); // } // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // } // Path: randomizer/awakening/singletons/AChapters.java import com.google.gson.Gson; import com.google.gson.reflect.TypeToken; import com.google.gson.stream.JsonReader; import randomizer.Randomizer; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.lang.reflect.Type; import java.util.ArrayList; import java.util.List; package randomizer.awakening.singletons; public class AChapters { private static AChapters instance; private List<Chapter> chapters; private AChapters() { Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); try { Gson gson = new Gson(); JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8"))); chapters = gson.fromJson(reader, chapterType); reader.close(); } catch (IOException e) { e.printStackTrace(); } } public static AChapters getInstance() { if (instance == null) instance = new AChapters(); return instance; }
public List<Chapter> getChaptersByType(ChapterType type) {
thane98/3DSFE-Randomizer
randomizer/common/structures/FEItem.java
// Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // }
import randomizer.common.enums.ItemType;
package randomizer.common.structures; public class FEItem { private String iid; private String name;
// Path: randomizer/common/enums/ItemType.java // public enum ItemType { // Swords, // Lances, // Axes, // Tomes, // Bows, // Shurikens, // Staves, // Beaststone, // Treasure, // Fists, // DarkBreath, // Breaths, // Stones, // Saws // } // Path: randomizer/common/structures/FEItem.java import randomizer.common.enums.ItemType; package randomizer.common.structures; public class FEItem { private String iid; private String name;
private ItemType type;
thane98/3DSFE-Randomizer
randomizer/common/fs/model/SubheaderParser.java
// Path: randomizer/common/utils/ByteUtils.java // public class ByteUtils { // public static short toShort(byte[] encodedValues, int index) { // return (short) (((encodedValues[index + 1] & 0xff) << 8) + (encodedValues[index] & 0xff)); // } // // public static int toBigEndianShort(byte[] encodedValues, int index) { // return (((encodedValues[index] << 8) & 0xFF00) | (encodedValues[index + 1] & 0xFF)); // } // // public static int toInt(byte[] encodedValue, int index) { // int value = (encodedValue[index + 3] << (Byte.SIZE * 3)); // value |= (encodedValue[index + 2] & 0xFF) << (Byte.SIZE * 2); // value |= (encodedValue[index + 1] & 0xFF) << (Byte.SIZE); // value |= (encodedValue[index] & 0xFF); // return value; // } // // public static byte[] toByteArray(short value) { // byte[] ret = new byte[2]; // ret[0] = (byte) (value & 0xff); // ret[1] = (byte) ((value >> 8) & 0xff); // return ret; // } // // public static List<Byte> toByteList(byte[] arr) { // List<Byte> bytes = new ArrayList<>(); // for (byte b : arr) // bytes.add(b); // return bytes; // } // // public static byte[] toByteArray(int value) { // byte[] encodedValue = new byte[Integer.SIZE / Byte.SIZE]; // encodedValue[3] = (byte) (value >> (Byte.SIZE * 3)); // encodedValue[2] = (byte) (value >> (Byte.SIZE * 2)); // encodedValue[1] = (byte) (value >> Byte.SIZE); // encodedValue[0] = (byte) value; // return encodedValue; // } // // public static String getString(byte[] source, int index) throws UnsupportedEncodingException { // int end = index; // while (source[end] != 0) { // end++; // } // return new String(Arrays.copyOfRange(source, index, end), "shift-jis"); // } // // public static String toString(byte[] input) { // StringBuilder builder = new StringBuilder("["); // for(int x = 0; x < input.length; x++) { // builder.append("0x").append(Long.toHexString(input[x] & 0xFF)); // if(x != input.length - 1) // builder.append(", "); // } // return builder.append("]").toString(); // } // }
import randomizer.common.utils.ByteUtils; import java.util.ArrayList;
package randomizer.common.fs.model; class SubheaderParser { static ArrayList<Byte> getSubheaderFromText(ScriptCompiler compiler, String[] input) throws Exception { ArrayList<Byte> result = new ArrayList<>(); int x = 1; while (!input[x].startsWith("end")) { if (input[x].startsWith("int")) { String parsed = ScriptUtils.parseSingleParameter(input[x]); if (parsed.toLowerCase().equals("ffffffff")) { for (int y = 0; y < 4; y++) result.add((byte) 0xFF); } else { int parsedInt = Long.decode(parsed).intValue();
// Path: randomizer/common/utils/ByteUtils.java // public class ByteUtils { // public static short toShort(byte[] encodedValues, int index) { // return (short) (((encodedValues[index + 1] & 0xff) << 8) + (encodedValues[index] & 0xff)); // } // // public static int toBigEndianShort(byte[] encodedValues, int index) { // return (((encodedValues[index] << 8) & 0xFF00) | (encodedValues[index + 1] & 0xFF)); // } // // public static int toInt(byte[] encodedValue, int index) { // int value = (encodedValue[index + 3] << (Byte.SIZE * 3)); // value |= (encodedValue[index + 2] & 0xFF) << (Byte.SIZE * 2); // value |= (encodedValue[index + 1] & 0xFF) << (Byte.SIZE); // value |= (encodedValue[index] & 0xFF); // return value; // } // // public static byte[] toByteArray(short value) { // byte[] ret = new byte[2]; // ret[0] = (byte) (value & 0xff); // ret[1] = (byte) ((value >> 8) & 0xff); // return ret; // } // // public static List<Byte> toByteList(byte[] arr) { // List<Byte> bytes = new ArrayList<>(); // for (byte b : arr) // bytes.add(b); // return bytes; // } // // public static byte[] toByteArray(int value) { // byte[] encodedValue = new byte[Integer.SIZE / Byte.SIZE]; // encodedValue[3] = (byte) (value >> (Byte.SIZE * 3)); // encodedValue[2] = (byte) (value >> (Byte.SIZE * 2)); // encodedValue[1] = (byte) (value >> Byte.SIZE); // encodedValue[0] = (byte) value; // return encodedValue; // } // // public static String getString(byte[] source, int index) throws UnsupportedEncodingException { // int end = index; // while (source[end] != 0) { // end++; // } // return new String(Arrays.copyOfRange(source, index, end), "shift-jis"); // } // // public static String toString(byte[] input) { // StringBuilder builder = new StringBuilder("["); // for(int x = 0; x < input.length; x++) { // builder.append("0x").append(Long.toHexString(input[x] & 0xFF)); // if(x != input.length - 1) // builder.append(", "); // } // return builder.append("]").toString(); // } // } // Path: randomizer/common/fs/model/SubheaderParser.java import randomizer.common.utils.ByteUtils; import java.util.ArrayList; package randomizer.common.fs.model; class SubheaderParser { static ArrayList<Byte> getSubheaderFromText(ScriptCompiler compiler, String[] input) throws Exception { ArrayList<Byte> result = new ArrayList<>(); int x = 1; while (!input[x].startsWith("end")) { if (input[x].startsWith("int")) { String parsed = ScriptUtils.parseSingleParameter(input[x]); if (parsed.toLowerCase().equals("ffffffff")) { for (int y = 0; y < 4; y++) result.add((byte) 0xFF); } else { int parsedInt = Long.decode(parsed).intValue();
byte[] bytes = ByteUtils.toByteArray(parsedInt);
thane98/3DSFE-Randomizer
randomizer/awakening/model/processors/prep/AVerifier.java
// Path: randomizer/awakening/singletons/AChapters.java // public class AChapters { // private static AChapters instance; // private List<Chapter> chapters; // // private AChapters() { // Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); // // try { // Gson gson = new Gson(); // JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class // .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8"))); // chapters = gson.fromJson(reader, chapterType); // reader.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static AChapters getInstance() { // if (instance == null) // instance = new AChapters(); // return instance; // } // // public List<Chapter> getChaptersByType(ChapterType type) { // List<Chapter> selected = new ArrayList<>(); // for(Chapter c : chapters) { // if(c.getType() == type) // selected.add(c); // } // return selected; // } // // public List<Chapter> getChapters() { // return chapters; // } // } // // Path: randomizer/awakening/singletons/AFiles.java // public class AFiles // { // private static AFiles instance; // // // Used in file verification phase. // private List<File> originalFileList; // private File rom; // // // Files mapped by chapter ID. // private Map<String, File> dispos = new HashMap<>(); // private Map<String, File> person = new HashMap<>(); // private Map<String, File> text = new HashMap<>(); // private Map<String, File> script = new HashMap<>(); // private Map<String, File> terrain = new HashMap<>(); // // // Individual files used by the randomizer. // private File gameData; // private File characterFile; // // private AFiles() { // // } // // public static AFiles getInstance() // { // if(instance == null) // instance = new AFiles(); // return instance; // } // // public List<File> getOriginalFileList() { // return originalFileList; // } // // public void setOriginalFileList(List<File> originalFileList) { // this.originalFileList = originalFileList; // } // // public File getRom() { // return rom; // } // // public void setRom(File rom) { // this.rom = rom; // } // // public Map<String, File> getDispos() { // return dispos; // } // // public Map<String, File> getPerson() { // return person; // } // // public Map<String, File> getText() { // return text; // } // // public void setText(Map<String, File> text) { // this.text = text; // } // // public Map<String, File> getScript() { // return script; // } // // public File getGameData() { // return gameData; // } // // public void setGameData(File gameData) { // this.gameData = gameData; // } // // public Map<String, File> getTerrain() { // return terrain; // } // // public File getCharacterFile() { // return characterFile; // } // // public void setCharacterFile(File characterFile) { // this.characterFile = characterFile; // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // }
import randomizer.awakening.singletons.AChapters; import randomizer.awakening.singletons.AFiles; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
mainText = new File(dir.getAbsolutePath() + "/m/G"); break; case "Europe - Italian": mainText = new File(dir.getAbsolutePath() + "/m/I"); break; case "Europe - French": mainText = new File(dir.getAbsolutePath() + "/m/F"); break; default: return false; // Invalid region. } // Verify that chapter-independent files exist. File file = new File(dir.getAbsolutePath() + GAMEDATA_PATH); if(file.exists()) verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + PERSON_PATH, "static.bin.lz"); if(file.exists()) verified.add(file); else failures.add(file); file = new File(mainText, "GameData.bin.lz"); if(file.exists()) { NameMatcher.matchNames(file); // Get names from IDs. } else failures.add(file);
// Path: randomizer/awakening/singletons/AChapters.java // public class AChapters { // private static AChapters instance; // private List<Chapter> chapters; // // private AChapters() { // Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); // // try { // Gson gson = new Gson(); // JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class // .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8"))); // chapters = gson.fromJson(reader, chapterType); // reader.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static AChapters getInstance() { // if (instance == null) // instance = new AChapters(); // return instance; // } // // public List<Chapter> getChaptersByType(ChapterType type) { // List<Chapter> selected = new ArrayList<>(); // for(Chapter c : chapters) { // if(c.getType() == type) // selected.add(c); // } // return selected; // } // // public List<Chapter> getChapters() { // return chapters; // } // } // // Path: randomizer/awakening/singletons/AFiles.java // public class AFiles // { // private static AFiles instance; // // // Used in file verification phase. // private List<File> originalFileList; // private File rom; // // // Files mapped by chapter ID. // private Map<String, File> dispos = new HashMap<>(); // private Map<String, File> person = new HashMap<>(); // private Map<String, File> text = new HashMap<>(); // private Map<String, File> script = new HashMap<>(); // private Map<String, File> terrain = new HashMap<>(); // // // Individual files used by the randomizer. // private File gameData; // private File characterFile; // // private AFiles() { // // } // // public static AFiles getInstance() // { // if(instance == null) // instance = new AFiles(); // return instance; // } // // public List<File> getOriginalFileList() { // return originalFileList; // } // // public void setOriginalFileList(List<File> originalFileList) { // this.originalFileList = originalFileList; // } // // public File getRom() { // return rom; // } // // public void setRom(File rom) { // this.rom = rom; // } // // public Map<String, File> getDispos() { // return dispos; // } // // public Map<String, File> getPerson() { // return person; // } // // public Map<String, File> getText() { // return text; // } // // public void setText(Map<String, File> text) { // this.text = text; // } // // public Map<String, File> getScript() { // return script; // } // // public File getGameData() { // return gameData; // } // // public void setGameData(File gameData) { // this.gameData = gameData; // } // // public Map<String, File> getTerrain() { // return terrain; // } // // public File getCharacterFile() { // return characterFile; // } // // public void setCharacterFile(File characterFile) { // this.characterFile = characterFile; // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // } // Path: randomizer/awakening/model/processors/prep/AVerifier.java import randomizer.awakening.singletons.AChapters; import randomizer.awakening.singletons.AFiles; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; mainText = new File(dir.getAbsolutePath() + "/m/G"); break; case "Europe - Italian": mainText = new File(dir.getAbsolutePath() + "/m/I"); break; case "Europe - French": mainText = new File(dir.getAbsolutePath() + "/m/F"); break; default: return false; // Invalid region. } // Verify that chapter-independent files exist. File file = new File(dir.getAbsolutePath() + GAMEDATA_PATH); if(file.exists()) verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + PERSON_PATH, "static.bin.lz"); if(file.exists()) verified.add(file); else failures.add(file); file = new File(mainText, "GameData.bin.lz"); if(file.exists()) { NameMatcher.matchNames(file); // Get names from IDs. } else failures.add(file);
for(Chapter c : AChapters.getInstance().getChapters()) {
thane98/3DSFE-Randomizer
randomizer/awakening/model/processors/prep/AVerifier.java
// Path: randomizer/awakening/singletons/AChapters.java // public class AChapters { // private static AChapters instance; // private List<Chapter> chapters; // // private AChapters() { // Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); // // try { // Gson gson = new Gson(); // JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class // .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8"))); // chapters = gson.fromJson(reader, chapterType); // reader.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static AChapters getInstance() { // if (instance == null) // instance = new AChapters(); // return instance; // } // // public List<Chapter> getChaptersByType(ChapterType type) { // List<Chapter> selected = new ArrayList<>(); // for(Chapter c : chapters) { // if(c.getType() == type) // selected.add(c); // } // return selected; // } // // public List<Chapter> getChapters() { // return chapters; // } // } // // Path: randomizer/awakening/singletons/AFiles.java // public class AFiles // { // private static AFiles instance; // // // Used in file verification phase. // private List<File> originalFileList; // private File rom; // // // Files mapped by chapter ID. // private Map<String, File> dispos = new HashMap<>(); // private Map<String, File> person = new HashMap<>(); // private Map<String, File> text = new HashMap<>(); // private Map<String, File> script = new HashMap<>(); // private Map<String, File> terrain = new HashMap<>(); // // // Individual files used by the randomizer. // private File gameData; // private File characterFile; // // private AFiles() { // // } // // public static AFiles getInstance() // { // if(instance == null) // instance = new AFiles(); // return instance; // } // // public List<File> getOriginalFileList() { // return originalFileList; // } // // public void setOriginalFileList(List<File> originalFileList) { // this.originalFileList = originalFileList; // } // // public File getRom() { // return rom; // } // // public void setRom(File rom) { // this.rom = rom; // } // // public Map<String, File> getDispos() { // return dispos; // } // // public Map<String, File> getPerson() { // return person; // } // // public Map<String, File> getText() { // return text; // } // // public void setText(Map<String, File> text) { // this.text = text; // } // // public Map<String, File> getScript() { // return script; // } // // public File getGameData() { // return gameData; // } // // public void setGameData(File gameData) { // this.gameData = gameData; // } // // public Map<String, File> getTerrain() { // return terrain; // } // // public File getCharacterFile() { // return characterFile; // } // // public void setCharacterFile(File characterFile) { // this.characterFile = characterFile; // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // }
import randomizer.awakening.singletons.AChapters; import randomizer.awakening.singletons.AFiles; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
mainText = new File(dir.getAbsolutePath() + "/m/G"); break; case "Europe - Italian": mainText = new File(dir.getAbsolutePath() + "/m/I"); break; case "Europe - French": mainText = new File(dir.getAbsolutePath() + "/m/F"); break; default: return false; // Invalid region. } // Verify that chapter-independent files exist. File file = new File(dir.getAbsolutePath() + GAMEDATA_PATH); if(file.exists()) verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + PERSON_PATH, "static.bin.lz"); if(file.exists()) verified.add(file); else failures.add(file); file = new File(mainText, "GameData.bin.lz"); if(file.exists()) { NameMatcher.matchNames(file); // Get names from IDs. } else failures.add(file);
// Path: randomizer/awakening/singletons/AChapters.java // public class AChapters { // private static AChapters instance; // private List<Chapter> chapters; // // private AChapters() { // Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); // // try { // Gson gson = new Gson(); // JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class // .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8"))); // chapters = gson.fromJson(reader, chapterType); // reader.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static AChapters getInstance() { // if (instance == null) // instance = new AChapters(); // return instance; // } // // public List<Chapter> getChaptersByType(ChapterType type) { // List<Chapter> selected = new ArrayList<>(); // for(Chapter c : chapters) { // if(c.getType() == type) // selected.add(c); // } // return selected; // } // // public List<Chapter> getChapters() { // return chapters; // } // } // // Path: randomizer/awakening/singletons/AFiles.java // public class AFiles // { // private static AFiles instance; // // // Used in file verification phase. // private List<File> originalFileList; // private File rom; // // // Files mapped by chapter ID. // private Map<String, File> dispos = new HashMap<>(); // private Map<String, File> person = new HashMap<>(); // private Map<String, File> text = new HashMap<>(); // private Map<String, File> script = new HashMap<>(); // private Map<String, File> terrain = new HashMap<>(); // // // Individual files used by the randomizer. // private File gameData; // private File characterFile; // // private AFiles() { // // } // // public static AFiles getInstance() // { // if(instance == null) // instance = new AFiles(); // return instance; // } // // public List<File> getOriginalFileList() { // return originalFileList; // } // // public void setOriginalFileList(List<File> originalFileList) { // this.originalFileList = originalFileList; // } // // public File getRom() { // return rom; // } // // public void setRom(File rom) { // this.rom = rom; // } // // public Map<String, File> getDispos() { // return dispos; // } // // public Map<String, File> getPerson() { // return person; // } // // public Map<String, File> getText() { // return text; // } // // public void setText(Map<String, File> text) { // this.text = text; // } // // public Map<String, File> getScript() { // return script; // } // // public File getGameData() { // return gameData; // } // // public void setGameData(File gameData) { // this.gameData = gameData; // } // // public Map<String, File> getTerrain() { // return terrain; // } // // public File getCharacterFile() { // return characterFile; // } // // public void setCharacterFile(File characterFile) { // this.characterFile = characterFile; // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // } // Path: randomizer/awakening/model/processors/prep/AVerifier.java import randomizer.awakening.singletons.AChapters; import randomizer.awakening.singletons.AFiles; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; mainText = new File(dir.getAbsolutePath() + "/m/G"); break; case "Europe - Italian": mainText = new File(dir.getAbsolutePath() + "/m/I"); break; case "Europe - French": mainText = new File(dir.getAbsolutePath() + "/m/F"); break; default: return false; // Invalid region. } // Verify that chapter-independent files exist. File file = new File(dir.getAbsolutePath() + GAMEDATA_PATH); if(file.exists()) verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + PERSON_PATH, "static.bin.lz"); if(file.exists()) verified.add(file); else failures.add(file); file = new File(mainText, "GameData.bin.lz"); if(file.exists()) { NameMatcher.matchNames(file); // Get names from IDs. } else failures.add(file);
for(Chapter c : AChapters.getInstance().getChapters()) {
thane98/3DSFE-Randomizer
randomizer/awakening/model/processors/prep/AVerifier.java
// Path: randomizer/awakening/singletons/AChapters.java // public class AChapters { // private static AChapters instance; // private List<Chapter> chapters; // // private AChapters() { // Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); // // try { // Gson gson = new Gson(); // JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class // .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8"))); // chapters = gson.fromJson(reader, chapterType); // reader.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static AChapters getInstance() { // if (instance == null) // instance = new AChapters(); // return instance; // } // // public List<Chapter> getChaptersByType(ChapterType type) { // List<Chapter> selected = new ArrayList<>(); // for(Chapter c : chapters) { // if(c.getType() == type) // selected.add(c); // } // return selected; // } // // public List<Chapter> getChapters() { // return chapters; // } // } // // Path: randomizer/awakening/singletons/AFiles.java // public class AFiles // { // private static AFiles instance; // // // Used in file verification phase. // private List<File> originalFileList; // private File rom; // // // Files mapped by chapter ID. // private Map<String, File> dispos = new HashMap<>(); // private Map<String, File> person = new HashMap<>(); // private Map<String, File> text = new HashMap<>(); // private Map<String, File> script = new HashMap<>(); // private Map<String, File> terrain = new HashMap<>(); // // // Individual files used by the randomizer. // private File gameData; // private File characterFile; // // private AFiles() { // // } // // public static AFiles getInstance() // { // if(instance == null) // instance = new AFiles(); // return instance; // } // // public List<File> getOriginalFileList() { // return originalFileList; // } // // public void setOriginalFileList(List<File> originalFileList) { // this.originalFileList = originalFileList; // } // // public File getRom() { // return rom; // } // // public void setRom(File rom) { // this.rom = rom; // } // // public Map<String, File> getDispos() { // return dispos; // } // // public Map<String, File> getPerson() { // return person; // } // // public Map<String, File> getText() { // return text; // } // // public void setText(Map<String, File> text) { // this.text = text; // } // // public Map<String, File> getScript() { // return script; // } // // public File getGameData() { // return gameData; // } // // public void setGameData(File gameData) { // this.gameData = gameData; // } // // public Map<String, File> getTerrain() { // return terrain; // } // // public File getCharacterFile() { // return characterFile; // } // // public void setCharacterFile(File characterFile) { // this.characterFile = characterFile; // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // }
import randomizer.awakening.singletons.AChapters; import randomizer.awakening.singletons.AFiles; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
break; case "Europe - Italian": mainText = new File(dir.getAbsolutePath() + "/m/I"); break; case "Europe - French": mainText = new File(dir.getAbsolutePath() + "/m/F"); break; default: return false; // Invalid region. } // Verify that chapter-independent files exist. File file = new File(dir.getAbsolutePath() + GAMEDATA_PATH); if(file.exists()) verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + PERSON_PATH, "static.bin.lz"); if(file.exists()) verified.add(file); else failures.add(file); file = new File(mainText, "GameData.bin.lz"); if(file.exists()) { NameMatcher.matchNames(file); // Get names from IDs. } else failures.add(file); for(Chapter c : AChapters.getInstance().getChapters()) {
// Path: randomizer/awakening/singletons/AChapters.java // public class AChapters { // private static AChapters instance; // private List<Chapter> chapters; // // private AChapters() { // Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); // // try { // Gson gson = new Gson(); // JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class // .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8"))); // chapters = gson.fromJson(reader, chapterType); // reader.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static AChapters getInstance() { // if (instance == null) // instance = new AChapters(); // return instance; // } // // public List<Chapter> getChaptersByType(ChapterType type) { // List<Chapter> selected = new ArrayList<>(); // for(Chapter c : chapters) { // if(c.getType() == type) // selected.add(c); // } // return selected; // } // // public List<Chapter> getChapters() { // return chapters; // } // } // // Path: randomizer/awakening/singletons/AFiles.java // public class AFiles // { // private static AFiles instance; // // // Used in file verification phase. // private List<File> originalFileList; // private File rom; // // // Files mapped by chapter ID. // private Map<String, File> dispos = new HashMap<>(); // private Map<String, File> person = new HashMap<>(); // private Map<String, File> text = new HashMap<>(); // private Map<String, File> script = new HashMap<>(); // private Map<String, File> terrain = new HashMap<>(); // // // Individual files used by the randomizer. // private File gameData; // private File characterFile; // // private AFiles() { // // } // // public static AFiles getInstance() // { // if(instance == null) // instance = new AFiles(); // return instance; // } // // public List<File> getOriginalFileList() { // return originalFileList; // } // // public void setOriginalFileList(List<File> originalFileList) { // this.originalFileList = originalFileList; // } // // public File getRom() { // return rom; // } // // public void setRom(File rom) { // this.rom = rom; // } // // public Map<String, File> getDispos() { // return dispos; // } // // public Map<String, File> getPerson() { // return person; // } // // public Map<String, File> getText() { // return text; // } // // public void setText(Map<String, File> text) { // this.text = text; // } // // public Map<String, File> getScript() { // return script; // } // // public File getGameData() { // return gameData; // } // // public void setGameData(File gameData) { // this.gameData = gameData; // } // // public Map<String, File> getTerrain() { // return terrain; // } // // public File getCharacterFile() { // return characterFile; // } // // public void setCharacterFile(File characterFile) { // this.characterFile = characterFile; // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // } // Path: randomizer/awakening/model/processors/prep/AVerifier.java import randomizer.awakening.singletons.AChapters; import randomizer.awakening.singletons.AFiles; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; break; case "Europe - Italian": mainText = new File(dir.getAbsolutePath() + "/m/I"); break; case "Europe - French": mainText = new File(dir.getAbsolutePath() + "/m/F"); break; default: return false; // Invalid region. } // Verify that chapter-independent files exist. File file = new File(dir.getAbsolutePath() + GAMEDATA_PATH); if(file.exists()) verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + PERSON_PATH, "static.bin.lz"); if(file.exists()) verified.add(file); else failures.add(file); file = new File(mainText, "GameData.bin.lz"); if(file.exists()) { NameMatcher.matchNames(file); // Get names from IDs. } else failures.add(file); for(Chapter c : AChapters.getInstance().getChapters()) {
if(c.getType() == ChapterType.AllRoutes || c.getType() == ChapterType.Child
thane98/3DSFE-Randomizer
randomizer/awakening/model/processors/prep/AVerifier.java
// Path: randomizer/awakening/singletons/AChapters.java // public class AChapters { // private static AChapters instance; // private List<Chapter> chapters; // // private AChapters() { // Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); // // try { // Gson gson = new Gson(); // JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class // .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8"))); // chapters = gson.fromJson(reader, chapterType); // reader.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static AChapters getInstance() { // if (instance == null) // instance = new AChapters(); // return instance; // } // // public List<Chapter> getChaptersByType(ChapterType type) { // List<Chapter> selected = new ArrayList<>(); // for(Chapter c : chapters) { // if(c.getType() == type) // selected.add(c); // } // return selected; // } // // public List<Chapter> getChapters() { // return chapters; // } // } // // Path: randomizer/awakening/singletons/AFiles.java // public class AFiles // { // private static AFiles instance; // // // Used in file verification phase. // private List<File> originalFileList; // private File rom; // // // Files mapped by chapter ID. // private Map<String, File> dispos = new HashMap<>(); // private Map<String, File> person = new HashMap<>(); // private Map<String, File> text = new HashMap<>(); // private Map<String, File> script = new HashMap<>(); // private Map<String, File> terrain = new HashMap<>(); // // // Individual files used by the randomizer. // private File gameData; // private File characterFile; // // private AFiles() { // // } // // public static AFiles getInstance() // { // if(instance == null) // instance = new AFiles(); // return instance; // } // // public List<File> getOriginalFileList() { // return originalFileList; // } // // public void setOriginalFileList(List<File> originalFileList) { // this.originalFileList = originalFileList; // } // // public File getRom() { // return rom; // } // // public void setRom(File rom) { // this.rom = rom; // } // // public Map<String, File> getDispos() { // return dispos; // } // // public Map<String, File> getPerson() { // return person; // } // // public Map<String, File> getText() { // return text; // } // // public void setText(Map<String, File> text) { // this.text = text; // } // // public Map<String, File> getScript() { // return script; // } // // public File getGameData() { // return gameData; // } // // public void setGameData(File gameData) { // this.gameData = gameData; // } // // public Map<String, File> getTerrain() { // return terrain; // } // // public File getCharacterFile() { // return characterFile; // } // // public void setCharacterFile(File characterFile) { // this.characterFile = characterFile; // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // }
import randomizer.awakening.singletons.AChapters; import randomizer.awakening.singletons.AFiles; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List;
verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + DISPOS_PATH, c.getCid() + ".bin.lz"); if(file.exists()) verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + PERSON_PATH, c.getCid() + ".bin.lz"); if(file.exists()) verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + SCRIPTS_PATH, c.getCid() + ".cmb"); if(file.exists()) verified.add(file); else failures.add(file); } file = new File(SCRIPTS_PATH, c.getCid() + "_Terrain.cmb"); if(file.exists()) verified.add(file); } // Run checks based off of failures and successes. if(failures.size() > 0) { outputErrorLog(failures); return false; }
// Path: randomizer/awakening/singletons/AChapters.java // public class AChapters { // private static AChapters instance; // private List<Chapter> chapters; // // private AChapters() { // Type chapterType = new TypeToken<List<Chapter>>() {}.getType(); // // try { // Gson gson = new Gson(); // JsonReader reader = new JsonReader(new BufferedReader(new InputStreamReader(Randomizer.class // .getResourceAsStream("data/json/AwakeningChapters.json"), "UTF-8"))); // chapters = gson.fromJson(reader, chapterType); // reader.close(); // } catch (IOException e) { // e.printStackTrace(); // } // } // // public static AChapters getInstance() { // if (instance == null) // instance = new AChapters(); // return instance; // } // // public List<Chapter> getChaptersByType(ChapterType type) { // List<Chapter> selected = new ArrayList<>(); // for(Chapter c : chapters) { // if(c.getType() == type) // selected.add(c); // } // return selected; // } // // public List<Chapter> getChapters() { // return chapters; // } // } // // Path: randomizer/awakening/singletons/AFiles.java // public class AFiles // { // private static AFiles instance; // // // Used in file verification phase. // private List<File> originalFileList; // private File rom; // // // Files mapped by chapter ID. // private Map<String, File> dispos = new HashMap<>(); // private Map<String, File> person = new HashMap<>(); // private Map<String, File> text = new HashMap<>(); // private Map<String, File> script = new HashMap<>(); // private Map<String, File> terrain = new HashMap<>(); // // // Individual files used by the randomizer. // private File gameData; // private File characterFile; // // private AFiles() { // // } // // public static AFiles getInstance() // { // if(instance == null) // instance = new AFiles(); // return instance; // } // // public List<File> getOriginalFileList() { // return originalFileList; // } // // public void setOriginalFileList(List<File> originalFileList) { // this.originalFileList = originalFileList; // } // // public File getRom() { // return rom; // } // // public void setRom(File rom) { // this.rom = rom; // } // // public Map<String, File> getDispos() { // return dispos; // } // // public Map<String, File> getPerson() { // return person; // } // // public Map<String, File> getText() { // return text; // } // // public void setText(Map<String, File> text) { // this.text = text; // } // // public Map<String, File> getScript() { // return script; // } // // public File getGameData() { // return gameData; // } // // public void setGameData(File gameData) { // this.gameData = gameData; // } // // public Map<String, File> getTerrain() { // return terrain; // } // // public File getCharacterFile() { // return characterFile; // } // // public void setCharacterFile(File characterFile) { // this.characterFile = characterFile; // } // } // // Path: randomizer/common/enums/ChapterType.java // public enum ChapterType { // Birthright, Conquest, Revelation, AllRoutes, Child, Amiibo // } // // Path: randomizer/common/structures/Chapter.java // public class Chapter { // private ChapterType type; // private String cid; // private String parentPid; // private String childPid; // private int id; // // public String getChildPid() { // return childPid; // } // // public void setChildPid(String childPid) { // this.childPid = childPid; // } // // public String getParentPid() { // return parentPid; // } // // public void setParentPid(String parentPid) { // this.parentPid = parentPid; // } // // public String getCid() { // return cid; // } // // public void setCid(String cid) { // this.cid = cid; // } // // public ChapterType getType() { // return type; // } // // public void setType(ChapterType type) { // this.type = type; // } // // public int getId() { // return id; // } // // public void setId(int id) { // this.id = id; // } // } // Path: randomizer/awakening/model/processors/prep/AVerifier.java import randomizer.awakening.singletons.AChapters; import randomizer.awakening.singletons.AFiles; import randomizer.common.enums.ChapterType; import randomizer.common.structures.Chapter; import java.io.File; import java.io.IOException; import java.nio.file.Files; import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + DISPOS_PATH, c.getCid() + ".bin.lz"); if(file.exists()) verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + PERSON_PATH, c.getCid() + ".bin.lz"); if(file.exists()) verified.add(file); else failures.add(file); file = new File(dir.getAbsolutePath() + SCRIPTS_PATH, c.getCid() + ".cmb"); if(file.exists()) verified.add(file); else failures.add(file); } file = new File(SCRIPTS_PATH, c.getCid() + "_Terrain.cmb"); if(file.exists()) verified.add(file); } // Run checks based off of failures and successes. if(failures.size() > 0) { outputErrorLog(failures); return false; }
AFiles.getInstance().setOriginalFileList(verified);
thane98/3DSFE-Randomizer
randomizer/fates/model/structures/SettingsWrapper.java
// Path: randomizer/fates/singletons/FatesGui.java // public class FatesGui { // private static transient FatesGui instance; // private transient IntegerProperty baseStatPasses = new SimpleIntegerProperty(); // private transient IntegerProperty baseStatMin = new SimpleIntegerProperty(); // private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); // private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); // private transient IntegerProperty growthMin = new SimpleIntegerProperty(); // private transient IntegerProperty growthMax = new SimpleIntegerProperty(); // private transient IntegerProperty modPasses = new SimpleIntegerProperty(); // private transient IntegerProperty modMin = new SimpleIntegerProperty(); // private transient IntegerProperty modMax = new SimpleIntegerProperty(); // private transient List<String> options; // private transient String[] paths = { "Birthright", "Conquest", "Revelation" }; // // private transient boolean[] selectedCharacters = new boolean[FatesCharacters.getInstance() // .getCharactersByType(CharacterType.NPC).size()]; // private boolean[] selectedJobs = new boolean[FatesJobs.getInstance().getJobs().size()]; // private boolean[] selectedItems = new boolean[FatesItems.getInstance().getWeapons().size()]; // private boolean[] selectedSkills = new boolean[FatesSkills.getInstance().getSkills().size()]; // private boolean[] selectedPaths = new boolean[paths.length]; // private boolean[] selectedOptions; // // private FatesGui() { // try { // // Parse options. // BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class // .getResourceAsStream("data/text/FatesOptions.txt"))); // options = new ArrayList<>(); // String line; // while((line = streamReader.readLine()) != null) { // options.add(line); // } // } catch (IOException e) { // e.printStackTrace(); // } // // // Set up default selections. // List<Skill> skills = FatesSkills.getInstance().getSkills(); // selectedOptions = new boolean[options.size()]; // for(int x = 0; x < selectedOptions.length; x++) { // selectedOptions[x] = true; // } // for(int x = 0; x < selectedCharacters.length; x++) { // selectedCharacters[x] = true; // } // for(int x = 0; x < selectedJobs.length; x++) { // selectedJobs[x] = true; // } // for(int x = 0; x < skills.size(); x++) { // selectedSkills[x] = skills.get(x).getType() != SkillType.Enemy; // } // for(int x = 0; x < selectedItems.length; x++) { // selectedItems[x] = true; // } // for(int x = 0; x < selectedPaths.length; x++) { // selectedPaths[x] = false; // } // } // // public static FatesGui getInstance() { // if (instance == null) // instance = new FatesGui(); // return instance; // } // // public boolean[] getSelectedCharacters() { // return selectedCharacters; // } // // public void setSelectedCharacters(boolean[] selectedCharacters) { // this.selectedCharacters = selectedCharacters; // } // // public boolean[] getSelectedJobs() { // return selectedJobs; // } // // public void setSelectedJobs(boolean[] selectedJobs) { // this.selectedJobs = selectedJobs; // } // // public boolean[] getSelectedItems() { // return selectedItems; // } // // public void setSelectedItems(boolean[] selectedItems) { // this.selectedItems = selectedItems; // } // // public boolean[] getSelectedSkills() { // return selectedSkills; // } // // public void setSelectedSkills(boolean[] selectedSkills) { // this.selectedSkills = selectedSkills; // } // // public List<String> getOptions() { // return options; // } // // public String[] getPaths() { // return paths; // } // // public boolean[] getSelectedOptions() { // return selectedOptions; // } // // public void setSelectedOptions(boolean[] selectedOptions) { // this.selectedOptions = selectedOptions; // } // // public boolean[] getSelectedPaths() { // return selectedPaths; // } // // public void setSelectedPaths(boolean[] selectedPaths) { // this.selectedPaths = selectedPaths; // } // // public int getBaseStatPasses() { // return baseStatPasses.get(); // } // // public IntegerProperty baseStatPassesProperty() { // return baseStatPasses; // } // // public int getBaseStatMin() { // return baseStatMin.get(); // } // // public IntegerProperty baseStatMinProperty() { // return baseStatMin; // } // // public int getBaseStatMax() { // return baseStatMax.get(); // } // // public IntegerProperty baseStatMaxProperty() { // return baseStatMax; // } // // public int getGrowthPasses() { // return growthPasses.get(); // } // // public IntegerProperty growthPassesProperty() { // return growthPasses; // } // // public int getGrowthMin() { // return growthMin.get(); // } // // public IntegerProperty growthMinProperty() { // return growthMin; // } // // public int getGrowthMax() { // return growthMax.get(); // } // // public IntegerProperty growthMaxProperty() { // return growthMax; // } // // public int getModPasses() { // return modPasses.get(); // } // // public IntegerProperty modPassesProperty() { // return modPasses; // } // // public int getModMin() { // return modMin.get(); // } // // public IntegerProperty modMinProperty() { // return modMin; // } // // public int getModMax() { // return modMax.get(); // } // // public IntegerProperty modMaxProperty() { // return modMax; // } // }
import randomizer.fates.singletons.FatesGui; import java.util.List;
package randomizer.fates.model.structures; public class SettingsWrapper { private List<FatesCharacter> characters;
// Path: randomizer/fates/singletons/FatesGui.java // public class FatesGui { // private static transient FatesGui instance; // private transient IntegerProperty baseStatPasses = new SimpleIntegerProperty(); // private transient IntegerProperty baseStatMin = new SimpleIntegerProperty(); // private transient IntegerProperty baseStatMax = new SimpleIntegerProperty(); // private transient IntegerProperty growthPasses = new SimpleIntegerProperty(); // private transient IntegerProperty growthMin = new SimpleIntegerProperty(); // private transient IntegerProperty growthMax = new SimpleIntegerProperty(); // private transient IntegerProperty modPasses = new SimpleIntegerProperty(); // private transient IntegerProperty modMin = new SimpleIntegerProperty(); // private transient IntegerProperty modMax = new SimpleIntegerProperty(); // private transient List<String> options; // private transient String[] paths = { "Birthright", "Conquest", "Revelation" }; // // private transient boolean[] selectedCharacters = new boolean[FatesCharacters.getInstance() // .getCharactersByType(CharacterType.NPC).size()]; // private boolean[] selectedJobs = new boolean[FatesJobs.getInstance().getJobs().size()]; // private boolean[] selectedItems = new boolean[FatesItems.getInstance().getWeapons().size()]; // private boolean[] selectedSkills = new boolean[FatesSkills.getInstance().getSkills().size()]; // private boolean[] selectedPaths = new boolean[paths.length]; // private boolean[] selectedOptions; // // private FatesGui() { // try { // // Parse options. // BufferedReader streamReader = new BufferedReader(new InputStreamReader(Randomizer.class // .getResourceAsStream("data/text/FatesOptions.txt"))); // options = new ArrayList<>(); // String line; // while((line = streamReader.readLine()) != null) { // options.add(line); // } // } catch (IOException e) { // e.printStackTrace(); // } // // // Set up default selections. // List<Skill> skills = FatesSkills.getInstance().getSkills(); // selectedOptions = new boolean[options.size()]; // for(int x = 0; x < selectedOptions.length; x++) { // selectedOptions[x] = true; // } // for(int x = 0; x < selectedCharacters.length; x++) { // selectedCharacters[x] = true; // } // for(int x = 0; x < selectedJobs.length; x++) { // selectedJobs[x] = true; // } // for(int x = 0; x < skills.size(); x++) { // selectedSkills[x] = skills.get(x).getType() != SkillType.Enemy; // } // for(int x = 0; x < selectedItems.length; x++) { // selectedItems[x] = true; // } // for(int x = 0; x < selectedPaths.length; x++) { // selectedPaths[x] = false; // } // } // // public static FatesGui getInstance() { // if (instance == null) // instance = new FatesGui(); // return instance; // } // // public boolean[] getSelectedCharacters() { // return selectedCharacters; // } // // public void setSelectedCharacters(boolean[] selectedCharacters) { // this.selectedCharacters = selectedCharacters; // } // // public boolean[] getSelectedJobs() { // return selectedJobs; // } // // public void setSelectedJobs(boolean[] selectedJobs) { // this.selectedJobs = selectedJobs; // } // // public boolean[] getSelectedItems() { // return selectedItems; // } // // public void setSelectedItems(boolean[] selectedItems) { // this.selectedItems = selectedItems; // } // // public boolean[] getSelectedSkills() { // return selectedSkills; // } // // public void setSelectedSkills(boolean[] selectedSkills) { // this.selectedSkills = selectedSkills; // } // // public List<String> getOptions() { // return options; // } // // public String[] getPaths() { // return paths; // } // // public boolean[] getSelectedOptions() { // return selectedOptions; // } // // public void setSelectedOptions(boolean[] selectedOptions) { // this.selectedOptions = selectedOptions; // } // // public boolean[] getSelectedPaths() { // return selectedPaths; // } // // public void setSelectedPaths(boolean[] selectedPaths) { // this.selectedPaths = selectedPaths; // } // // public int getBaseStatPasses() { // return baseStatPasses.get(); // } // // public IntegerProperty baseStatPassesProperty() { // return baseStatPasses; // } // // public int getBaseStatMin() { // return baseStatMin.get(); // } // // public IntegerProperty baseStatMinProperty() { // return baseStatMin; // } // // public int getBaseStatMax() { // return baseStatMax.get(); // } // // public IntegerProperty baseStatMaxProperty() { // return baseStatMax; // } // // public int getGrowthPasses() { // return growthPasses.get(); // } // // public IntegerProperty growthPassesProperty() { // return growthPasses; // } // // public int getGrowthMin() { // return growthMin.get(); // } // // public IntegerProperty growthMinProperty() { // return growthMin; // } // // public int getGrowthMax() { // return growthMax.get(); // } // // public IntegerProperty growthMaxProperty() { // return growthMax; // } // // public int getModPasses() { // return modPasses.get(); // } // // public IntegerProperty modPassesProperty() { // return modPasses; // } // // public int getModMin() { // return modMin.get(); // } // // public IntegerProperty modMinProperty() { // return modMin; // } // // public int getModMax() { // return modMax.get(); // } // // public IntegerProperty modMaxProperty() { // return modMax; // } // } // Path: randomizer/fates/model/structures/SettingsWrapper.java import randomizer.fates.singletons.FatesGui; import java.util.List; package randomizer.fates.model.structures; public class SettingsWrapper { private List<FatesCharacter> characters;
private FatesGui gui;
IanGClifton/auid2
chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolListFragment.java
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/Tool.java // public class Tool implements Parcelable { // // private static final int DETAILS_COUNT = 3; // // private final String mName; // private final String mPrice; // private final String[] mDetails; // private final String mDescription; // private final int mImageResourceId; // private final int mThumbnailResourceId; // // public Tool(String name, String price, String[] details, String description, @DrawableRes int imageResourceId, @DrawableRes int thumbnailResourceId) { // mName = name; // mPrice = price; // mDetails = new String[DETAILS_COUNT]; // if (details != null) { // System.arraycopy(details, 0, mDetails, 0, details.length); // } // mDescription = description; // mImageResourceId = imageResourceId; // mThumbnailResourceId = thumbnailResourceId; // } // // public String getDescription() { // return mDescription; // } // // public String[] getDetails() { // return mDetails; // } // // public String getName() { // return mName; // } // // public String getPrice() { // return mPrice; // } // // public int getImageResourceId() { // return mImageResourceId; // } // // public int getThumbnailResourceId() { // return mThumbnailResourceId; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(mName); // dest.writeString(mPrice); // dest.writeStringArray(mDetails); // dest.writeString(mDescription); // dest.writeInt(mImageResourceId); // dest.writeInt(mThumbnailResourceId); // } // // private Tool(Parcel in) { // mName = in.readString(); // mPrice = in.readString(); // mDetails = in.createStringArray(); // mDescription = in.readString(); // mImageResourceId = in.readInt(); // mThumbnailResourceId = in.readInt(); // } // // public static final Parcelable.Creator<Tool> CREATOR = new Parcelable.Creator<Tool>() { // public Tool createFromParcel(Parcel source) { // return new Tool(source); // } // // public Tool[] newArray(int size) { // return new Tool[size]; // } // }; // } // // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/tooldetails/ToolDetailActivity.java // public class ToolDetailActivity extends AppCompatActivity { // // private static final String EXTRA_TOOL = "com.iangclifton.woodworkingtools.TOOL"; // // public static void startActivity(Activity activity, Tool tool, Bundle activityOptions) { // final Intent intent = new Intent(activity, ToolDetailActivity.class); // intent.putExtra(EXTRA_TOOL, tool); // ActivityCompat.startActivity(activity, intent, activityOptions); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_detail); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowTitleEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // final Tool tool = getIntent().getParcelableExtra(EXTRA_TOOL); // if (tool == null) { // throw new IllegalStateException("Tool not available as extra; use startActivity when creating an activity instance"); // } // // final CaptionedImageView captionedImageView = (CaptionedImageView) findViewById(R.id.hero_image); // captionedImageView.getImageView().setSquare(false); // captionedImageView.getTextView().setText(tool.getName()); // captionedImageView.setImageResource(tool.getImageResourceId()); // // findAndSetTextView(R.id.price, tool.getPrice()); // findAndSetTextView(R.id.detail_0, tool.getDetails()[0]); // findAndSetTextView(R.id.detail_1, tool.getDetails()[1]); // findAndSetTextView(R.id.detail_2, tool.getDetails()[2]); // findAndSetTextView(R.id.description, tool.getDescription()); // } // // private void findAndSetTextView(int id, String text) { // final TextView textView = (TextView) findViewById(id); // textView.setText(text); // } // }
import android.os.Bundle; import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.ListFragment; import android.support.v4.util.Pair; import android.view.View; import android.widget.AdapterView; import com.iangclifton.woodworkingtools.R; import com.iangclifton.woodworkingtools.Tool; import com.iangclifton.woodworkingtools.tooldetails.ToolDetailActivity; import java.util.List;
package com.iangclifton.woodworkingtools.toollist; /** * A placeholder fragment containing a simple view. */ public class ToolListFragment extends ListFragment implements AdapterView.OnItemClickListener { private static final String ARG_TOOL_TAB = "toolTab"; private ToolTab mToolTab; private ToolArrayAdapter mToolArrayAdapter; public static ToolListFragment newInstance(ToolTab toolTab) { final ToolListFragment fragment = new ToolListFragment(); final Bundle args = new Bundle(); args.putParcelable(ARG_TOOL_TAB, toolTab); fragment.setArguments(args); return fragment; } public ToolListFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); if (args == null) { throw new IllegalStateException("No arguments set; use newInstance when constructing!"); } mToolTab = args.getParcelable(ARG_TOOL_TAB);
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/Tool.java // public class Tool implements Parcelable { // // private static final int DETAILS_COUNT = 3; // // private final String mName; // private final String mPrice; // private final String[] mDetails; // private final String mDescription; // private final int mImageResourceId; // private final int mThumbnailResourceId; // // public Tool(String name, String price, String[] details, String description, @DrawableRes int imageResourceId, @DrawableRes int thumbnailResourceId) { // mName = name; // mPrice = price; // mDetails = new String[DETAILS_COUNT]; // if (details != null) { // System.arraycopy(details, 0, mDetails, 0, details.length); // } // mDescription = description; // mImageResourceId = imageResourceId; // mThumbnailResourceId = thumbnailResourceId; // } // // public String getDescription() { // return mDescription; // } // // public String[] getDetails() { // return mDetails; // } // // public String getName() { // return mName; // } // // public String getPrice() { // return mPrice; // } // // public int getImageResourceId() { // return mImageResourceId; // } // // public int getThumbnailResourceId() { // return mThumbnailResourceId; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(mName); // dest.writeString(mPrice); // dest.writeStringArray(mDetails); // dest.writeString(mDescription); // dest.writeInt(mImageResourceId); // dest.writeInt(mThumbnailResourceId); // } // // private Tool(Parcel in) { // mName = in.readString(); // mPrice = in.readString(); // mDetails = in.createStringArray(); // mDescription = in.readString(); // mImageResourceId = in.readInt(); // mThumbnailResourceId = in.readInt(); // } // // public static final Parcelable.Creator<Tool> CREATOR = new Parcelable.Creator<Tool>() { // public Tool createFromParcel(Parcel source) { // return new Tool(source); // } // // public Tool[] newArray(int size) { // return new Tool[size]; // } // }; // } // // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/tooldetails/ToolDetailActivity.java // public class ToolDetailActivity extends AppCompatActivity { // // private static final String EXTRA_TOOL = "com.iangclifton.woodworkingtools.TOOL"; // // public static void startActivity(Activity activity, Tool tool, Bundle activityOptions) { // final Intent intent = new Intent(activity, ToolDetailActivity.class); // intent.putExtra(EXTRA_TOOL, tool); // ActivityCompat.startActivity(activity, intent, activityOptions); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_detail); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowTitleEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // final Tool tool = getIntent().getParcelableExtra(EXTRA_TOOL); // if (tool == null) { // throw new IllegalStateException("Tool not available as extra; use startActivity when creating an activity instance"); // } // // final CaptionedImageView captionedImageView = (CaptionedImageView) findViewById(R.id.hero_image); // captionedImageView.getImageView().setSquare(false); // captionedImageView.getTextView().setText(tool.getName()); // captionedImageView.setImageResource(tool.getImageResourceId()); // // findAndSetTextView(R.id.price, tool.getPrice()); // findAndSetTextView(R.id.detail_0, tool.getDetails()[0]); // findAndSetTextView(R.id.detail_1, tool.getDetails()[1]); // findAndSetTextView(R.id.detail_2, tool.getDetails()[2]); // findAndSetTextView(R.id.description, tool.getDescription()); // } // // private void findAndSetTextView(int id, String text) { // final TextView textView = (TextView) findViewById(id); // textView.setText(text); // } // } // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolListFragment.java import android.os.Bundle; import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.ListFragment; import android.support.v4.util.Pair; import android.view.View; import android.widget.AdapterView; import com.iangclifton.woodworkingtools.R; import com.iangclifton.woodworkingtools.Tool; import com.iangclifton.woodworkingtools.tooldetails.ToolDetailActivity; import java.util.List; package com.iangclifton.woodworkingtools.toollist; /** * A placeholder fragment containing a simple view. */ public class ToolListFragment extends ListFragment implements AdapterView.OnItemClickListener { private static final String ARG_TOOL_TAB = "toolTab"; private ToolTab mToolTab; private ToolArrayAdapter mToolArrayAdapter; public static ToolListFragment newInstance(ToolTab toolTab) { final ToolListFragment fragment = new ToolListFragment(); final Bundle args = new Bundle(); args.putParcelable(ARG_TOOL_TAB, toolTab); fragment.setArguments(args); return fragment; } public ToolListFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); if (args == null) { throw new IllegalStateException("No arguments set; use newInstance when constructing!"); } mToolTab = args.getParcelable(ARG_TOOL_TAB);
final List<Tool> tools = ToolListGenerator.getTools(mToolTab);
IanGClifton/auid2
chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolListFragment.java
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/Tool.java // public class Tool implements Parcelable { // // private static final int DETAILS_COUNT = 3; // // private final String mName; // private final String mPrice; // private final String[] mDetails; // private final String mDescription; // private final int mImageResourceId; // private final int mThumbnailResourceId; // // public Tool(String name, String price, String[] details, String description, @DrawableRes int imageResourceId, @DrawableRes int thumbnailResourceId) { // mName = name; // mPrice = price; // mDetails = new String[DETAILS_COUNT]; // if (details != null) { // System.arraycopy(details, 0, mDetails, 0, details.length); // } // mDescription = description; // mImageResourceId = imageResourceId; // mThumbnailResourceId = thumbnailResourceId; // } // // public String getDescription() { // return mDescription; // } // // public String[] getDetails() { // return mDetails; // } // // public String getName() { // return mName; // } // // public String getPrice() { // return mPrice; // } // // public int getImageResourceId() { // return mImageResourceId; // } // // public int getThumbnailResourceId() { // return mThumbnailResourceId; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(mName); // dest.writeString(mPrice); // dest.writeStringArray(mDetails); // dest.writeString(mDescription); // dest.writeInt(mImageResourceId); // dest.writeInt(mThumbnailResourceId); // } // // private Tool(Parcel in) { // mName = in.readString(); // mPrice = in.readString(); // mDetails = in.createStringArray(); // mDescription = in.readString(); // mImageResourceId = in.readInt(); // mThumbnailResourceId = in.readInt(); // } // // public static final Parcelable.Creator<Tool> CREATOR = new Parcelable.Creator<Tool>() { // public Tool createFromParcel(Parcel source) { // return new Tool(source); // } // // public Tool[] newArray(int size) { // return new Tool[size]; // } // }; // } // // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/tooldetails/ToolDetailActivity.java // public class ToolDetailActivity extends AppCompatActivity { // // private static final String EXTRA_TOOL = "com.iangclifton.woodworkingtools.TOOL"; // // public static void startActivity(Activity activity, Tool tool, Bundle activityOptions) { // final Intent intent = new Intent(activity, ToolDetailActivity.class); // intent.putExtra(EXTRA_TOOL, tool); // ActivityCompat.startActivity(activity, intent, activityOptions); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_detail); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowTitleEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // final Tool tool = getIntent().getParcelableExtra(EXTRA_TOOL); // if (tool == null) { // throw new IllegalStateException("Tool not available as extra; use startActivity when creating an activity instance"); // } // // final CaptionedImageView captionedImageView = (CaptionedImageView) findViewById(R.id.hero_image); // captionedImageView.getImageView().setSquare(false); // captionedImageView.getTextView().setText(tool.getName()); // captionedImageView.setImageResource(tool.getImageResourceId()); // // findAndSetTextView(R.id.price, tool.getPrice()); // findAndSetTextView(R.id.detail_0, tool.getDetails()[0]); // findAndSetTextView(R.id.detail_1, tool.getDetails()[1]); // findAndSetTextView(R.id.detail_2, tool.getDetails()[2]); // findAndSetTextView(R.id.description, tool.getDescription()); // } // // private void findAndSetTextView(int id, String text) { // final TextView textView = (TextView) findViewById(id); // textView.setText(text); // } // }
import android.os.Bundle; import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.ListFragment; import android.support.v4.util.Pair; import android.view.View; import android.widget.AdapterView; import com.iangclifton.woodworkingtools.R; import com.iangclifton.woodworkingtools.Tool; import com.iangclifton.woodworkingtools.tooldetails.ToolDetailActivity; import java.util.List;
public ToolListFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); if (args == null) { throw new IllegalStateException("No arguments set; use newInstance when constructing!"); } mToolTab = args.getParcelable(ARG_TOOL_TAB); final List<Tool> tools = ToolListGenerator.getTools(mToolTab); mToolArrayAdapter = new ToolArrayAdapter(getActivity(), tools); setListAdapter(mToolArrayAdapter); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getListView().setOnItemClickListener(this); } @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), new Pair<View, String>(view.findViewById(R.id.thumbnail), getString(R.string.transition_image_view)) );
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/Tool.java // public class Tool implements Parcelable { // // private static final int DETAILS_COUNT = 3; // // private final String mName; // private final String mPrice; // private final String[] mDetails; // private final String mDescription; // private final int mImageResourceId; // private final int mThumbnailResourceId; // // public Tool(String name, String price, String[] details, String description, @DrawableRes int imageResourceId, @DrawableRes int thumbnailResourceId) { // mName = name; // mPrice = price; // mDetails = new String[DETAILS_COUNT]; // if (details != null) { // System.arraycopy(details, 0, mDetails, 0, details.length); // } // mDescription = description; // mImageResourceId = imageResourceId; // mThumbnailResourceId = thumbnailResourceId; // } // // public String getDescription() { // return mDescription; // } // // public String[] getDetails() { // return mDetails; // } // // public String getName() { // return mName; // } // // public String getPrice() { // return mPrice; // } // // public int getImageResourceId() { // return mImageResourceId; // } // // public int getThumbnailResourceId() { // return mThumbnailResourceId; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(mName); // dest.writeString(mPrice); // dest.writeStringArray(mDetails); // dest.writeString(mDescription); // dest.writeInt(mImageResourceId); // dest.writeInt(mThumbnailResourceId); // } // // private Tool(Parcel in) { // mName = in.readString(); // mPrice = in.readString(); // mDetails = in.createStringArray(); // mDescription = in.readString(); // mImageResourceId = in.readInt(); // mThumbnailResourceId = in.readInt(); // } // // public static final Parcelable.Creator<Tool> CREATOR = new Parcelable.Creator<Tool>() { // public Tool createFromParcel(Parcel source) { // return new Tool(source); // } // // public Tool[] newArray(int size) { // return new Tool[size]; // } // }; // } // // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/tooldetails/ToolDetailActivity.java // public class ToolDetailActivity extends AppCompatActivity { // // private static final String EXTRA_TOOL = "com.iangclifton.woodworkingtools.TOOL"; // // public static void startActivity(Activity activity, Tool tool, Bundle activityOptions) { // final Intent intent = new Intent(activity, ToolDetailActivity.class); // intent.putExtra(EXTRA_TOOL, tool); // ActivityCompat.startActivity(activity, intent, activityOptions); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_detail); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowTitleEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // final Tool tool = getIntent().getParcelableExtra(EXTRA_TOOL); // if (tool == null) { // throw new IllegalStateException("Tool not available as extra; use startActivity when creating an activity instance"); // } // // final CaptionedImageView captionedImageView = (CaptionedImageView) findViewById(R.id.hero_image); // captionedImageView.getImageView().setSquare(false); // captionedImageView.getTextView().setText(tool.getName()); // captionedImageView.setImageResource(tool.getImageResourceId()); // // findAndSetTextView(R.id.price, tool.getPrice()); // findAndSetTextView(R.id.detail_0, tool.getDetails()[0]); // findAndSetTextView(R.id.detail_1, tool.getDetails()[1]); // findAndSetTextView(R.id.detail_2, tool.getDetails()[2]); // findAndSetTextView(R.id.description, tool.getDescription()); // } // // private void findAndSetTextView(int id, String text) { // final TextView textView = (TextView) findViewById(id); // textView.setText(text); // } // } // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolListFragment.java import android.os.Bundle; import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.app.ListFragment; import android.support.v4.util.Pair; import android.view.View; import android.widget.AdapterView; import com.iangclifton.woodworkingtools.R; import com.iangclifton.woodworkingtools.Tool; import com.iangclifton.woodworkingtools.tooldetails.ToolDetailActivity; import java.util.List; public ToolListFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); if (args == null) { throw new IllegalStateException("No arguments set; use newInstance when constructing!"); } mToolTab = args.getParcelable(ARG_TOOL_TAB); final List<Tool> tools = ToolListGenerator.getTools(mToolTab); mToolArrayAdapter = new ToolArrayAdapter(getActivity(), tools); setListAdapter(mToolArrayAdapter); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getListView().setOnItemClickListener(this); } @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), new Pair<View, String>(view.findViewById(R.id.thumbnail), getString(R.string.transition_image_view)) );
ToolDetailActivity.startActivity(getActivity(), mToolArrayAdapter.getItem(position), activityOptions.toBundle());
IanGClifton/auid2
chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolListActivity.java
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps_1080), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw_1080), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill_1080), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander_1080), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router_1080), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe_1080), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more_1080), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // }
import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.ActivityCompat; import android.support.v4.app.SharedElementCallback; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.view.ViewTreeObserver; import com.iangclifton.woodworkingtools.R; import com.iangclifton.woodworkingtools.ToolType; import java.util.List; import java.util.Map;
package com.iangclifton.woodworkingtools.toollist; public class ToolListActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener { private static final String EXTRA_TOOL_TYPE = "com.iangclifton.woodworkingtools.TOOL_TYPE";
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps_1080), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw_1080), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill_1080), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander_1080), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router_1080), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe_1080), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more_1080), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // } // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolListActivity.java import android.app.Activity; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.app.ActivityCompat; import android.support.v4.app.SharedElementCallback; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import android.view.View; import android.view.ViewTreeObserver; import com.iangclifton.woodworkingtools.R; import com.iangclifton.woodworkingtools.ToolType; import java.util.List; import java.util.Map; package com.iangclifton.woodworkingtools.toollist; public class ToolListActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener { private static final String EXTRA_TOOL_TYPE = "com.iangclifton.woodworkingtools.TOOL_TYPE";
private ToolType mToolType;
IanGClifton/auid2
chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolTab.java
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps_1080), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw_1080), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill_1080), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander_1080), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router_1080), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe_1080), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more_1080), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // }
import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; import android.support.annotation.StringRes; import com.iangclifton.woodworkingtools.ToolType;
package com.iangclifton.woodworkingtools.toollist; /** * Represents a tab for a particular ToolType. * * @author Ian G. Clifton */ public class ToolTab implements Parcelable { private final int mStringResourceId; private final int mTabId;
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps_1080), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw_1080), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill_1080), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander_1080), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router_1080), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe_1080), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more_1080), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // } // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolTab.java import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; import android.support.annotation.StringRes; import com.iangclifton.woodworkingtools.ToolType; package com.iangclifton.woodworkingtools.toollist; /** * Represents a tab for a particular ToolType. * * @author Ian G. Clifton */ public class ToolTab implements Parcelable { private final int mStringResourceId; private final int mTabId;
private final ToolType mToolType;
IanGClifton/auid2
chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolListActivity.java
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // }
import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.auidbook.woodworkingtools.R; import com.auidbook.woodworkingtools.ToolType;
package com.auidbook.woodworkingtools.toollist; public class ToolListActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener { private static final String EXTRA_TOOL_TYPE = "com.auidbook.woodworkingtools.TOOL_TYPE";
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // } // Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolListActivity.java import android.content.Context; import android.content.Intent; import android.os.Bundle; import android.support.design.widget.TabLayout; import android.support.v4.view.ViewPager; import android.support.v7.app.AppCompatActivity; import android.support.v7.widget.Toolbar; import com.auidbook.woodworkingtools.R; import com.auidbook.woodworkingtools.ToolType; package com.auidbook.woodworkingtools.toollist; public class ToolListActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener { private static final String EXTRA_TOOL_TYPE = "com.auidbook.woodworkingtools.TOOL_TYPE";
private ToolType mToolType;
IanGClifton/auid2
chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolListFragment.java
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/Tool.java // public class Tool implements Parcelable { // // private static final int DETAILS_COUNT = 3; // // private final String mName; // private final String mPrice; // private final String[] mDetails; // private final String mDescription; // private final int mImageResourceId; // private final int mThumbnailResourceId; // // public Tool(String name, String price, String[] details, String description, @DrawableRes int imageResourceId, @DrawableRes int thumbnailResourceId) { // mName = name; // mPrice = price; // mDetails = new String[DETAILS_COUNT]; // if (details != null) { // System.arraycopy(details, 0, mDetails, 0, details.length); // } // mDescription = description; // mImageResourceId = imageResourceId; // mThumbnailResourceId = thumbnailResourceId; // } // // public String getDescription() { // return mDescription; // } // // public String[] getDetails() { // return mDetails; // } // // public String getName() { // return mName; // } // // public String getPrice() { // return mPrice; // } // // public int getImageResourceId() { // return mImageResourceId; // } // // public int getThumbnailResourceId() { // return mThumbnailResourceId; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(mName); // dest.writeString(mPrice); // dest.writeStringArray(mDetails); // dest.writeString(mDescription); // dest.writeInt(mImageResourceId); // dest.writeInt(mThumbnailResourceId); // } // // private Tool(Parcel in) { // mName = in.readString(); // mPrice = in.readString(); // mDetails = in.createStringArray(); // mDescription = in.readString(); // mImageResourceId = in.readInt(); // mThumbnailResourceId = in.readInt(); // } // // public static final Parcelable.Creator<Tool> CREATOR = new Parcelable.Creator<Tool>() { // public Tool createFromParcel(Parcel source) { // return new Tool(source); // } // // public Tool[] newArray(int size) { // return new Tool[size]; // } // }; // } // // Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/tooldetails/ToolDetailActivity.java // public class ToolDetailActivity extends AppCompatActivity { // // private static final String EXTRA_TOOL = "com.auidbook.woodworkingtools.TOOL"; // // public static void startActivity(Context context, Tool tool) { // final Intent intent = new Intent(context, ToolDetailActivity.class); // intent.putExtra(EXTRA_TOOL, tool); // context.startActivity(intent); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_detail); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowTitleEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // final Tool tool = getIntent().getParcelableExtra(EXTRA_TOOL); // if (tool == null) { // throw new IllegalStateException("Tool not available as extra; use startActivity when creating an activity instance"); // } // // final CaptionedImageView captionedImageView = (CaptionedImageView) findViewById(R.id.hero_image); // captionedImageView.getImageView().setSquare(false); // captionedImageView.getTextView().setText(tool.getName()); // captionedImageView.setImageResource(tool.getImageResourceId()); // // findAndSetTextView(R.id.price, tool.getPrice()); // findAndSetTextView(R.id.detail_0, tool.getDetails()[0]); // findAndSetTextView(R.id.detail_1, tool.getDetails()[1]); // findAndSetTextView(R.id.detail_2, tool.getDetails()[2]); // findAndSetTextView(R.id.description, tool.getDescription()); // } // // private void findAndSetTextView(int id, String text) { // final TextView textView = (TextView) findViewById(id); // textView.setText(text); // } // }
import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.View; import android.widget.AdapterView; import com.auidbook.woodworkingtools.Tool; import com.auidbook.woodworkingtools.tooldetails.ToolDetailActivity; import java.util.List;
package com.auidbook.woodworkingtools.toollist; /** * A placeholder fragment containing a simple view. */ public class ToolListFragment extends ListFragment implements AdapterView.OnItemClickListener { private static final String ARG_TOOL_TAB = "toolTab"; private ToolTab mToolTab; private ToolArrayAdapter mToolArrayAdapter; public static ToolListFragment newInstance(ToolTab toolTab) { final ToolListFragment fragment = new ToolListFragment(); final Bundle args = new Bundle(); args.putParcelable(ARG_TOOL_TAB, toolTab); fragment.setArguments(args); return fragment; } public ToolListFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); if (args == null) { throw new IllegalStateException("No arguments set; use newInstance when constructing!"); } mToolTab = args.getParcelable(ARG_TOOL_TAB);
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/Tool.java // public class Tool implements Parcelable { // // private static final int DETAILS_COUNT = 3; // // private final String mName; // private final String mPrice; // private final String[] mDetails; // private final String mDescription; // private final int mImageResourceId; // private final int mThumbnailResourceId; // // public Tool(String name, String price, String[] details, String description, @DrawableRes int imageResourceId, @DrawableRes int thumbnailResourceId) { // mName = name; // mPrice = price; // mDetails = new String[DETAILS_COUNT]; // if (details != null) { // System.arraycopy(details, 0, mDetails, 0, details.length); // } // mDescription = description; // mImageResourceId = imageResourceId; // mThumbnailResourceId = thumbnailResourceId; // } // // public String getDescription() { // return mDescription; // } // // public String[] getDetails() { // return mDetails; // } // // public String getName() { // return mName; // } // // public String getPrice() { // return mPrice; // } // // public int getImageResourceId() { // return mImageResourceId; // } // // public int getThumbnailResourceId() { // return mThumbnailResourceId; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(mName); // dest.writeString(mPrice); // dest.writeStringArray(mDetails); // dest.writeString(mDescription); // dest.writeInt(mImageResourceId); // dest.writeInt(mThumbnailResourceId); // } // // private Tool(Parcel in) { // mName = in.readString(); // mPrice = in.readString(); // mDetails = in.createStringArray(); // mDescription = in.readString(); // mImageResourceId = in.readInt(); // mThumbnailResourceId = in.readInt(); // } // // public static final Parcelable.Creator<Tool> CREATOR = new Parcelable.Creator<Tool>() { // public Tool createFromParcel(Parcel source) { // return new Tool(source); // } // // public Tool[] newArray(int size) { // return new Tool[size]; // } // }; // } // // Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/tooldetails/ToolDetailActivity.java // public class ToolDetailActivity extends AppCompatActivity { // // private static final String EXTRA_TOOL = "com.auidbook.woodworkingtools.TOOL"; // // public static void startActivity(Context context, Tool tool) { // final Intent intent = new Intent(context, ToolDetailActivity.class); // intent.putExtra(EXTRA_TOOL, tool); // context.startActivity(intent); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_detail); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowTitleEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // final Tool tool = getIntent().getParcelableExtra(EXTRA_TOOL); // if (tool == null) { // throw new IllegalStateException("Tool not available as extra; use startActivity when creating an activity instance"); // } // // final CaptionedImageView captionedImageView = (CaptionedImageView) findViewById(R.id.hero_image); // captionedImageView.getImageView().setSquare(false); // captionedImageView.getTextView().setText(tool.getName()); // captionedImageView.setImageResource(tool.getImageResourceId()); // // findAndSetTextView(R.id.price, tool.getPrice()); // findAndSetTextView(R.id.detail_0, tool.getDetails()[0]); // findAndSetTextView(R.id.detail_1, tool.getDetails()[1]); // findAndSetTextView(R.id.detail_2, tool.getDetails()[2]); // findAndSetTextView(R.id.description, tool.getDescription()); // } // // private void findAndSetTextView(int id, String text) { // final TextView textView = (TextView) findViewById(id); // textView.setText(text); // } // } // Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolListFragment.java import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.View; import android.widget.AdapterView; import com.auidbook.woodworkingtools.Tool; import com.auidbook.woodworkingtools.tooldetails.ToolDetailActivity; import java.util.List; package com.auidbook.woodworkingtools.toollist; /** * A placeholder fragment containing a simple view. */ public class ToolListFragment extends ListFragment implements AdapterView.OnItemClickListener { private static final String ARG_TOOL_TAB = "toolTab"; private ToolTab mToolTab; private ToolArrayAdapter mToolArrayAdapter; public static ToolListFragment newInstance(ToolTab toolTab) { final ToolListFragment fragment = new ToolListFragment(); final Bundle args = new Bundle(); args.putParcelable(ARG_TOOL_TAB, toolTab); fragment.setArguments(args); return fragment; } public ToolListFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); if (args == null) { throw new IllegalStateException("No arguments set; use newInstance when constructing!"); } mToolTab = args.getParcelable(ARG_TOOL_TAB);
final List<Tool> tools = ToolListGenerator.getTools(mToolTab);
IanGClifton/auid2
chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolListFragment.java
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/Tool.java // public class Tool implements Parcelable { // // private static final int DETAILS_COUNT = 3; // // private final String mName; // private final String mPrice; // private final String[] mDetails; // private final String mDescription; // private final int mImageResourceId; // private final int mThumbnailResourceId; // // public Tool(String name, String price, String[] details, String description, @DrawableRes int imageResourceId, @DrawableRes int thumbnailResourceId) { // mName = name; // mPrice = price; // mDetails = new String[DETAILS_COUNT]; // if (details != null) { // System.arraycopy(details, 0, mDetails, 0, details.length); // } // mDescription = description; // mImageResourceId = imageResourceId; // mThumbnailResourceId = thumbnailResourceId; // } // // public String getDescription() { // return mDescription; // } // // public String[] getDetails() { // return mDetails; // } // // public String getName() { // return mName; // } // // public String getPrice() { // return mPrice; // } // // public int getImageResourceId() { // return mImageResourceId; // } // // public int getThumbnailResourceId() { // return mThumbnailResourceId; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(mName); // dest.writeString(mPrice); // dest.writeStringArray(mDetails); // dest.writeString(mDescription); // dest.writeInt(mImageResourceId); // dest.writeInt(mThumbnailResourceId); // } // // private Tool(Parcel in) { // mName = in.readString(); // mPrice = in.readString(); // mDetails = in.createStringArray(); // mDescription = in.readString(); // mImageResourceId = in.readInt(); // mThumbnailResourceId = in.readInt(); // } // // public static final Parcelable.Creator<Tool> CREATOR = new Parcelable.Creator<Tool>() { // public Tool createFromParcel(Parcel source) { // return new Tool(source); // } // // public Tool[] newArray(int size) { // return new Tool[size]; // } // }; // } // // Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/tooldetails/ToolDetailActivity.java // public class ToolDetailActivity extends AppCompatActivity { // // private static final String EXTRA_TOOL = "com.auidbook.woodworkingtools.TOOL"; // // public static void startActivity(Context context, Tool tool) { // final Intent intent = new Intent(context, ToolDetailActivity.class); // intent.putExtra(EXTRA_TOOL, tool); // context.startActivity(intent); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_detail); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowTitleEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // final Tool tool = getIntent().getParcelableExtra(EXTRA_TOOL); // if (tool == null) { // throw new IllegalStateException("Tool not available as extra; use startActivity when creating an activity instance"); // } // // final CaptionedImageView captionedImageView = (CaptionedImageView) findViewById(R.id.hero_image); // captionedImageView.getImageView().setSquare(false); // captionedImageView.getTextView().setText(tool.getName()); // captionedImageView.setImageResource(tool.getImageResourceId()); // // findAndSetTextView(R.id.price, tool.getPrice()); // findAndSetTextView(R.id.detail_0, tool.getDetails()[0]); // findAndSetTextView(R.id.detail_1, tool.getDetails()[1]); // findAndSetTextView(R.id.detail_2, tool.getDetails()[2]); // findAndSetTextView(R.id.description, tool.getDescription()); // } // // private void findAndSetTextView(int id, String text) { // final TextView textView = (TextView) findViewById(id); // textView.setText(text); // } // }
import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.View; import android.widget.AdapterView; import com.auidbook.woodworkingtools.Tool; import com.auidbook.woodworkingtools.tooldetails.ToolDetailActivity; import java.util.List;
fragment.setArguments(args); return fragment; } public ToolListFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); if (args == null) { throw new IllegalStateException("No arguments set; use newInstance when constructing!"); } mToolTab = args.getParcelable(ARG_TOOL_TAB); final List<Tool> tools = ToolListGenerator.getTools(mToolTab); mToolArrayAdapter = new ToolArrayAdapter(getActivity(), tools); setListAdapter(mToolArrayAdapter); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getListView().setOnItemClickListener(this); } @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/Tool.java // public class Tool implements Parcelable { // // private static final int DETAILS_COUNT = 3; // // private final String mName; // private final String mPrice; // private final String[] mDetails; // private final String mDescription; // private final int mImageResourceId; // private final int mThumbnailResourceId; // // public Tool(String name, String price, String[] details, String description, @DrawableRes int imageResourceId, @DrawableRes int thumbnailResourceId) { // mName = name; // mPrice = price; // mDetails = new String[DETAILS_COUNT]; // if (details != null) { // System.arraycopy(details, 0, mDetails, 0, details.length); // } // mDescription = description; // mImageResourceId = imageResourceId; // mThumbnailResourceId = thumbnailResourceId; // } // // public String getDescription() { // return mDescription; // } // // public String[] getDetails() { // return mDetails; // } // // public String getName() { // return mName; // } // // public String getPrice() { // return mPrice; // } // // public int getImageResourceId() { // return mImageResourceId; // } // // public int getThumbnailResourceId() { // return mThumbnailResourceId; // } // // @Override // public int describeContents() { // return 0; // } // // @Override // public void writeToParcel(Parcel dest, int flags) { // dest.writeString(mName); // dest.writeString(mPrice); // dest.writeStringArray(mDetails); // dest.writeString(mDescription); // dest.writeInt(mImageResourceId); // dest.writeInt(mThumbnailResourceId); // } // // private Tool(Parcel in) { // mName = in.readString(); // mPrice = in.readString(); // mDetails = in.createStringArray(); // mDescription = in.readString(); // mImageResourceId = in.readInt(); // mThumbnailResourceId = in.readInt(); // } // // public static final Parcelable.Creator<Tool> CREATOR = new Parcelable.Creator<Tool>() { // public Tool createFromParcel(Parcel source) { // return new Tool(source); // } // // public Tool[] newArray(int size) { // return new Tool[size]; // } // }; // } // // Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/tooldetails/ToolDetailActivity.java // public class ToolDetailActivity extends AppCompatActivity { // // private static final String EXTRA_TOOL = "com.auidbook.woodworkingtools.TOOL"; // // public static void startActivity(Context context, Tool tool) { // final Intent intent = new Intent(context, ToolDetailActivity.class); // intent.putExtra(EXTRA_TOOL, tool); // context.startActivity(intent); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_detail); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayShowTitleEnabled(false); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // final Tool tool = getIntent().getParcelableExtra(EXTRA_TOOL); // if (tool == null) { // throw new IllegalStateException("Tool not available as extra; use startActivity when creating an activity instance"); // } // // final CaptionedImageView captionedImageView = (CaptionedImageView) findViewById(R.id.hero_image); // captionedImageView.getImageView().setSquare(false); // captionedImageView.getTextView().setText(tool.getName()); // captionedImageView.setImageResource(tool.getImageResourceId()); // // findAndSetTextView(R.id.price, tool.getPrice()); // findAndSetTextView(R.id.detail_0, tool.getDetails()[0]); // findAndSetTextView(R.id.detail_1, tool.getDetails()[1]); // findAndSetTextView(R.id.detail_2, tool.getDetails()[2]); // findAndSetTextView(R.id.description, tool.getDescription()); // } // // private void findAndSetTextView(int id, String text) { // final TextView textView = (TextView) findViewById(id); // textView.setText(text); // } // } // Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolListFragment.java import android.os.Bundle; import android.support.v4.app.ListFragment; import android.view.View; import android.widget.AdapterView; import com.auidbook.woodworkingtools.Tool; import com.auidbook.woodworkingtools.tooldetails.ToolDetailActivity; import java.util.List; fragment.setArguments(args); return fragment; } public ToolListFragment() { // Required empty public constructor } @Override public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); final Bundle args = getArguments(); if (args == null) { throw new IllegalStateException("No arguments set; use newInstance when constructing!"); } mToolTab = args.getParcelable(ARG_TOOL_TAB); final List<Tool> tools = ToolListGenerator.getTools(mToolTab); mToolArrayAdapter = new ToolArrayAdapter(getActivity(), tools); setListAdapter(mToolArrayAdapter); } @Override public void onActivityCreated(Bundle savedInstanceState) { super.onActivityCreated(savedInstanceState); getListView().setOnItemClickListener(this); } @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
ToolDetailActivity.startActivity(getActivity(), mToolArrayAdapter.getItem(position));
IanGClifton/auid2
chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolGridAdapter.java
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/utils/BitmapUtils.java // public class BitmapUtils { // // private static final int THUMBNAIL_SIZE_336 = 336; // private static final int THUMBNAIL_SIZE_468 = 468; // // private static final BitmapCache BITMAP_CACHE = new BitmapCache(); // // public synchronized static void cacheBitmap(@NonNull String key, @NonNull Bitmap bitmap) { // BITMAP_CACHE.put(key, bitmap); // } // // public synchronized static Bitmap getBitmap(@NonNull String key) { // return BITMAP_CACHE.get(key); // } // // public synchronized static Bitmap getBitmap(@NonNull Resources res, @DrawableRes int resId) { // String key = String.valueOf(resId); // Bitmap bitmap = BITMAP_CACHE.get(key); // if (bitmap == null) { // bitmap = BitmapFactory.decodeResource(res, resId); // BITMAP_CACHE.put(key, bitmap); // } // return bitmap; // } // // public static int getScreenWidth(@NonNull Context context) { // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Display display = windowManager.getDefaultDisplay(); // Point point = new Point(); // display.getSize(point); // return point.x; // } // // /** // * Returns a resource ID to a smaller version of the drawable, when possible. // * // * This is intended just for the hero images. If a smaller size of the resource ID cannot // * be found, the original resource ID is returned. // * // * @param resourceId int drawable resource ID to look for // * @param desiredSize int desired size in pixels of the drawable // * @return int drawable resource ID to use // */ // @DrawableRes // public static int getPresizedImage(@DrawableRes int resourceId, int desiredSize) { // switch (resourceId) { // case R.drawable.hero_image_clamps_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_clamps_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_clamps_468; // } // break; // case R.drawable.hero_image_saw_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_saw_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_saw_468; // } // break; // case R.drawable.hero_image_drill_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_drill_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_drill_468; // } // break; // case R.drawable.hero_image_sander_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_sander_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_sander_468; // } // break; // case R.drawable.hero_image_router_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_router_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_router_468; // } // break; // case R.drawable.hero_image_lathe_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_lathe_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_lathe_468; // } // break; // case R.drawable.hero_image_more_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_more_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_more_468; // } // break; // } // // return resourceId; // } // // public static Bitmap getSizedBitmap(@NonNull Resources res, @DrawableRes int resId, int desiredWidth) { // // Load just the size of the image // BitmapFactory.Options options = new BitmapFactory.Options(); // options.inJustDecodeBounds = true; // BitmapFactory.decodeResource(res, resId, options); // // // Options now has the bounds; prepare it for getting the actual image // options.inSampleSize = 1; // options.inJustDecodeBounds = false; // // if (options.outWidth > desiredWidth) { // final int halfWidth = options.outWidth / 2; // // while (halfWidth / options.inSampleSize > desiredWidth) { // options.inSampleSize *= 2; // } // } // // return BitmapFactory.decodeResource(res, resId, options); // } // }
import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import com.iangclifton.woodworkingtools.utils.BitmapUtils;
package com.iangclifton.woodworkingtools; /** * Adapter for a GridView showing the ToolTypes. * * @author Ian G. Clifton */ public class ToolGridAdapter extends BaseAdapter { private final ToolType[] mToolTypes = ToolType.values(); private final Context mContext; private final int mThumbnailSize; public ToolGridAdapter(Context context) { mContext = context;
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/utils/BitmapUtils.java // public class BitmapUtils { // // private static final int THUMBNAIL_SIZE_336 = 336; // private static final int THUMBNAIL_SIZE_468 = 468; // // private static final BitmapCache BITMAP_CACHE = new BitmapCache(); // // public synchronized static void cacheBitmap(@NonNull String key, @NonNull Bitmap bitmap) { // BITMAP_CACHE.put(key, bitmap); // } // // public synchronized static Bitmap getBitmap(@NonNull String key) { // return BITMAP_CACHE.get(key); // } // // public synchronized static Bitmap getBitmap(@NonNull Resources res, @DrawableRes int resId) { // String key = String.valueOf(resId); // Bitmap bitmap = BITMAP_CACHE.get(key); // if (bitmap == null) { // bitmap = BitmapFactory.decodeResource(res, resId); // BITMAP_CACHE.put(key, bitmap); // } // return bitmap; // } // // public static int getScreenWidth(@NonNull Context context) { // WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE); // Display display = windowManager.getDefaultDisplay(); // Point point = new Point(); // display.getSize(point); // return point.x; // } // // /** // * Returns a resource ID to a smaller version of the drawable, when possible. // * // * This is intended just for the hero images. If a smaller size of the resource ID cannot // * be found, the original resource ID is returned. // * // * @param resourceId int drawable resource ID to look for // * @param desiredSize int desired size in pixels of the drawable // * @return int drawable resource ID to use // */ // @DrawableRes // public static int getPresizedImage(@DrawableRes int resourceId, int desiredSize) { // switch (resourceId) { // case R.drawable.hero_image_clamps_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_clamps_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_clamps_468; // } // break; // case R.drawable.hero_image_saw_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_saw_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_saw_468; // } // break; // case R.drawable.hero_image_drill_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_drill_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_drill_468; // } // break; // case R.drawable.hero_image_sander_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_sander_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_sander_468; // } // break; // case R.drawable.hero_image_router_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_router_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_router_468; // } // break; // case R.drawable.hero_image_lathe_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_lathe_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_lathe_468; // } // break; // case R.drawable.hero_image_more_1080: // if (desiredSize <= THUMBNAIL_SIZE_336) { // return R.drawable.hero_image_more_336; // } else if (desiredSize <= THUMBNAIL_SIZE_468) { // return R.drawable.hero_image_more_468; // } // break; // } // // return resourceId; // } // // public static Bitmap getSizedBitmap(@NonNull Resources res, @DrawableRes int resId, int desiredWidth) { // // Load just the size of the image // BitmapFactory.Options options = new BitmapFactory.Options(); // options.inJustDecodeBounds = true; // BitmapFactory.decodeResource(res, resId, options); // // // Options now has the bounds; prepare it for getting the actual image // options.inSampleSize = 1; // options.inJustDecodeBounds = false; // // if (options.outWidth > desiredWidth) { // final int halfWidth = options.outWidth / 2; // // while (halfWidth / options.inSampleSize > desiredWidth) { // options.inSampleSize *= 2; // } // } // // return BitmapFactory.decodeResource(res, resId, options); // } // } // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolGridAdapter.java import android.content.Context; import android.view.View; import android.view.ViewGroup; import android.widget.BaseAdapter; import com.iangclifton.woodworkingtools.utils.BitmapUtils; package com.iangclifton.woodworkingtools; /** * Adapter for a GridView showing the ToolTypes. * * @author Ian G. Clifton */ public class ToolGridAdapter extends BaseAdapter { private final ToolType[] mToolTypes = ToolType.values(); private final Context mContext; private final int mThumbnailSize; public ToolGridAdapter(Context context) { mContext = context;
int screenWidth = BitmapUtils.getScreenWidth(context);
IanGClifton/auid2
chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolTab.java
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // }
import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; import android.support.annotation.StringRes; import com.auidbook.woodworkingtools.ToolType;
package com.auidbook.woodworkingtools.toollist; /** * Represents a tab for a particular ToolType. * * @author Ian G. Clifton */ public class ToolTab implements Parcelable { private final int mStringResourceId; private final int mTabId;
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // } // Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolTab.java import android.os.Parcel; import android.os.Parcelable; import android.support.annotation.NonNull; import android.support.annotation.StringRes; import com.auidbook.woodworkingtools.ToolType; package com.auidbook.woodworkingtools.toollist; /** * Represents a tab for a particular ToolType. * * @author Ian G. Clifton */ public class ToolTab implements Parcelable { private final int mStringResourceId; private final int mTabId;
private final ToolType mToolType;
IanGClifton/auid2
chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolPagerAdapter.java
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps_1080), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw_1080), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill_1080), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander_1080), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router_1080), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe_1080), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more_1080), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // }
import android.content.res.Resources; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import com.iangclifton.woodworkingtools.R; import com.iangclifton.woodworkingtools.ToolType; import java.util.ArrayList; import java.util.List;
package com.iangclifton.woodworkingtools.toollist; /** * FragmentPagerAdapter for Tools. * * @author Ian G. Clifton */ public class ToolPagerAdapter extends FragmentPagerAdapter { private final CharSequence[] mTitles; private final List<ToolTab> mToolTabs;
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps_1080), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw_1080), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill_1080), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander_1080), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router_1080), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe_1080), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more_1080), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // } // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolPagerAdapter.java import android.content.res.Resources; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import com.iangclifton.woodworkingtools.R; import com.iangclifton.woodworkingtools.ToolType; import java.util.ArrayList; import java.util.List; package com.iangclifton.woodworkingtools.toollist; /** * FragmentPagerAdapter for Tools. * * @author Ian G. Clifton */ public class ToolPagerAdapter extends FragmentPagerAdapter { private final CharSequence[] mTitles; private final List<ToolTab> mToolTabs;
private final ToolType mToolType;
IanGClifton/auid2
chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolGridFragment.java
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolListActivity.java // public class ToolListActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener { // // private static final String EXTRA_TOOL_TYPE = "com.iangclifton.woodworkingtools.TOOL_TYPE"; // // private ToolType mToolType; // private ViewPager mViewPager; // // public static void startActivity(Activity activity, ToolType toolType, Bundle activityOptions) { // final Intent intent = new Intent(activity, ToolListActivity.class); // intent.putExtra(EXTRA_TOOL_TYPE, toolType); // ActivityCompat.startActivity(activity, intent, activityOptions); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_list); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // mToolType = (ToolType) getIntent().getSerializableExtra(EXTRA_TOOL_TYPE); // if (mToolType == null) { // throw new IllegalStateException("ToolType not available as extra; use startActivity"); // } // setTitle(mToolType.getToolNameResourceId()); // // // Set up tabs // mViewPager = (ViewPager) findViewById(R.id.viewpager); // final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); // final ToolPagerAdapter toolPagerAdapter = new ToolPagerAdapter(getSupportFragmentManager(), getResources(), mToolType); // tabLayout.setTabsFromPagerAdapter(toolPagerAdapter); // mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); // mViewPager.setAdapter(toolPagerAdapter); // tabLayout.setOnTabSelectedListener(this); // // // Handle animation from previous activity // postponeEnterTransition(); // mViewPager.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // mViewPager.getViewTreeObserver().removeOnPreDrawListener(this); // startPostponedEnterTransition(); // return true; // } // }); // // setEnterSharedElementCallback(new SharedElementCallback() { // @Override // public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { // if (mViewPager.getCurrentItem() != 0) { // // Not displaying the about page, which has the hero image // names.clear(); // sharedElements.clear(); // } // } // }); // // // } // // // @Override // public void onTabSelected(TabLayout.Tab tab) { // mViewPager.setCurrentItem(tab.getPosition()); // } // // @Override // public void onTabUnselected(TabLayout.Tab tab) { // // } // // @Override // public void onTabReselected(TabLayout.Tab tab) { // // } // }
import android.app.Fragment; import android.os.Bundle; import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.util.Pair; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.GridView; import com.iangclifton.woodworkingtools.toollist.ToolListActivity;
package com.iangclifton.woodworkingtools; /** * Fragment displaying a GridView of tool types. * * @author Ian G. Clifton */ public class ToolGridFragment extends Fragment implements AdapterView.OnItemClickListener { private ToolGridAdapter mToolGridAdapter; public ToolGridFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_tool_grid, container, false); final GridView gridView = (GridView) rootView.findViewById(R.id.gridview); mToolGridAdapter = new ToolGridAdapter(getActivity()); gridView.setAdapter(mToolGridAdapter); gridView.setOnItemClickListener(this); return rootView; } @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { final CaptionedImageView captionedImageView = (CaptionedImageView) view; ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), new Pair<View, String>(captionedImageView.getImageView(), getString(R.string.transition_image_view)), new Pair<View, String>(captionedImageView.getTextView(), getString(R.string.transition_text_view)) );
// Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/toollist/ToolListActivity.java // public class ToolListActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener { // // private static final String EXTRA_TOOL_TYPE = "com.iangclifton.woodworkingtools.TOOL_TYPE"; // // private ToolType mToolType; // private ViewPager mViewPager; // // public static void startActivity(Activity activity, ToolType toolType, Bundle activityOptions) { // final Intent intent = new Intent(activity, ToolListActivity.class); // intent.putExtra(EXTRA_TOOL_TYPE, toolType); // ActivityCompat.startActivity(activity, intent, activityOptions); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_list); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // mToolType = (ToolType) getIntent().getSerializableExtra(EXTRA_TOOL_TYPE); // if (mToolType == null) { // throw new IllegalStateException("ToolType not available as extra; use startActivity"); // } // setTitle(mToolType.getToolNameResourceId()); // // // Set up tabs // mViewPager = (ViewPager) findViewById(R.id.viewpager); // final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); // final ToolPagerAdapter toolPagerAdapter = new ToolPagerAdapter(getSupportFragmentManager(), getResources(), mToolType); // tabLayout.setTabsFromPagerAdapter(toolPagerAdapter); // mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); // mViewPager.setAdapter(toolPagerAdapter); // tabLayout.setOnTabSelectedListener(this); // // // Handle animation from previous activity // postponeEnterTransition(); // mViewPager.getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() { // @Override // public boolean onPreDraw() { // mViewPager.getViewTreeObserver().removeOnPreDrawListener(this); // startPostponedEnterTransition(); // return true; // } // }); // // setEnterSharedElementCallback(new SharedElementCallback() { // @Override // public void onMapSharedElements(List<String> names, Map<String, View> sharedElements) { // if (mViewPager.getCurrentItem() != 0) { // // Not displaying the about page, which has the hero image // names.clear(); // sharedElements.clear(); // } // } // }); // // // } // // // @Override // public void onTabSelected(TabLayout.Tab tab) { // mViewPager.setCurrentItem(tab.getPosition()); // } // // @Override // public void onTabUnselected(TabLayout.Tab tab) { // // } // // @Override // public void onTabReselected(TabLayout.Tab tab) { // // } // } // Path: chapter10/WoodworkingTools/app/src/main/java/com/iangclifton/woodworkingtools/ToolGridFragment.java import android.app.Fragment; import android.os.Bundle; import android.support.v4.app.ActivityOptionsCompat; import android.support.v4.util.Pair; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.GridView; import com.iangclifton.woodworkingtools.toollist.ToolListActivity; package com.iangclifton.woodworkingtools; /** * Fragment displaying a GridView of tool types. * * @author Ian G. Clifton */ public class ToolGridFragment extends Fragment implements AdapterView.OnItemClickListener { private ToolGridAdapter mToolGridAdapter; public ToolGridFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_tool_grid, container, false); final GridView gridView = (GridView) rootView.findViewById(R.id.gridview); mToolGridAdapter = new ToolGridAdapter(getActivity()); gridView.setAdapter(mToolGridAdapter); gridView.setOnItemClickListener(this); return rootView; } @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) { final CaptionedImageView captionedImageView = (CaptionedImageView) view; ActivityOptionsCompat activityOptions = ActivityOptionsCompat.makeSceneTransitionAnimation( getActivity(), new Pair<View, String>(captionedImageView.getImageView(), getString(R.string.transition_image_view)), new Pair<View, String>(captionedImageView.getTextView(), getString(R.string.transition_text_view)) );
ToolListActivity.startActivity(getActivity(), mToolGridAdapter.getItem(position), activityOptions.toBundle());
IanGClifton/auid2
chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolPagerAdapter.java
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // }
import android.content.res.Resources; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import com.auidbook.woodworkingtools.R; import com.auidbook.woodworkingtools.ToolType; import java.util.ArrayList; import java.util.List;
package com.auidbook.woodworkingtools.toollist; /** * FragmentPagerAdapter for Tools. * * @author Ian G. Clifton */ public class ToolPagerAdapter extends FragmentPagerAdapter { private final CharSequence[] mTitles; private final List<ToolTab> mToolTabs;
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/ToolType.java // public enum ToolType { // CLAMPS(R.string.clamps, R.string.clamps_description, R.drawable.hero_image_clamps), // SAWS(R.string.saws, R.string.saws_description, R.drawable.hero_image_saw), // DRILLS(R.string.drills, R.string.drills_description, R.drawable.hero_image_drill), // SANDERS(R.string.sanders, R.string.sanders_description, R.drawable.hero_image_sander), // ROUTERS(R.string.routers, R.string.routers_description, R.drawable.hero_image_router), // LATHES(R.string.lathes, R.string.lathes_description, R.drawable.hero_image_lathe), // MORE(R.string.more, R.string.more_description, R.drawable.hero_image_more), // ; // // private final int mToolNameResourceId; // private final int mToolDescriptionResourceId; // private final int mToolImageResourceId; // // private ToolType(@StringRes int toolName, @StringRes int toolDescription, @DrawableRes int toolImage) { // mToolNameResourceId = toolName; // mToolDescriptionResourceId = toolDescription; // mToolImageResourceId = toolImage; // } // // @StringRes // public int getToolDescriptionResourceId() { // return mToolDescriptionResourceId; // } // // @StringRes // public int getToolNameResourceId() { // return mToolNameResourceId; // } // // @DrawableRes // public int getToolImageResourceId() { // return mToolImageResourceId; // } // } // Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolPagerAdapter.java import android.content.res.Resources; import android.support.v4.app.Fragment; import android.support.v4.app.FragmentManager; import android.support.v4.app.FragmentPagerAdapter; import com.auidbook.woodworkingtools.R; import com.auidbook.woodworkingtools.ToolType; import java.util.ArrayList; import java.util.List; package com.auidbook.woodworkingtools.toollist; /** * FragmentPagerAdapter for Tools. * * @author Ian G. Clifton */ public class ToolPagerAdapter extends FragmentPagerAdapter { private final CharSequence[] mTitles; private final List<ToolTab> mToolTabs;
private final ToolType mToolType;
IanGClifton/auid2
chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/ToolGridFragment.java
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolListActivity.java // public class ToolListActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener { // // private static final String EXTRA_TOOL_TYPE = "com.auidbook.woodworkingtools.TOOL_TYPE"; // // private ToolType mToolType; // private ViewPager mViewPager; // // public static void startActivity(Context context, ToolType toolType) { // final Intent intent = new Intent(context, ToolListActivity.class); // intent.putExtra(EXTRA_TOOL_TYPE, toolType); // context.startActivity(intent); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_list); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // mToolType = (ToolType) getIntent().getSerializableExtra(EXTRA_TOOL_TYPE); // if (mToolType == null) { // throw new IllegalStateException("ToolType not available as extra; use startActivity"); // } // setTitle(mToolType.getToolNameResourceId()); // // // Set up tabs // mViewPager = (ViewPager) findViewById(R.id.viewpager); // final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); // final ToolPagerAdapter toolPagerAdapter = new ToolPagerAdapter(getSupportFragmentManager(), getResources(), mToolType); // tabLayout.setTabsFromPagerAdapter(toolPagerAdapter); // mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); // mViewPager.setAdapter(toolPagerAdapter); // tabLayout.setOnTabSelectedListener(this); // } // // // @Override // public void onTabSelected(TabLayout.Tab tab) { // mViewPager.setCurrentItem(tab.getPosition()); // } // // @Override // public void onTabUnselected(TabLayout.Tab tab) { // // } // // @Override // public void onTabReselected(TabLayout.Tab tab) { // // } // }
import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.GridView; import com.auidbook.woodworkingtools.toollist.ToolListActivity;
package com.auidbook.woodworkingtools; /** * Fragment displaying a GridView of tool types. * * @author Ian G. Clifton */ public class ToolGridFragment extends Fragment implements AdapterView.OnItemClickListener { private ToolGridAdapter mToolGridAdapter; public ToolGridFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_tool_grid, container, false); final GridView gridView = (GridView) rootView.findViewById(R.id.gridview); mToolGridAdapter = new ToolGridAdapter(getActivity()); gridView.setAdapter(mToolGridAdapter); gridView.setOnItemClickListener(this); return rootView; } @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
// Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/toollist/ToolListActivity.java // public class ToolListActivity extends AppCompatActivity implements TabLayout.OnTabSelectedListener { // // private static final String EXTRA_TOOL_TYPE = "com.auidbook.woodworkingtools.TOOL_TYPE"; // // private ToolType mToolType; // private ViewPager mViewPager; // // public static void startActivity(Context context, ToolType toolType) { // final Intent intent = new Intent(context, ToolListActivity.class); // intent.putExtra(EXTRA_TOOL_TYPE, toolType); // context.startActivity(intent); // } // // @Override // protected void onCreate(Bundle savedInstanceState) { // super.onCreate(savedInstanceState); // setContentView(R.layout.activity_tool_list); // // final Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); // setSupportActionBar(toolbar); // getSupportActionBar().setDisplayHomeAsUpEnabled(true); // // mToolType = (ToolType) getIntent().getSerializableExtra(EXTRA_TOOL_TYPE); // if (mToolType == null) { // throw new IllegalStateException("ToolType not available as extra; use startActivity"); // } // setTitle(mToolType.getToolNameResourceId()); // // // Set up tabs // mViewPager = (ViewPager) findViewById(R.id.viewpager); // final TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs); // final ToolPagerAdapter toolPagerAdapter = new ToolPagerAdapter(getSupportFragmentManager(), getResources(), mToolType); // tabLayout.setTabsFromPagerAdapter(toolPagerAdapter); // mViewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout)); // mViewPager.setAdapter(toolPagerAdapter); // tabLayout.setOnTabSelectedListener(this); // } // // // @Override // public void onTabSelected(TabLayout.Tab tab) { // mViewPager.setCurrentItem(tab.getPosition()); // } // // @Override // public void onTabUnselected(TabLayout.Tab tab) { // // } // // @Override // public void onTabReselected(TabLayout.Tab tab) { // // } // } // Path: chapter08/WoodworkingTools/app/src/main/java/com/auidbook/woodworkingtools/ToolGridFragment.java import android.app.Fragment; import android.os.Bundle; import android.view.LayoutInflater; import android.view.View; import android.view.ViewGroup; import android.widget.AdapterView; import android.widget.GridView; import com.auidbook.woodworkingtools.toollist.ToolListActivity; package com.auidbook.woodworkingtools; /** * Fragment displaying a GridView of tool types. * * @author Ian G. Clifton */ public class ToolGridFragment extends Fragment implements AdapterView.OnItemClickListener { private ToolGridAdapter mToolGridAdapter; public ToolGridFragment() { } @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { final View rootView = inflater.inflate(R.layout.fragment_tool_grid, container, false); final GridView gridView = (GridView) rootView.findViewById(R.id.gridview); mToolGridAdapter = new ToolGridAdapter(getActivity()); gridView.setAdapter(mToolGridAdapter); gridView.setOnItemClickListener(this); return rootView; } @Override public void onItemClick(AdapterView<?> adapterView, View view, int position, long id) {
ToolListActivity.startActivity(getActivity(), mToolGridAdapter.getItem(position));
fusesource/jdbm
src/main/jdbm/helper/DefaultSerializer.java
// Path: src/main/jdbm/SerializerOutput.java // public class SerializerOutput extends DataOutputStream{ // // // public SerializerOutput(OutputStream out) { // super(out); // } // // public void writeObject(Object obj) throws IOException{ // Serialization.writeObject(this, obj); // } // // public void writePackedLong(long i) throws IOException{ // LongPacker.packLong(this, i); // } // // public void writePackedInt(int i) throws IOException{ // LongPacker.packInt(this, i); // } // // }
import java.io.IOException; import jdbm.Serializer; import jdbm.SerializerInput; import jdbm.SerializerOutput;
/******************************************************************************* * Copyright 2010 Cees De Groot, Alex Boisvert, Jan Kotek * * 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. ******************************************************************************/ package jdbm.helper; /** * Default java serializer. Constructor is privite, use DefaultSerializer.INSTANCE * * @author <a href="mailto:[email protected]">Alex Boisvert</a> */ public class DefaultSerializer implements Serializer<Object> { private static final long serialVersionUID = -3818545055661017388L; public static final DefaultSerializer INSTANCE = new DefaultSerializer(); /** * Construct a DefaultSerializer, is private to make sure every one uses INSTANCE */ private DefaultSerializer() { // no op } /** * Serialize the content of an object into a byte array. * * @param obj Object to serialize * @return a byte array representing the object's state */
// Path: src/main/jdbm/SerializerOutput.java // public class SerializerOutput extends DataOutputStream{ // // // public SerializerOutput(OutputStream out) { // super(out); // } // // public void writeObject(Object obj) throws IOException{ // Serialization.writeObject(this, obj); // } // // public void writePackedLong(long i) throws IOException{ // LongPacker.packLong(this, i); // } // // public void writePackedInt(int i) throws IOException{ // LongPacker.packInt(this, i); // } // // } // Path: src/main/jdbm/helper/DefaultSerializer.java import java.io.IOException; import jdbm.Serializer; import jdbm.SerializerInput; import jdbm.SerializerOutput; /******************************************************************************* * Copyright 2010 Cees De Groot, Alex Boisvert, Jan Kotek * * 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. ******************************************************************************/ package jdbm.helper; /** * Default java serializer. Constructor is privite, use DefaultSerializer.INSTANCE * * @author <a href="mailto:[email protected]">Alex Boisvert</a> */ public class DefaultSerializer implements Serializer<Object> { private static final long serialVersionUID = -3818545055661017388L; public static final DefaultSerializer INSTANCE = new DefaultSerializer(); /** * Construct a DefaultSerializer, is private to make sure every one uses INSTANCE */ private DefaultSerializer() { // no op } /** * Serialize the content of an object into a byte array. * * @param obj Object to serialize * @return a byte array representing the object's state */
public void serialize(SerializerOutput out,Object obj)
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/GhostSystem.java
// Path: core/src/com/ychstudio/components/GhostComponent.java // public class GhostComponent implements Component { // // // state // public static final int MOVE_UP = 0; // public static final int MOVE_DOWN = 1; // public static final int MOVE_LEFT = 2; // public static final int MOVE_RIGHT = 3; // public static final int ESCAPE = 4; // public static final int DIE = 5; // // public static final float WEAK_TIME = 10f; // public float weak_time; // // public GhostAgent ghostAgent; // // private final Body body; // // public int currentState; // // public boolean weaken; // public int hp; // // public GhostComponent(Body body) { // this.body = body; // ghostAgent = new GhostAgent(this); // ghostAgent.stateMachine.setInitialState(GhostState.MOVE_UP); // currentState = MOVE_UP; // weaken = false; // hp = 1; // } // // public Body getBody() { // return body; // } // // public void respawn() { // hp = 1; // weaken = false; // } // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.ychstudio.components.GhostComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.gamesys.GameManager;
package com.ychstudio.systems; public class GhostSystem extends IteratingSystem { private final ComponentMapper<GhostComponent> ghostM = ComponentMapper.getFor(GhostComponent.class);
// Path: core/src/com/ychstudio/components/GhostComponent.java // public class GhostComponent implements Component { // // // state // public static final int MOVE_UP = 0; // public static final int MOVE_DOWN = 1; // public static final int MOVE_LEFT = 2; // public static final int MOVE_RIGHT = 3; // public static final int ESCAPE = 4; // public static final int DIE = 5; // // public static final float WEAK_TIME = 10f; // public float weak_time; // // public GhostAgent ghostAgent; // // private final Body body; // // public int currentState; // // public boolean weaken; // public int hp; // // public GhostComponent(Body body) { // this.body = body; // ghostAgent = new GhostAgent(this); // ghostAgent.stateMachine.setInitialState(GhostState.MOVE_UP); // currentState = MOVE_UP; // weaken = false; // hp = 1; // } // // public Body getBody() { // return body; // } // // public void respawn() { // hp = 1; // weaken = false; // } // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/systems/GhostSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.ychstudio.components.GhostComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.gamesys.GameManager; package com.ychstudio.systems; public class GhostSystem extends IteratingSystem { private final ComponentMapper<GhostComponent> ghostM = ComponentMapper.getFor(GhostComponent.class);
private final ComponentMapper<StateComponent> stateM = ComponentMapper.getFor(StateComponent.class);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/GhostSystem.java
// Path: core/src/com/ychstudio/components/GhostComponent.java // public class GhostComponent implements Component { // // // state // public static final int MOVE_UP = 0; // public static final int MOVE_DOWN = 1; // public static final int MOVE_LEFT = 2; // public static final int MOVE_RIGHT = 3; // public static final int ESCAPE = 4; // public static final int DIE = 5; // // public static final float WEAK_TIME = 10f; // public float weak_time; // // public GhostAgent ghostAgent; // // private final Body body; // // public int currentState; // // public boolean weaken; // public int hp; // // public GhostComponent(Body body) { // this.body = body; // ghostAgent = new GhostAgent(this); // ghostAgent.stateMachine.setInitialState(GhostState.MOVE_UP); // currentState = MOVE_UP; // weaken = false; // hp = 1; // } // // public Body getBody() { // return body; // } // // public void respawn() { // hp = 1; // weaken = false; // } // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.ychstudio.components.GhostComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.gamesys.GameManager;
package com.ychstudio.systems; public class GhostSystem extends IteratingSystem { private final ComponentMapper<GhostComponent> ghostM = ComponentMapper.getFor(GhostComponent.class); private final ComponentMapper<StateComponent> stateM = ComponentMapper.getFor(StateComponent.class); public GhostSystem() { super(Family.all(GhostComponent.class, StateComponent.class).get()); } @Override public void update(float deltaTime) { super.update(deltaTime);
// Path: core/src/com/ychstudio/components/GhostComponent.java // public class GhostComponent implements Component { // // // state // public static final int MOVE_UP = 0; // public static final int MOVE_DOWN = 1; // public static final int MOVE_LEFT = 2; // public static final int MOVE_RIGHT = 3; // public static final int ESCAPE = 4; // public static final int DIE = 5; // // public static final float WEAK_TIME = 10f; // public float weak_time; // // public GhostAgent ghostAgent; // // private final Body body; // // public int currentState; // // public boolean weaken; // public int hp; // // public GhostComponent(Body body) { // this.body = body; // ghostAgent = new GhostAgent(this); // ghostAgent.stateMachine.setInitialState(GhostState.MOVE_UP); // currentState = MOVE_UP; // weaken = false; // hp = 1; // } // // public Body getBody() { // return body; // } // // public void respawn() { // hp = 1; // weaken = false; // } // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/systems/GhostSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.ychstudio.components.GhostComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.gamesys.GameManager; package com.ychstudio.systems; public class GhostSystem extends IteratingSystem { private final ComponentMapper<GhostComponent> ghostM = ComponentMapper.getFor(GhostComponent.class); private final ComponentMapper<StateComponent> stateM = ComponentMapper.getFor(StateComponent.class); public GhostSystem() { super(Family.all(GhostComponent.class, StateComponent.class).get()); } @Override public void update(float deltaTime) { super.update(deltaTime);
GameManager.instance.bigPillEaten = false;
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/MovementSystem.java
// Path: core/src/com/ychstudio/components/MovementComponent.java // public class MovementComponent implements Component { // // public float speed = 3.6f; // public Body body; // // public MovementComponent(Body body) { // this.body = body; // } // } // // Path: core/src/com/ychstudio/components/TransformComponent.java // public class TransformComponent implements Component { // // public Vector2 pos = new Vector2(); // public Vector2 scale = new Vector2(1, 1); // // public int zIndex; // // public float rotation = 0; // // public TransformComponent(float x, float y) { // this(x, y, 0); // } // // public TransformComponent(float x, float y, int zIndex) { // this(x, y, zIndex, 1.0f, 1.0f, 0); // } // // public TransformComponent(float x, float y, int zIndex, float sclX, float sclY, float rotation) { // pos.set(x, y); // this.zIndex = zIndex; // scale.set(sclX, sclY); // this.rotation = rotation; // } // // public TransformComponent(Vector2 pos, Vector2 scl, float rotation) { // this.pos.set(pos); // this.scale.set(scl); // this.rotation = rotation; // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.ychstudio.components.MovementComponent; import com.ychstudio.components.TransformComponent;
package com.ychstudio.systems; public class MovementSystem extends IteratingSystem { private ComponentMapper<MovementComponent> movementM = ComponentMapper.getFor(MovementComponent.class);
// Path: core/src/com/ychstudio/components/MovementComponent.java // public class MovementComponent implements Component { // // public float speed = 3.6f; // public Body body; // // public MovementComponent(Body body) { // this.body = body; // } // } // // Path: core/src/com/ychstudio/components/TransformComponent.java // public class TransformComponent implements Component { // // public Vector2 pos = new Vector2(); // public Vector2 scale = new Vector2(1, 1); // // public int zIndex; // // public float rotation = 0; // // public TransformComponent(float x, float y) { // this(x, y, 0); // } // // public TransformComponent(float x, float y, int zIndex) { // this(x, y, zIndex, 1.0f, 1.0f, 0); // } // // public TransformComponent(float x, float y, int zIndex, float sclX, float sclY, float rotation) { // pos.set(x, y); // this.zIndex = zIndex; // scale.set(sclX, sclY); // this.rotation = rotation; // } // // public TransformComponent(Vector2 pos, Vector2 scl, float rotation) { // this.pos.set(pos); // this.scale.set(scl); // this.rotation = rotation; // } // } // Path: core/src/com/ychstudio/systems/MovementSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.ychstudio.components.MovementComponent; import com.ychstudio.components.TransformComponent; package com.ychstudio.systems; public class MovementSystem extends IteratingSystem { private ComponentMapper<MovementComponent> movementM = ComponentMapper.getFor(MovementComponent.class);
private ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class);
yichen0831/Pacman_libGdx
html/src/com/ychstudio/client/HtmlLauncher.java
// Path: core/src/com/ychstudio/PacMan.java // public class PacMan extends Game { // // public SpriteBatch batch; // // @Override // public void create() { // batch = new SpriteBatch(); // setScreen(new PlayScreen(this)); // } // // @Override // public void render() { // super.render(); // } // // @Override // public void dispose() { // batch.dispose(); // GameManager.instance.dispose(); // } // }
import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.backends.gwt.GwtApplication; import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration; import com.ychstudio.PacMan;
package com.ychstudio.client; public class HtmlLauncher extends GwtApplication { @Override public GwtApplicationConfiguration getConfig () { return new GwtApplicationConfiguration(428, 518); } @Override public ApplicationListener createApplicationListener () {
// Path: core/src/com/ychstudio/PacMan.java // public class PacMan extends Game { // // public SpriteBatch batch; // // @Override // public void create() { // batch = new SpriteBatch(); // setScreen(new PlayScreen(this)); // } // // @Override // public void render() { // super.render(); // } // // @Override // public void dispose() { // batch.dispose(); // GameManager.instance.dispose(); // } // } // Path: html/src/com/ychstudio/client/HtmlLauncher.java import com.badlogic.gdx.ApplicationListener; import com.badlogic.gdx.backends.gwt.GwtApplication; import com.badlogic.gdx.backends.gwt.GwtApplicationConfiguration; import com.ychstudio.PacMan; package com.ychstudio.client; public class HtmlLauncher extends GwtApplication { @Override public GwtApplicationConfiguration getConfig () { return new GwtApplicationConfiguration(428, 518); } @Override public ApplicationListener createApplicationListener () {
return new PacMan();
yichen0831/Pacman_libGdx
core/src/com/ychstudio/ai/fsm/GhostState.java
// Path: core/src/com/ychstudio/ai/astar/AStarMap.java // public class AStarMap { // // private Node[][] map; // // private final int width; // private final int height; // // public AStarMap(int width, int height) { // this.width = width; // this.height = height; // // map = new Node[height][width]; // for (int y = 0; y < height; y++) { // for (int x = 0; x < width; x++) { // map[y][x] = new Node(this, x, y); // } // } // } // // public int getWidth() { // return width; // } // // public int getHeight() { // return height; // } // // public Node getNodeAt(int x, int y) { // return map[y][x]; // } // // @Override // public String toString() { // StringBuilder stringBuilder = new StringBuilder(); // for (int y = 0; y < height; y++) { // for (int x = 0; x < width; x++) { // stringBuilder.append(map[y][x].isWall ? "#" : " "); // } // stringBuilder.append("\n"); // } // return stringBuilder.toString(); // } // // } // // Path: core/src/com/ychstudio/components/GhostComponent.java // public class GhostComponent implements Component { // // // state // public static final int MOVE_UP = 0; // public static final int MOVE_DOWN = 1; // public static final int MOVE_LEFT = 2; // public static final int MOVE_RIGHT = 3; // public static final int ESCAPE = 4; // public static final int DIE = 5; // // public static final float WEAK_TIME = 10f; // public float weak_time; // // public GhostAgent ghostAgent; // // private final Body body; // // public int currentState; // // public boolean weaken; // public int hp; // // public GhostComponent(Body body) { // this.body = body; // ghostAgent = new GhostAgent(this); // ghostAgent.stateMachine.setInitialState(GhostState.MOVE_UP); // currentState = MOVE_UP; // weaken = false; // hp = 1; // } // // public Body getBody() { // return body; // } // // public void respawn() { // hp = 1; // weaken = false; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.gdx.ai.fsm.State; import com.badlogic.gdx.ai.msg.Telegram; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.Fixture; import com.badlogic.gdx.physics.box2d.RayCastCallback; import com.badlogic.gdx.physics.box2d.World; import com.ychstudio.ai.astar.AStarMap; import com.ychstudio.components.GhostComponent; import com.ychstudio.gamesys.GameManager; import java.util.ArrayList; import java.util.Iterator; import java.util.List;
package com.ychstudio.ai.fsm; public enum GhostState implements State<GhostAgent> { MOVE_UP() { @Override public void update(GhostAgent entity) {
// Path: core/src/com/ychstudio/ai/astar/AStarMap.java // public class AStarMap { // // private Node[][] map; // // private final int width; // private final int height; // // public AStarMap(int width, int height) { // this.width = width; // this.height = height; // // map = new Node[height][width]; // for (int y = 0; y < height; y++) { // for (int x = 0; x < width; x++) { // map[y][x] = new Node(this, x, y); // } // } // } // // public int getWidth() { // return width; // } // // public int getHeight() { // return height; // } // // public Node getNodeAt(int x, int y) { // return map[y][x]; // } // // @Override // public String toString() { // StringBuilder stringBuilder = new StringBuilder(); // for (int y = 0; y < height; y++) { // for (int x = 0; x < width; x++) { // stringBuilder.append(map[y][x].isWall ? "#" : " "); // } // stringBuilder.append("\n"); // } // return stringBuilder.toString(); // } // // } // // Path: core/src/com/ychstudio/components/GhostComponent.java // public class GhostComponent implements Component { // // // state // public static final int MOVE_UP = 0; // public static final int MOVE_DOWN = 1; // public static final int MOVE_LEFT = 2; // public static final int MOVE_RIGHT = 3; // public static final int ESCAPE = 4; // public static final int DIE = 5; // // public static final float WEAK_TIME = 10f; // public float weak_time; // // public GhostAgent ghostAgent; // // private final Body body; // // public int currentState; // // public boolean weaken; // public int hp; // // public GhostComponent(Body body) { // this.body = body; // ghostAgent = new GhostAgent(this); // ghostAgent.stateMachine.setInitialState(GhostState.MOVE_UP); // currentState = MOVE_UP; // weaken = false; // hp = 1; // } // // public Body getBody() { // return body; // } // // public void respawn() { // hp = 1; // weaken = false; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/ai/fsm/GhostState.java import com.badlogic.gdx.ai.fsm.State; import com.badlogic.gdx.ai.msg.Telegram; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.Fixture; import com.badlogic.gdx.physics.box2d.RayCastCallback; import com.badlogic.gdx.physics.box2d.World; import com.ychstudio.ai.astar.AStarMap; import com.ychstudio.components.GhostComponent; import com.ychstudio.gamesys.GameManager; import java.util.ArrayList; import java.util.Iterator; import java.util.List; package com.ychstudio.ai.fsm; public enum GhostState implements State<GhostAgent> { MOVE_UP() { @Override public void update(GhostAgent entity) {
entity.ghostComponent.currentState = GhostComponent.MOVE_UP;
yichen0831/Pacman_libGdx
core/src/com/ychstudio/ai/PlayerAI.java
// Path: core/src/com/ychstudio/utils/Box2dLocation.java // public class Box2dLocation implements Location<Vector2>{ // // Vector2 position; // float orientation; // // public Box2dLocation() { // position = new Vector2(); // orientation = 0; // } // // @Override // public Vector2 getPosition() { // return position; // } // // @Override // public float getOrientation() { // return orientation; // } // // @Override // public void setOrientation(float orientation) { // this.orientation = orientation; // } // // @Override // public float vectorToAngle(Vector2 vector) { // return Box2dSteeringUtils.vectorToAngle(vector); // } // // @Override // public Vector2 angleToVector(Vector2 outVector, float angle) { // return Box2dSteeringUtils.angleToVector(outVector, angle); // } // // @Override // public Location<Vector2> newLocation() { // return new Box2dLocation(); // } // // } // // Path: core/src/com/ychstudio/utils/Box2dSteeringUtils.java // public final class Box2dSteeringUtils { // // private Box2dSteeringUtils() { // // } // // public static float vectorToAngle(Vector2 vector) { // return (float) Math.atan2(-vector.x, vector.y); // } // // public static Vector2 angleToVector(Vector2 outVector, float angle) { // outVector.x = -(float) Math.sin(angle); // outVector.y = (float) Math.cos(angle); // // return outVector; // } // }
import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.utils.Box2dLocation; import com.ychstudio.utils.Box2dSteeringUtils;
package com.ychstudio.ai; public class PlayerAI implements Location<Vector2> { private final Body body; public PlayerAI(Body body) { this.body = body; } @Override public Vector2 getPosition() { return body.getPosition(); } @Override public float getOrientation() { return body.getAngle(); } @Override public void setOrientation(float orientation) { body.setTransform(getPosition(), orientation); } @Override public float vectorToAngle(Vector2 vector) {
// Path: core/src/com/ychstudio/utils/Box2dLocation.java // public class Box2dLocation implements Location<Vector2>{ // // Vector2 position; // float orientation; // // public Box2dLocation() { // position = new Vector2(); // orientation = 0; // } // // @Override // public Vector2 getPosition() { // return position; // } // // @Override // public float getOrientation() { // return orientation; // } // // @Override // public void setOrientation(float orientation) { // this.orientation = orientation; // } // // @Override // public float vectorToAngle(Vector2 vector) { // return Box2dSteeringUtils.vectorToAngle(vector); // } // // @Override // public Vector2 angleToVector(Vector2 outVector, float angle) { // return Box2dSteeringUtils.angleToVector(outVector, angle); // } // // @Override // public Location<Vector2> newLocation() { // return new Box2dLocation(); // } // // } // // Path: core/src/com/ychstudio/utils/Box2dSteeringUtils.java // public final class Box2dSteeringUtils { // // private Box2dSteeringUtils() { // // } // // public static float vectorToAngle(Vector2 vector) { // return (float) Math.atan2(-vector.x, vector.y); // } // // public static Vector2 angleToVector(Vector2 outVector, float angle) { // outVector.x = -(float) Math.sin(angle); // outVector.y = (float) Math.cos(angle); // // return outVector; // } // } // Path: core/src/com/ychstudio/ai/PlayerAI.java import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.utils.Box2dLocation; import com.ychstudio.utils.Box2dSteeringUtils; package com.ychstudio.ai; public class PlayerAI implements Location<Vector2> { private final Body body; public PlayerAI(Body body) { this.body = body; } @Override public Vector2 getPosition() { return body.getPosition(); } @Override public float getOrientation() { return body.getAngle(); } @Override public void setOrientation(float orientation) { body.setTransform(getPosition(), orientation); } @Override public float vectorToAngle(Vector2 vector) {
return Box2dSteeringUtils.vectorToAngle(vector);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/ai/PlayerAI.java
// Path: core/src/com/ychstudio/utils/Box2dLocation.java // public class Box2dLocation implements Location<Vector2>{ // // Vector2 position; // float orientation; // // public Box2dLocation() { // position = new Vector2(); // orientation = 0; // } // // @Override // public Vector2 getPosition() { // return position; // } // // @Override // public float getOrientation() { // return orientation; // } // // @Override // public void setOrientation(float orientation) { // this.orientation = orientation; // } // // @Override // public float vectorToAngle(Vector2 vector) { // return Box2dSteeringUtils.vectorToAngle(vector); // } // // @Override // public Vector2 angleToVector(Vector2 outVector, float angle) { // return Box2dSteeringUtils.angleToVector(outVector, angle); // } // // @Override // public Location<Vector2> newLocation() { // return new Box2dLocation(); // } // // } // // Path: core/src/com/ychstudio/utils/Box2dSteeringUtils.java // public final class Box2dSteeringUtils { // // private Box2dSteeringUtils() { // // } // // public static float vectorToAngle(Vector2 vector) { // return (float) Math.atan2(-vector.x, vector.y); // } // // public static Vector2 angleToVector(Vector2 outVector, float angle) { // outVector.x = -(float) Math.sin(angle); // outVector.y = (float) Math.cos(angle); // // return outVector; // } // }
import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.utils.Box2dLocation; import com.ychstudio.utils.Box2dSteeringUtils;
package com.ychstudio.ai; public class PlayerAI implements Location<Vector2> { private final Body body; public PlayerAI(Body body) { this.body = body; } @Override public Vector2 getPosition() { return body.getPosition(); } @Override public float getOrientation() { return body.getAngle(); } @Override public void setOrientation(float orientation) { body.setTransform(getPosition(), orientation); } @Override public float vectorToAngle(Vector2 vector) { return Box2dSteeringUtils.vectorToAngle(vector); } @Override public Vector2 angleToVector(Vector2 outVector, float angle) { return Box2dSteeringUtils.angleToVector(outVector, angle); } @Override public Location<Vector2> newLocation() {
// Path: core/src/com/ychstudio/utils/Box2dLocation.java // public class Box2dLocation implements Location<Vector2>{ // // Vector2 position; // float orientation; // // public Box2dLocation() { // position = new Vector2(); // orientation = 0; // } // // @Override // public Vector2 getPosition() { // return position; // } // // @Override // public float getOrientation() { // return orientation; // } // // @Override // public void setOrientation(float orientation) { // this.orientation = orientation; // } // // @Override // public float vectorToAngle(Vector2 vector) { // return Box2dSteeringUtils.vectorToAngle(vector); // } // // @Override // public Vector2 angleToVector(Vector2 outVector, float angle) { // return Box2dSteeringUtils.angleToVector(outVector, angle); // } // // @Override // public Location<Vector2> newLocation() { // return new Box2dLocation(); // } // // } // // Path: core/src/com/ychstudio/utils/Box2dSteeringUtils.java // public final class Box2dSteeringUtils { // // private Box2dSteeringUtils() { // // } // // public static float vectorToAngle(Vector2 vector) { // return (float) Math.atan2(-vector.x, vector.y); // } // // public static Vector2 angleToVector(Vector2 outVector, float angle) { // outVector.x = -(float) Math.sin(angle); // outVector.y = (float) Math.cos(angle); // // return outVector; // } // } // Path: core/src/com/ychstudio/ai/PlayerAI.java import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.utils.Box2dLocation; import com.ychstudio.utils.Box2dSteeringUtils; package com.ychstudio.ai; public class PlayerAI implements Location<Vector2> { private final Body body; public PlayerAI(Body body) { this.body = body; } @Override public Vector2 getPosition() { return body.getPosition(); } @Override public float getOrientation() { return body.getAngle(); } @Override public void setOrientation(float orientation) { body.setTransform(getPosition(), orientation); } @Override public float vectorToAngle(Vector2 vector) { return Box2dSteeringUtils.vectorToAngle(vector); } @Override public Vector2 angleToVector(Vector2 outVector, float angle) { return Box2dSteeringUtils.angleToVector(outVector, angle); } @Override public Location<Vector2> newLocation() {
return new Box2dLocation();
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/PlayerSystem.java
// Path: core/src/com/ychstudio/components/MovementComponent.java // public class MovementComponent implements Component { // // public float speed = 3.6f; // public Body body; // // public MovementComponent(Body body) { // this.body = body; // } // } // // Path: core/src/com/ychstudio/components/PlayerComponent.java // public class PlayerComponent implements Component { // // public static final int IDLE = 0; // public static final int IDLE_UP = 0; // public static final int IDLE_DOWN = 1; // public static final int IDLE_LEFT = 2; // public static final int IDLE_RIGHT = 3; // // public static final int MOVE_UP = 4; // public static final int MOVE_DOWN = 5; // public static final int MOVE_LEFT = 6; // public static final int MOVE_RIGHT = 7; // public static final int DIE = 8; // // public PlayerAI ai; // public PlayerAgent playerAgent; // // private final Body body; // // public int currentState; // // public int hp; // // public float invincibleTimer; // // public PlayerComponent(Body body) { // this.body = body; // ai = new PlayerAI(body); // playerAgent = new PlayerAgent(this); // playerAgent.stateMachine.setInitialState(PlayerState.IDLE_RIGHT); // currentState = IDLE_RIGHT; // hp = 1; // invincibleTimer = 0; // } // // public Body getBody() { // return body; // } // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.Fixture; import com.badlogic.gdx.physics.box2d.RayCastCallback; import com.badlogic.gdx.physics.box2d.World; import com.ychstudio.components.MovementComponent; import com.ychstudio.components.PlayerComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.gamesys.GameManager;
package com.ychstudio.systems; public class PlayerSystem extends IteratingSystem { private final ComponentMapper<PlayerComponent> playerM = ComponentMapper.getFor(PlayerComponent.class);
// Path: core/src/com/ychstudio/components/MovementComponent.java // public class MovementComponent implements Component { // // public float speed = 3.6f; // public Body body; // // public MovementComponent(Body body) { // this.body = body; // } // } // // Path: core/src/com/ychstudio/components/PlayerComponent.java // public class PlayerComponent implements Component { // // public static final int IDLE = 0; // public static final int IDLE_UP = 0; // public static final int IDLE_DOWN = 1; // public static final int IDLE_LEFT = 2; // public static final int IDLE_RIGHT = 3; // // public static final int MOVE_UP = 4; // public static final int MOVE_DOWN = 5; // public static final int MOVE_LEFT = 6; // public static final int MOVE_RIGHT = 7; // public static final int DIE = 8; // // public PlayerAI ai; // public PlayerAgent playerAgent; // // private final Body body; // // public int currentState; // // public int hp; // // public float invincibleTimer; // // public PlayerComponent(Body body) { // this.body = body; // ai = new PlayerAI(body); // playerAgent = new PlayerAgent(this); // playerAgent.stateMachine.setInitialState(PlayerState.IDLE_RIGHT); // currentState = IDLE_RIGHT; // hp = 1; // invincibleTimer = 0; // } // // public Body getBody() { // return body; // } // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/systems/PlayerSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.Fixture; import com.badlogic.gdx.physics.box2d.RayCastCallback; import com.badlogic.gdx.physics.box2d.World; import com.ychstudio.components.MovementComponent; import com.ychstudio.components.PlayerComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.gamesys.GameManager; package com.ychstudio.systems; public class PlayerSystem extends IteratingSystem { private final ComponentMapper<PlayerComponent> playerM = ComponentMapper.getFor(PlayerComponent.class);
private final ComponentMapper<MovementComponent> movementM = ComponentMapper.getFor(MovementComponent.class);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/PlayerSystem.java
// Path: core/src/com/ychstudio/components/MovementComponent.java // public class MovementComponent implements Component { // // public float speed = 3.6f; // public Body body; // // public MovementComponent(Body body) { // this.body = body; // } // } // // Path: core/src/com/ychstudio/components/PlayerComponent.java // public class PlayerComponent implements Component { // // public static final int IDLE = 0; // public static final int IDLE_UP = 0; // public static final int IDLE_DOWN = 1; // public static final int IDLE_LEFT = 2; // public static final int IDLE_RIGHT = 3; // // public static final int MOVE_UP = 4; // public static final int MOVE_DOWN = 5; // public static final int MOVE_LEFT = 6; // public static final int MOVE_RIGHT = 7; // public static final int DIE = 8; // // public PlayerAI ai; // public PlayerAgent playerAgent; // // private final Body body; // // public int currentState; // // public int hp; // // public float invincibleTimer; // // public PlayerComponent(Body body) { // this.body = body; // ai = new PlayerAI(body); // playerAgent = new PlayerAgent(this); // playerAgent.stateMachine.setInitialState(PlayerState.IDLE_RIGHT); // currentState = IDLE_RIGHT; // hp = 1; // invincibleTimer = 0; // } // // public Body getBody() { // return body; // } // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.Fixture; import com.badlogic.gdx.physics.box2d.RayCastCallback; import com.badlogic.gdx.physics.box2d.World; import com.ychstudio.components.MovementComponent; import com.ychstudio.components.PlayerComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.gamesys.GameManager;
package com.ychstudio.systems; public class PlayerSystem extends IteratingSystem { private final ComponentMapper<PlayerComponent> playerM = ComponentMapper.getFor(PlayerComponent.class); private final ComponentMapper<MovementComponent> movementM = ComponentMapper.getFor(MovementComponent.class);
// Path: core/src/com/ychstudio/components/MovementComponent.java // public class MovementComponent implements Component { // // public float speed = 3.6f; // public Body body; // // public MovementComponent(Body body) { // this.body = body; // } // } // // Path: core/src/com/ychstudio/components/PlayerComponent.java // public class PlayerComponent implements Component { // // public static final int IDLE = 0; // public static final int IDLE_UP = 0; // public static final int IDLE_DOWN = 1; // public static final int IDLE_LEFT = 2; // public static final int IDLE_RIGHT = 3; // // public static final int MOVE_UP = 4; // public static final int MOVE_DOWN = 5; // public static final int MOVE_LEFT = 6; // public static final int MOVE_RIGHT = 7; // public static final int DIE = 8; // // public PlayerAI ai; // public PlayerAgent playerAgent; // // private final Body body; // // public int currentState; // // public int hp; // // public float invincibleTimer; // // public PlayerComponent(Body body) { // this.body = body; // ai = new PlayerAI(body); // playerAgent = new PlayerAgent(this); // playerAgent.stateMachine.setInitialState(PlayerState.IDLE_RIGHT); // currentState = IDLE_RIGHT; // hp = 1; // invincibleTimer = 0; // } // // public Body getBody() { // return body; // } // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/systems/PlayerSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.Gdx; import com.badlogic.gdx.Input; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.badlogic.gdx.physics.box2d.Fixture; import com.badlogic.gdx.physics.box2d.RayCastCallback; import com.badlogic.gdx.physics.box2d.World; import com.ychstudio.components.MovementComponent; import com.ychstudio.components.PlayerComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.gamesys.GameManager; package com.ychstudio.systems; public class PlayerSystem extends IteratingSystem { private final ComponentMapper<PlayerComponent> playerM = ComponentMapper.getFor(PlayerComponent.class); private final ComponentMapper<MovementComponent> movementM = ComponentMapper.getFor(MovementComponent.class);
private final ComponentMapper<StateComponent> stateM = ComponentMapper.getFor(StateComponent.class);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/AnimationSystem.java
// Path: core/src/com/ychstudio/components/AnimationComponent.java // public class AnimationComponent implements Component { // public IntMap<Animation> animations = new IntMap<>(); // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/components/TextureComponent.java // public class TextureComponent implements Component { // // public TextureRegion region; // // public TextureComponent(TextureRegion textureRegion) { // region = new TextureRegion(textureRegion); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.ychstudio.components.AnimationComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.components.TextureComponent;
package com.ychstudio.systems; public class AnimationSystem extends IteratingSystem { private final ComponentMapper<TextureComponent> textureM = ComponentMapper.getFor(TextureComponent.class);
// Path: core/src/com/ychstudio/components/AnimationComponent.java // public class AnimationComponent implements Component { // public IntMap<Animation> animations = new IntMap<>(); // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/components/TextureComponent.java // public class TextureComponent implements Component { // // public TextureRegion region; // // public TextureComponent(TextureRegion textureRegion) { // region = new TextureRegion(textureRegion); // } // } // Path: core/src/com/ychstudio/systems/AnimationSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.ychstudio.components.AnimationComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.components.TextureComponent; package com.ychstudio.systems; public class AnimationSystem extends IteratingSystem { private final ComponentMapper<TextureComponent> textureM = ComponentMapper.getFor(TextureComponent.class);
private final ComponentMapper<AnimationComponent> animationM = ComponentMapper.getFor(AnimationComponent.class);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/AnimationSystem.java
// Path: core/src/com/ychstudio/components/AnimationComponent.java // public class AnimationComponent implements Component { // public IntMap<Animation> animations = new IntMap<>(); // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/components/TextureComponent.java // public class TextureComponent implements Component { // // public TextureRegion region; // // public TextureComponent(TextureRegion textureRegion) { // region = new TextureRegion(textureRegion); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.ychstudio.components.AnimationComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.components.TextureComponent;
package com.ychstudio.systems; public class AnimationSystem extends IteratingSystem { private final ComponentMapper<TextureComponent> textureM = ComponentMapper.getFor(TextureComponent.class); private final ComponentMapper<AnimationComponent> animationM = ComponentMapper.getFor(AnimationComponent.class);
// Path: core/src/com/ychstudio/components/AnimationComponent.java // public class AnimationComponent implements Component { // public IntMap<Animation> animations = new IntMap<>(); // } // // Path: core/src/com/ychstudio/components/StateComponent.java // public class StateComponent implements Component { // private float stateTime; // private int state; // // public StateComponent() { // this(0); // } // // public StateComponent(int state) { // this.state = state; // stateTime = 0; // } // // public void increaseStateTime(float delta) { // stateTime += delta; // } // // public float getStateTime() { // return stateTime; // } // // public void resetStateTime() { // stateTime = 0; // } // // public int getState() { // return state; // } // // public void setState(int newState) { // if (state == newState) { // return; // } // state = newState; // stateTime = 0; // } // } // // Path: core/src/com/ychstudio/components/TextureComponent.java // public class TextureComponent implements Component { // // public TextureRegion region; // // public TextureComponent(TextureRegion textureRegion) { // region = new TextureRegion(textureRegion); // } // } // Path: core/src/com/ychstudio/systems/AnimationSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.ychstudio.components.AnimationComponent; import com.ychstudio.components.StateComponent; import com.ychstudio.components.TextureComponent; package com.ychstudio.systems; public class AnimationSystem extends IteratingSystem { private final ComponentMapper<TextureComponent> textureM = ComponentMapper.getFor(TextureComponent.class); private final ComponentMapper<AnimationComponent> animationM = ComponentMapper.getFor(AnimationComponent.class);
private final ComponentMapper<StateComponent> stateM = ComponentMapper.getFor(StateComponent.class);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/ai/GhostAI.java
// Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // // Path: core/src/com/ychstudio/utils/Box2dLocation.java // public class Box2dLocation implements Location<Vector2>{ // // Vector2 position; // float orientation; // // public Box2dLocation() { // position = new Vector2(); // orientation = 0; // } // // @Override // public Vector2 getPosition() { // return position; // } // // @Override // public float getOrientation() { // return orientation; // } // // @Override // public void setOrientation(float orientation) { // this.orientation = orientation; // } // // @Override // public float vectorToAngle(Vector2 vector) { // return Box2dSteeringUtils.vectorToAngle(vector); // } // // @Override // public Vector2 angleToVector(Vector2 outVector, float angle) { // return Box2dSteeringUtils.angleToVector(outVector, angle); // } // // @Override // public Location<Vector2> newLocation() { // return new Box2dLocation(); // } // // } // // Path: core/src/com/ychstudio/utils/Box2dSteeringUtils.java // public final class Box2dSteeringUtils { // // private Box2dSteeringUtils() { // // } // // public static float vectorToAngle(Vector2 vector) { // return (float) Math.atan2(-vector.x, vector.y); // } // // public static Vector2 angleToVector(Vector2 outVector, float angle) { // outVector.x = -(float) Math.sin(angle); // outVector.y = (float) Math.cos(angle); // // return outVector; // } // }
import com.badlogic.gdx.ai.steer.Steerable; import com.badlogic.gdx.ai.steer.SteeringAcceleration; import com.badlogic.gdx.ai.steer.SteeringBehavior; import com.badlogic.gdx.ai.steer.behaviors.Arrive; import com.badlogic.gdx.ai.steer.behaviors.Wander; import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.gamesys.GameManager; import com.ychstudio.utils.Box2dLocation; import com.ychstudio.utils.Box2dSteeringUtils;
private SteeringBehavior<Vector2> steeringBehavior; private final SteeringAcceleration<Vector2> steeringOutput = new SteeringAcceleration<>(new Vector2()); private Wander<Vector2> wanderBehavior; private Arrive<Vector2> arriveBehavior; public GhostAI(Body body, float boundingRadius) { this.body = body; this.boundingRadius = boundingRadius; tagged = false; maxAngularAcceleration = 1.0f; maxLinearAcceleration = 1.0f; maxLinearSpeed = 2f; maxAngularSpeed = 1.0f; createWanderBehavior(); } private void createWanderBehavior() { wanderBehavior = new Wander<>(this) .setEnabled(true) .setWanderRadius(2f) .setWanderRate(MathUtils.PI2 * 4); } public void setBehavior(int behavior) { switch (behavior) { case ARRIVE_BEHAVIOR: if (arriveBehavior == null) {
// Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // // Path: core/src/com/ychstudio/utils/Box2dLocation.java // public class Box2dLocation implements Location<Vector2>{ // // Vector2 position; // float orientation; // // public Box2dLocation() { // position = new Vector2(); // orientation = 0; // } // // @Override // public Vector2 getPosition() { // return position; // } // // @Override // public float getOrientation() { // return orientation; // } // // @Override // public void setOrientation(float orientation) { // this.orientation = orientation; // } // // @Override // public float vectorToAngle(Vector2 vector) { // return Box2dSteeringUtils.vectorToAngle(vector); // } // // @Override // public Vector2 angleToVector(Vector2 outVector, float angle) { // return Box2dSteeringUtils.angleToVector(outVector, angle); // } // // @Override // public Location<Vector2> newLocation() { // return new Box2dLocation(); // } // // } // // Path: core/src/com/ychstudio/utils/Box2dSteeringUtils.java // public final class Box2dSteeringUtils { // // private Box2dSteeringUtils() { // // } // // public static float vectorToAngle(Vector2 vector) { // return (float) Math.atan2(-vector.x, vector.y); // } // // public static Vector2 angleToVector(Vector2 outVector, float angle) { // outVector.x = -(float) Math.sin(angle); // outVector.y = (float) Math.cos(angle); // // return outVector; // } // } // Path: core/src/com/ychstudio/ai/GhostAI.java import com.badlogic.gdx.ai.steer.Steerable; import com.badlogic.gdx.ai.steer.SteeringAcceleration; import com.badlogic.gdx.ai.steer.SteeringBehavior; import com.badlogic.gdx.ai.steer.behaviors.Arrive; import com.badlogic.gdx.ai.steer.behaviors.Wander; import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.gamesys.GameManager; import com.ychstudio.utils.Box2dLocation; import com.ychstudio.utils.Box2dSteeringUtils; private SteeringBehavior<Vector2> steeringBehavior; private final SteeringAcceleration<Vector2> steeringOutput = new SteeringAcceleration<>(new Vector2()); private Wander<Vector2> wanderBehavior; private Arrive<Vector2> arriveBehavior; public GhostAI(Body body, float boundingRadius) { this.body = body; this.boundingRadius = boundingRadius; tagged = false; maxAngularAcceleration = 1.0f; maxLinearAcceleration = 1.0f; maxLinearSpeed = 2f; maxAngularSpeed = 1.0f; createWanderBehavior(); } private void createWanderBehavior() { wanderBehavior = new Wander<>(this) .setEnabled(true) .setWanderRadius(2f) .setWanderRate(MathUtils.PI2 * 4); } public void setBehavior(int behavior) { switch (behavior) { case ARRIVE_BEHAVIOR: if (arriveBehavior == null) {
if (GameManager.instance.playerLocation != null) {
yichen0831/Pacman_libGdx
core/src/com/ychstudio/ai/GhostAI.java
// Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // // Path: core/src/com/ychstudio/utils/Box2dLocation.java // public class Box2dLocation implements Location<Vector2>{ // // Vector2 position; // float orientation; // // public Box2dLocation() { // position = new Vector2(); // orientation = 0; // } // // @Override // public Vector2 getPosition() { // return position; // } // // @Override // public float getOrientation() { // return orientation; // } // // @Override // public void setOrientation(float orientation) { // this.orientation = orientation; // } // // @Override // public float vectorToAngle(Vector2 vector) { // return Box2dSteeringUtils.vectorToAngle(vector); // } // // @Override // public Vector2 angleToVector(Vector2 outVector, float angle) { // return Box2dSteeringUtils.angleToVector(outVector, angle); // } // // @Override // public Location<Vector2> newLocation() { // return new Box2dLocation(); // } // // } // // Path: core/src/com/ychstudio/utils/Box2dSteeringUtils.java // public final class Box2dSteeringUtils { // // private Box2dSteeringUtils() { // // } // // public static float vectorToAngle(Vector2 vector) { // return (float) Math.atan2(-vector.x, vector.y); // } // // public static Vector2 angleToVector(Vector2 outVector, float angle) { // outVector.x = -(float) Math.sin(angle); // outVector.y = (float) Math.cos(angle); // // return outVector; // } // }
import com.badlogic.gdx.ai.steer.Steerable; import com.badlogic.gdx.ai.steer.SteeringAcceleration; import com.badlogic.gdx.ai.steer.SteeringBehavior; import com.badlogic.gdx.ai.steer.behaviors.Arrive; import com.badlogic.gdx.ai.steer.behaviors.Wander; import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.gamesys.GameManager; import com.ychstudio.utils.Box2dLocation; import com.ychstudio.utils.Box2dSteeringUtils;
return boundingRadius; } @Override public boolean isTagged() { return tagged; } @Override public void setTagged(boolean tagged) { this.tagged = tagged; } @Override public Vector2 getPosition() { return body.getPosition(); } @Override public float getOrientation() { return body.getAngle(); } @Override public void setOrientation(float orientation) { body.setTransform(getPosition(), orientation); } @Override public float vectorToAngle(Vector2 vector) {
// Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // // Path: core/src/com/ychstudio/utils/Box2dLocation.java // public class Box2dLocation implements Location<Vector2>{ // // Vector2 position; // float orientation; // // public Box2dLocation() { // position = new Vector2(); // orientation = 0; // } // // @Override // public Vector2 getPosition() { // return position; // } // // @Override // public float getOrientation() { // return orientation; // } // // @Override // public void setOrientation(float orientation) { // this.orientation = orientation; // } // // @Override // public float vectorToAngle(Vector2 vector) { // return Box2dSteeringUtils.vectorToAngle(vector); // } // // @Override // public Vector2 angleToVector(Vector2 outVector, float angle) { // return Box2dSteeringUtils.angleToVector(outVector, angle); // } // // @Override // public Location<Vector2> newLocation() { // return new Box2dLocation(); // } // // } // // Path: core/src/com/ychstudio/utils/Box2dSteeringUtils.java // public final class Box2dSteeringUtils { // // private Box2dSteeringUtils() { // // } // // public static float vectorToAngle(Vector2 vector) { // return (float) Math.atan2(-vector.x, vector.y); // } // // public static Vector2 angleToVector(Vector2 outVector, float angle) { // outVector.x = -(float) Math.sin(angle); // outVector.y = (float) Math.cos(angle); // // return outVector; // } // } // Path: core/src/com/ychstudio/ai/GhostAI.java import com.badlogic.gdx.ai.steer.Steerable; import com.badlogic.gdx.ai.steer.SteeringAcceleration; import com.badlogic.gdx.ai.steer.SteeringBehavior; import com.badlogic.gdx.ai.steer.behaviors.Arrive; import com.badlogic.gdx.ai.steer.behaviors.Wander; import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.gamesys.GameManager; import com.ychstudio.utils.Box2dLocation; import com.ychstudio.utils.Box2dSteeringUtils; return boundingRadius; } @Override public boolean isTagged() { return tagged; } @Override public void setTagged(boolean tagged) { this.tagged = tagged; } @Override public Vector2 getPosition() { return body.getPosition(); } @Override public float getOrientation() { return body.getAngle(); } @Override public void setOrientation(float orientation) { body.setTransform(getPosition(), orientation); } @Override public float vectorToAngle(Vector2 vector) {
return Box2dSteeringUtils.vectorToAngle(vector);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/ai/GhostAI.java
// Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // // Path: core/src/com/ychstudio/utils/Box2dLocation.java // public class Box2dLocation implements Location<Vector2>{ // // Vector2 position; // float orientation; // // public Box2dLocation() { // position = new Vector2(); // orientation = 0; // } // // @Override // public Vector2 getPosition() { // return position; // } // // @Override // public float getOrientation() { // return orientation; // } // // @Override // public void setOrientation(float orientation) { // this.orientation = orientation; // } // // @Override // public float vectorToAngle(Vector2 vector) { // return Box2dSteeringUtils.vectorToAngle(vector); // } // // @Override // public Vector2 angleToVector(Vector2 outVector, float angle) { // return Box2dSteeringUtils.angleToVector(outVector, angle); // } // // @Override // public Location<Vector2> newLocation() { // return new Box2dLocation(); // } // // } // // Path: core/src/com/ychstudio/utils/Box2dSteeringUtils.java // public final class Box2dSteeringUtils { // // private Box2dSteeringUtils() { // // } // // public static float vectorToAngle(Vector2 vector) { // return (float) Math.atan2(-vector.x, vector.y); // } // // public static Vector2 angleToVector(Vector2 outVector, float angle) { // outVector.x = -(float) Math.sin(angle); // outVector.y = (float) Math.cos(angle); // // return outVector; // } // }
import com.badlogic.gdx.ai.steer.Steerable; import com.badlogic.gdx.ai.steer.SteeringAcceleration; import com.badlogic.gdx.ai.steer.SteeringBehavior; import com.badlogic.gdx.ai.steer.behaviors.Arrive; import com.badlogic.gdx.ai.steer.behaviors.Wander; import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.gamesys.GameManager; import com.ychstudio.utils.Box2dLocation; import com.ychstudio.utils.Box2dSteeringUtils;
this.tagged = tagged; } @Override public Vector2 getPosition() { return body.getPosition(); } @Override public float getOrientation() { return body.getAngle(); } @Override public void setOrientation(float orientation) { body.setTransform(getPosition(), orientation); } @Override public float vectorToAngle(Vector2 vector) { return Box2dSteeringUtils.vectorToAngle(vector); } @Override public Vector2 angleToVector(Vector2 outVector, float angle) { return Box2dSteeringUtils.angleToVector(outVector, angle); } @Override public Location<Vector2> newLocation() {
// Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // // Path: core/src/com/ychstudio/utils/Box2dLocation.java // public class Box2dLocation implements Location<Vector2>{ // // Vector2 position; // float orientation; // // public Box2dLocation() { // position = new Vector2(); // orientation = 0; // } // // @Override // public Vector2 getPosition() { // return position; // } // // @Override // public float getOrientation() { // return orientation; // } // // @Override // public void setOrientation(float orientation) { // this.orientation = orientation; // } // // @Override // public float vectorToAngle(Vector2 vector) { // return Box2dSteeringUtils.vectorToAngle(vector); // } // // @Override // public Vector2 angleToVector(Vector2 outVector, float angle) { // return Box2dSteeringUtils.angleToVector(outVector, angle); // } // // @Override // public Location<Vector2> newLocation() { // return new Box2dLocation(); // } // // } // // Path: core/src/com/ychstudio/utils/Box2dSteeringUtils.java // public final class Box2dSteeringUtils { // // private Box2dSteeringUtils() { // // } // // public static float vectorToAngle(Vector2 vector) { // return (float) Math.atan2(-vector.x, vector.y); // } // // public static Vector2 angleToVector(Vector2 outVector, float angle) { // outVector.x = -(float) Math.sin(angle); // outVector.y = (float) Math.cos(angle); // // return outVector; // } // } // Path: core/src/com/ychstudio/ai/GhostAI.java import com.badlogic.gdx.ai.steer.Steerable; import com.badlogic.gdx.ai.steer.SteeringAcceleration; import com.badlogic.gdx.ai.steer.SteeringBehavior; import com.badlogic.gdx.ai.steer.behaviors.Arrive; import com.badlogic.gdx.ai.steer.behaviors.Wander; import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.gamesys.GameManager; import com.ychstudio.utils.Box2dLocation; import com.ychstudio.utils.Box2dSteeringUtils; this.tagged = tagged; } @Override public Vector2 getPosition() { return body.getPosition(); } @Override public float getOrientation() { return body.getAngle(); } @Override public void setOrientation(float orientation) { body.setTransform(getPosition(), orientation); } @Override public float vectorToAngle(Vector2 vector) { return Box2dSteeringUtils.vectorToAngle(vector); } @Override public Vector2 angleToVector(Vector2 outVector, float angle) { return Box2dSteeringUtils.angleToVector(outVector, angle); } @Override public Location<Vector2> newLocation() {
return new Box2dLocation();
yichen0831/Pacman_libGdx
core/src/com/ychstudio/ai/fsm/GhostAgent.java
// Path: core/src/com/ychstudio/ai/astar/Node.java // public class Node { // // public final int x; // public final int y; // public boolean isWall; // private final int index; // private final Array<Connection<Node>> connections; // // public Node(AStarMap map, int x, int y) { // this.x = x; // this.y = y; // this.index = x * map.getHeight() + y; // this.isWall = false; // this.connections = new Array<Connection<Node>>(); // } // // public int getIndex () { // return index; // } // // public Array<Connection<Node>> getConnections () { // return connections; // } // // @Override // public String toString() { // return "Node: (" + x + ", " + y + ")"; // } // // } // // Path: core/src/com/ychstudio/components/GhostComponent.java // public class GhostComponent implements Component { // // // state // public static final int MOVE_UP = 0; // public static final int MOVE_DOWN = 1; // public static final int MOVE_LEFT = 2; // public static final int MOVE_RIGHT = 3; // public static final int ESCAPE = 4; // public static final int DIE = 5; // // public static final float WEAK_TIME = 10f; // public float weak_time; // // public GhostAgent ghostAgent; // // private final Body body; // // public int currentState; // // public boolean weaken; // public int hp; // // public GhostComponent(Body body) { // this.body = body; // ghostAgent = new GhostAgent(this); // ghostAgent.stateMachine.setInitialState(GhostState.MOVE_UP); // currentState = MOVE_UP; // weaken = false; // hp = 1; // } // // public Body getBody() { // return body; // } // // public void respawn() { // hp = 1; // weaken = false; // } // }
import com.badlogic.gdx.ai.fsm.DefaultStateMachine; import com.badlogic.gdx.ai.fsm.StateMachine; import com.badlogic.gdx.ai.msg.Telegram; import com.badlogic.gdx.ai.msg.Telegraph; import com.badlogic.gdx.math.Vector2; import com.ychstudio.ai.astar.Node; import com.ychstudio.components.GhostComponent;
package com.ychstudio.ai.fsm; public class GhostAgent implements Telegraph { public StateMachine<GhostAgent, GhostState> stateMachine;
// Path: core/src/com/ychstudio/ai/astar/Node.java // public class Node { // // public final int x; // public final int y; // public boolean isWall; // private final int index; // private final Array<Connection<Node>> connections; // // public Node(AStarMap map, int x, int y) { // this.x = x; // this.y = y; // this.index = x * map.getHeight() + y; // this.isWall = false; // this.connections = new Array<Connection<Node>>(); // } // // public int getIndex () { // return index; // } // // public Array<Connection<Node>> getConnections () { // return connections; // } // // @Override // public String toString() { // return "Node: (" + x + ", " + y + ")"; // } // // } // // Path: core/src/com/ychstudio/components/GhostComponent.java // public class GhostComponent implements Component { // // // state // public static final int MOVE_UP = 0; // public static final int MOVE_DOWN = 1; // public static final int MOVE_LEFT = 2; // public static final int MOVE_RIGHT = 3; // public static final int ESCAPE = 4; // public static final int DIE = 5; // // public static final float WEAK_TIME = 10f; // public float weak_time; // // public GhostAgent ghostAgent; // // private final Body body; // // public int currentState; // // public boolean weaken; // public int hp; // // public GhostComponent(Body body) { // this.body = body; // ghostAgent = new GhostAgent(this); // ghostAgent.stateMachine.setInitialState(GhostState.MOVE_UP); // currentState = MOVE_UP; // weaken = false; // hp = 1; // } // // public Body getBody() { // return body; // } // // public void respawn() { // hp = 1; // weaken = false; // } // } // Path: core/src/com/ychstudio/ai/fsm/GhostAgent.java import com.badlogic.gdx.ai.fsm.DefaultStateMachine; import com.badlogic.gdx.ai.fsm.StateMachine; import com.badlogic.gdx.ai.msg.Telegram; import com.badlogic.gdx.ai.msg.Telegraph; import com.badlogic.gdx.math.Vector2; import com.ychstudio.ai.astar.Node; import com.ychstudio.components.GhostComponent; package com.ychstudio.ai.fsm; public class GhostAgent implements Telegraph { public StateMachine<GhostAgent, GhostState> stateMachine;
public GhostComponent ghostComponent;
yichen0831/Pacman_libGdx
core/src/com/ychstudio/ai/fsm/GhostAgent.java
// Path: core/src/com/ychstudio/ai/astar/Node.java // public class Node { // // public final int x; // public final int y; // public boolean isWall; // private final int index; // private final Array<Connection<Node>> connections; // // public Node(AStarMap map, int x, int y) { // this.x = x; // this.y = y; // this.index = x * map.getHeight() + y; // this.isWall = false; // this.connections = new Array<Connection<Node>>(); // } // // public int getIndex () { // return index; // } // // public Array<Connection<Node>> getConnections () { // return connections; // } // // @Override // public String toString() { // return "Node: (" + x + ", " + y + ")"; // } // // } // // Path: core/src/com/ychstudio/components/GhostComponent.java // public class GhostComponent implements Component { // // // state // public static final int MOVE_UP = 0; // public static final int MOVE_DOWN = 1; // public static final int MOVE_LEFT = 2; // public static final int MOVE_RIGHT = 3; // public static final int ESCAPE = 4; // public static final int DIE = 5; // // public static final float WEAK_TIME = 10f; // public float weak_time; // // public GhostAgent ghostAgent; // // private final Body body; // // public int currentState; // // public boolean weaken; // public int hp; // // public GhostComponent(Body body) { // this.body = body; // ghostAgent = new GhostAgent(this); // ghostAgent.stateMachine.setInitialState(GhostState.MOVE_UP); // currentState = MOVE_UP; // weaken = false; // hp = 1; // } // // public Body getBody() { // return body; // } // // public void respawn() { // hp = 1; // weaken = false; // } // }
import com.badlogic.gdx.ai.fsm.DefaultStateMachine; import com.badlogic.gdx.ai.fsm.StateMachine; import com.badlogic.gdx.ai.msg.Telegram; import com.badlogic.gdx.ai.msg.Telegraph; import com.badlogic.gdx.math.Vector2; import com.ychstudio.ai.astar.Node; import com.ychstudio.components.GhostComponent;
package com.ychstudio.ai.fsm; public class GhostAgent implements Telegraph { public StateMachine<GhostAgent, GhostState> stateMachine; public GhostComponent ghostComponent; public float speed = 2.4f; public float timer;
// Path: core/src/com/ychstudio/ai/astar/Node.java // public class Node { // // public final int x; // public final int y; // public boolean isWall; // private final int index; // private final Array<Connection<Node>> connections; // // public Node(AStarMap map, int x, int y) { // this.x = x; // this.y = y; // this.index = x * map.getHeight() + y; // this.isWall = false; // this.connections = new Array<Connection<Node>>(); // } // // public int getIndex () { // return index; // } // // public Array<Connection<Node>> getConnections () { // return connections; // } // // @Override // public String toString() { // return "Node: (" + x + ", " + y + ")"; // } // // } // // Path: core/src/com/ychstudio/components/GhostComponent.java // public class GhostComponent implements Component { // // // state // public static final int MOVE_UP = 0; // public static final int MOVE_DOWN = 1; // public static final int MOVE_LEFT = 2; // public static final int MOVE_RIGHT = 3; // public static final int ESCAPE = 4; // public static final int DIE = 5; // // public static final float WEAK_TIME = 10f; // public float weak_time; // // public GhostAgent ghostAgent; // // private final Body body; // // public int currentState; // // public boolean weaken; // public int hp; // // public GhostComponent(Body body) { // this.body = body; // ghostAgent = new GhostAgent(this); // ghostAgent.stateMachine.setInitialState(GhostState.MOVE_UP); // currentState = MOVE_UP; // weaken = false; // hp = 1; // } // // public Body getBody() { // return body; // } // // public void respawn() { // hp = 1; // weaken = false; // } // } // Path: core/src/com/ychstudio/ai/fsm/GhostAgent.java import com.badlogic.gdx.ai.fsm.DefaultStateMachine; import com.badlogic.gdx.ai.fsm.StateMachine; import com.badlogic.gdx.ai.msg.Telegram; import com.badlogic.gdx.ai.msg.Telegraph; import com.badlogic.gdx.math.Vector2; import com.ychstudio.ai.astar.Node; import com.ychstudio.components.GhostComponent; package com.ychstudio.ai.fsm; public class GhostAgent implements Telegraph { public StateMachine<GhostAgent, GhostState> stateMachine; public GhostComponent ghostComponent; public float speed = 2.4f; public float timer;
public Node nextNode; // for pursue or escape
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/PillSystem.java
// Path: core/src/com/ychstudio/components/MovementComponent.java // public class MovementComponent implements Component { // // public float speed = 3.6f; // public Body body; // // public MovementComponent(Body body) { // this.body = body; // } // } // // Path: core/src/com/ychstudio/components/PillComponent.java // public class PillComponent implements Component { // public boolean eaten; // public boolean big; // // public PillComponent(boolean isBig) { // big = isBig; // eaten = false; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.components.MovementComponent; import com.ychstudio.components.PillComponent; import com.ychstudio.gamesys.GameManager;
package com.ychstudio.systems; public class PillSystem extends IteratingSystem { private final ComponentMapper<PillComponent> pillM = ComponentMapper.getFor(PillComponent.class);
// Path: core/src/com/ychstudio/components/MovementComponent.java // public class MovementComponent implements Component { // // public float speed = 3.6f; // public Body body; // // public MovementComponent(Body body) { // this.body = body; // } // } // // Path: core/src/com/ychstudio/components/PillComponent.java // public class PillComponent implements Component { // public boolean eaten; // public boolean big; // // public PillComponent(boolean isBig) { // big = isBig; // eaten = false; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/systems/PillSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.components.MovementComponent; import com.ychstudio.components.PillComponent; import com.ychstudio.gamesys.GameManager; package com.ychstudio.systems; public class PillSystem extends IteratingSystem { private final ComponentMapper<PillComponent> pillM = ComponentMapper.getFor(PillComponent.class);
private final ComponentMapper<MovementComponent> movementM = ComponentMapper.getFor(MovementComponent.class);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/PillSystem.java
// Path: core/src/com/ychstudio/components/MovementComponent.java // public class MovementComponent implements Component { // // public float speed = 3.6f; // public Body body; // // public MovementComponent(Body body) { // this.body = body; // } // } // // Path: core/src/com/ychstudio/components/PillComponent.java // public class PillComponent implements Component { // public boolean eaten; // public boolean big; // // public PillComponent(boolean isBig) { // big = isBig; // eaten = false; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.components.MovementComponent; import com.ychstudio.components.PillComponent; import com.ychstudio.gamesys.GameManager;
package com.ychstudio.systems; public class PillSystem extends IteratingSystem { private final ComponentMapper<PillComponent> pillM = ComponentMapper.getFor(PillComponent.class); private final ComponentMapper<MovementComponent> movementM = ComponentMapper.getFor(MovementComponent.class); public PillSystem() { super(Family.all(PillComponent.class, MovementComponent.class).get()); } @Override protected void processEntity(Entity entity, float deltaTime) { PillComponent pill = pillM.get(entity); MovementComponent movement = movementM.get(entity); Body body = movement.body; if (pill.eaten) { if (pill.big) {
// Path: core/src/com/ychstudio/components/MovementComponent.java // public class MovementComponent implements Component { // // public float speed = 3.6f; // public Body body; // // public MovementComponent(Body body) { // this.body = body; // } // } // // Path: core/src/com/ychstudio/components/PillComponent.java // public class PillComponent implements Component { // public boolean eaten; // public boolean big; // // public PillComponent(boolean isBig) { // big = isBig; // eaten = false; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/systems/PillSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.physics.box2d.Body; import com.ychstudio.components.MovementComponent; import com.ychstudio.components.PillComponent; import com.ychstudio.gamesys.GameManager; package com.ychstudio.systems; public class PillSystem extends IteratingSystem { private final ComponentMapper<PillComponent> pillM = ComponentMapper.getFor(PillComponent.class); private final ComponentMapper<MovementComponent> movementM = ComponentMapper.getFor(MovementComponent.class); public PillSystem() { super(Family.all(PillComponent.class, MovementComponent.class).get()); } @Override protected void processEntity(Entity entity, float deltaTime) { PillComponent pill = pillM.get(entity); MovementComponent movement = movementM.get(entity); Body body = movement.body; if (pill.eaten) { if (pill.big) {
GameManager.instance.addScore(500);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/RenderSystem.java
// Path: core/src/com/ychstudio/components/TextureComponent.java // public class TextureComponent implements Component { // // public TextureRegion region; // // public TextureComponent(TextureRegion textureRegion) { // region = new TextureRegion(textureRegion); // } // } // // Path: core/src/com/ychstudio/components/TransformComponent.java // public class TransformComponent implements Component { // // public Vector2 pos = new Vector2(); // public Vector2 scale = new Vector2(1, 1); // // public int zIndex; // // public float rotation = 0; // // public TransformComponent(float x, float y) { // this(x, y, 0); // } // // public TransformComponent(float x, float y, int zIndex) { // this(x, y, zIndex, 1.0f, 1.0f, 0); // } // // public TransformComponent(float x, float y, int zIndex, float sclX, float sclY, float rotation) { // pos.set(x, y); // this.zIndex = zIndex; // scale.set(sclX, sclY); // this.rotation = rotation; // } // // public TransformComponent(Vector2 pos, Vector2 scl, float rotation) { // this.pos.set(pos); // this.scale.set(scl); // this.rotation = rotation; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.Array; import com.ychstudio.components.TextureComponent; import com.ychstudio.components.TransformComponent; import com.ychstudio.gamesys.GameManager; import java.util.Comparator;
package com.ychstudio.systems; public class RenderSystem extends IteratingSystem { private final Array<Entity> renderArray; private final SpriteBatch batch;
// Path: core/src/com/ychstudio/components/TextureComponent.java // public class TextureComponent implements Component { // // public TextureRegion region; // // public TextureComponent(TextureRegion textureRegion) { // region = new TextureRegion(textureRegion); // } // } // // Path: core/src/com/ychstudio/components/TransformComponent.java // public class TransformComponent implements Component { // // public Vector2 pos = new Vector2(); // public Vector2 scale = new Vector2(1, 1); // // public int zIndex; // // public float rotation = 0; // // public TransformComponent(float x, float y) { // this(x, y, 0); // } // // public TransformComponent(float x, float y, int zIndex) { // this(x, y, zIndex, 1.0f, 1.0f, 0); // } // // public TransformComponent(float x, float y, int zIndex, float sclX, float sclY, float rotation) { // pos.set(x, y); // this.zIndex = zIndex; // scale.set(sclX, sclY); // this.rotation = rotation; // } // // public TransformComponent(Vector2 pos, Vector2 scl, float rotation) { // this.pos.set(pos); // this.scale.set(scl); // this.rotation = rotation; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/systems/RenderSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.Array; import com.ychstudio.components.TextureComponent; import com.ychstudio.components.TransformComponent; import com.ychstudio.gamesys.GameManager; import java.util.Comparator; package com.ychstudio.systems; public class RenderSystem extends IteratingSystem { private final Array<Entity> renderArray; private final SpriteBatch batch;
private final ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/RenderSystem.java
// Path: core/src/com/ychstudio/components/TextureComponent.java // public class TextureComponent implements Component { // // public TextureRegion region; // // public TextureComponent(TextureRegion textureRegion) { // region = new TextureRegion(textureRegion); // } // } // // Path: core/src/com/ychstudio/components/TransformComponent.java // public class TransformComponent implements Component { // // public Vector2 pos = new Vector2(); // public Vector2 scale = new Vector2(1, 1); // // public int zIndex; // // public float rotation = 0; // // public TransformComponent(float x, float y) { // this(x, y, 0); // } // // public TransformComponent(float x, float y, int zIndex) { // this(x, y, zIndex, 1.0f, 1.0f, 0); // } // // public TransformComponent(float x, float y, int zIndex, float sclX, float sclY, float rotation) { // pos.set(x, y); // this.zIndex = zIndex; // scale.set(sclX, sclY); // this.rotation = rotation; // } // // public TransformComponent(Vector2 pos, Vector2 scl, float rotation) { // this.pos.set(pos); // this.scale.set(scl); // this.rotation = rotation; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.Array; import com.ychstudio.components.TextureComponent; import com.ychstudio.components.TransformComponent; import com.ychstudio.gamesys.GameManager; import java.util.Comparator;
package com.ychstudio.systems; public class RenderSystem extends IteratingSystem { private final Array<Entity> renderArray; private final SpriteBatch batch; private final ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class);
// Path: core/src/com/ychstudio/components/TextureComponent.java // public class TextureComponent implements Component { // // public TextureRegion region; // // public TextureComponent(TextureRegion textureRegion) { // region = new TextureRegion(textureRegion); // } // } // // Path: core/src/com/ychstudio/components/TransformComponent.java // public class TransformComponent implements Component { // // public Vector2 pos = new Vector2(); // public Vector2 scale = new Vector2(1, 1); // // public int zIndex; // // public float rotation = 0; // // public TransformComponent(float x, float y) { // this(x, y, 0); // } // // public TransformComponent(float x, float y, int zIndex) { // this(x, y, zIndex, 1.0f, 1.0f, 0); // } // // public TransformComponent(float x, float y, int zIndex, float sclX, float sclY, float rotation) { // pos.set(x, y); // this.zIndex = zIndex; // scale.set(sclX, sclY); // this.rotation = rotation; // } // // public TransformComponent(Vector2 pos, Vector2 scl, float rotation) { // this.pos.set(pos); // this.scale.set(scl); // this.rotation = rotation; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/systems/RenderSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.Array; import com.ychstudio.components.TextureComponent; import com.ychstudio.components.TransformComponent; import com.ychstudio.gamesys.GameManager; import java.util.Comparator; package com.ychstudio.systems; public class RenderSystem extends IteratingSystem { private final Array<Entity> renderArray; private final SpriteBatch batch; private final ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class);
private final ComponentMapper<TextureComponent> rendererM = ComponentMapper.getFor(TextureComponent.class);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/systems/RenderSystem.java
// Path: core/src/com/ychstudio/components/TextureComponent.java // public class TextureComponent implements Component { // // public TextureRegion region; // // public TextureComponent(TextureRegion textureRegion) { // region = new TextureRegion(textureRegion); // } // } // // Path: core/src/com/ychstudio/components/TransformComponent.java // public class TransformComponent implements Component { // // public Vector2 pos = new Vector2(); // public Vector2 scale = new Vector2(1, 1); // // public int zIndex; // // public float rotation = 0; // // public TransformComponent(float x, float y) { // this(x, y, 0); // } // // public TransformComponent(float x, float y, int zIndex) { // this(x, y, zIndex, 1.0f, 1.0f, 0); // } // // public TransformComponent(float x, float y, int zIndex, float sclX, float sclY, float rotation) { // pos.set(x, y); // this.zIndex = zIndex; // scale.set(sclX, sclY); // this.rotation = rotation; // } // // public TransformComponent(Vector2 pos, Vector2 scl, float rotation) { // this.pos.set(pos); // this.scale.set(scl); // this.rotation = rotation; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.Array; import com.ychstudio.components.TextureComponent; import com.ychstudio.components.TransformComponent; import com.ychstudio.gamesys.GameManager; import java.util.Comparator;
package com.ychstudio.systems; public class RenderSystem extends IteratingSystem { private final Array<Entity> renderArray; private final SpriteBatch batch; private final ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class); private final ComponentMapper<TextureComponent> rendererM = ComponentMapper.getFor(TextureComponent.class); public RenderSystem(SpriteBatch batch) { super(Family.all(TransformComponent.class, TextureComponent.class).get()); this.batch = batch; renderArray = new Array<>(); } @Override public void update(float deltaTime) { super.update(deltaTime); renderArray.sort(new Comparator<Entity>() { @Override public int compare(Entity o1, Entity o2) { TransformComponent transform1 = transformM.get(o1); TransformComponent transform2 = transformM.get(o2); return transform2.zIndex - transform1.zIndex; } }); batch.begin(); for (Entity entity : renderArray) { TransformComponent transform = transformM.get(entity); TextureComponent tex = rendererM.get(entity);
// Path: core/src/com/ychstudio/components/TextureComponent.java // public class TextureComponent implements Component { // // public TextureRegion region; // // public TextureComponent(TextureRegion textureRegion) { // region = new TextureRegion(textureRegion); // } // } // // Path: core/src/com/ychstudio/components/TransformComponent.java // public class TransformComponent implements Component { // // public Vector2 pos = new Vector2(); // public Vector2 scale = new Vector2(1, 1); // // public int zIndex; // // public float rotation = 0; // // public TransformComponent(float x, float y) { // this(x, y, 0); // } // // public TransformComponent(float x, float y, int zIndex) { // this(x, y, zIndex, 1.0f, 1.0f, 0); // } // // public TransformComponent(float x, float y, int zIndex, float sclX, float sclY, float rotation) { // pos.set(x, y); // this.zIndex = zIndex; // scale.set(sclX, sclY); // this.rotation = rotation; // } // // public TransformComponent(Vector2 pos, Vector2 scl, float rotation) { // this.pos.set(pos); // this.scale.set(scl); // this.rotation = rotation; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/systems/RenderSystem.java import com.badlogic.ashley.core.ComponentMapper; import com.badlogic.ashley.core.Entity; import com.badlogic.ashley.core.Family; import com.badlogic.ashley.systems.IteratingSystem; import com.badlogic.gdx.graphics.g2d.SpriteBatch; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.Array; import com.ychstudio.components.TextureComponent; import com.ychstudio.components.TransformComponent; import com.ychstudio.gamesys.GameManager; import java.util.Comparator; package com.ychstudio.systems; public class RenderSystem extends IteratingSystem { private final Array<Entity> renderArray; private final SpriteBatch batch; private final ComponentMapper<TransformComponent> transformM = ComponentMapper.getFor(TransformComponent.class); private final ComponentMapper<TextureComponent> rendererM = ComponentMapper.getFor(TextureComponent.class); public RenderSystem(SpriteBatch batch) { super(Family.all(TransformComponent.class, TextureComponent.class).get()); this.batch = batch; renderArray = new Array<>(); } @Override public void update(float deltaTime) { super.update(deltaTime); renderArray.sort(new Comparator<Entity>() { @Override public int compare(Entity o1, Entity o2) { TransformComponent transform1 = transformM.get(o1); TransformComponent transform2 = transformM.get(o2); return transform2.zIndex - transform1.zIndex; } }); batch.begin(); for (Entity entity : renderArray) { TransformComponent transform = transformM.get(entity); TextureComponent tex = rendererM.get(entity);
float width = tex.region.getRegionWidth() / GameManager.PPM;
yichen0831/Pacman_libGdx
core/src/com/ychstudio/gamesys/GameManager.java
// Path: core/src/com/ychstudio/ai/astar/AStartPathFinding.java // public class AStartPathFinding { // public final AStarMap map; // private final PathFinder<Node> pathfinder; // private final Heuristic<Node> heuristic; // private final GraphPath<Connection<Node>> connectionPath; // // public AStartPathFinding(AStarMap map) { // this.map = map; // this.pathfinder = new IndexedAStarPathFinder<Node>(createGraph(map)); // this.connectionPath = new DefaultGraphPath<Connection<Node>>(); // this.heuristic = new Heuristic<Node>() { // @Override // public float estimate (Node node, Node endNode) { // // Manhattan distance // return Math.abs(endNode.x - node.x) + Math.abs(endNode.y - node.y); // } // }; // } // // public Node findNextNode(Vector2 source, Vector2 target) { // int sourceX = MathUtils.floor(source.x); // int sourceY = MathUtils.floor(source.y); // int targetX = MathUtils.floor(target.x); // int targetY = MathUtils.floor(target.y); // // if (map == null // || sourceX < 0 || sourceX >= map.getWidth() // || sourceY < 0 || sourceY >= map.getHeight() // || targetX < 0 || targetX >= map.getWidth() // || targetY < 0 || targetY >= map.getHeight()) { // return null; // } // // Node sourceNode = map.getNodeAt(sourceX, sourceY); // Node targetNode = map.getNodeAt(targetX, targetY); // connectionPath.clear(); // pathfinder.searchConnectionPath(sourceNode, targetNode, heuristic, connectionPath); // // return connectionPath.getCount() == 0 ? null : connectionPath.get(0).getToNode(); // } // // private static final int[][] NEIGHBORHOOD = new int[][] { // new int[] {-1, 0}, // new int[] { 0, -1}, // new int[] { 0, 1}, // new int[] { 1, 0} // }; // // public static MyGraph createGraph (AStarMap map) { // final int height = map.getHeight(); // final int width = map.getWidth(); // MyGraph graph = new MyGraph(map); // for (int y = 0; y < height; y++) { // for (int x = 0; x < width; x++) { // Node node = map.getNodeAt(x, y); // if (node.isWall) { // continue; // } // // Add a connection for each valid neighbor // for (int offset = 0; offset < NEIGHBORHOOD.length; offset++) { // int neighborX = node.x + NEIGHBORHOOD[offset][0]; // int neighborY = node.y + NEIGHBORHOOD[offset][1]; // if (neighborX >= 0 && neighborX < width && neighborY >= 0 && neighborY < height) { // Node neighbor = map.getNodeAt(neighborX, neighborY); // if (!neighbor.isWall) { // // Add connection to walkable neighbor // node.getConnections().add(new DefaultConnection<Node>(node, neighbor)); // } // } // } // node.getConnections().shuffle(); // } // } // return graph; // } // // private static class MyGraph implements IndexedGraph<Node> { // // AStarMap map; // // public MyGraph (AStarMap map) { // this.map = map; // } // // @Override // public int getIndex(Node node) { // return node.getIndex(); // } // // @Override // public Array<Connection<Node>> getConnections(Node fromNode) { // return fromNode.getConnections(); // } // // @Override // public int getNodeCount() { // return map.getHeight() * map.getwidth(); // } // // } // }
import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Disposable; import com.ychstudio.ai.astar.AStartPathFinding;
package com.ychstudio.gamesys; public class GameManager implements Disposable { public static final GameManager instance = new GameManager(); public static final float PPM = 16f; public static final short NOTHING_BIT = 0; public static final short WALL_BIT = 1; public static final short PLAYER_BIT = 1 << 1; public static final short PILL_BIT = 1 << 2; public static final short GHOST_BIT = 1 << 3; public static final short GATE_BIT = 1 << 4; public static final short LIGHT_BIT = 1 << 5; public AssetManager assetManager; public Vector2 playerSpawnPos; public Vector2 ghostSpawnPos; public int totalPills = 0; public int highScore = 0; public int score = 0; public int displayScore = 0; public int displayHighScore = 0; public int playerLives = 4; public boolean playerIsInvincible = true; public boolean bigPillEaten = false; public boolean playerIsAlive = true; private boolean gameOver = false;
// Path: core/src/com/ychstudio/ai/astar/AStartPathFinding.java // public class AStartPathFinding { // public final AStarMap map; // private final PathFinder<Node> pathfinder; // private final Heuristic<Node> heuristic; // private final GraphPath<Connection<Node>> connectionPath; // // public AStartPathFinding(AStarMap map) { // this.map = map; // this.pathfinder = new IndexedAStarPathFinder<Node>(createGraph(map)); // this.connectionPath = new DefaultGraphPath<Connection<Node>>(); // this.heuristic = new Heuristic<Node>() { // @Override // public float estimate (Node node, Node endNode) { // // Manhattan distance // return Math.abs(endNode.x - node.x) + Math.abs(endNode.y - node.y); // } // }; // } // // public Node findNextNode(Vector2 source, Vector2 target) { // int sourceX = MathUtils.floor(source.x); // int sourceY = MathUtils.floor(source.y); // int targetX = MathUtils.floor(target.x); // int targetY = MathUtils.floor(target.y); // // if (map == null // || sourceX < 0 || sourceX >= map.getWidth() // || sourceY < 0 || sourceY >= map.getHeight() // || targetX < 0 || targetX >= map.getWidth() // || targetY < 0 || targetY >= map.getHeight()) { // return null; // } // // Node sourceNode = map.getNodeAt(sourceX, sourceY); // Node targetNode = map.getNodeAt(targetX, targetY); // connectionPath.clear(); // pathfinder.searchConnectionPath(sourceNode, targetNode, heuristic, connectionPath); // // return connectionPath.getCount() == 0 ? null : connectionPath.get(0).getToNode(); // } // // private static final int[][] NEIGHBORHOOD = new int[][] { // new int[] {-1, 0}, // new int[] { 0, -1}, // new int[] { 0, 1}, // new int[] { 1, 0} // }; // // public static MyGraph createGraph (AStarMap map) { // final int height = map.getHeight(); // final int width = map.getWidth(); // MyGraph graph = new MyGraph(map); // for (int y = 0; y < height; y++) { // for (int x = 0; x < width; x++) { // Node node = map.getNodeAt(x, y); // if (node.isWall) { // continue; // } // // Add a connection for each valid neighbor // for (int offset = 0; offset < NEIGHBORHOOD.length; offset++) { // int neighborX = node.x + NEIGHBORHOOD[offset][0]; // int neighborY = node.y + NEIGHBORHOOD[offset][1]; // if (neighborX >= 0 && neighborX < width && neighborY >= 0 && neighborY < height) { // Node neighbor = map.getNodeAt(neighborX, neighborY); // if (!neighbor.isWall) { // // Add connection to walkable neighbor // node.getConnections().add(new DefaultConnection<Node>(node, neighbor)); // } // } // } // node.getConnections().shuffle(); // } // } // return graph; // } // // private static class MyGraph implements IndexedGraph<Node> { // // AStarMap map; // // public MyGraph (AStarMap map) { // this.map = map; // } // // @Override // public int getIndex(Node node) { // return node.getIndex(); // } // // @Override // public Array<Connection<Node>> getConnections(Node fromNode) { // return fromNode.getConnections(); // } // // @Override // public int getNodeCount() { // return map.getHeight() * map.getwidth(); // } // // } // } // Path: core/src/com/ychstudio/gamesys/GameManager.java import com.badlogic.gdx.ai.utils.Location; import com.badlogic.gdx.assets.AssetManager; import com.badlogic.gdx.audio.Sound; import com.badlogic.gdx.graphics.g2d.TextureAtlas; import com.badlogic.gdx.math.Vector2; import com.badlogic.gdx.utils.Disposable; import com.ychstudio.ai.astar.AStartPathFinding; package com.ychstudio.gamesys; public class GameManager implements Disposable { public static final GameManager instance = new GameManager(); public static final float PPM = 16f; public static final short NOTHING_BIT = 0; public static final short WALL_BIT = 1; public static final short PLAYER_BIT = 1 << 1; public static final short PILL_BIT = 1 << 2; public static final short GHOST_BIT = 1 << 3; public static final short GATE_BIT = 1 << 4; public static final short LIGHT_BIT = 1 << 5; public AssetManager assetManager; public Vector2 playerSpawnPos; public Vector2 ghostSpawnPos; public int totalPills = 0; public int highScore = 0; public int score = 0; public int displayScore = 0; public int displayHighScore = 0; public int playerLives = 4; public boolean playerIsInvincible = true; public boolean bigPillEaten = false; public boolean playerIsAlive = true; private boolean gameOver = false;
public AStartPathFinding pathfinder;
yichen0831/Pacman_libGdx
desktop/src/com/ychstudio/desktop/DesktopLauncher.java
// Path: core/src/com/ychstudio/PacMan.java // public class PacMan extends Game { // // public SpriteBatch batch; // // @Override // public void create() { // batch = new SpriteBatch(); // setScreen(new PlayScreen(this)); // } // // @Override // public void render() { // super.render(); // } // // @Override // public void dispose() { // batch.dispose(); // GameManager.instance.dispose(); // } // }
import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.ychstudio.PacMan;
package com.ychstudio.desktop; public class DesktopLauncher { public static void main(String[] arg) { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.width = 428; // 570 config.height = 518; // 690
// Path: core/src/com/ychstudio/PacMan.java // public class PacMan extends Game { // // public SpriteBatch batch; // // @Override // public void create() { // batch = new SpriteBatch(); // setScreen(new PlayScreen(this)); // } // // @Override // public void render() { // super.render(); // } // // @Override // public void dispose() { // batch.dispose(); // GameManager.instance.dispose(); // } // } // Path: desktop/src/com/ychstudio/desktop/DesktopLauncher.java import com.badlogic.gdx.backends.lwjgl.LwjglApplication; import com.badlogic.gdx.backends.lwjgl.LwjglApplicationConfiguration; import com.ychstudio.PacMan; package com.ychstudio.desktop; public class DesktopLauncher { public static void main(String[] arg) { LwjglApplicationConfiguration config = new LwjglApplicationConfiguration(); config.width = 428; // 570 config.height = 518; // 690
new LwjglApplication(new PacMan(), config);
yichen0831/Pacman_libGdx
core/src/com/ychstudio/ai/fsm/PlayerState.java
// Path: core/src/com/ychstudio/components/PlayerComponent.java // public class PlayerComponent implements Component { // // public static final int IDLE = 0; // public static final int IDLE_UP = 0; // public static final int IDLE_DOWN = 1; // public static final int IDLE_LEFT = 2; // public static final int IDLE_RIGHT = 3; // // public static final int MOVE_UP = 4; // public static final int MOVE_DOWN = 5; // public static final int MOVE_LEFT = 6; // public static final int MOVE_RIGHT = 7; // public static final int DIE = 8; // // public PlayerAI ai; // public PlayerAgent playerAgent; // // private final Body body; // // public int currentState; // // public int hp; // // public float invincibleTimer; // // public PlayerComponent(Body body) { // this.body = body; // ai = new PlayerAI(body); // playerAgent = new PlayerAgent(this); // playerAgent.stateMachine.setInitialState(PlayerState.IDLE_RIGHT); // currentState = IDLE_RIGHT; // hp = 1; // invincibleTimer = 0; // } // // public Body getBody() { // return body; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.gdx.ai.fsm.State; import com.badlogic.gdx.ai.msg.Telegram; import com.badlogic.gdx.math.Vector2; import com.ychstudio.components.PlayerComponent; import com.ychstudio.gamesys.GameManager;
package com.ychstudio.ai.fsm; public enum PlayerState implements State<PlayerAgent> { MOVE_UP() { @Override public void update(PlayerAgent entity) {
// Path: core/src/com/ychstudio/components/PlayerComponent.java // public class PlayerComponent implements Component { // // public static final int IDLE = 0; // public static final int IDLE_UP = 0; // public static final int IDLE_DOWN = 1; // public static final int IDLE_LEFT = 2; // public static final int IDLE_RIGHT = 3; // // public static final int MOVE_UP = 4; // public static final int MOVE_DOWN = 5; // public static final int MOVE_LEFT = 6; // public static final int MOVE_RIGHT = 7; // public static final int DIE = 8; // // public PlayerAI ai; // public PlayerAgent playerAgent; // // private final Body body; // // public int currentState; // // public int hp; // // public float invincibleTimer; // // public PlayerComponent(Body body) { // this.body = body; // ai = new PlayerAI(body); // playerAgent = new PlayerAgent(this); // playerAgent.stateMachine.setInitialState(PlayerState.IDLE_RIGHT); // currentState = IDLE_RIGHT; // hp = 1; // invincibleTimer = 0; // } // // public Body getBody() { // return body; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/ai/fsm/PlayerState.java import com.badlogic.gdx.ai.fsm.State; import com.badlogic.gdx.ai.msg.Telegram; import com.badlogic.gdx.math.Vector2; import com.ychstudio.components.PlayerComponent; import com.ychstudio.gamesys.GameManager; package com.ychstudio.ai.fsm; public enum PlayerState implements State<PlayerAgent> { MOVE_UP() { @Override public void update(PlayerAgent entity) {
entity.playerComponent.currentState = PlayerComponent.MOVE_UP;
yichen0831/Pacman_libGdx
core/src/com/ychstudio/ai/fsm/PlayerState.java
// Path: core/src/com/ychstudio/components/PlayerComponent.java // public class PlayerComponent implements Component { // // public static final int IDLE = 0; // public static final int IDLE_UP = 0; // public static final int IDLE_DOWN = 1; // public static final int IDLE_LEFT = 2; // public static final int IDLE_RIGHT = 3; // // public static final int MOVE_UP = 4; // public static final int MOVE_DOWN = 5; // public static final int MOVE_LEFT = 6; // public static final int MOVE_RIGHT = 7; // public static final int DIE = 8; // // public PlayerAI ai; // public PlayerAgent playerAgent; // // private final Body body; // // public int currentState; // // public int hp; // // public float invincibleTimer; // // public PlayerComponent(Body body) { // this.body = body; // ai = new PlayerAI(body); // playerAgent = new PlayerAgent(this); // playerAgent.stateMachine.setInitialState(PlayerState.IDLE_RIGHT); // currentState = IDLE_RIGHT; // hp = 1; // invincibleTimer = 0; // } // // public Body getBody() { // return body; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // }
import com.badlogic.gdx.ai.fsm.State; import com.badlogic.gdx.ai.msg.Telegram; import com.badlogic.gdx.math.Vector2; import com.ychstudio.components.PlayerComponent; import com.ychstudio.gamesys.GameManager;
}, IDLE_LEFT() { @Override public void update(PlayerAgent entity) { entity.playerComponent.currentState = PlayerComponent.IDLE_LEFT; changeStateUponVelocity(entity); if (entity.playerComponent.hp <= 0) { entity.stateMachine.changeState(DIE); } } }, IDLE_RIGHT() { @Override public void update(PlayerAgent entity) { entity.playerComponent.currentState = PlayerComponent.IDLE_RIGHT; changeStateUponVelocity(entity); if (entity.playerComponent.hp <= 0) { entity.stateMachine.changeState(DIE); } } }, DIE() { @Override public void update(PlayerAgent entity) { entity.playerComponent.currentState = PlayerComponent.DIE;
// Path: core/src/com/ychstudio/components/PlayerComponent.java // public class PlayerComponent implements Component { // // public static final int IDLE = 0; // public static final int IDLE_UP = 0; // public static final int IDLE_DOWN = 1; // public static final int IDLE_LEFT = 2; // public static final int IDLE_RIGHT = 3; // // public static final int MOVE_UP = 4; // public static final int MOVE_DOWN = 5; // public static final int MOVE_LEFT = 6; // public static final int MOVE_RIGHT = 7; // public static final int DIE = 8; // // public PlayerAI ai; // public PlayerAgent playerAgent; // // private final Body body; // // public int currentState; // // public int hp; // // public float invincibleTimer; // // public PlayerComponent(Body body) { // this.body = body; // ai = new PlayerAI(body); // playerAgent = new PlayerAgent(this); // playerAgent.stateMachine.setInitialState(PlayerState.IDLE_RIGHT); // currentState = IDLE_RIGHT; // hp = 1; // invincibleTimer = 0; // } // // public Body getBody() { // return body; // } // } // // Path: core/src/com/ychstudio/gamesys/GameManager.java // public class GameManager implements Disposable { // // public static final GameManager instance = new GameManager(); // // public static final float PPM = 16f; // // public static final short NOTHING_BIT = 0; // public static final short WALL_BIT = 1; // public static final short PLAYER_BIT = 1 << 1; // public static final short PILL_BIT = 1 << 2; // public static final short GHOST_BIT = 1 << 3; // public static final short GATE_BIT = 1 << 4; // public static final short LIGHT_BIT = 1 << 5; // // public AssetManager assetManager; // // public Vector2 playerSpawnPos; // public Vector2 ghostSpawnPos; // // public int totalPills = 0; // // public int highScore = 0; // public int score = 0; // // public int displayScore = 0; // public int displayHighScore = 0; // // public int playerLives = 4; // public boolean playerIsInvincible = true; // // public boolean bigPillEaten = false; // public boolean playerIsAlive = true; // private boolean gameOver = false; // // public AStartPathFinding pathfinder; // // public Location<Vector2> playerLocation; // // private GameManager() { // assetManager = new AssetManager(); // assetManager.load("images/actors.pack", TextureAtlas.class); // assetManager.load("sounds/pill.ogg", Sound.class); // assetManager.load("sounds/big_pill.ogg", Sound.class); // assetManager.load("sounds/ghost_die.ogg", Sound.class); // assetManager.load("sounds/pacman_die.ogg", Sound.class); // assetManager.load("sounds/clear.ogg", Sound.class); // // assetManager.finishLoading(); // // playerSpawnPos = new Vector2(); // ghostSpawnPos = new Vector2(); // } // // public void decreasePlayerLives() { // playerLives--; // } // // public void resetPlayerLives() { // playerLives = 3; // } // // public void makeGameOver() { // gameOver = true; // } // // public boolean isGameOver() { // return gameOver; // } // // public void resetGame(boolean restart) { // if (restart) { // score = 0; // displayScore = 0; // resetPlayerLives(); // } // totalPills = 0; // playerIsAlive = true; // bigPillEaten = false; // gameOver = false; // } // // public void addScore(int score) { // this.score += score; // if (this.score > highScore) { // highScore = this.score; // } // } // // @Override // public void dispose() { // assetManager.dispose(); // } // } // Path: core/src/com/ychstudio/ai/fsm/PlayerState.java import com.badlogic.gdx.ai.fsm.State; import com.badlogic.gdx.ai.msg.Telegram; import com.badlogic.gdx.math.Vector2; import com.ychstudio.components.PlayerComponent; import com.ychstudio.gamesys.GameManager; }, IDLE_LEFT() { @Override public void update(PlayerAgent entity) { entity.playerComponent.currentState = PlayerComponent.IDLE_LEFT; changeStateUponVelocity(entity); if (entity.playerComponent.hp <= 0) { entity.stateMachine.changeState(DIE); } } }, IDLE_RIGHT() { @Override public void update(PlayerAgent entity) { entity.playerComponent.currentState = PlayerComponent.IDLE_RIGHT; changeStateUponVelocity(entity); if (entity.playerComponent.hp <= 0) { entity.stateMachine.changeState(DIE); } } }, DIE() { @Override public void update(PlayerAgent entity) { entity.playerComponent.currentState = PlayerComponent.DIE;
GameManager.instance.playerIsAlive = false;
sing-group/bicycle
src/test/java/es/cnio/bioinfo/bicycle/gatk/MDIteratorTest.java
// Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/ListerFilter.java // protected static class MDTagIterator implements Iterator<MDTagOperator> { // static final Pattern mdPat = Pattern.compile("\\G(?:([0-9]+)|([ACTGNactgn])|(\\^[ACTGNactgn]+))"); // // private final boolean reverse; // private List<MDTagOperation> mdOperations; // private int currentMDOperationsPos; // // private int repetitionsOfCurrentOperation = 0; // private MDTagOperator currentOperator = null; // // private List<MDTagOperation> decodeMDTag(String mdString) { // Matcher matcher = mdPat.matcher(mdString); // // ArrayList result = new ArrayList<>(); // while (matcher.find()) { // if (matcher.group(1) != null) { // // match // int length = Integer.parseInt(matcher.group(1)); // if (length > 0) { // result.add(new SequenceMatchOperation(Integer.parseInt(matcher.group(1)))); // } // } else if (matcher.group(2) != null) { // // variant // result.add(new SequenceVariantOperation(matcher.group(2).charAt(0))); // } else if (matcher.group(3) != null) { // // deletion // result.add(new DeletionOperation(matcher.group(3).substring(1))); // } // } // // return result; // } // // public MDTagIterator(String mdString, boolean reverse) { // this.mdOperations = decodeMDTag(mdString); // this.reverse = reverse; // this.currentMDOperationsPos = this.reverse ? mdOperations.size() : -1; // this.advanceMDOperation(); // } // // @Override // public boolean hasNext() { // return repetitionsOfCurrentOperation > 0 // || (this.currentMDOperationsPos >= 0 && this.currentMDOperationsPos < this.mdOperations.size()); // } // // @Override // public MDTagOperator next() { // // MDTagOperator result = this.currentOperator; // this.repetitionsOfCurrentOperation--; // if (repetitionsOfCurrentOperation == 0 && (this.currentMDOperationsPos >= 0 && this // .currentMDOperationsPos < this.mdOperations.size())) { // advanceMDOperation(); // } // // return result; // } // // private void advanceMDOperation() { // this.currentMDOperationsPos = this.currentMDOperationsPos + (this.reverse ? -1 : 1); // if (this.currentMDOperationsPos >= 0 && this.currentMDOperationsPos < this.mdOperations.size()) { // MDTagOperation element = this.mdOperations.get(this.currentMDOperationsPos); // this.repetitionsOfCurrentOperation = element.getLength(); // this.currentOperator = element.getOperator(); // } // } // } // // Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/ListerFilter.java // protected enum MDTagOperator { // DELETION, SEQUENCE_MATCH, VARIANT // }
import static junit.framework.Assert.assertEquals; import org.junit.Test; import es.cnio.bioinfo.bicycle.gatk.ListerFilter.MDTagIterator; import es.cnio.bioinfo.bicycle.gatk.ListerFilter.MDTagOperator; import net.sf.samtools.CigarOperator;
package es.cnio.bioinfo.bicycle.gatk; public class MDIteratorTest { @Test public void testPerfectMatch() {
// Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/ListerFilter.java // protected static class MDTagIterator implements Iterator<MDTagOperator> { // static final Pattern mdPat = Pattern.compile("\\G(?:([0-9]+)|([ACTGNactgn])|(\\^[ACTGNactgn]+))"); // // private final boolean reverse; // private List<MDTagOperation> mdOperations; // private int currentMDOperationsPos; // // private int repetitionsOfCurrentOperation = 0; // private MDTagOperator currentOperator = null; // // private List<MDTagOperation> decodeMDTag(String mdString) { // Matcher matcher = mdPat.matcher(mdString); // // ArrayList result = new ArrayList<>(); // while (matcher.find()) { // if (matcher.group(1) != null) { // // match // int length = Integer.parseInt(matcher.group(1)); // if (length > 0) { // result.add(new SequenceMatchOperation(Integer.parseInt(matcher.group(1)))); // } // } else if (matcher.group(2) != null) { // // variant // result.add(new SequenceVariantOperation(matcher.group(2).charAt(0))); // } else if (matcher.group(3) != null) { // // deletion // result.add(new DeletionOperation(matcher.group(3).substring(1))); // } // } // // return result; // } // // public MDTagIterator(String mdString, boolean reverse) { // this.mdOperations = decodeMDTag(mdString); // this.reverse = reverse; // this.currentMDOperationsPos = this.reverse ? mdOperations.size() : -1; // this.advanceMDOperation(); // } // // @Override // public boolean hasNext() { // return repetitionsOfCurrentOperation > 0 // || (this.currentMDOperationsPos >= 0 && this.currentMDOperationsPos < this.mdOperations.size()); // } // // @Override // public MDTagOperator next() { // // MDTagOperator result = this.currentOperator; // this.repetitionsOfCurrentOperation--; // if (repetitionsOfCurrentOperation == 0 && (this.currentMDOperationsPos >= 0 && this // .currentMDOperationsPos < this.mdOperations.size())) { // advanceMDOperation(); // } // // return result; // } // // private void advanceMDOperation() { // this.currentMDOperationsPos = this.currentMDOperationsPos + (this.reverse ? -1 : 1); // if (this.currentMDOperationsPos >= 0 && this.currentMDOperationsPos < this.mdOperations.size()) { // MDTagOperation element = this.mdOperations.get(this.currentMDOperationsPos); // this.repetitionsOfCurrentOperation = element.getLength(); // this.currentOperator = element.getOperator(); // } // } // } // // Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/ListerFilter.java // protected enum MDTagOperator { // DELETION, SEQUENCE_MATCH, VARIANT // } // Path: src/test/java/es/cnio/bioinfo/bicycle/gatk/MDIteratorTest.java import static junit.framework.Assert.assertEquals; import org.junit.Test; import es.cnio.bioinfo.bicycle.gatk.ListerFilter.MDTagIterator; import es.cnio.bioinfo.bicycle.gatk.ListerFilter.MDTagOperator; import net.sf.samtools.CigarOperator; package es.cnio.bioinfo.bicycle.gatk; public class MDIteratorTest { @Test public void testPerfectMatch() {
MDTagIterator iterator = new MDTagIterator("3", false);
sing-group/bicycle
src/test/java/es/cnio/bioinfo/bicycle/gatk/MDIteratorTest.java
// Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/ListerFilter.java // protected static class MDTagIterator implements Iterator<MDTagOperator> { // static final Pattern mdPat = Pattern.compile("\\G(?:([0-9]+)|([ACTGNactgn])|(\\^[ACTGNactgn]+))"); // // private final boolean reverse; // private List<MDTagOperation> mdOperations; // private int currentMDOperationsPos; // // private int repetitionsOfCurrentOperation = 0; // private MDTagOperator currentOperator = null; // // private List<MDTagOperation> decodeMDTag(String mdString) { // Matcher matcher = mdPat.matcher(mdString); // // ArrayList result = new ArrayList<>(); // while (matcher.find()) { // if (matcher.group(1) != null) { // // match // int length = Integer.parseInt(matcher.group(1)); // if (length > 0) { // result.add(new SequenceMatchOperation(Integer.parseInt(matcher.group(1)))); // } // } else if (matcher.group(2) != null) { // // variant // result.add(new SequenceVariantOperation(matcher.group(2).charAt(0))); // } else if (matcher.group(3) != null) { // // deletion // result.add(new DeletionOperation(matcher.group(3).substring(1))); // } // } // // return result; // } // // public MDTagIterator(String mdString, boolean reverse) { // this.mdOperations = decodeMDTag(mdString); // this.reverse = reverse; // this.currentMDOperationsPos = this.reverse ? mdOperations.size() : -1; // this.advanceMDOperation(); // } // // @Override // public boolean hasNext() { // return repetitionsOfCurrentOperation > 0 // || (this.currentMDOperationsPos >= 0 && this.currentMDOperationsPos < this.mdOperations.size()); // } // // @Override // public MDTagOperator next() { // // MDTagOperator result = this.currentOperator; // this.repetitionsOfCurrentOperation--; // if (repetitionsOfCurrentOperation == 0 && (this.currentMDOperationsPos >= 0 && this // .currentMDOperationsPos < this.mdOperations.size())) { // advanceMDOperation(); // } // // return result; // } // // private void advanceMDOperation() { // this.currentMDOperationsPos = this.currentMDOperationsPos + (this.reverse ? -1 : 1); // if (this.currentMDOperationsPos >= 0 && this.currentMDOperationsPos < this.mdOperations.size()) { // MDTagOperation element = this.mdOperations.get(this.currentMDOperationsPos); // this.repetitionsOfCurrentOperation = element.getLength(); // this.currentOperator = element.getOperator(); // } // } // } // // Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/ListerFilter.java // protected enum MDTagOperator { // DELETION, SEQUENCE_MATCH, VARIANT // }
import static junit.framework.Assert.assertEquals; import org.junit.Test; import es.cnio.bioinfo.bicycle.gatk.ListerFilter.MDTagIterator; import es.cnio.bioinfo.bicycle.gatk.ListerFilter.MDTagOperator; import net.sf.samtools.CigarOperator;
package es.cnio.bioinfo.bicycle.gatk; public class MDIteratorTest { @Test public void testPerfectMatch() { MDTagIterator iterator = new MDTagIterator("3", false);
// Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/ListerFilter.java // protected static class MDTagIterator implements Iterator<MDTagOperator> { // static final Pattern mdPat = Pattern.compile("\\G(?:([0-9]+)|([ACTGNactgn])|(\\^[ACTGNactgn]+))"); // // private final boolean reverse; // private List<MDTagOperation> mdOperations; // private int currentMDOperationsPos; // // private int repetitionsOfCurrentOperation = 0; // private MDTagOperator currentOperator = null; // // private List<MDTagOperation> decodeMDTag(String mdString) { // Matcher matcher = mdPat.matcher(mdString); // // ArrayList result = new ArrayList<>(); // while (matcher.find()) { // if (matcher.group(1) != null) { // // match // int length = Integer.parseInt(matcher.group(1)); // if (length > 0) { // result.add(new SequenceMatchOperation(Integer.parseInt(matcher.group(1)))); // } // } else if (matcher.group(2) != null) { // // variant // result.add(new SequenceVariantOperation(matcher.group(2).charAt(0))); // } else if (matcher.group(3) != null) { // // deletion // result.add(new DeletionOperation(matcher.group(3).substring(1))); // } // } // // return result; // } // // public MDTagIterator(String mdString, boolean reverse) { // this.mdOperations = decodeMDTag(mdString); // this.reverse = reverse; // this.currentMDOperationsPos = this.reverse ? mdOperations.size() : -1; // this.advanceMDOperation(); // } // // @Override // public boolean hasNext() { // return repetitionsOfCurrentOperation > 0 // || (this.currentMDOperationsPos >= 0 && this.currentMDOperationsPos < this.mdOperations.size()); // } // // @Override // public MDTagOperator next() { // // MDTagOperator result = this.currentOperator; // this.repetitionsOfCurrentOperation--; // if (repetitionsOfCurrentOperation == 0 && (this.currentMDOperationsPos >= 0 && this // .currentMDOperationsPos < this.mdOperations.size())) { // advanceMDOperation(); // } // // return result; // } // // private void advanceMDOperation() { // this.currentMDOperationsPos = this.currentMDOperationsPos + (this.reverse ? -1 : 1); // if (this.currentMDOperationsPos >= 0 && this.currentMDOperationsPos < this.mdOperations.size()) { // MDTagOperation element = this.mdOperations.get(this.currentMDOperationsPos); // this.repetitionsOfCurrentOperation = element.getLength(); // this.currentOperator = element.getOperator(); // } // } // } // // Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/ListerFilter.java // protected enum MDTagOperator { // DELETION, SEQUENCE_MATCH, VARIANT // } // Path: src/test/java/es/cnio/bioinfo/bicycle/gatk/MDIteratorTest.java import static junit.framework.Assert.assertEquals; import org.junit.Test; import es.cnio.bioinfo.bicycle.gatk.ListerFilter.MDTagIterator; import es.cnio.bioinfo.bicycle.gatk.ListerFilter.MDTagOperator; import net.sf.samtools.CigarOperator; package es.cnio.bioinfo.bicycle.gatk; public class MDIteratorTest { @Test public void testPerfectMatch() { MDTagIterator iterator = new MDTagIterator("3", false);
assertEquals(MDTagOperator.SEQUENCE_MATCH, iterator.next());
sing-group/bicycle
src/main/java/es/cnio/bioinfo/bicycle/operations/CtoTReader.java
// Path: src/main/java/es/cnio/bioinfo/bicycle/Sample.java // public class Sample { // // private String name = "unnamed-sample"; // private List<File> readsFiles = new LinkedList<File>(); // private boolean paired = false; // private boolean directional = true; //directional = Lister, Cokus otherwise // private String mate1Regexp = "_1.fastq"; // //for paired-end // private List<File> readsFilesM1 = new LinkedList<File>(); // private List<File> readsFilesM2 = new LinkedList<File>(); // // private Project project; // // Sample(Project project, String name, boolean paired, boolean directional, // String mate1Regexp) { // super(); // this.name = name; // this.project = project; // this.paired = paired; // this.directional = directional; // this.mate1Regexp = mate1Regexp; // } // // Sample(Project project, String name) { // super(); // this.name = name; // this.project = project; // } // // public String getName() { // return name; // } // // public boolean isPaired() { // return paired; // } // // public boolean isDirectional() { // return directional; // } // // public List<File> getReadsFiles() { // return Collections.unmodifiableList(readsFiles); // } // // public List<File> getReadsMate1Files() { // if (!this.project.isPaired()) { // throw new IllegalArgumentException("The project is not a paired-end project"); // } // return Collections.unmodifiableList(readsFilesM1); // } // // public List<File> getReadsMate2Files() { // if (!this.project.isPaired()) { // throw new IllegalArgumentException("The project is not a paired-end project"); // } // return Collections.unmodifiableList(readsFilesM2); // // } // // public Project getProject() { // return project; // } // // private void addReadsFile(File f) { // this.readsFiles.add(f); // if (this.paired) { // if (f.getName().matches(".*" + this.mate1Regexp + ".*")) { // this.readsFilesM1.add(f); // } else { // this.readsFilesM2.add(f); // } // } // } // // public static List<Sample> buildSamples(Project project) { // return buildSamples(project, false, true, ""); // } // // /** // * Builds samples from a directory which should contain reads files. Each reads file in the root of // * the path is a independent sample (with 1 reads file). If there are subdirectories, each subdirectory is a // * sample with all reads files inside it belonging to this sample. // * // * @param readsPath // * @return // */ // public static List<Sample> buildSamples(Project project, boolean paired, boolean directional, String mate1Regexp) { // File readsPath = project.getReadsDirectory(); // if (!readsPath.exists() || !readsPath.isDirectory()) { // throw new IllegalArgumentException("Cannot find " + readsPath.getAbsolutePath() + " or it is not a " + // "directory, or it is not accessible"); // } // List<Sample> toret = new LinkedList<Sample>(); // for (File file : readsPath.listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // return !name.equals("CVS"); // } // })) { // // if (file.isDirectory()) { // if (file.isHidden()) continue; // Sample s = new Sample(project, file.getName(), paired, directional, mate1Regexp); // // File[] files = file.listFiles(); // Arrays.sort(files, new Comparator<File>() { // @Override // public int compare(File arg0, File arg1) { // return arg0.getName().compareTo(arg1.getName()); // } // // }); // for (File subdirFile : files) { // if (!subdirFile.isDirectory() && !file.isHidden()) { // s.addReadsFile(subdirFile); // } // } // // s.validate(); // toret.add(s); // } else if (!file.isHidden()) { // if (paired) // throw new IllegalArgumentException("Paired-end samples files must be inside a directory per " + // "sample"); // Sample s = new Sample(project, file.getName(), paired, directional, mate1Regexp); // s.addReadsFile(file); // toret.add(s); // s.validate(); // } // } // return toret; // } // // private void validate() { // if (this.paired && this.readsFilesM1.size() != this.readsFilesM2.size()) { // throw new IllegalArgumentException("This sample is paired end, but has a different number of read files " + // "for each mate. mate 1: " + this.readsFilesM1 + ". mate 2: " + this.readsFilesM2); // } // // } // // @Override // public boolean equals(Object obj) { // if (!(obj instanceof Sample)) { // return false; // } // Sample sample = (Sample) obj; // return sample.getName().equals(this.getName()) && sample.readsFiles.equals(this.readsFiles); // } // // @Override // public String toString() { // return this.getName(); // } // // }
import java.io.BufferedReader; import java.io.IOException; import java.util.LinkedList; import java.util.Queue; import es.cnio.bioinfo.bicycle.Sample;
package es.cnio.bioinfo.bicycle.operations; public class CtoTReader extends ReadsReader { private boolean skipUnconverted = false;
// Path: src/main/java/es/cnio/bioinfo/bicycle/Sample.java // public class Sample { // // private String name = "unnamed-sample"; // private List<File> readsFiles = new LinkedList<File>(); // private boolean paired = false; // private boolean directional = true; //directional = Lister, Cokus otherwise // private String mate1Regexp = "_1.fastq"; // //for paired-end // private List<File> readsFilesM1 = new LinkedList<File>(); // private List<File> readsFilesM2 = new LinkedList<File>(); // // private Project project; // // Sample(Project project, String name, boolean paired, boolean directional, // String mate1Regexp) { // super(); // this.name = name; // this.project = project; // this.paired = paired; // this.directional = directional; // this.mate1Regexp = mate1Regexp; // } // // Sample(Project project, String name) { // super(); // this.name = name; // this.project = project; // } // // public String getName() { // return name; // } // // public boolean isPaired() { // return paired; // } // // public boolean isDirectional() { // return directional; // } // // public List<File> getReadsFiles() { // return Collections.unmodifiableList(readsFiles); // } // // public List<File> getReadsMate1Files() { // if (!this.project.isPaired()) { // throw new IllegalArgumentException("The project is not a paired-end project"); // } // return Collections.unmodifiableList(readsFilesM1); // } // // public List<File> getReadsMate2Files() { // if (!this.project.isPaired()) { // throw new IllegalArgumentException("The project is not a paired-end project"); // } // return Collections.unmodifiableList(readsFilesM2); // // } // // public Project getProject() { // return project; // } // // private void addReadsFile(File f) { // this.readsFiles.add(f); // if (this.paired) { // if (f.getName().matches(".*" + this.mate1Regexp + ".*")) { // this.readsFilesM1.add(f); // } else { // this.readsFilesM2.add(f); // } // } // } // // public static List<Sample> buildSamples(Project project) { // return buildSamples(project, false, true, ""); // } // // /** // * Builds samples from a directory which should contain reads files. Each reads file in the root of // * the path is a independent sample (with 1 reads file). If there are subdirectories, each subdirectory is a // * sample with all reads files inside it belonging to this sample. // * // * @param readsPath // * @return // */ // public static List<Sample> buildSamples(Project project, boolean paired, boolean directional, String mate1Regexp) { // File readsPath = project.getReadsDirectory(); // if (!readsPath.exists() || !readsPath.isDirectory()) { // throw new IllegalArgumentException("Cannot find " + readsPath.getAbsolutePath() + " or it is not a " + // "directory, or it is not accessible"); // } // List<Sample> toret = new LinkedList<Sample>(); // for (File file : readsPath.listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // return !name.equals("CVS"); // } // })) { // // if (file.isDirectory()) { // if (file.isHidden()) continue; // Sample s = new Sample(project, file.getName(), paired, directional, mate1Regexp); // // File[] files = file.listFiles(); // Arrays.sort(files, new Comparator<File>() { // @Override // public int compare(File arg0, File arg1) { // return arg0.getName().compareTo(arg1.getName()); // } // // }); // for (File subdirFile : files) { // if (!subdirFile.isDirectory() && !file.isHidden()) { // s.addReadsFile(subdirFile); // } // } // // s.validate(); // toret.add(s); // } else if (!file.isHidden()) { // if (paired) // throw new IllegalArgumentException("Paired-end samples files must be inside a directory per " + // "sample"); // Sample s = new Sample(project, file.getName(), paired, directional, mate1Regexp); // s.addReadsFile(file); // toret.add(s); // s.validate(); // } // } // return toret; // } // // private void validate() { // if (this.paired && this.readsFilesM1.size() != this.readsFilesM2.size()) { // throw new IllegalArgumentException("This sample is paired end, but has a different number of read files " + // "for each mate. mate 1: " + this.readsFilesM1 + ". mate 2: " + this.readsFilesM2); // } // // } // // @Override // public boolean equals(Object obj) { // if (!(obj instanceof Sample)) { // return false; // } // Sample sample = (Sample) obj; // return sample.getName().equals(this.getName()) && sample.readsFiles.equals(this.readsFiles); // } // // @Override // public String toString() { // return this.getName(); // } // // } // Path: src/main/java/es/cnio/bioinfo/bicycle/operations/CtoTReader.java import java.io.BufferedReader; import java.io.IOException; import java.util.LinkedList; import java.util.Queue; import es.cnio.bioinfo.bicycle.Sample; package es.cnio.bioinfo.bicycle.operations; public class CtoTReader extends ReadsReader { private boolean skipUnconverted = false;
public CtoTReader(Sample sample, BufferedReader reader) {
sing-group/bicycle
src/main/java/es/cnio/bioinfo/bicycle/Tools.java
// Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/Strand.java // public enum Strand { // // WATSON(".*CT.*WATSON.*"), CRICK(".*CT.*CRICK.*"); // // private Pattern fileRegExp; // // private Strand(String suffix) { // this.fileRegExp = Pattern.compile(suffix); // } // // public Pattern getFileRegExp() { // return this.fileRegExp; // } // // public Context getContext(ReferenceContext ref, long pos) { // if (this == WATSON) { // if (ref.getBase() == 'C') { // if (ref.getWindow().getStop() - pos == 2) { // // byte[] downstream = ref.getBases(); // // correct index if pos <= 2 // int correction = pos == 2? -1:pos == 1? -2: 0; // if (downstream[3+correction] == 'G') { // return Context.CG; // } else if (downstream[4+correction] == 'G') { // return Context.CHG; // } else { // return Context.CHH; // } // } else { // System.err.println("null context in " + ref.getLocus().getContig() + ":" + pos + " strand Watson"); // return null; // } // } else { // throw new IllegalArgumentException("Can't compute Watson context in a reference which is not C"); // } // } else if (this == CRICK) { // if (ref.getBase() == 'G') { // if (pos <= 2) { // System.err.println("Cannot compute context for " + ref.getLocus().getContig() + ":" + pos + " strand Crick"); // return null; // } // if (pos - ref.getWindow().getStart() == 2) { // // byte[] bases = ref.getBases(); // byte[] upstream = new byte[2]; // System.arraycopy(bases, 0, upstream, 0, 2); // // if (upstream[1] == 'C') { // return Context.CG; // } else if (upstream[0] == 'C') { // return Context.CHG; // } else { // return Context.CHH; // } // } else { // System.err.println("null context in " + ref.getLocus().getContig() + ":" + pos + " strand Crick"); // return null; // } // } else { // throw new IllegalArgumentException("Can't compute Watson context in a reference which is not C"); // } // } else { // throw new IllegalArgumentException("this strand " + this + " does not support context calculation"); // } // } // // public char getCytosineBase() { // if (this == WATSON) { // return 'C'; // } // if (this == CRICK) { // return 'G'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getCytonsine"); // } // // public char getGuanineBase() { // if (this == WATSON) { // return 'G'; // } // if (this == CRICK) { // return 'C'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getGuanine"); // } // // public char getThymineBase() { // if (this == WATSON) { // return 'T'; // } // if (this == CRICK) { // return 'A'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getThymine"); // } // // public long downstream(long pos) { // if (this == WATSON) { // return pos + 1; // } // if (this == CRICK) { // return pos - 1; // } // throw new IllegalArgumentException("this strand " + this + " does not support downstream"); // } // // public boolean isNegative() { // if (this == WATSON) { // return false; // } // if (this == CRICK) { // return true; // } // throw new IllegalArgumentException("this strand " + this + " does not support isNegative"); // } // // // }
import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.nio.BufferUnderflowException; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.Enumeration; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import es.cnio.bioinfo.bicycle.gatk.Strand; import net.sf.picard.filter.SamRecordFilter; import net.sf.picard.util.Interval; import net.sf.picard.util.IntervalList; import net.sf.picard.util.SamLocusIterator; import net.sf.picard.util.SamLocusIterator.LocusInfo; import net.sf.picard.util.SamLocusIterator.RecordAndOffset; import net.sf.samtools.SAMFileReader;
byte[] buf = new byte[1024]; int len; try { while((len = FROM.read(buf))>0) TO.write(buf, 0, len); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { FROM.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { TO.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // ahora borro el fichero original boolean success=from.delete(); if (!success) throw new IllegalArgumentException("Delete: "+from.toString()+" deletion failed"); */ }
// Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/Strand.java // public enum Strand { // // WATSON(".*CT.*WATSON.*"), CRICK(".*CT.*CRICK.*"); // // private Pattern fileRegExp; // // private Strand(String suffix) { // this.fileRegExp = Pattern.compile(suffix); // } // // public Pattern getFileRegExp() { // return this.fileRegExp; // } // // public Context getContext(ReferenceContext ref, long pos) { // if (this == WATSON) { // if (ref.getBase() == 'C') { // if (ref.getWindow().getStop() - pos == 2) { // // byte[] downstream = ref.getBases(); // // correct index if pos <= 2 // int correction = pos == 2? -1:pos == 1? -2: 0; // if (downstream[3+correction] == 'G') { // return Context.CG; // } else if (downstream[4+correction] == 'G') { // return Context.CHG; // } else { // return Context.CHH; // } // } else { // System.err.println("null context in " + ref.getLocus().getContig() + ":" + pos + " strand Watson"); // return null; // } // } else { // throw new IllegalArgumentException("Can't compute Watson context in a reference which is not C"); // } // } else if (this == CRICK) { // if (ref.getBase() == 'G') { // if (pos <= 2) { // System.err.println("Cannot compute context for " + ref.getLocus().getContig() + ":" + pos + " strand Crick"); // return null; // } // if (pos - ref.getWindow().getStart() == 2) { // // byte[] bases = ref.getBases(); // byte[] upstream = new byte[2]; // System.arraycopy(bases, 0, upstream, 0, 2); // // if (upstream[1] == 'C') { // return Context.CG; // } else if (upstream[0] == 'C') { // return Context.CHG; // } else { // return Context.CHH; // } // } else { // System.err.println("null context in " + ref.getLocus().getContig() + ":" + pos + " strand Crick"); // return null; // } // } else { // throw new IllegalArgumentException("Can't compute Watson context in a reference which is not C"); // } // } else { // throw new IllegalArgumentException("this strand " + this + " does not support context calculation"); // } // } // // public char getCytosineBase() { // if (this == WATSON) { // return 'C'; // } // if (this == CRICK) { // return 'G'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getCytonsine"); // } // // public char getGuanineBase() { // if (this == WATSON) { // return 'G'; // } // if (this == CRICK) { // return 'C'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getGuanine"); // } // // public char getThymineBase() { // if (this == WATSON) { // return 'T'; // } // if (this == CRICK) { // return 'A'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getThymine"); // } // // public long downstream(long pos) { // if (this == WATSON) { // return pos + 1; // } // if (this == CRICK) { // return pos - 1; // } // throw new IllegalArgumentException("this strand " + this + " does not support downstream"); // } // // public boolean isNegative() { // if (this == WATSON) { // return false; // } // if (this == CRICK) { // return true; // } // throw new IllegalArgumentException("this strand " + this + " does not support isNegative"); // } // // // } // Path: src/main/java/es/cnio/bioinfo/bicycle/Tools.java import java.io.BufferedOutputStream; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; import java.io.PrintWriter; import java.nio.BufferUnderflowException; import java.text.NumberFormat; import java.util.ArrayList; import java.util.Calendar; import java.util.Collection; import java.util.Collections; import java.util.Date; import java.util.Enumeration; import java.util.HashMap; import java.util.LinkedList; import java.util.List; import java.util.Map; import es.cnio.bioinfo.bicycle.gatk.Strand; import net.sf.picard.filter.SamRecordFilter; import net.sf.picard.util.Interval; import net.sf.picard.util.IntervalList; import net.sf.picard.util.SamLocusIterator; import net.sf.picard.util.SamLocusIterator.LocusInfo; import net.sf.picard.util.SamLocusIterator.RecordAndOffset; import net.sf.samtools.SAMFileReader; byte[] buf = new byte[1024]; int len; try { while((len = FROM.read(buf))>0) TO.write(buf, 0, len); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { FROM.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } try { TO.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } // ahora borro el fichero original boolean success=from.delete(); if (!success) throw new IllegalArgumentException("Delete: "+from.toString()+" deletion failed"); */ }
private static ThreadLocal<HashMap<Strand, SamLocusIterator>> previousIterators = new ThreadLocal<>();
sing-group/bicycle
src/main/java/es/cnio/bioinfo/bicycle/MethylationCall.java
// Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/Context.java // public enum Context { // CG, CHG, CHH; // } // // Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/Strand.java // public enum Strand { // // WATSON(".*CT.*WATSON.*"), CRICK(".*CT.*CRICK.*"); // // private Pattern fileRegExp; // // private Strand(String suffix) { // this.fileRegExp = Pattern.compile(suffix); // } // // public Pattern getFileRegExp() { // return this.fileRegExp; // } // // public Context getContext(ReferenceContext ref, long pos) { // if (this == WATSON) { // if (ref.getBase() == 'C') { // if (ref.getWindow().getStop() - pos == 2) { // // byte[] downstream = ref.getBases(); // // correct index if pos <= 2 // int correction = pos == 2? -1:pos == 1? -2: 0; // if (downstream[3+correction] == 'G') { // return Context.CG; // } else if (downstream[4+correction] == 'G') { // return Context.CHG; // } else { // return Context.CHH; // } // } else { // System.err.println("null context in " + ref.getLocus().getContig() + ":" + pos + " strand Watson"); // return null; // } // } else { // throw new IllegalArgumentException("Can't compute Watson context in a reference which is not C"); // } // } else if (this == CRICK) { // if (ref.getBase() == 'G') { // if (pos <= 2) { // System.err.println("Cannot compute context for " + ref.getLocus().getContig() + ":" + pos + " strand Crick"); // return null; // } // if (pos - ref.getWindow().getStart() == 2) { // // byte[] bases = ref.getBases(); // byte[] upstream = new byte[2]; // System.arraycopy(bases, 0, upstream, 0, 2); // // if (upstream[1] == 'C') { // return Context.CG; // } else if (upstream[0] == 'C') { // return Context.CHG; // } else { // return Context.CHH; // } // } else { // System.err.println("null context in " + ref.getLocus().getContig() + ":" + pos + " strand Crick"); // return null; // } // } else { // throw new IllegalArgumentException("Can't compute Watson context in a reference which is not C"); // } // } else { // throw new IllegalArgumentException("this strand " + this + " does not support context calculation"); // } // } // // public char getCytosineBase() { // if (this == WATSON) { // return 'C'; // } // if (this == CRICK) { // return 'G'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getCytonsine"); // } // // public char getGuanineBase() { // if (this == WATSON) { // return 'G'; // } // if (this == CRICK) { // return 'C'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getGuanine"); // } // // public char getThymineBase() { // if (this == WATSON) { // return 'T'; // } // if (this == CRICK) { // return 'A'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getThymine"); // } // // public long downstream(long pos) { // if (this == WATSON) { // return pos + 1; // } // if (this == CRICK) { // return pos - 1; // } // throw new IllegalArgumentException("this strand " + this + " does not support downstream"); // } // // public boolean isNegative() { // if (this == WATSON) { // return false; // } // if (this == CRICK) { // return true; // } // throw new IllegalArgumentException("this strand " + this + " does not support isNegative"); // } // // // }
import java.io.PrintStream; import java.util.LinkedList; import java.util.List; import es.cnio.bioinfo.bicycle.gatk.Context; import es.cnio.bioinfo.bicycle.gatk.Strand;
/* Copyright 2012 Daniel Gonzalez Pe��a, Osvaldo Gra��a This file is part of the bicycle Project. bicycle Project is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. bicycle Project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser Public License for more details. You should have received a copy of the GNU Lesser Public License along with bicycle Project. If not, see <http://www.gnu.org/licenses/>. */ package es.cnio.bioinfo.bicycle; public class MethylationCall { private Context context; private double pval; private int depth; private int CTdepth; private String pileup; private int cytosines; private String contig; private long position;
// Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/Context.java // public enum Context { // CG, CHG, CHH; // } // // Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/Strand.java // public enum Strand { // // WATSON(".*CT.*WATSON.*"), CRICK(".*CT.*CRICK.*"); // // private Pattern fileRegExp; // // private Strand(String suffix) { // this.fileRegExp = Pattern.compile(suffix); // } // // public Pattern getFileRegExp() { // return this.fileRegExp; // } // // public Context getContext(ReferenceContext ref, long pos) { // if (this == WATSON) { // if (ref.getBase() == 'C') { // if (ref.getWindow().getStop() - pos == 2) { // // byte[] downstream = ref.getBases(); // // correct index if pos <= 2 // int correction = pos == 2? -1:pos == 1? -2: 0; // if (downstream[3+correction] == 'G') { // return Context.CG; // } else if (downstream[4+correction] == 'G') { // return Context.CHG; // } else { // return Context.CHH; // } // } else { // System.err.println("null context in " + ref.getLocus().getContig() + ":" + pos + " strand Watson"); // return null; // } // } else { // throw new IllegalArgumentException("Can't compute Watson context in a reference which is not C"); // } // } else if (this == CRICK) { // if (ref.getBase() == 'G') { // if (pos <= 2) { // System.err.println("Cannot compute context for " + ref.getLocus().getContig() + ":" + pos + " strand Crick"); // return null; // } // if (pos - ref.getWindow().getStart() == 2) { // // byte[] bases = ref.getBases(); // byte[] upstream = new byte[2]; // System.arraycopy(bases, 0, upstream, 0, 2); // // if (upstream[1] == 'C') { // return Context.CG; // } else if (upstream[0] == 'C') { // return Context.CHG; // } else { // return Context.CHH; // } // } else { // System.err.println("null context in " + ref.getLocus().getContig() + ":" + pos + " strand Crick"); // return null; // } // } else { // throw new IllegalArgumentException("Can't compute Watson context in a reference which is not C"); // } // } else { // throw new IllegalArgumentException("this strand " + this + " does not support context calculation"); // } // } // // public char getCytosineBase() { // if (this == WATSON) { // return 'C'; // } // if (this == CRICK) { // return 'G'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getCytonsine"); // } // // public char getGuanineBase() { // if (this == WATSON) { // return 'G'; // } // if (this == CRICK) { // return 'C'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getGuanine"); // } // // public char getThymineBase() { // if (this == WATSON) { // return 'T'; // } // if (this == CRICK) { // return 'A'; // } // throw new IllegalArgumentException("this strand " + this + " does not support getThymine"); // } // // public long downstream(long pos) { // if (this == WATSON) { // return pos + 1; // } // if (this == CRICK) { // return pos - 1; // } // throw new IllegalArgumentException("this strand " + this + " does not support downstream"); // } // // public boolean isNegative() { // if (this == WATSON) { // return false; // } // if (this == CRICK) { // return true; // } // throw new IllegalArgumentException("this strand " + this + " does not support isNegative"); // } // // // } // Path: src/main/java/es/cnio/bioinfo/bicycle/MethylationCall.java import java.io.PrintStream; import java.util.LinkedList; import java.util.List; import es.cnio.bioinfo.bicycle.gatk.Context; import es.cnio.bioinfo.bicycle.gatk.Strand; /* Copyright 2012 Daniel Gonzalez Pe��a, Osvaldo Gra��a This file is part of the bicycle Project. bicycle Project is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. bicycle Project is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser Public License for more details. You should have received a copy of the GNU Lesser Public License along with bicycle Project. If not, see <http://www.gnu.org/licenses/>. */ package es.cnio.bioinfo.bicycle; public class MethylationCall { private Context context; private double pval; private int depth; private int CTdepth; private String pileup; private int cytosines; private String contig; private long position;
private Strand strand;
sing-group/bicycle
src/test/java/es/cnio/bioinfo/bicycle/gatk/CigarIteratorTest.java
// Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/ListerFilter.java // protected static class CigarIterator implements Iterator<CigarOperator> { // // private final boolean reverse; // private List<CigarElement> cigarElements; // private int currentCigarElementsPos; // // private int repetitionsOfCurrentOperation = 0; // private CigarOperator currentOperator = null; // // public CigarIterator(String cigar, boolean reverse) { // this.cigarElements = new ArrayList(TextCigarCodec.getSingleton().decode(cigar).getCigarElements()); // this.reverse = reverse; // this.currentCigarElementsPos = this.reverse ? cigarElements.size() : -1; // this.advanceCigarElement(); // } // // @Override // public boolean hasNext() { // return repetitionsOfCurrentOperation > 0 // || (this.currentCigarElementsPos >= 0 && this.currentCigarElementsPos < this.cigarElements.size()); // } // // @Override // public CigarOperator next() { // // CigarOperator result = this.currentOperator; // this.repetitionsOfCurrentOperation--; // if (repetitionsOfCurrentOperation == 0 && (this.currentCigarElementsPos >= 0 && this // .currentCigarElementsPos < this.cigarElements.size())) { // advanceCigarElement(); // } // // return result; // } // // private void advanceCigarElement() { // this.currentCigarElementsPos = this.currentCigarElementsPos + (this.reverse ? -1 : 1); // if (this.currentCigarElementsPos >= 0 && this.currentCigarElementsPos < this.cigarElements.size()) { // CigarElement element = this.cigarElements.get(this.currentCigarElementsPos); // this.repetitionsOfCurrentOperation = element.getLength(); // this.currentOperator = element.getOperator(); // } // } // }
import static junit.framework.Assert.assertEquals; import java.io.IOException; import org.junit.Test; import es.cnio.bioinfo.bicycle.gatk.ListerFilter.CigarIterator; import net.sf.samtools.CigarOperator;
package es.cnio.bioinfo.bicycle.gatk; public class CigarIteratorTest { @Test public void testPerfectMatch() {
// Path: src/main/java/es/cnio/bioinfo/bicycle/gatk/ListerFilter.java // protected static class CigarIterator implements Iterator<CigarOperator> { // // private final boolean reverse; // private List<CigarElement> cigarElements; // private int currentCigarElementsPos; // // private int repetitionsOfCurrentOperation = 0; // private CigarOperator currentOperator = null; // // public CigarIterator(String cigar, boolean reverse) { // this.cigarElements = new ArrayList(TextCigarCodec.getSingleton().decode(cigar).getCigarElements()); // this.reverse = reverse; // this.currentCigarElementsPos = this.reverse ? cigarElements.size() : -1; // this.advanceCigarElement(); // } // // @Override // public boolean hasNext() { // return repetitionsOfCurrentOperation > 0 // || (this.currentCigarElementsPos >= 0 && this.currentCigarElementsPos < this.cigarElements.size()); // } // // @Override // public CigarOperator next() { // // CigarOperator result = this.currentOperator; // this.repetitionsOfCurrentOperation--; // if (repetitionsOfCurrentOperation == 0 && (this.currentCigarElementsPos >= 0 && this // .currentCigarElementsPos < this.cigarElements.size())) { // advanceCigarElement(); // } // // return result; // } // // private void advanceCigarElement() { // this.currentCigarElementsPos = this.currentCigarElementsPos + (this.reverse ? -1 : 1); // if (this.currentCigarElementsPos >= 0 && this.currentCigarElementsPos < this.cigarElements.size()) { // CigarElement element = this.cigarElements.get(this.currentCigarElementsPos); // this.repetitionsOfCurrentOperation = element.getLength(); // this.currentOperator = element.getOperator(); // } // } // } // Path: src/test/java/es/cnio/bioinfo/bicycle/gatk/CigarIteratorTest.java import static junit.framework.Assert.assertEquals; import java.io.IOException; import org.junit.Test; import es.cnio.bioinfo.bicycle.gatk.ListerFilter.CigarIterator; import net.sf.samtools.CigarOperator; package es.cnio.bioinfo.bicycle.gatk; public class CigarIteratorTest { @Test public void testPerfectMatch() {
CigarIterator iterator = new CigarIterator("3M", false);
sing-group/bicycle
src/main/java/es/cnio/bioinfo/bicycle/operations/ReadsReader.java
// Path: src/main/java/es/cnio/bioinfo/bicycle/Sample.java // public class Sample { // // private String name = "unnamed-sample"; // private List<File> readsFiles = new LinkedList<File>(); // private boolean paired = false; // private boolean directional = true; //directional = Lister, Cokus otherwise // private String mate1Regexp = "_1.fastq"; // //for paired-end // private List<File> readsFilesM1 = new LinkedList<File>(); // private List<File> readsFilesM2 = new LinkedList<File>(); // // private Project project; // // Sample(Project project, String name, boolean paired, boolean directional, // String mate1Regexp) { // super(); // this.name = name; // this.project = project; // this.paired = paired; // this.directional = directional; // this.mate1Regexp = mate1Regexp; // } // // Sample(Project project, String name) { // super(); // this.name = name; // this.project = project; // } // // public String getName() { // return name; // } // // public boolean isPaired() { // return paired; // } // // public boolean isDirectional() { // return directional; // } // // public List<File> getReadsFiles() { // return Collections.unmodifiableList(readsFiles); // } // // public List<File> getReadsMate1Files() { // if (!this.project.isPaired()) { // throw new IllegalArgumentException("The project is not a paired-end project"); // } // return Collections.unmodifiableList(readsFilesM1); // } // // public List<File> getReadsMate2Files() { // if (!this.project.isPaired()) { // throw new IllegalArgumentException("The project is not a paired-end project"); // } // return Collections.unmodifiableList(readsFilesM2); // // } // // public Project getProject() { // return project; // } // // private void addReadsFile(File f) { // this.readsFiles.add(f); // if (this.paired) { // if (f.getName().matches(".*" + this.mate1Regexp + ".*")) { // this.readsFilesM1.add(f); // } else { // this.readsFilesM2.add(f); // } // } // } // // public static List<Sample> buildSamples(Project project) { // return buildSamples(project, false, true, ""); // } // // /** // * Builds samples from a directory which should contain reads files. Each reads file in the root of // * the path is a independent sample (with 1 reads file). If there are subdirectories, each subdirectory is a // * sample with all reads files inside it belonging to this sample. // * // * @param readsPath // * @return // */ // public static List<Sample> buildSamples(Project project, boolean paired, boolean directional, String mate1Regexp) { // File readsPath = project.getReadsDirectory(); // if (!readsPath.exists() || !readsPath.isDirectory()) { // throw new IllegalArgumentException("Cannot find " + readsPath.getAbsolutePath() + " or it is not a " + // "directory, or it is not accessible"); // } // List<Sample> toret = new LinkedList<Sample>(); // for (File file : readsPath.listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // return !name.equals("CVS"); // } // })) { // // if (file.isDirectory()) { // if (file.isHidden()) continue; // Sample s = new Sample(project, file.getName(), paired, directional, mate1Regexp); // // File[] files = file.listFiles(); // Arrays.sort(files, new Comparator<File>() { // @Override // public int compare(File arg0, File arg1) { // return arg0.getName().compareTo(arg1.getName()); // } // // }); // for (File subdirFile : files) { // if (!subdirFile.isDirectory() && !file.isHidden()) { // s.addReadsFile(subdirFile); // } // } // // s.validate(); // toret.add(s); // } else if (!file.isHidden()) { // if (paired) // throw new IllegalArgumentException("Paired-end samples files must be inside a directory per " + // "sample"); // Sample s = new Sample(project, file.getName(), paired, directional, mate1Regexp); // s.addReadsFile(file); // toret.add(s); // s.validate(); // } // } // return toret; // } // // private void validate() { // if (this.paired && this.readsFilesM1.size() != this.readsFilesM2.size()) { // throw new IllegalArgumentException("This sample is paired end, but has a different number of read files " + // "for each mate. mate 1: " + this.readsFilesM1 + ". mate 2: " + this.readsFilesM2); // } // // } // // @Override // public boolean equals(Object obj) { // if (!(obj instanceof Sample)) { // return false; // } // Sample sample = (Sample) obj; // return sample.getName().equals(this.getName()) && sample.readsFiles.equals(this.readsFiles); // } // // @Override // public String toString() { // return this.getName(); // } // // }
import java.io.BufferedReader; import java.io.File; import es.cnio.bioinfo.bicycle.Sample;
package es.cnio.bioinfo.bicycle.operations; public class ReadsReader extends BufferedReader { protected BufferedReader internalReader; private int barcodePosition = -1;
// Path: src/main/java/es/cnio/bioinfo/bicycle/Sample.java // public class Sample { // // private String name = "unnamed-sample"; // private List<File> readsFiles = new LinkedList<File>(); // private boolean paired = false; // private boolean directional = true; //directional = Lister, Cokus otherwise // private String mate1Regexp = "_1.fastq"; // //for paired-end // private List<File> readsFilesM1 = new LinkedList<File>(); // private List<File> readsFilesM2 = new LinkedList<File>(); // // private Project project; // // Sample(Project project, String name, boolean paired, boolean directional, // String mate1Regexp) { // super(); // this.name = name; // this.project = project; // this.paired = paired; // this.directional = directional; // this.mate1Regexp = mate1Regexp; // } // // Sample(Project project, String name) { // super(); // this.name = name; // this.project = project; // } // // public String getName() { // return name; // } // // public boolean isPaired() { // return paired; // } // // public boolean isDirectional() { // return directional; // } // // public List<File> getReadsFiles() { // return Collections.unmodifiableList(readsFiles); // } // // public List<File> getReadsMate1Files() { // if (!this.project.isPaired()) { // throw new IllegalArgumentException("The project is not a paired-end project"); // } // return Collections.unmodifiableList(readsFilesM1); // } // // public List<File> getReadsMate2Files() { // if (!this.project.isPaired()) { // throw new IllegalArgumentException("The project is not a paired-end project"); // } // return Collections.unmodifiableList(readsFilesM2); // // } // // public Project getProject() { // return project; // } // // private void addReadsFile(File f) { // this.readsFiles.add(f); // if (this.paired) { // if (f.getName().matches(".*" + this.mate1Regexp + ".*")) { // this.readsFilesM1.add(f); // } else { // this.readsFilesM2.add(f); // } // } // } // // public static List<Sample> buildSamples(Project project) { // return buildSamples(project, false, true, ""); // } // // /** // * Builds samples from a directory which should contain reads files. Each reads file in the root of // * the path is a independent sample (with 1 reads file). If there are subdirectories, each subdirectory is a // * sample with all reads files inside it belonging to this sample. // * // * @param readsPath // * @return // */ // public static List<Sample> buildSamples(Project project, boolean paired, boolean directional, String mate1Regexp) { // File readsPath = project.getReadsDirectory(); // if (!readsPath.exists() || !readsPath.isDirectory()) { // throw new IllegalArgumentException("Cannot find " + readsPath.getAbsolutePath() + " or it is not a " + // "directory, or it is not accessible"); // } // List<Sample> toret = new LinkedList<Sample>(); // for (File file : readsPath.listFiles(new FilenameFilter() { // @Override // public boolean accept(File dir, String name) { // return !name.equals("CVS"); // } // })) { // // if (file.isDirectory()) { // if (file.isHidden()) continue; // Sample s = new Sample(project, file.getName(), paired, directional, mate1Regexp); // // File[] files = file.listFiles(); // Arrays.sort(files, new Comparator<File>() { // @Override // public int compare(File arg0, File arg1) { // return arg0.getName().compareTo(arg1.getName()); // } // // }); // for (File subdirFile : files) { // if (!subdirFile.isDirectory() && !file.isHidden()) { // s.addReadsFile(subdirFile); // } // } // // s.validate(); // toret.add(s); // } else if (!file.isHidden()) { // if (paired) // throw new IllegalArgumentException("Paired-end samples files must be inside a directory per " + // "sample"); // Sample s = new Sample(project, file.getName(), paired, directional, mate1Regexp); // s.addReadsFile(file); // toret.add(s); // s.validate(); // } // } // return toret; // } // // private void validate() { // if (this.paired && this.readsFilesM1.size() != this.readsFilesM2.size()) { // throw new IllegalArgumentException("This sample is paired end, but has a different number of read files " + // "for each mate. mate 1: " + this.readsFilesM1 + ". mate 2: " + this.readsFilesM2); // } // // } // // @Override // public boolean equals(Object obj) { // if (!(obj instanceof Sample)) { // return false; // } // Sample sample = (Sample) obj; // return sample.getName().equals(this.getName()) && sample.readsFiles.equals(this.readsFiles); // } // // @Override // public String toString() { // return this.getName(); // } // // } // Path: src/main/java/es/cnio/bioinfo/bicycle/operations/ReadsReader.java import java.io.BufferedReader; import java.io.File; import es.cnio.bioinfo.bicycle.Sample; package es.cnio.bioinfo.bicycle.operations; public class ReadsReader extends BufferedReader { protected BufferedReader internalReader; private int barcodePosition = -1;
private Sample sample;