Imports System
Imports uCalcSoftware
Public Module Program
   Public Sub Main()
      Dim uc As New uCalc()
      '// 1. Define the initial game state
      uc.DefineVariable("p1_pos = 0")
      uc.DefineVariable("p1_gold = 10")
      uc.DefineVariable("p2_pos = 0")
      uc.DefineVariable("p2_gold = 10")
      
      '// 2. Define the DSL rules
      Dim t = uc.ExpressionTransformer
      t.FromTo("PLAYER {@Number:p} MOVES {@Number:n}", "p{p}_pos = p{p}_pos + {n}")
      t.FromTo("PLAYER {@Number:p} GAINS {@Number:n} GOLD", "p{p}_gold = p{p}_gold + {n}")
      
      '// 3. Define the script for the turn
      Dim game_turn_script = "
PLAYER 1 MOVES 4
PLAYER 2 MOVES 2
PLAYER 1 GAINS 5 GOLD
PLAYER 2 MOVES 3
"
      
      '// 4. Execute the script
      uc.EvalStr(game_turn_script)
      
      '// 5. Display the final state
      Console.WriteLine("--- End of Turn State ---")
      Console.WriteLine($"Player 1 Position: {uc.EvalStr("p1_pos")}")
      Console.WriteLine($"Player 1 Gold: {uc.EvalStr("p1_gold")}")
      Console.WriteLine($"Player 2 Position: {uc.EvalStr("p2_pos")}")
      Console.WriteLine($"Player 2 Gold: {uc.EvalStr("p2_gold")}")
   End Sub
End Module