You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
The string generated by @type should be passed as the string input parameter to both damage and hitdice filters.
Actual Behaviour
input is empty in damage and hitdice.
Full Script Details
usingSystem;usingSystem.Collections;usingSystem.Collections.Generic;usingUnityEngine;usingCalyx;publicenumHitDamage{Piercing,Bludgeoning,Slashing}publicenumElementalDamage{Fire,Poison,Cold}publicenumDice{D4,D6,D8,D10}publicclassStatblockHelpers{publicstaticHitDamageGetDamageType(stringinput){Debug.Log(input);switch(input){case"sword":case"axe":returnHitDamage.Slashing;case"polearm":case"bow":case"crossbow":case"blowgun":returnHitDamage.Piercing;case"mace":case"hammer":returnHitDamage.Bludgeoning;default:returnHitDamage.Slashing;}}publicstaticDiceGetBaseHitDice(stringinput){Debug.Log(input);switch(input){case"sword":case"bow":case"hammer":returnDice.D8;case"polearm":case"crossbow":returnDice.D10;case"mace":returnDice.D6;case"blowgun":returnDice.D4;default:returnDice.D6;}}[FilterName("damage")]publicstaticstringDamageFilter(stringinput,Optionsoptions){Debug.Log(input);returnGetDamageType(input).ToString();}[FilterName("hitdice")]publicstaticstringHitDiceFilter(stringinput,Optionsoptions){Debug.Log(input);returnGetBaseHitDice(input).ToString();}}publicclassWeapon{publicreadonlystringtype;publicreadonlyHitDamagehitDamage;publicreadonlyElementalDamageelementalDamage;publicreadonlyDicehitDice;publicreadonlyintbonus;// Construct by parsing a grammar result statblockpublicWeapon(string[]stats){type=stats[0];hitDamage=(HitDamage)Enum.Parse(typeof(HitDamage),stats[1]);hitDice=(Dice)Enum.Parse(typeof(Dice),stats[2]);elementalDamage=(ElementalDamage)Enum.Parse(typeof(ElementalDamage),stats[3]);bonus=Int32.Parse(stats[4]);}// Construct manually from type stringspublicWeapon(stringtypestr,stringelementstr,stringbonusstr){type=typestr;hitDamage=StatblockHelpers.GetDamageType(type);hitDice=StatblockHelpers.GetBaseHitDice(type);elementalDamage=(ElementalDamage)Enum.Parse(typeof(ElementalDamage),elementstr);bonus=Int32.Parse(bonusstr);}}publicclassWeaponGen:MonoBehaviour{voidStart(){Grammarweapons=newGrammar(G =>{G.Rule("start","{@type};{@type.damage};{@type.hitdice};{element};{bonus}");G.Rule("element",Enum.GetNames(typeof(ElementalDamage)));G.Rule("bonus",new[]{"+1","+2","+3"});G.Rule("type",new[]{"{ranged}","{melee}"});G.Rule("ranged",new[]{"bow","crossbow","blowgun"});G.Rule("melee",new[]{"sword","axe","polearm","mace","hammer"});G.Filters(typeof(StatblockHelpers));});Resultw1=weapons.Generate();Debug.Log(w1.Text);Weaponweapon1=newWeapon(w1.Text.Split(';'));Weaponweapon2=newWeapon(weapons.Generate("type").Text,weapons.Generate("element").Text,weapons.Generate("bonus").Text);// Debug.Log(weapon1.type);// Debug.Log(weapon1.hitDice);// Debug.Log(weapon1.hitDamage);// Debug.Log(weapon1.elementalDamage);// Debug.Log(weapon1.bonus);//// Debug.Log(weapon2.type);// Debug.Log(weapon2.hitDice);// Debug.Log(weapon2.hitDamage);// Debug.Log(weapon2.elementalDamage);// Debug.Log(weapon2.bonus);}}
The text was updated successfully, but these errors were encountered:
Environment/Platform
Steps to Reproduce
CalyxSharp.dll
into the Unity projectAssets
folderWeaponGen
inAssets
and assign it as a component to a game object in the sceneclass WeaponGen
inheriting fromMonoBehaviour
@type
rule being expanded with thedamage
andhitdice
filters:Expected Behaviour
The string generated by
@type
should be passed as thestring input
parameter to bothdamage
andhitdice
filters.Actual Behaviour
input
is empty indamage
andhitdice
.Full Script Details
The text was updated successfully, but these errors were encountered: