Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merge latets integrated changes #1

Merged
merged 35 commits into from
Sep 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
35 commits
Select commit Hold shift + click to select a range
44da45e
Slight SimpleJson code tidying
joethephish Jul 9, 2016
f95f37c
Check for null/empty paths, make string components setter private, an…
joethephish Jul 23, 2016
beaf30c
Make Path a bit more immutable by making isRelative's setter private
joethephish Jul 23, 2016
6d4f42b
Don't use ink's internal function calling within choice text producti…
joethephish Jul 25, 2016
1b6254d
Test for temp usage in choices
joethephish Jul 26, 2016
bde59a9
Better support for evaluating arbitrary ink on command line
joethephish Jul 27, 2016
57651aa
Ability to call an ink function from game code
joethephish Aug 3, 2016
1b5f585
Ability to optionally get the text output from EvaluateFunction
joethephish Aug 3, 2016
59d51d2
Document EvaluateFunction
joethephish Aug 3, 2016
b2dfbef
Throw an exception that's caught in play mode when there's an unbound…
joethephish Aug 4, 2016
910313a
Improved version of EvaluateFunction that doesn't clobber the current…
joethephish Aug 4, 2016
1c5b4cd
EvaluateFunction can take ink arguments, and added another Test for it
joethephish Aug 4, 2016
de7e834
Document the EvaluateFunction arguments param
joethephish Aug 4, 2016
1da7428
Oops
joethephish Aug 4, 2016
6c6f349
Add function exists function
tomkail Aug 4, 2016
a9396b7
Add missing semicolon
tomkail Aug 4, 2016
195ccce
Rename function
tomkail Aug 4, 2016
dbcc43c
Replace Debug.Fail instances with simple exception throws, for compat…
joethephish Aug 12, 2016
cff539c
Clone Element's temporaryVariables
cduquesne Aug 21, 2016
8968b6b
Merge pull request #159 from cduquesne/smallfixes
joethephish Aug 21, 2016
a9d1a50
Fix casting issue in TryCoerce function
cduquesne Aug 22, 2016
cfa8af0
Merge pull request #161 from cduquesne/patch-1
joethephish Aug 22, 2016
ea63335
Fix comment that still mentioned Json.net
joethephish Aug 22, 2016
fbee47a
Throw if evaluating a null/empty function
tomkail Aug 22, 2016
285d537
Merge branch 'master' of https://github.com/inkle/ink
tomkail Aug 22, 2016
343f638
Make float.Parse work independent of local culture (so it doesn't exp…
joethephish Sep 6, 2016
b822360
A call to -> END resets the state of "previousContentObject", which a…
joethephish Sep 9, 2016
a064ce4
-> DONE should stop flow in the current thread.
joethephish Sep 11, 2016
fc3b27f
RANDOM and SEED_RANDOM implementations, although not currently produc…
joethephish Sep 11, 2016
532d6ed
Add warning for using "else:" instead of "- else:" within a branch.
joethephish Sep 11, 2016
1998410
Better algorithm for generating a set of consistent set of random num…
joethephish Sep 11, 2016
5d0c19f
Merge branch 'random'
joethephish Sep 11, 2016
6360931
Bah stupid me for pushing before running unit tests. Fixed!
joethephish Sep 11, 2016
d9f7f51
Show error when passing "-> myVar" as a divert target rather than jus…
joethephish Sep 14, 2016
488a3e0
Fix for mismatched left/right glue. I had assumed that only the most …
joethephish Sep 14, 2016
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ink-engine-runtime/CallStack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public Element(PushPopType type, Container container, int contentIndex, bool inE
public Element Copy()
{
var copy = new Element (this.type, this.currentContainer, this.currentContentIndex, this.inExpressionEvaluation);
copy.temporaryVariables = this.temporaryVariables;
copy.temporaryVariables = new Dictionary<string,Object>(this.temporaryVariables);
return copy;
}
}
Expand Down Expand Up @@ -246,7 +246,7 @@ public void PopThread()
if (canPopThread) {
_threads.Remove (currentThread);
} else {
Debug.Fail ("Can't pop thread");
throw new System.Exception("Can't pop thread");
}
}

Expand Down Expand Up @@ -280,7 +280,7 @@ public void Pop(PushPopType? type = null)
callStack.RemoveAt (callStack.Count - 1);
return;
} else {
Debug.Fail ("Mismatched push/pop in Callstack");
throw new System.Exception("Mismatched push/pop in Callstack");
}
}

Expand Down
12 changes: 12 additions & 0 deletions ink-engine-runtime/ControlCommand.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ public enum CommandType
NoOp,
ChoiceCount,
TurnsSince,
Random,
SeedRandom,
VisitIndex,
SequenceShuffleIndex,
StartThread,
Expand Down Expand Up @@ -100,6 +102,16 @@ public static ControlCommand TurnsSince() {
return new ControlCommand(CommandType.TurnsSince);
}

public static ControlCommand Random ()
{
return new ControlCommand (CommandType.Random);
}

public static ControlCommand SeedRandom ()
{
return new ControlCommand (CommandType.SeedRandom);
}

public static ControlCommand VisitIndex() {
return new ControlCommand(CommandType.VisitIndex);
}
Expand Down
2 changes: 2 additions & 0 deletions ink-engine-runtime/JsonSerialisation.cs
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,8 @@ static Json()
_controlCommandNames [(int)ControlCommand.CommandType.NoOp] = "nop";
_controlCommandNames [(int)ControlCommand.CommandType.ChoiceCount] = "choiceCnt";
_controlCommandNames [(int)ControlCommand.CommandType.TurnsSince] = "turns";
_controlCommandNames [(int)ControlCommand.CommandType.Random] = "rnd";
_controlCommandNames [(int)ControlCommand.CommandType.SeedRandom] = "srnd";
_controlCommandNames [(int)ControlCommand.CommandType.VisitIndex] = "visit";
_controlCommandNames [(int)ControlCommand.CommandType.SequenceShuffleIndex] = "seq";
_controlCommandNames [(int)ControlCommand.CommandType.StartThread] = "thread";
Expand Down
3 changes: 1 addition & 2 deletions ink-engine-runtime/Object.cs
Original file line number Diff line number Diff line change
Expand Up @@ -152,8 +152,7 @@ internal Path ConvertPathToRelative(Path globalPath)
for (int down = lastSharedPathCompIndex + 1; down < globalPath.components.Count; ++down)
newPathComps.Add (globalPath.components [down]);

var relativePath = new Path (newPathComps);
relativePath.isRelative = true;
var relativePath = new Path (newPathComps, relative:true);
return relativePath;
}

Expand Down
16 changes: 12 additions & 4 deletions ink-engine-runtime/Path.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ public override int GetHashCode ()

public List<Component> components { get; private set; }

public bool isRelative { get; set; }
public bool isRelative { get; private set; }

public Component head
{
Expand Down Expand Up @@ -145,9 +145,10 @@ public Path(Component head, Path tail) : this()
components.AddRange (tail.components);
}

public Path(IEnumerable<Component> components) : this()
public Path(IEnumerable<Component> components, bool relative = false) : this()
{
this.components.AddRange (components);
this.isRelative = relative;
}

public Path(string componentsString) : this()
Expand Down Expand Up @@ -195,18 +196,25 @@ public string componentsString {
else
return compsStr;
}
set {
private set {
components.Clear ();

var componentsStr = value;

// Empty path, empty components
// (path is to root, like "/" in file system)
if (string.IsNullOrEmpty(componentsStr))
return;

// When components start with ".", it indicates a relative path, e.g.
// .^.^.hello.5
// is equivalent to file system style path:
// ../../hello/5
if (componentsStr [0] == '.') {
isRelative = true;
this.isRelative = true;
componentsStr = componentsStr.Substring (1);
} else {
this.isRelative = false;
}

var componentStrings = componentsStr.Split('.');
Expand Down
67 changes: 23 additions & 44 deletions ink-engine-runtime/SimpleJson.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,39 +42,28 @@ object ReadObject ()
{
var currentChar = _text [_offset];

object obj = null;
switch (currentChar) {
case '{':
obj = ReadDictionary ();
break;
case '[':
obj = ReadArray ();
break;
case '"':
obj = ReadString ();
break;
default:
if (IsNumberChar(currentChar)) {
obj = ReadNumber ();
break;
}
if( currentChar == '{' )
return ReadDictionary ();

else if (currentChar == '[')
return ReadArray ();

if (TryRead ("true")) {
return true;
}
else if (currentChar == '"')
return ReadString ();

if (TryRead ("false")) {
return false;
}
else if (IsNumberChar(currentChar))
return ReadNumber ();

if (TryRead ("null")) {
return null;
}
else if (TryRead ("true"))
return true;

throw new System.Exception ("Unhandled object type in JSON: "+_text.Substring (_offset, 30));
}
else if (TryRead ("false"))
return false;

return obj;
else if (TryRead ("null"))
return null;

throw new System.Exception ("Unhandled object type in JSON: "+_text.Substring (_offset, 30));
}

Dictionary<string, object> ReadDictionary ()
Expand All @@ -91,6 +80,8 @@ Dictionary<string, object> ReadDictionary ()

do {

SkipWhitespace ();

// Key
var key = ReadString ();
Expect (key != null, "dictionary key");
Expand All @@ -111,14 +102,7 @@ Dictionary<string, object> ReadDictionary ()

SkipWhitespace ();

if (TryRead (",")) {
SkipWhitespace ();
continue;
} else {
break;
}

} while (true);
} while ( TryRead (",") );

Expect ("}");

Expand All @@ -139,6 +123,8 @@ List<object> ReadArray ()

do {

SkipWhitespace ();

// Value
var val = ReadObject ();

Expand All @@ -147,14 +133,7 @@ List<object> ReadArray ()

SkipWhitespace ();

if (TryRead (",")) {
SkipWhitespace ();
continue;
} else {
break;
}

} while (true);
} while (TryRead (","));

Expect ("]");

Expand Down
Loading