1
- use super :: { expression:: CompileInto , Compile , SnippetCompiler , RESERVED_MEMORY } ;
1
+ use super :: { expression:: CompileInto , Compile , SnippetCompiler , PRIVATE_MEMORY } ;
2
2
use crate :: {
3
3
ast:: { self , UberStateType } ,
4
4
output:: {
5
5
ArithmeticOperator , Command , CommandBoolean , CommandFloat , CommandInteger , CommandString ,
6
- CommandVoid , CommandZone , EqualityComparator , Operation ,
6
+ CommandVoid , CommandZone , Comparator , EqualityComparator , Operation ,
7
7
} ,
8
8
} ;
9
9
use arrayvec:: ArrayVec ;
@@ -1090,8 +1090,13 @@ fn item_message(message: CommandString) -> CommandVoid {
1090
1090
}
1091
1091
}
1092
1092
1093
+ fn set_spirit_light_string ( value : & str ) -> Box < CommandVoid > {
1094
+ Box :: new ( CommandVoid :: SetString {
1095
+ id : PRIVATE_MEMORY ,
1096
+ value : value. into ( ) ,
1097
+ } )
1098
+ }
1093
1099
fn spirit_light_string ( amount : CommandInteger , rng : & mut Pcg64Mcg , remove : bool ) -> CommandString {
1094
- const SPIRIT_LIGHT_STRING_ID : usize = RESERVED_MEMORY + 1 ;
1095
1100
CommandString :: Multi {
1096
1101
commands : vec ! [
1097
1102
CommandVoid :: If {
@@ -1101,12 +1106,7 @@ fn spirit_light_string(amount: CommandInteger, rng: &mut Pcg64Mcg, remove: bool)
1101
1106
member: 0 ,
1102
1107
} ,
1103
1108
} ,
1104
- command: Box :: new( CommandVoid :: SetString {
1105
- id: SPIRIT_LIGHT_STRING_ID ,
1106
- value: ( * SPIRIT_LIGHT_NAMES . choose( rng) . unwrap( ) )
1107
- . to_string( )
1108
- . into( ) ,
1109
- } ) ,
1109
+ command: set_random_spirit_light_string( & amount, rng) ,
1110
1110
} ,
1111
1111
CommandVoid :: If {
1112
1112
condition: CommandBoolean :: CompareBoolean {
@@ -1121,10 +1121,7 @@ fn spirit_light_string(amount: CommandInteger, rng: &mut Pcg64Mcg, remove: bool)
1121
1121
right: false . into( ) ,
1122
1122
} ) ,
1123
1123
} ,
1124
- command: Box :: new( CommandVoid :: SetString {
1125
- id: SPIRIT_LIGHT_STRING_ID ,
1126
- value: "Spirit Light" . into( ) ,
1127
- } ) ,
1124
+ command: set_spirit_light_string( "Spirit Light" ) ,
1128
1125
} ,
1129
1126
] ,
1130
1127
last : Box :: new ( if remove {
@@ -1142,9 +1139,7 @@ fn spirit_light_string(amount: CommandInteger, rng: &mut Pcg64Mcg, remove: bool)
1142
1139
} ,
1143
1140
} ) ,
1144
1141
right : Box :: new ( CommandString :: Concatenate {
1145
- left : Box :: new ( CommandString :: GetString {
1146
- id : SPIRIT_LIGHT_STRING_ID ,
1147
- } ) ,
1142
+ left : Box :: new ( CommandString :: GetString { id : PRIVATE_MEMORY } ) ,
1148
1143
right : Box :: new ( "@" . into ( ) ) ,
1149
1144
} ) ,
1150
1145
}
@@ -1159,13 +1154,54 @@ fn spirit_light_string(amount: CommandInteger, rng: &mut Pcg64Mcg, remove: bool)
1159
1154
right : Box :: new ( " " . into ( ) ) ,
1160
1155
} ,
1161
1156
} ) ,
1162
- right : Box :: new ( CommandString :: GetString {
1163
- id : SPIRIT_LIGHT_STRING_ID ,
1164
- } ) ,
1157
+ right : Box :: new ( CommandString :: GetString { id : PRIVATE_MEMORY } ) ,
1165
1158
}
1166
1159
} ) ,
1167
1160
}
1168
1161
}
1162
+ fn set_random_spirit_light_string ( amount : & CommandInteger , rng : & mut Pcg64Mcg ) -> Box < CommandVoid > {
1163
+ let name = SPIRIT_LIGHT_NAMES . choose ( rng) . unwrap ( ) ;
1164
+ let constant_singular = amount. as_constant ( ) . map ( |amount| matches ! ( amount, 1 | -1 ) ) ;
1165
+
1166
+ match constant_singular {
1167
+ Some ( true ) => set_spirit_light_string ( name. 0 ) ,
1168
+ Some ( false ) => set_spirit_light_string ( name. 1 ) ,
1169
+ None => Box :: new ( CommandVoid :: Multi {
1170
+ commands : vec ! [
1171
+ CommandVoid :: SetBoolean {
1172
+ id: PRIVATE_MEMORY ,
1173
+ value: CommandBoolean :: CompareInteger {
1174
+ operation: Box :: new( Operation {
1175
+ left: CommandInteger :: Arithmetic {
1176
+ operation: Box :: new( Operation {
1177
+ left: amount. clone( ) ,
1178
+ operator: ArithmeticOperator :: Multiply ,
1179
+ right: amount. clone( ) ,
1180
+ } ) ,
1181
+ } ,
1182
+ operator: Comparator :: Equal ,
1183
+ right: 1 . into( ) ,
1184
+ } ) ,
1185
+ } ,
1186
+ } ,
1187
+ CommandVoid :: If {
1188
+ condition: CommandBoolean :: GetBoolean { id: PRIVATE_MEMORY } ,
1189
+ command: set_spirit_light_string( name. 0 ) ,
1190
+ } ,
1191
+ CommandVoid :: If {
1192
+ condition: CommandBoolean :: CompareBoolean {
1193
+ operation: Box :: new( Operation {
1194
+ left: CommandBoolean :: GetBoolean { id: PRIVATE_MEMORY } ,
1195
+ operator: EqualityComparator :: Equal ,
1196
+ right: false . into( ) ,
1197
+ } ) ,
1198
+ } ,
1199
+ command: set_spirit_light_string( name. 1 ) ,
1200
+ } ,
1201
+ ] ,
1202
+ } ) ,
1203
+ }
1204
+ }
1169
1205
fn resource_string ( resource : & str , remove : bool ) -> CommandString {
1170
1206
if remove {
1171
1207
format ! ( "@Remove {resource}@" ) . into ( )
@@ -1359,91 +1395,91 @@ where
1359
1395
Command :: Void ( CommandVoid :: Lookup { index } )
1360
1396
}
1361
1397
1362
- // TODO update
1363
- const SPIRIT_LIGHT_NAMES : & [ & str ] = & [
1364
- "Spirit Light" ,
1365
- "Gallons" ,
1366
- "Spirit Bucks" ,
1367
- "Gold" ,
1368
- "Geo" ,
1369
- "EXP" ,
1370
- "Experience" ,
1371
- "XP" ,
1372
- "Gil" ,
1373
- "GP" ,
1374
- "Dollars" ,
1375
- "Tokens" ,
1376
- "Tickets" ,
1377
- "Pounds Sterling" ,
1378
- "Brownie Points" ,
1379
- "Euros" ,
1380
- "Credits" ,
1381
- "Bells" ,
1382
- "Fish" ,
1383
- "Zenny" ,
1384
- "Pesos" ,
1385
- "Exalted Orbs" ,
1386
- "Hryvnia" ,
1387
- "Poké" ,
1388
- "Glod" ,
1389
- "Dollerydoos" ,
1390
- "Boonbucks" ,
1391
- "Pieces of Eight" ,
1392
- "Shillings" ,
1393
- "Farthings" ,
1394
- "Kalganids" ,
1395
- "Quatloos" ,
1396
- "Crowns" ,
1397
- "Solari" ,
1398
- "Widgets" ,
1399
- "Ori Money" ,
1400
- "Money" ,
1401
- "Cash" ,
1402
- "Munny" ,
1403
- "Nuyen" ,
1404
- "Rings" ,
1405
- "Rupees" ,
1406
- "Coins" ,
1407
- "Echoes" ,
1408
- "Sovereigns" ,
1409
- "Points" ,
1410
- "Drams" ,
1411
- "Doubloons" ,
1412
- "Spheres" ,
1413
- "Silver" ,
1414
- "Slivers" ,
1415
- "Rubies" ,
1416
- "Emeralds" ,
1417
- "Notes" ,
1418
- "Yen" ,
1419
- "Złoty" ,
1420
- "Likes" ,
1421
- "Comments" ,
1422
- "Subs" ,
1423
- "Bananas" ,
1424
- "Sapphires" ,
1425
- "Diamonds" ,
1426
- "Fun" ,
1427
- "Minerals" ,
1428
- "Vespene Gas" ,
1429
- "Sheep" ,
1430
- "Brick" ,
1431
- "Wheat" ,
1432
- "Wood" ,
1433
- "Quills" ,
1434
- "Bits" ,
1435
- "Bytes" ,
1436
- "Nuts" ,
1437
- "Bolts" ,
1438
- "Souls" ,
1439
- "Runes" ,
1440
- "Pons" ,
1441
- "Boxings" ,
1442
- "Stonks" ,
1443
- "Leaves" ,
1444
- "Marbles" ,
1445
- "Stamps" ,
1446
- "Hugs" ,
1447
- "Nobles" ,
1448
- "Socks" ,
1398
+ const SPIRIT_LIGHT_NAMES : [ ( & str , & str ) ; 86 ] = [
1399
+ ( "Banana" , "Bananas" ) ,
1400
+ ( "Bell" , "Bells" ) ,
1401
+ ( "Bit" , "Bits" ) ,
1402
+ ( "Bolt" , "Bolts" ) ,
1403
+ ( "Boonbuck" , "Boonbucks" ) ,
1404
+ ( "Boxing" , "Boxings" ) ,
1405
+ ( "Brick" , "Brick" ) ,
1406
+ ( "Brownie Point" , "Brownie Points" ) ,
1407
+ ( "Byte" , "Bytes" ) ,
1408
+ ( "Cash" , "Cash" ) ,
1409
+ ( "Coin" , "Coins" ) ,
1410
+ ( "Comment" , "Comments" ) ,
1411
+ ( "Credit" , "Credits" ) ,
1412
+ ( "Crown" , "Crowns" ) ,
1413
+ ( "Diamond" , "Diamonds" ) ,
1414
+ ( "Dollar" , "Dollars" ) ,
1415
+ ( "Dollerydoo" , "Dollerydoos" ) ,
1416
+ ( "Doubloon" , "Doubloons" ) ,
1417
+ ( "Dram" , "Drams" ) ,
1418
+ ( "Echoe" , "Echoes" ) ,
1419
+ ( "Emerald" , "Emeralds" ) ,
1420
+ ( "Euro" , "Euros" ) ,
1421
+ ( "Exalted Orb" , "Exalted Orbs") ,
1422
+ ( "EXP" , "EXP" ) ,
1423
+ ( "Experience" , "Experience" ) ,
1424
+ ( "Farthing" , "Farthings" ) ,
1425
+ ( "Fish" , "Fish" ) ,
1426
+ ( "Fun" , "Fun" ) ,
1427
+ ( "Gallon" , "Gallons" ) ,
1428
+ ( "Geo" , "Geo" ) ,
1429
+ ( "Gil" , "Gil" ) ,
1430
+ ( "Glod" , "Glod" ) ,
1431
+ ( "Gold" , "Gold" ) ,
1432
+ ( "GP" , "GP" ) ,
1433
+ ( "Hryvnia" , "Hryvnia" ) ,
1434
+ ( "Hug" , "Hugs" ) ,
1435
+ ( "Kalganid" , "Kalganids" ) ,
1436
+ ( "Leaf" , "Leaves" ) ,
1437
+ ( "Like" , "Likes" ) ,
1438
+ ( "Marble" , "Marbles" ) ,
1439
+ ( "Mineral" , "Minerals" ) ,
1440
+ ( "Money" , "Money" ) ,
1441
+ ( "Munny" , "Munny" ) ,
1442
+ ( "Noble" , "Nobles" ) ,
1443
+ ( "Note" , "Notes" ) ,
1444
+ ( "Nut" , "Nuts" ) ,
1445
+ ( "Nuyen" , "Nuyen" ) ,
1446
+ ( "Ori" , "Ori Money" ) ,
1447
+ ( "Pesos" , "Pesos" ) ,
1448
+ ( "Piece of Eight" , "Pieces of Eight" ) ,
1449
+ ( "Point" , "Points" ) ,
1450
+ ( "Poké" , "Poké" ) ,
1451
+ ( "Pon" , "Pons" ) ,
1452
+ ( "Pound Sterling" , "Pounds Sterling" ) ,
1453
+ ( "Quatloo" , "Quatloos" ) ,
1454
+ ( "Quill" , "Quills" ) ,
1455
+ ( "Ring" , "Rings" ) ,
1456
+ ( "Ruby" , "Rubies" ) ,
1457
+ ( "Rune" , "Runes" ) ,
1458
+ ( "Rupee" , "Rupees" ) ,
1459
+ ( "Sapphire" , "Sapphires" ) ,
1460
+ ( "Sheep" , "Sheep" ) ,
1461
+ ( "Shilling" , "Shillings" ) ,
1462
+ ( "Silver" , "Silver" ) ,
1463
+ ( "Sliver" , "Slivers" ) ,
1464
+ ( "Smackerooni" , "Smackeroonis" ) ,
1465
+ ( "Sock" , "Socks" ) ,
1466
+ ( "Solari" , "Solari" ) ,
1467
+ ( "Soul" , "Souls" ) ,
1468
+ ( "Sovereign" , "Sovereigns" ) ,
1469
+ ( "Sphere" , "Spheres" ) ,
1470
+ ( "Spirit Buck" , "Spirit Bucks" ) ,
1471
+ ( "Spirit" , "Spirit Light" ) ,
1472
+ ( "Stamp" , "Stamps" ) ,
1473
+ ( "Stonk" , "Stonks" ) ,
1474
+ ( "Sub" , "Subs" ) ,
1475
+ ( "Ticket" , "Tickets" ) ,
1476
+ ( "Token" , "Tokens" ) ,
1477
+ ( "Vespine" , "Vespine Gas" ) ,
1478
+ ( "Wheat" , "Wheat" ) ,
1479
+ ( "Widget" , "Widgets" ) ,
1480
+ ( "Wood" , "Wood" ) ,
1481
+ ( "XP" , "XP" ) ,
1482
+ ( "Yen" , "Yen" ) ,
1483
+ ( "Zenny" , "Zenny" ) ,
1484
+ ( "Złoty" , "Złoty" ) ,
1449
1485
] ;
0 commit comments