Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

buy_potion() mismatch #3

Open
hawkest opened this issue Apr 11, 2021 · 0 comments
Open

buy_potion() mismatch #3

hawkest opened this issue Apr 11, 2021 · 0 comments

Comments

@hawkest
Copy link

hawkest commented Apr 11, 2021

hp/mp missmatch

// run only by the merchant, who delivers potions to the farmers
function buy_potions(){
    var mp = potion_types[1];
    var hp = potion_types[0];
    var stack = potion_types[2];
    // if we have enough gold to purchase, and we need at least one potion
    if(character.gold >= parent.G.items[hp].g && (stack - quantity(hp)) > 0){
        // we buy enough potions to top off and meet the stack amount
        parent.buy_with_gold(mp, stack - quantity(mp));
    }
    // if we have enough gold to purchase, and we need at least one potion
    if(character.gold >= parent.G.items[mp].g && (stack - quantity(mp)) > 0){
        // we buy enough potions to top off and meet the stack amount
        parent.buy_with_gold(hp, stack - quantity(hp));
    }
}

needs to be

// run only by the merchant, who delivers potions to the farmers
function buy_potions(){
    var mp = potion_types[1];
    var hp = potion_types[0];
    var stack = potion_types[2];
    // if we have enough gold to purchase, and we need at least one potion
    if(character.gold >= parent.G.items[mp].g && (stack - quantity(mp)) > 0){
        // we buy enough potions to top off and meet the stack amount
        parent.buy_with_gold(mp, stack - quantity(mp));
    }
    // if we have enough gold to purchase, and we need at least one potion
    if(character.gold >= parent.G.items[hp].g && (stack - quantity(hp)) > 0){
        // we buy enough potions to top off and meet the stack amount
        parent.buy_with_gold(hp, stack - quantity(hp));
    }
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant