Skip to content

Creating a instruction set for gameplay #4

Description

@Aerex

I figured that running a list of if and else statements for effects would not be practical. A better way would be to include an instruction set that can be parsed and executed on runtime, The instruction set would be a stack that generalizes the effects so they can be chained. Literals would be enumerators for instance PLAYER could represent the number 32 or something like that.

<card>
    <name>Dark Hole</name>
    <type>Spell</type>
    <id>123</id>
    <property>Normal</property>
    <actions>
        PLAYER
        1
        DESTROY
        MONSTERS
        ALL
        PLAYER 
        2
        DESTROY
        MONSTERS
        ALL
    </actions>
</card>

<card>
    <name>Ookazi</name>
    <type>Spell</type>
    <id>122</id>
    <property>normal</property>
    <actions>
        PLAYER
        1
        DAMAGE
        800
        LIFEPOINTS
    </actions>
</card>


<card>
    <name>Invigoration</name>
    <type>Equip</type>
    <id>121</id>
    <property>normal</property>
    <actions>
        PLAYER
        0
        CARD
        MONSTER
        EARTH
        NULL
        INCREASE
        200
        ATK
        DECREASE
        400
        DEF
    </actions>
</card>


switch(instruction){

    case PLAYER:
        player = stack.pop()
        break;
    case DESTROY
        type = stack.pop();
        number = stack.pop();
        break;
        destroy(player, type, number);
    case DAMAGE:
        amount = stack.pop();
        type = stack.pop();
        damage(player,amount, destroy)
        break;
    case INCREASE:
        amount = stack.pop();
        type = stack.pop();
        increase(amount, type, player, card)
               break;
    case DECREASE:
        amount = stack.pop();
        type = stack.pop();
        decrease(amount, type, player, card)
    case CARD:
        card = new Card();
            Card.type = stack.pop();
            Card.atr = stack.pop();
            Card.subtype = stack.pop();
             break;
}

I wanted to hear your thoughts before I attempt to implement this.

Metadata

Metadata

Assignees

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions