<?xml version="1.0"?>
<flowgorithm fileversion="2.11">
    <attributes>
        <attribute name="name" value=""/>
        <attribute name="authors" value="burrin"/>
        <attribute name="about" value=""/>
        <attribute name="saved" value="2020-10-26 03:10:12 PM"/>
        <attribute name="created" value="YnVycmluO0RFU0tUT1AtNzQ5RDJJRjsyMDIwLTEwLTI2OzEwOjM3OjI1IEFNOzI5MjY="/>
        <attribute name="edited" value="YnVycmluO0RFU0tUT1AtNzQ5RDJJRjsyMDIwLTEwLTI2OzEwOjQwOjIyIEFNOzM7Um9iZXJ0bztST0JFUlRPLVBDOzIwMTYtMDEtMTg7MDg6Mjc6MTA7Q2FyZEdhbWUuZnByZzs2OTM2"/>
        <attribute name="edited" value="YnVycmluO0RFU0tUT1AtNzQ5RDJJRjsyMDIwLTEwLTI2OzAzOjEwOjEyIFBNOzE3OzMwOTM="/>
    </attributes>
    <function name="Main" type="None" variable="">
        <parameters/>
        <body>
            <declare name="Score" type="Integer" array="True" size="2"/>
            <declare name="P1Deck" type="String" array="True" size="30"/>
            <declare name="P2Deck" type="String" array="True" size="30"/>
            <assign variable="Score[0]" expression="0"/>
            <assign variable="Score[1]" expression="0"/>
            <declare name="drawCount" type="Integer" array="False" size=""/>
            <assign variable="drawCount" expression="0"/>
            <declare name="Deck" type="String" array="True" size="30"/>
            <call expression="LoadArray(Deck,P1Deck,P2Deck)"/>
            <call expression="ShuffleArrayString(Deck)"/>
            <breakpoint/>
            <for variable="drawCount" start="0" end="29" direction="inc" step="2">
                <call expression="Draw(drawCount,Deck,P1Deck,P2Deck,Score)"/>
            </for>
            <breakpoint/>
            <call expression="DisplayResult(Score,P1Deck,P2Deck)"/>
            <breakpoint/>
        </body>
    </function>
    <function name="DisplayResult" type="None" variable="">
        <parameters>
            <parameter name="Score" type="Integer" array="True"/>
            <parameter name="P1Deck" type="String" array="True"/>
            <parameter name="P2Deck" type="String" array="True"/>
        </parameters>
        <body>
            <declare name="Counter" type="Integer" array="False" size=""/>
            <output expression="&quot;Player 1: &quot; &amp;Score[0] &amp; &quot; - Player 2: &quot; &amp;Score[1]" newline="True"/>
            <if expression="Score[0] &gt; Score[1]">
                <then>
                    <output expression="&quot;Player 1 Wins - Here is the Deck&quot;" newline="True"/>
                    <for variable="Counter" start="0" end="29" direction="inc" step="1">
                        <if expression="Len(P1Deck[Counter])&gt;0">
                            <then>
                                <output expression="P1Deck[Counter]" newline="True"/>
                            </then>
                            <else/>
                        </if>
                    </for>
                </then>
                <else>
                    <output expression="&quot;Player 2 Wins - Here is the Deck&quot;" newline="True"/>
                    <for variable="Counter" start="0" end="29" direction="inc" step="1">
                        <if expression="Len(P2Deck[Counter])&gt;0">
                            <then>
                                <output expression="P2Deck[Counter]" newline="True"/>
                            </then>
                            <else/>
                        </if>
                    </for>
                </else>
            </if>
        </body>
    </function>
    <function name="Draw" type="None" variable="">
        <parameters>
            <parameter name="drawCount" type="Integer" array="False"/>
            <parameter name="Deck" type="String" array="True"/>
            <parameter name="P1Deck" type="String" array="True"/>
            <parameter name="P2Deck" type="String" array="True"/>
            <parameter name="Score" type="Integer" array="True"/>
        </parameters>
        <body>
            <declare name="P1Draw" type="String" array="False" size=""/>
            <declare name="P2Draw" type="String" array="False" size=""/>
            <assign variable="P1Draw" expression="Deck[drawCount]"/>
            <assign variable="P2Draw" expression="Deck[drawCount+1]"/>
            <output expression="&quot;Player 1 Draws &quot; &amp;P1Draw" newline="True"/>
            <output expression="&quot; Player 2 Draws &quot;&amp;P2Draw" newline="True"/>
            <if expression="Char(P1Draw,0) == Char(P2Draw,0)">
                <then>
                    <if expression="P1Draw &gt; P2Draw">
                        <then>
                            <output expression="&quot;P1 Win&quot;" newline="True"/>
                            <assign variable="P1Deck[drawCount]" expression="P1Draw"/>
                            <assign variable="P1Deck[[drawCount]+1]" expression="P2Draw"/>
                            <assign variable="Score[0]" expression="Score[0]+1"/>
                        </then>
                        <else>
                            <output expression="&quot;P2 Win&quot;" newline="True"/>
                            <assign variable="P2Deck[drawCount]" expression="P2Draw"/>
                            <assign variable="P2Deck[drawCount+1]" expression="P1Draw"/>
                            <assign variable="Score[1]" expression="Score[1]+1"/>
                        </else>
                    </if>
                </then>
                <else>
                    <if expression="Char(P1Draw,0)=&quot;R&quot; AND Char(P2Draw,0) =&quot;B&quot; OR Char(P1Draw,0)=&quot;Y&quot; AND Char(P2Draw,0) =&quot;R&quot; OR Char(P1Draw,0)=&quot;B&quot; AND Char(P2Draw,0) =&quot;Y&quot;">
                        <then>
                            <output expression="&quot;P1 Win&quot;" newline="True"/>
                            <assign variable="P1Deck[drawCount]" expression="P1Draw"/>
                            <assign variable="P1Deck[drawCount+1]" expression="P2Draw"/>
                            <assign variable="Score[0]" expression="Score[0]+1"/>
                        </then>
                        <else>
                            <output expression="&quot;P2 Win&quot;" newline="True"/>
                            <assign variable="P2Deck[drawCount]" expression="P2Draw"/>
                            <assign variable="P2Deck[drawCount+1]" expression="P1Draw"/>
                            <assign variable="Score[1]" expression="Score[1]+1"/>
                        </else>
                    </if>
                </else>
            </if>
        </body>
    </function>
    <function name="LoadArray" type="None" variable="">
        <parameters>
            <parameter name="Deck" type="String" array="True"/>
            <parameter name="P1Deck" type="String" array="True"/>
            <parameter name="P2Deck" type="String" array="True"/>
        </parameters>
        <body>
            <declare name="count" type="Integer" array="False" size=""/>
            <for variable="count" start="0" end="9" direction="inc" step="1">
                <assign variable="Deck[count]" expression="&quot;R&quot;&amp;count+1"/>
            </for>
            <declare name="count2" type="Integer" array="False" size=""/>
            <assign variable="count2" expression="1"/>
            <for variable="count" start="10" end="19" direction="inc" step="1">
                <assign variable="Deck[count]" expression="&quot;Y&quot;&amp;count2"/>
                <assign variable="count2" expression="count2+1"/>
            </for>
            <assign variable="count2" expression="1"/>
            <for variable="count" start="20" end="29" direction="inc" step="1">
                <assign variable="Deck[count]" expression="&quot;B&quot;&amp;count2"/>
                <assign variable="count2" expression="count2+1"/>
            </for>
            <for variable="count" start="0" end="29" direction="inc" step="1">
                <assign variable="P1Deck[count]" expression="&quot;&quot;"/>
                <assign variable="P2Deck[count]" expression="&quot;&quot;"/>
            </for>
        </body>
    </function>
    <function name="ShuffleArrayString" type="None" variable="">
        <parameters>
            <parameter name="a" type="String" array="True"/>
        </parameters>
        <body>
            <declare name="length" type="Integer" array="False" size=""/>
            <declare name="i" type="Integer" array="False" size=""/>
            <declare name="change" type="Integer" array="False" size=""/>
            <declare name="k" type="Integer" array="False" size=""/>
            <assign variable="length" expression="size(a)"/>
            <for variable="i" start="0" end="length - 1" direction="inc" step="1">
                <assign variable="k" expression="length - i"/>
                <assign variable="change" expression="i + (random(k))"/>
                <call expression="SwapArrayString(a, i, change)"/>
            </for>
        </body>
    </function>
    <function name="SwapArrayString" type="None" variable="">
        <parameters>
            <parameter name="a" type="String" array="True"/>
            <parameter name="i" type="Integer" array="False"/>
            <parameter name="change" type="Integer" array="False"/>
        </parameters>
        <body>
            <declare name="tmp" type="String" array="False" size=""/>
            <assign variable="tmp" expression="a[i]"/>
            <assign variable="a[i]" expression="a[change]"/>
            <assign variable="a[change]" expression="tmp"/>
        </body>
    </function>
</flowgorithm>
