-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
7bed05e
commit 1cfce8f
Showing
23 changed files
with
321 additions
and
15 deletions.
There are no files selected for viewing
File renamed without changes.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
2 changes: 1 addition & 1 deletion
2
Assignments/.idea/modules.xml → Assignments/04-Stag/.idea/modules.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
File renamed without changes.
59 changes: 54 additions & 5 deletions
59
Assignments/.idea/workspace.xml → Assignments/04-Stag/.idea/workspace.xml
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<module type="JAVA_MODULE" version="4"> | ||
<component name="NewModuleRootManager" inherit-compiler-output="true"> | ||
<exclude-output /> | ||
<content url="file://$MODULE_DIR$"> | ||
<sourceFolder url="file://$MODULE_DIR$/src" isTestSource="false" /> | ||
</content> | ||
<orderEntry type="inheritedJdk" /> | ||
<orderEntry type="sourceFolder" forTests="false" /> | ||
<orderEntry type="module-library" exported=""> | ||
<library> | ||
<CLASSES> | ||
<root url="jar://$MODULE_DIR$/src/libs/dot-parser.jar!/" /> | ||
</CLASSES> | ||
<JAVADOC /> | ||
<SOURCES /> | ||
</library> | ||
</orderEntry> | ||
<orderEntry type="module-library" exported=""> | ||
<library> | ||
<CLASSES> | ||
<root url="jar://$MODULE_DIR$/src/libs/json-parser.jar!/" /> | ||
</CLASSES> | ||
<JAVADOC /> | ||
<SOURCES /> | ||
</library> | ||
</orderEntry> | ||
<orderEntry type="library" name="libs" level="project" /> | ||
</component> | ||
</module> |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
default: build | ||
|
||
build: | ||
javac -classpath ./libs/dot-parser.jar:./libs/json-parser.jar:. StagServer.java | ||
|
||
run: build | ||
java -classpath ./libs/dot-parser.jar:./libs/json-parser.jar:. StagServer data/entities.dot data/actions.json | ||
|
||
clean: | ||
rm *.class |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
|
||
import java.io.File; | ||
import java.io.FileNotFoundException; | ||
import java.io.FileReader; | ||
import java.util.ArrayList; | ||
|
||
import com.alexmerz.graphviz.ParseException; | ||
import com.alexmerz.graphviz.Parser; | ||
import com.alexmerz.graphviz.objects.Edge; | ||
import com.alexmerz.graphviz.objects.Graph; | ||
import com.alexmerz.graphviz.objects.Id; | ||
import com.alexmerz.graphviz.objects.Node; | ||
|
||
public class ParserClass { | ||
|
||
public static void main(String[] args) { | ||
FileReader in=null; | ||
File f = new File( "C:\\Users\\Matt\\Documents\\CompSciLinux\\Java\\Assignments\\04-Stag\\src\\data/entities.dot" ); | ||
|
||
try { | ||
in = new FileReader(f); | ||
Parser p = new Parser(); | ||
p.parse(in); | ||
} catch (FileNotFoundException e) { | ||
System.out.println(); | ||
} catch (ParseException e) { | ||
// do something if the parser caused a parser error | ||
} | ||
|
||
// everything ok | ||
ArrayList<Graph> gl = p.getGraphs(); | ||
|
||
// do something with the Graph objects | ||
} | ||
} | ||
|
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
import java.io.*; | ||
import java.net.*; | ||
|
||
public class StagClient | ||
{ | ||
public static void main(String args[]) | ||
{ | ||
if(args.length != 1) System.out.println("Usage: java StageClient <player-name>"); | ||
else { | ||
String playerName = args[0]; | ||
BufferedReader commandLine = new BufferedReader(new InputStreamReader(System.in)); | ||
while(true) handleNextCommand(commandLine, playerName); | ||
} | ||
} | ||
|
||
private static void handleNextCommand(BufferedReader commandLine, String playerName) | ||
{ | ||
try { | ||
String incoming; | ||
System.out.print("\n" + playerName + ": "); | ||
String command = commandLine.readLine(); | ||
Socket socket = new Socket("127.0.0.1", 8888); | ||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); | ||
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); | ||
out.write(playerName + ": " + command + "\n"); | ||
out.flush(); | ||
while((incoming = in.readLine()) != null) System.out.println(incoming); | ||
in.close(); | ||
out.close(); | ||
socket.close(); | ||
} catch(IOException ioe) { | ||
System.out.println(ioe); | ||
} | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import java.io.*; | ||
import java.net.*; | ||
import java.util.*; | ||
|
||
class StagServer | ||
{ | ||
public static void main(String args[]) | ||
{ | ||
if(args.length != 2) System.out.println("Usage: java StagServer <entity-file> <action-file>"); | ||
else new StagServer(args[0], args[1], 8888); | ||
} | ||
|
||
public StagServer(String entityFilename, String actionFilename, int portNumber) | ||
{ | ||
try { | ||
ServerSocket ss = new ServerSocket(portNumber); | ||
System.out.println("Server Listening"); | ||
while(true) acceptNextConnection(ss); | ||
} catch(IOException ioe) { | ||
System.err.println(ioe); | ||
} | ||
} | ||
|
||
private void acceptNextConnection(ServerSocket ss) | ||
{ | ||
try { | ||
// Next line will block until a connection is received | ||
Socket socket = ss.accept(); | ||
BufferedReader in = new BufferedReader(new InputStreamReader(socket.getInputStream())); | ||
BufferedWriter out = new BufferedWriter(new OutputStreamWriter(socket.getOutputStream())); | ||
processNextCommand(in, out); | ||
out.close(); | ||
in.close(); | ||
socket.close(); | ||
} catch(IOException ioe) { | ||
System.err.println(ioe); | ||
} | ||
} | ||
|
||
private void processNextCommand(BufferedReader in, BufferedWriter out) throws IOException | ||
{ | ||
String line = in.readLine(); | ||
out.write("You said... " + line + "\n"); | ||
} | ||
} |
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
{ | ||
"actions": [ | ||
|
||
{ | ||
"triggers": ["open", "unlock"], | ||
"subjects": ["door", "key"], | ||
"consumed": ["key"], | ||
"produced": ["cellar"], | ||
"narration": "You unlock the door and see steps leading down into a cellar" | ||
}, | ||
|
||
{ | ||
"triggers": ["chop", "cut", "cutdown"], | ||
"subjects": ["tree", "axe"], | ||
"consumed": ["tree"], | ||
"produced": ["log"], | ||
"narration": "You cut down the tree with the axe" | ||
}, | ||
|
||
{ | ||
"triggers": ["drink"], | ||
"subjects": ["potion"], | ||
"consumed": ["potion"], | ||
"produced": ["health"], | ||
"narration": "You drink the potion and your health improves" | ||
}, | ||
|
||
{ | ||
"triggers": ["fight", "hit", "punch", "kick", "slap", "attack", "kill"], | ||
"subjects": ["elf"], | ||
"consumed": ["health"], | ||
"produced": [], | ||
"narration": "You attack the elf, but he fights back and you lose some health" | ||
} | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
digraph layout { | ||
/* ortho splines just makes the arrows into straight lines (rather than curvy ones !) */ | ||
splines = ortho; | ||
node [shape = "rect"]; | ||
|
||
subgraph locations { | ||
subgraph cluster001 { | ||
node [shape = "none"]; | ||
start [description = "An empty room"]; | ||
subgraph artefacts { | ||
node [shape = "diamond"]; | ||
potion [description = "Magic potion"]; | ||
} | ||
subgraph furniture { | ||
node [shape = "hexagon"]; | ||
door [description = "Wooden door"]; | ||
} | ||
} | ||
|
||
subgraph cluster002 { | ||
node [shape = "none"]; | ||
forest [description = "A dark forest"]; | ||
subgraph artefacts { | ||
node [shape = "diamond"]; | ||
key [description = "Brass key"]; | ||
} | ||
} | ||
|
||
subgraph cluster003 { | ||
node [shape = "none"]; | ||
cellar [description = "A dusty cellar"] | ||
subgraph characters { | ||
node [shape = "ellipse"]; | ||
elf [description = "Angry Elf"]; | ||
} | ||
} | ||
} | ||
|
||
subgraph paths { | ||
start -> forest; | ||
forest -> start; | ||
cellar -> start; | ||
} | ||
|
||
} |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
Binary file not shown.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Oops, something went wrong.