From cc7c2bea77fc6c56935cd05fba787ad4eb502b3e Mon Sep 17 00:00:00 2001 From: skippi Date: Fri, 4 Nov 2022 18:58:02 -0500 Subject: [PATCH] add .state conditional (#1024) This is useful for telling the user the current state (or last executed action) of the player for apl sims. --- pkg/conditional/conditional.go | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/pkg/conditional/conditional.go b/pkg/conditional/conditional.go index b7c91fcaf..f6180c5c3 100644 --- a/pkg/conditional/conditional.go +++ b/pkg/conditional/conditional.go @@ -9,7 +9,12 @@ import ( func fieldsCheck(fields []string, expecting int, category string) error { if len(fields) < expecting { - return fmt.Errorf("bad %v condition; invalid num of fields; expecting at least %v; got %v", category, expecting, len(fields)) + return fmt.Errorf( + "bad %v condition; invalid num of fields; expecting at least %v; got %v", + category, + expecting, + len(fields), + ) } return nil } @@ -33,8 +38,10 @@ func Eval(c *core.Core, fields []string) (any, error) { return evalGadgets(c, fields) case "keys": return evalKeys(c, fields) + case "state": + return int(c.Player.CurrentState()), nil default: - //check if it's a char name; if so check char custom eval func + // check if it's a char name; if so check char custom eval func name := fields[0] if key, ok := shortcut.CharNameToKey[name]; ok { return evalCharacter(c, key, fields)