void commerce_create(Commerce *commerce, Planet *planet, unsigned level) { int randNumWeapon = rand_born(0, MAX_WEAPON_ITEM); int randNumArmor = rand_born(0, MAX_ARMOR_ITEM); int randNumEngine = rand_born(0, MAX_ENGINE_ITEM); int randNumHull = rand_born(0, MAX_HULL_ITEM); for (int i = 0; i < MAX_WEAPON_ITEM; ++i) { if (i < randNumWeapon) { Weapon w = weapon_create_rand(level); commerce_add_item(commerce, I_WEAPON, &w, i); } else commerce->weapon[i].isVisible = false; } for (int i = 0; i < MAX_ARMOR_ITEM; ++i) { if (i < randNumArmor) { Armor a = armor_create_rand(level); commerce_add_item(commerce, I_ARMOR, &a, i); } else commerce->armor[i].isVisible = false; } }
void drop_weapon(Player *player) { if (CHANCE(10)) { Weapon w = weapon_create_rand(player->lvl); char c; printf("Vous trouvez une arme: "); weapon_display(w); printf("Voulez vous la prendre [o/n]? "); scanf("%c", &c); if (c == 'o') { player_setItem(player, I_WEAPON, &w); } } }
void drop_weapon(Player *player) { if (CHANCE(10)) { Weapon w = weapon_create_rand(player->lvl); char c; printf("\nVous trouvez une arme: "); weapon_display(w); printf("Voulez vous la prendre [o/n]? "); scanf("%c", &c); purge_stdin(); if (c == 'o') { ship_set_item(&player->ship, I_WEAPON, 0, &w); } } }