summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorgumi <git@gumi.ca>2020-08-21 21:50:04 -0400
committergumi <git@gumi.ca>2020-08-21 21:50:10 -0400
commitbc848331618cf512fadc41f4a88b628c13bca97c (patch)
tree04594c3e72ef1cb5731db930cb16547b38609fdd /src
parentb5cc367814b76f960f7366352a2a23d5cb1e7ab9 (diff)
downloadevol-hercules-bc848331618cf512fadc41f4a88b628c13bca97c.tar.gz
evol-hercules-bc848331618cf512fadc41f4a88b628c13bca97c.tar.bz2
evol-hercules-bc848331618cf512fadc41f4a88b628c13bca97c.tar.xz
evol-hercules-bc848331618cf512fadc41f4a88b628c13bca97c.zip
Allow to use item groups in AllowCards
This allows to limit an entire group of cards instead of just individual cards
Diffstat (limited to 'src')
-rw-r--r--src/emap/pc.c32
1 files changed, 29 insertions, 3 deletions
diff --git a/src/emap/pc.c b/src/emap/pc.c
index 21e59aa..d719173 100644
--- a/src/emap/pc.c
+++ b/src/emap/pc.c
@@ -542,11 +542,28 @@ bool epc_can_insert_card_into_post(bool retVal,
const int newCardId = sd->status.inventory[idx_card].nameid;
int cardAmountLimit = 0;
+ struct item_group *card_group = NULL;
+
for (f = 0; f < sz; f ++)
{
struct ItemCardExt *const card = &VECTOR_INDEX(data->allowedCards, f);
- if (card->id == newCardId)
- {
+ struct item_data *card_itemdata = itemdb->search(card->id);
+
+ if (card_itemdata->group != NULL) {
+ card_group = card_itemdata->group;
+
+ for (int c = 0; c < card_group->qty; c++) {
+ if (card_group->nameid[c] == newCardId) {
+ cardAmountLimit = card->amount;
+ break;
+ }
+ }
+
+ if (cardAmountLimit) {
+ // we found it in a group, so break
+ break;
+ }
+ } else if (card->id == newCardId) {
cardAmountLimit = card->amount;
break;
}
@@ -559,8 +576,17 @@ bool epc_can_insert_card_into_post(bool retVal,
for (f = 0; f < slots; f ++)
{
const int cardId = sd->status.inventory[idx_equip].card[f];
- if (cardId == newCardId)
+ if (cardId == newCardId) {
cardsAmount ++;
+ } else if (card_group != NULL) {
+ // use the same counter for all cards that belong to the group
+ for (int c = 0; c < card_group->qty; c++) {
+ if (card_group->nameid[c] == cardId) {
+ cardsAmount++;
+ break;
+ }
+ }
+ }
}
return cardAmountLimit > cardsAmount;
}