Code Monkey home page Code Monkey logo

Comments (3)

ritamganguli avatar ritamganguli commented on August 27, 2024

can u please give example of some potions

from hag.

JohnathonNow avatar JohnathonNow commented on August 27, 2024

hag/src/logic/item.c

Lines 102 to 195 in 7eaeaf5

void item_drink(item_t* item)
{
char msg[80];
if (item && item->type == POTION) {
list_remove(item->node);
add_action("Drank a potion");
get_player_obj()->potion_count += 1;
switch (item->stat) {
case 0: /* str */
if (item->power > 0) {
sprintf(msg, "It increased your strength by %d points", item->power);
add_action(msg);
} else if (item->power < 0) {
sprintf(msg, "It decreased your strength by %d points", -item->power);
add_action(msg);
} else {
add_action("It did nothing.");
}
get_player_obj()->strength += item->power;
if (get_player_obj()->strength < 1) {
get_player_obj()->strength = 1;
}
break;
case 1: /* dex */
if (item->power > 0) {
sprintf(msg, "It increased your dexterity by %d points", item->power);
add_action(msg);
} else if (item->power < 0) {
sprintf(msg, "It decreased your dexterity by %d points", -item->power);
add_action(msg);
} else {
add_action("It did nothing.");
}
get_player_obj()->dexterity += item->power;
if (get_player_obj()->dexterity < 1) {
get_player_obj()->dexterity = 1;
}
break;
case 2: /* int */
if (item->power > 0) {
sprintf(msg, "It increased your intelligence by %d points", item->power);
add_action(msg);
} else if (item->power < 0) {
sprintf(msg, "It decreased your intelligence by %d points", -item->power);
add_action(msg);
} else {
add_action("It did nothing.");
}
get_player_obj()->intelligence += item->power;
if (get_player_obj()->intelligence < 1) {
get_player_obj()->intelligence = 1;
}
break;
case 3: /* hp */
item->power /= 3;
get_player_obj()->max_hp += item->power;
get_player_obj()->current_hp += item->power;
if (item->power > 0) {
sprintf(msg, "It increased your health by %d points", item->power);
add_action(msg);
} else if (item->power < 0) {
sprintf(msg, "It decreased your health by %d points", -item->power);
add_action(msg);
} else {
add_action("It did nothing.");
}
break;
case 4: /* luck */
if (item->power > 0) {
sprintf(msg, "It increased your luck by %d points", 100 * item->power);
add_action(msg);
} else if (item->power < 0) {
sprintf(msg, "It decreased your luck by %d points", -100 * item->power);
add_action(msg);
} else {
add_action("It did nothing.");
}
get_player_obj()->luck += item->power * 100;
if (get_player_obj()->luck < 2) {
get_player_obj()->luck = 2;
}
break;
case 5: /* exp */
default:
add_action("It gave you new life experiences");
if (item->power > 0) {
player_gain_exp(item->power);
} else {
player_gain_exp(item->power * -2 + 1);
}
break;
}
}
}

Basically the game has Strength, Dexterity, Intelligence, Luck, Health, and Experience potions. Each potion can be either positive or negative. For example, you could drink a potion that adds 3 to strength, or one that removes 4 intelligence.

from hag.

JohnathonNow avatar JohnathonNow commented on August 27, 2024

@a3qz does it make sense to move potions out of the item module into their own? Then we can add things like a bitset representing what kinds of potions have been identified/consumed.

from hag.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.