public class RollOfDice{ public delegate Roll()=>int; public static Random rng = new Random; protected int minimumValue; public int MinimumValue{ get{ return(minimumValue); } } protected int maximumValue; public int MaximumValue{ get{ return(maximumValue); } } public static Create( void -> int rollProcedure, int min, int max) => RollOfDice { local RollOfDice rtn = new RollOfDice; rtn.Roll = rollProcedure; rtn.minimumValue = min; rtn.maximumValue = max; return(rtn); } public static CreateDie( int sides ) => RollOfDice{ return( // bug #67, // static scoping needs full path. RollOfDice.Create( ()=>int{ return( (RollOfDice.rng.Next(sides))+1 ); }, 1, sides ) ); }}// bug #65, custom initializer is fubar'd//public RollOfDice d20 = RollOfDice.CreateDie(20);public RollOfDice d20;public RollOfDice d12;public RollOfDice d10;public RollOfDice d8;public RollOfDice d6;public RollOfDice d4;public static create dice => void { d20 = RollOfDice.CreateDie(20); d12 = RollOfDice.CreateDie(12); d10 = RollOfDice.CreateDie(10); d8 = RollOfDice.CreateDie(8); d6 = RollOfDice.CreateDie(6); d4 = RollOfDice.CreateDie(4);}public static roll (RollOfDice die) => int{ return(die.Roll());}public class int{ public this (RollOfDice die) => RollOfDice{ local int min = die.MinimumValue * this; local int max = die.MaximumValue * this; local void -> int newDie = ()=>int{ local int rtn = 0; foreach(int count in 0 to this - 1){ local int dieroll = roll die; print "Rolling one " die.MaximumValue " sided die: " dieroll "\r\n"; rtn = rtn + dieroll; } return(rtn); }; return(RollOfDice.Create(newDie,min,max)); }}public static main()=>void{ create dice; print roll 3d6 "\r\n\r\n"; print "10 d20:\r\n"; foreach( int x in 0 to 10 ){ print roll d20 "\r\n"; }}
The problem was that the VM wouldn't run both of the dice rolls in main... If I commented out the roll 3d6 line, the d20's would roll. If I commented out the d20's then the 3d6 would roll. If I left them in, then too the 3d6 was the only thing run.
The problem eventually turned out to be in the generator for n to m. The cursor was not being reset for the yieldy bit of code, so it could only be run once before it always reported done. The auto-generated GetEnumerator call now also triggers Reset so that doesn't happen. Yay.
I unfortunately don't expect too much more progress in the near future. Once motivated I want to really focus on cleaning everything up for a release. Something I can actually show off to people and garner more interesting feedback than "it doesn't work."