close the first half of #417

This commit is contained in:
petrak@ 2023-02-26 14:47:21 -06:00
parent b9a4e8c204
commit a3b62c4ab8
4 changed files with 38 additions and 8 deletions

View file

@ -0,0 +1,16 @@
package at.petrak.hexcasting.common.casting.operators.math.logic
import at.petrak.hexcasting.api.casting.asActionResult
import at.petrak.hexcasting.api.casting.castables.ConstMediaAction
import at.petrak.hexcasting.api.casting.eval.CastingEnvironment
import at.petrak.hexcasting.api.casting.getBool
import at.petrak.hexcasting.api.casting.iota.Iota
object OpBoolToNumber : ConstMediaAction {
override val argc = 1
override fun execute(args: List<Iota>, ctx: CastingEnvironment): List<Iota> {
val arg = args.getBool(0, argc)
return (if (arg) 1.0 else 0.0).asActionResult
}
}

View file

@ -191,6 +191,8 @@ public class HexActions {
new ActionRegistryEntry(HexPattern.fromAngles("dw", HexDir.NORTH_WEST), OpBoolNot.INSTANCE));
public static final ActionRegistryEntry BOOL_COERCE = make("bool_coerce",
new ActionRegistryEntry(HexPattern.fromAngles("aw", HexDir.NORTH_EAST), OpCoerceToBool.INSTANCE));
public static final ActionRegistryEntry BOOL_TO_NUMBER = make("bool_to_number",
new ActionRegistryEntry(HexPattern.fromAngles("awd", HexDir.SOUTH_EAST), OpBoolToNumber.INSTANCE));
public static final ActionRegistryEntry IF = make("if",
new ActionRegistryEntry(HexPattern.fromAngles("awdd", HexDir.SOUTH_EAST), OpBoolIf.INSTANCE));

View file

@ -332,6 +332,7 @@
"hexcasting.action.book.hexcasting:const/vec/y": "Vector Rfln. +Y/-Y",
"hexcasting.action.book.hexcasting:const/vec/z": "Vector Rfln. +Z/-Z",
"hexcasting.action.book.hexcasting:read/entity": "Chronicler's Prfn.",
"hexcasting.action.book.hexcasting:bool_to_number": "Numerologist's Prfn.",
"hexcasting.action.book.hexcasting:number": "Numerical Reflection",
"hexcasting.action.book.hexcasting:mask": "Bookkeeper's Gambit",
@ -427,6 +428,7 @@
"hexcasting.action.hexcasting:not_equals": "Inequality Distillation",
"hexcasting.action.hexcasting:not": "Negation Purification",
"hexcasting.action.hexcasting:bool_coerce": "Augur's Purification",
"hexcasting.action.hexcasting:bool_to_number": "Numerologist's Purification",
"hexcasting.action.hexcasting:if": "Augur's Exaltation",
"hexcasting.action.hexcasting:add": "Additive Distillation",
@ -557,6 +559,7 @@
"hexcasting.mishap.invalid_value.int.positive.less.equal": "a positive integer less than or equal to %d",
"hexcasting.mishap.invalid_value.int.between": "an integer between %d and %d",
"hexcasting.mishap.invalid_value.evaluatable": "something evaluatable",
"hexcasting.mishap.invalid_value.bool_commute": "a boolean, 0, or 1",
"hexcasting.mishap.not_enough_args": "expected %s or more arguments but the stack was only %s tall",
"hexcasting.mishap.no_args": "expected %s or more arguments but the stack was empty",
"hexcasting.mishap.too_many_close_parens": "Did not first use Introspection",
@ -1002,6 +1005,7 @@
"hexcasting.entry.logic": "Logical Operators",
"hexcasting.page.logic.bool_coerce": "Convert an argument to a boolean. The number $(thing)0/$, $(l:influences#null)$(thing)Null/$, and the empty list become False; everything else becomes True.",
"hexcasting.page.logic.bool_to_number": "Convert a boolean to a number; True becomes $(thing)1/$, and False becomes $(thing)0/$.",
"hexcasting.page.logic.not": "If the argument is True, return False; if it is False, return True.",
"hexcasting.page.logic.or": "Returns True if at least one of the arguments are True; otherwise returns False.",
"hexcasting.page.logic.and": "Returns True if both arguments are true; otherwise returns False.",

View file

@ -6,14 +6,6 @@
"advancement": "hexcasting:root",
"read_by_default": true,
"pages": [
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:not",
"anchor": "hexcasting:not",
"input": "any",
"output": "number",
"text": "hexcasting.page.logic.not"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:bool_coerce",
@ -22,6 +14,22 @@
"output": "bool",
"text": "hexcasting.page.logic.bool_coerce"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:bool_to_number",
"anchor": "hexcasting:bool_to_number",
"input": "bool",
"output": "number",
"text": "hexcasting.page.logic.bool_to_number"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:not",
"anchor": "hexcasting:not",
"input": "any",
"output": "number",
"text": "hexcasting.page.logic.not"
},
{
"type": "hexcasting:pattern",
"op_id": "hexcasting:or",