1
+ using System ;
2
+ using System . Linq ;
3
+
1
4
namespace Deltin . Deltinteger . Elements
2
5
{
3
6
public class Rule
@@ -43,6 +46,11 @@ public Rule(string name, string subroutine)
43
46
44
47
public void ToWorkshop ( WorkshopBuilder builder )
45
48
{
49
+
50
+ // Element count comment.
51
+ if ( builder . IncludeComments )
52
+ builder . AppendLine ( "// Rule Element Count: " + ElementCount ( ) ) ;
53
+
46
54
if ( Disabled )
47
55
{
48
56
builder . AppendKeyword ( "disabled" )
@@ -51,7 +59,6 @@ public void ToWorkshop(WorkshopBuilder builder)
51
59
builder . AppendKeyword ( "rule" )
52
60
. AppendLine ( "(\" " + Name + "\" )" )
53
61
. AppendLine ( "{" )
54
- . AppendLine ( )
55
62
. Indent ( )
56
63
. AppendKeywordLine ( "event" )
57
64
. AppendLine ( "{" )
@@ -78,10 +85,13 @@ public void ToWorkshop(WorkshopBuilder builder)
78
85
builder . Outdent ( )
79
86
. AppendLine ( "}" ) ;
80
87
81
- if ( Conditions ? . Length > 0 )
82
- {
83
- builder . AppendLine ( )
84
- . AppendKeywordLine ( "conditions" )
88
+ if ( Conditions ? . Length > 0 ) {
89
+ builder . AppendLine ( ) ;
90
+
91
+ if ( builder . IncludeComments )
92
+ builder . AppendLine ( "// Element Count: " + Conditions . Sum ( x => x . ElementCount ( ) ) + ", Condition Count: " + Conditions . Length ) ;
93
+
94
+ builder . AppendKeywordLine ( "conditions" )
85
95
. AppendLine ( "{" )
86
96
. Indent ( ) ;
87
97
@@ -96,10 +106,20 @@ public void ToWorkshop(WorkshopBuilder builder)
96
106
{
97
107
builder . AppendLine ( ) ;
98
108
99
- // Action count comment.
109
+ // Action and element count comment.
100
110
if ( builder . IncludeComments )
101
- builder . AppendLine ( "// Action count: " + Actions . Length ) ;
102
-
111
+ {
112
+ int largestCount = Actions . Max ( x => x . ElementCount ( ) ) ;
113
+ Element largestAction = Array . FindIndex ( Actions , x => x . ElementCount ( ) == largestCount ) ;
114
+ int totalElementCount = Actions . Sum ( x => x . ElementCount ( ) ) ;
115
+
116
+ builder . AppendLine ( $ "// Element Count: { totalElementCount } , Action Count: { Actions . Length } ") ;
117
+ if ( Actions . Length > 1 ) {
118
+ builder . AppendLine ( $ "// Largest Action Index: { largestAction } using { largestCount } Elements") ;
119
+ }
120
+
121
+ }
122
+
103
123
builder . AppendKeywordLine ( "actions" ) . AppendLine ( "{" ) . Indent ( ) ;
104
124
int resetIndentInCaseOfUnbalance = builder . GetCurrentIndent ( ) ;
105
125
0 commit comments