Skip to content

Commit

Permalink
Reformat all code with spotless
Browse files Browse the repository at this point in the history
  • Loading branch information
bladecoder committed Dec 21, 2022
1 parent ddde5af commit 9344cdc
Show file tree
Hide file tree
Showing 66 changed files with 8,954 additions and 9,307 deletions.
4 changes: 3 additions & 1 deletion .github/workflows/gradle-build-push.yml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
name: Run Gradle build on push

on: [push]
on: [ push ]

jobs:
build:
Expand All @@ -23,6 +23,8 @@ jobs:
${{ runner.os }}-gradle-
- name: Build with Gradle
run: ./gradlew build
- name: Pass tests and checks
run: ./gradlew check
- name: Cleanup Gradle Cache
# Remove some files from the Gradle cache, so they aren't cached by GitHub Actions.
# Restoring these files from a GitHub Actions cache might cause problems for future builds.
Expand Down
98 changes: 49 additions & 49 deletions src/main/java/com/bladecoder/ink/runtime/AbstractValue.java
Original file line number Diff line number Diff line change
@@ -1,49 +1,49 @@
package com.bladecoder.ink.runtime;

public abstract class AbstractValue extends RTObject {
public abstract ValueType getValueType();

public abstract boolean isTruthy() throws Exception;

public abstract AbstractValue cast(ValueType newType) throws Exception;

public abstract Object getValueObject();

public static AbstractValue create(Object val) {
// Implicitly lose precision from any doubles we get passed in
if (val instanceof Double) {
double doub = (Double) val;
val = (float) doub;
}

if (val instanceof Boolean) {
return new BoolValue((Boolean) val);
} else if (val instanceof Integer) {
return new IntValue((Integer) val);
} else if (val instanceof Long) {
return new IntValue(((Long) val).intValue());
} else if (val instanceof Float) {
return new FloatValue((Float) val);
} else if (val instanceof Double) {
return new FloatValue((((Double) val).floatValue()));
} else if (val instanceof String) {
return new StringValue((String) val);
} else if (val instanceof Path) {
return new DivertTargetValue((Path) val);
} else if (val instanceof InkList) {
return new ListValue((InkList) val);
}

return null;
}

@Override
RTObject copy() {
return create(getValueObject());
}

protected StoryException BadCastException(ValueType targetType) throws Exception {
return new StoryException(
"Can't cast " + this.getValueObject() + " from " + this.getValueType() + " to " + targetType);
}
}
package com.bladecoder.ink.runtime;

public abstract class AbstractValue extends RTObject {
public abstract ValueType getValueType();

public abstract boolean isTruthy() throws Exception;

public abstract AbstractValue cast(ValueType newType) throws Exception;

public abstract Object getValueObject();

public static AbstractValue create(Object val) {
// Implicitly lose precision from any doubles we get passed in
if (val instanceof Double) {
double doub = (Double) val;
val = (float) doub;
}

if (val instanceof Boolean) {
return new BoolValue((Boolean) val);
} else if (val instanceof Integer) {
return new IntValue((Integer) val);
} else if (val instanceof Long) {
return new IntValue(((Long) val).intValue());
} else if (val instanceof Float) {
return new FloatValue((Float) val);
} else if (val instanceof Double) {
return new FloatValue((((Double) val).floatValue()));
} else if (val instanceof String) {
return new StringValue((String) val);
} else if (val instanceof Path) {
return new DivertTargetValue((Path) val);
} else if (val instanceof InkList) {
return new ListValue((InkList) val);
}

return null;
}

@Override
RTObject copy() {
return create(getValueObject());
}

protected StoryException BadCastException(ValueType targetType) throws Exception {
return new StoryException(
"Can't cast " + this.getValueObject() + " from " + this.getValueType() + " to " + targetType);
}
}
77 changes: 38 additions & 39 deletions src/main/java/com/bladecoder/ink/runtime/BoolValue.java
Original file line number Diff line number Diff line change
@@ -1,43 +1,42 @@
package com.bladecoder.ink.runtime;

class BoolValue extends Value<Boolean> {
public BoolValue() {
this(false);
}

public BoolValue(boolean boolVal) {
super(boolVal);
}

@Override
public AbstractValue cast(ValueType newType) throws Exception {
if (newType == getValueType()) {
return this;
}

if (newType == ValueType.Int) {
return new IntValue(value ? 1 : 0);
}

if (newType == ValueType.Float) {
return new FloatValue(value ? 1f : 0f);
}

if (newType == ValueType.String) {
return new StringValue(value.toString());
}

throw BadCastException(newType);
}

@Override
public boolean isTruthy() {
return value;
}

@Override
public ValueType getValueType() {
return ValueType.Bool;
}

public BoolValue() {
this(false);
}

public BoolValue(boolean boolVal) {
super(boolVal);
}

@Override
public AbstractValue cast(ValueType newType) throws Exception {
if (newType == getValueType()) {
return this;
}

if (newType == ValueType.Int) {
return new IntValue(value ? 1 : 0);
}

if (newType == ValueType.Float) {
return new FloatValue(value ? 1f : 0f);
}

if (newType == ValueType.String) {
return new StringValue(value.toString());
}

throw BadCastException(newType);
}

@Override
public boolean isTruthy() {
return value;
}

@Override
public ValueType getValueType() {
return ValueType.Bool;
}
}

0 comments on commit 9344cdc

Please sign in to comment.