Search code examples
javascriptsyntax-errorgame-enginediagrammermaid

Syntax error in a mermaid diagram for a game economy mechanic


I am trying to build a simple model of League of Legends game economy into a mermaid diagram.

I tried to run what I wrote in a live mermaid live editor, but I got a syntax error on line 8. I am not able to figure out why.

Can you help?

Here is my mermaid code

graph LR
    S1[Kill Minions] --> Q1
    S2[Kill Jungle Monsters] --> Q2
    S3[Kill Opponent Champions] --> Q3
    S4[Destroy Enemy Structures] --> Q4
    S5[Regular Intervals] --> Q5
    S6[Team Objectives] --> Q6
    S7[Penalties] --> D1[Penalties (Drain)]

    Q1 -->|Delay| P1[Gold Pool]
    Q1 -->|Delay| P2[XP Pool]
    Q2 -->|Delay| P1
    Q2 -->|Delay| P2
    Q3 -->|Delay| P1
    Q3 -->|Delay| P2
    Q4 -->|Delay| P1
    Q4 -->|Delay| P2
    Q5 -->|Delay| P1
    Q5 -->|Delay| P2
    Q6 -->|Delay| P1
    Q6 -->|Delay| P2

    P1 -->|Gold| G1[Gate for Purchases]
    P1 -->|Gold| G2[Gate for Game End]
    P2 -->|XP| V2[XP Converter (Level Up)]

    V2 -->|Convert| P4[Level Pool]
    P4 -->|Register| R2[Level Register]

    G1 -->|Purchase| V1[Shop (Converter)]
    V1 -->|Convert| P3[Items Pool]
    P3 -->|Register| R1[Items Register]
    P3 -->|Drain| D1[Sell Items (Drain)]

    G2 -->|Game End| E1[End Game]
    P4 -->|Level| E1

    P4 -->|Level| G3[Gate for Abilities]
    G3 -->|Level Up| P5[Abilities Pool]
    P5 -->|Register| R3[Abilities Register]
    P5 -->|Drain| D2[Abilities Usage (Drain)]

Here the error error syntax diagram

This might be too much information, but here is the type of node in the diagram:

  • Sources (S) are Nodes that produce an infinite number of Resources for other Nodes to use. They can generate resources for an unlimited number of Nodes simultaneously and at various rates.

  • Pools (P) store Resources and are the building blocks. They can receive Resources and send them forward to other Nodes.

  • Drains (D) consume Resources from Pools and other Nodes. They can drain Resources from multiple Nodes at the same time and at various rates. Resources that go into a Drain are permanently removed from your games’ economy!

  • Converters (V) are advanced Nodes that convert one or more Resources into a specified output amount of Resources.

  • Gates (G) are Nodes that either sort Resources without collecting them, or trigger other Nodes’ actions.

  • Registers (R) can alter the state of Nodes or influence the flow of Resources based on the computation of multiple inputs coming from either Nodes in the diagram or your own input during a diagram Step-by-Step Run.

  • Delays (Q) can be used to delay the flow of Resources as they get distributed in your diagram. You can switch between Delay and Queue using the buttons in the Action area of the Properties panel.

  • End Conditions (E) are used to end a game when any of its end conditions is met. They only accept State Connections as input.


Solution

  • You can't have brackets in the name without quoting it. To fix this, wrap each name in quotation marks (diagram)

    graph LR
        S1["Kill Minions"] --> Q1
        S2["Kill Jungle Monsters"] --> Q2
        S3["Kill Opponent Champions"] --> Q3
        S4["Destroy Enemy Structures"] --> Q4
        S5["Regular Intervals"] --> Q5
        S6["Team Objectives"] --> Q6
        S7["Penalties"] --> D1["Penalties (Drain)"]
    
        Q1 -->|Delay| P1["Gold Pool"]
        Q1 -->|Delay| P2["XP Pool"]
        Q2 -->|Delay| P1
        Q2 -->|Delay| P2
        Q3 -->|Delay| P1
        Q3 -->|Delay| P2
        Q4 -->|Delay| P1
        Q4 -->|Delay| P2
        Q5 -->|Delay| P1
        Q5 -->|Delay| P2
        Q6 -->|Delay| P1
        Q6 -->|Delay| P2
    
        P1 -->|Gold| G1["Gate for Purchases"]
        P1 -->|Gold| G2["Gate for Game End"]
        P2 -->|XP| V2["XP Converter (Level Up)"]
    
        V2 -->|Convert| P4["Level Pool"]
        P4 -->|Register| R2["Level Register"]
    
        G1 -->|Purchase| V1["Shop (Converter)"]
        V1 -->|Convert| P3["Items Pool"]
        P3 -->|Register| R1["Items Register"]
        P3 -->|Drain| D1["Sell Items (Drain)"]
    
        G2 -->|Game End| E1["End Game"]
        P4 -->|Level| E1
    
        P4 -->|Level| G3["Gate for Abilities"]
        G3 -->|Level Up| P5["Abilities Pool"]
        P5 -->|Register| R3["Abilities Register"]
        P5 -->|Drain| D2["Abilities Usage (Drain)"]