-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathmud.config.ts
793 lines (777 loc) · 18.2 KB
/
mud.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
import { mudConfig, resolveTableId } from "@latticexyz/world/register";
export default mudConfig({
userTypes: {
PackedCounter: { filePath: "@latticexyz/store/src/PackedCounter.sol", internalType: "bytes32" },
ResourceId: { filePath: "@latticexyz/store/src/ResourceId.sol", internalType: "bytes32" },
},
enums: {
UnitTypes: [
"Unknown",
"Swordsman",
"Pikeman",
"Golem",
"Rider",
"Knight",
"Dragon",
"Archer",
"Catapult",
"Wizard",
],
TerrainTypes: [
"Unknown",
"Grass",
"Mountain",
"Water",
"Wall",
"Forest",
"StoneWall",
"LavaGround",
"LavaMountain",
"LavaForest",
"Lava",
"RockWall",
],
StructureTypes: [
"Unknown",
"Settlement",
"SpawnSettlement",
"GoldShrine",
"EscapePortal",
"Portal",
"Container",
"SummoningAltar",
"BlazingHeartShrine",
"WoodenWall",
"GoldMine",
"Village",
"EmberCrownShrine",
"CrystalGenerator",
"MetalGenerator",
"FossilGenerator",
"WidgetGenerator",
],
ItemTypes: [
"Unknown",
"Gold",
"EmberCrown",
"BlazingHeart",
"MovementBanner",
"SwordBanner",
"StaminaBanner",
"Crystal",
"Metal",
"Fossil",
"Widget",
],
},
overrideSystems: {
AttackSystem: {
openAccess: false,
accessList: [],
name: "AttackSystem",
},
CombatResultSystem: {
openAccess: false,
accessList: [],
name: "CombatResultSystem",
},
FinishSystem: {
openAccess: false,
accessList: [],
name: "FinishSystem",
},
},
tables: {
// temporarily used in the client for backwards compat while we update frontend
// this marks entities (eg. units, structures) as being part of the `matchEntity` match
// TODO: remove
Match: {
offchainOnly: true,
keySchema: {
matchEntityKey: "bytes32", // same as matchEntity below, but renamed to avoid arg name conflicts in tablegen
entity: "bytes32",
},
valueSchema: {
matchEntity: "bytes32", // leave this as matchEntity because frontend queries based on this value
},
},
/**
* Used on terrain to modify the armor of entities standing on it.
*/
ArmorModifier: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "int32",
},
/**
* Marks an entity as capturable.
* Instead of dying, they will return to full health
* and change ownership to the capturer.
*/
Capturable: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "bool",
},
/**
* The time at which charging started. This is used to determine
* how much stamina to recharge when refreshing the charged unit in the
* future.
* Charger => StartTime
*/
ChargedByStart: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "uint256",
},
/**
* References the entity that is being charged.
* Charger => Chargee
*/
Chargee: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "bytes32",
},
Chargers: {
keySchema: {
matchEntity: "bytes32",
chargee: "bytes32",
},
valueSchema: {
chargers: "bytes32[]",
},
},
/**
* Sets an entity as a charger. The value here is
* added to the total amount of stamina recharged
* when the target entity is refreshed.
*/
Charger: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "int32",
},
/**
* Used to track the total amount of stamina recharged by a Charger.
* Used to implement depletable Gold Mines.
*/
ChargeCap: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: {
cap: "int32",
totalCharged: "int32",
},
},
/**
* If an entity has this it is able to engage in combat.
* All values represented in thousands.
* i.e. 100_000 HP = 100 HP
*/
Combat: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: {
health: "int32",
maxHealth: "int32",
armor: "int32",
strength: "int32",
structureStrength: "int32",
counterStrength: "int32",
},
},
/**
* The amount of Stamina (Gold) a Player receives when killing a unit.
*/
StaminaOnKill: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "int32",
},
/**
* Emitted during combat to inform client animations.
*/
CombatResult: {
offchainOnly: true,
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: {
attacker: "bytes32",
defender: "bytes32",
attackerDamageReceived: "int32",
defenderDamageReceived: "int32",
attackerDamage: "int32",
defenderDamage: "int32",
ranged: "bool",
attackerDied: "bool",
defenderDied: "bool",
defenderCaptured: "bool",
},
},
/**
* Marks an entity as able to construct other entities.
*/
Factory: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: {
prototypeIds: "bytes32[]",
staminaCosts: "int32[]",
},
},
/**
* Used to mark something as an Item.
* NOTE: Only use this to determine if something is an item contract-side.
* Specific Item Types are only used client-side to deteremine rendering.
*/
ItemType: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "ItemTypes",
},
/**
* Used in conjuction with Stamina to lazily calculate Stamina regen.
*/
LastAction: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "uint256",
},
/**
* Used in map creation to mark the center of the map.
*/
MapCenter: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "bool",
},
/**
* Marks an entity as able to move.
* The value is how many units there are able to move.
* Represented in thousands.
* i.e. 1000 = 1 unit.
*/
Movable: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "int32",
},
/**
* Given to terrain to determine how much it costs to move onto it.
* Used in conjunction with Movable during path calculation.
*/
MoveDifficulty: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "int32",
},
/**
* HEAVILY used to determine ownership chains.
* i.e. Player -> Unit
*/
OwnedBy: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "bytes32",
},
/**
* Marks a player address as a player.
* Value is an incrementing integer.
*/
Player: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "uint32",
},
/**
* Used in the lobby system to determine if a player is ready.
*/
PlayerReady: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "uint256",
},
/**
* The position of an entity.
*/
Position: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: {
x: "int32",
y: "int32",
},
},
EntitiesAtPosition: {
keySchema: {
matchEntity: "bytes32",
x: "int32",
y: "int32",
},
valueSchema: {
entities: "bytes32[]",
},
},
/**
* The range at which an entity can engage in combat.
*/
Range: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: {
min: "int32",
max: "int32",
},
},
/**
* Set during Player registration to reserve a specific SpawnPoint in a level for a player entity.
*/
SpawnReservedBy: {
keySchema: {
matchEntity: "bytes32",
index: "uint256",
},
valueSchema: "bytes32",
},
/**
* Marks an entity as a Spawn Point.
* Players can use it to enter a match.
*/
SpawnPoint: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "bool",
},
/**
* Stamina is the base resource that everything in the game uses to take actions.
* It is lazily calculated whenever an entity takes an action.
* Stamina is regenerated every turn.
* Used in conjunction with LastAction to lazily calculate Stamina regen.
*/
Stamina: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: {
current: "int32",
},
},
/**
* Used to mark something as an Structure.
* NOTE: Only use this to determine if something is an Structure contract-side.
* Specific Structure Types are only used client-side to deteremine rendering.
*/
StructureType: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "StructureTypes",
},
/**
* Used to mark something as Terrain.
* NOTE: Only use this to determine if something is Terrain contract-side.
* Specific Terrain Types are only used client-side to deteremine rendering.
*/
TerrainType: {
offchainOnly: true,
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "TerrainTypes",
},
/**
* Used to mark something as a Unit.
* NOTE: Only use this to determine if something is a Unit contract-side.
* Specific Unit Types are only used client-side to deteremine rendering.
*/
UnitType: {
offchainOnly: true,
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "UnitTypes",
},
/**
* Whethere this entity blocks the movement of other entities.
*/
Untraversable: {
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "bool",
},
Tier: {
offchainOnly: true,
keySchema: {
matchEntity: "bytes32",
entity: "bytes32",
},
valueSchema: "uint32",
},
/**
* Index for finding a player in a given Match.
*/
MatchPlayer: {
keySchema: {
matchEntity: "bytes32",
playerAddress: "address",
},
valueSchema: {
playerEntity: "bytes32",
},
},
// ______________________ SKYPOOL ____________________________
/**
* Stores players chosen names.
*/
Name: "string",
/**
* Marks an entity as an admin. Used on address entities.
*/
Admin: "bool",
/**
* Marks a template as a Hero in the standard rotation.
*/
HeroInRotation: "bool",
/**
* Marks a template as a Hero in the season pass only rotation.
*/
HeroInSeasonPassRotation: "bool",
/**
* Marks an entity as having the season pass.
*/
SeasonPass: {
keySchema: {
account: "address",
},
valueSchema: {
hasSeasonPass: "bool",
},
},
/**
* SkyPool settings:
* - Creation cost of SkyPool matches.
* - Window (in blocks) to determine match rewards.
* - The entity that holds the SkyPools balance.
* - Token that is used in SkyPool rewards.
* - The fraction that each place in the match should win
*/
SkyPoolConfig: {
keySchema: {},
valueSchema: {
cost: "uint256",
window: "uint256",
entity: "bytes32",
token: "bytes32",
},
},
/**
* SkyPool match rewards broken down by
* the number of players in a match.
*/
MatchRewardPercentages: {
keySchema: {
numPlayers: "uint256",
},
valueSchema: {
percentages: "uint256[]",
},
},
LevelInStandardRotation: {
keySchema: {
levelId: "bytes32",
},
valueSchema: "bool",
},
LevelInSeasonPassRotation: {
keySchema: {
levelId: "bytes32",
},
valueSchema: "bool",
},
LastMatchIndex: {
keySchema: {},
valueSchema: {
matchIndex: "uint32",
},
},
/**
* Map match entities to their match index (derived from auto-incrementing LastMatchIndex), used in pool rewards
*/
MatchIndex: {
keySchema: {
matchEntity: "bytes32",
},
valueSchema: {
matchIndex: "uint32",
},
},
/**
* Map match indices to their match entity.
* Used when calculating rewards for a match to look up matches
* by their index only.
*/
MatchIndexToEntity: {
keySchema: {
matchIndex: "uint32",
},
valueSchema: {
matchEntity: "bytes32",
},
},
// ______________________ MATCH ____________________________
/**
* Counter for match-specific entities, used to derive a bytes32 entity via `encodeMatchEntity`.
* We'll use this as a fallback in case we don't ship match composite keys in time.
*/
MatchEntityCounter: {
keySchema: {
matchEntity: "bytes32",
},
valueSchema: {
// ~4 billion entities per match seems like plenty for now
entityCounter: "uint32",
},
},
/**
* Used to keep track of all the instantiated SpawnPoints in a match.
*/
MatchSpawnPoints: "bytes32[]",
/**
* Kept up to date with all of the player entities present in a Match.
*/
MatchPlayers: "bytes32[]",
/**
* Match data for SkyPool
*/
MatchSky: {
valueSchema: {
createdAt: "uint256",
reward: "uint256",
},
},
/**
* Match gameplay settings.
*/
MatchConfig: {
valueSchema: {
startTime: "uint256",
turnLength: "uint256",
levelId: "bytes32",
createdBy: "bytes32",
},
},
/**
* Match access control resource and function selector.
*/
MatchAccessControl: {
valueSchema: {
systemId: "ResourceId",
},
},
MatchAllowed: {
keySchema: {
matchEntity: "bytes32",
account: "address",
},
valueSchema: "bool",
},
/**
* Whether a match has finished.
*/
MatchFinished: "bool",
MatchMapCopyProgress: "uint256",
/**
* Time when match Level copying is completed.
*/
MatchReady: "uint256",
/**
* The ordered ranks of each player in the match.
*/
MatchRanking: {
valueSchema: "bytes32[]",
},
/**
* The rewards for each place (1st, 2nd etc...) of match players.
*/
MatchReward: {
keySchema: {
entity: "bytes32",
rank: "uint256",
},
valueSchema: {
token: "bytes32",
value: "uint256",
},
},
// ______________________ TEMPLATES + LEVELS ____________________________
/**
* Stores the table IDs a template is composed of.
*/
TemplateTables: "bytes32[]",
/**
* Stores the content of each record in a template.
*/
TemplateContent: {
dataStruct: false,
keySchema: {
templateId: "bytes32",
tableId: "ResourceId",
},
valueSchema: {
encodedLengths: "PackedCounter",
staticData: "bytes",
dynamicData: "bytes",
},
},
/**
* Stores the template for each index in a level.
*/
LevelTemplates: "bytes32[]",
/**
* Stores the indices of Level entities with a given `templateId`.
*/
LevelTemplatesIndex: {
keySchema: {
levelId: "bytes32",
templateId: "bytes32",
},
valueSchema: "uint256[]",
},
/**
* Stores the table IDs a level entity is composed of.
*/
LevelTables: {
keySchema: {
levelId: "bytes32",
index: "uint256",
},
valueSchema: "bytes32[]",
},
/**
* Stores the content of each record in a level entity.
*/
LevelContent: {
dataStruct: false,
keySchema: {
levelId: "bytes32",
index: "uint256",
tableId: "ResourceId",
},
valueSchema: {
encodedLengths: "PackedCounter",
staticData: "bytes",
dynamicData: "bytes",
},
},
/**
* Stores the indices of Level entities with the given component values.
*/
LevelContentIndex: {
keySchema: {
levelId: "bytes32",
tableId: "ResourceId",
encodedLengths: "PackedCounter",
staticDataHash: "bytes32",
dynamicDataHash: "bytes32",
},
valueSchema: "uint256[]",
},
/**
* Whether a template is "virtual", meaning it is not instantiated during Level copying.
*/
VirtualLevelTemplates: "bool",
// ______________________ TOKENS ____________________________
/**
* The metadata for each token.
*/
TokenMetadata: {
valueSchema: {
decimals: "uint8",
name: "string",
emoji: "string",
},
},
/**
* The supply for each token.
*/
TokenSupply: "uint256",
/**
* The allowance of each entity for a given token.
*/
TokenAllowance: {
keySchema: {
token: "bytes32",
account: "bytes32",
spender: "bytes32",
},
valueSchema: "uint256",
},
/**
* The number of tokens owned by each entity for a given token.
*/
TokenBalance: {
keySchema: {
token: "bytes32",
entity: "bytes32",
},
valueSchema: "uint256",
},
},
modules: [
// KeysWithValueModule
{
name: "KeysWithValueModule",
root: true,
args: [resolveTableId("Name")],
},
],
});