Fluorohydride / ygopro-core

ygopro script engine.
MIT License
327 stars 134 forks source link

Use array to store setcode #541

Closed salix5 closed 8 months ago

salix5 commented 9 months ago

@mercury233 @465uytrewq 由於sqlite3的int最大是8 bytes 改用陣列儲存setcode以便對應5組以上的情況

class card_data

is_setcode() bool is_setcode(uint32 value) const Check if the setcode conatins value.

bool is_alternative() const Check if this card is an alternative artwork card.

void set_setcode(uint64 value) Set the setcode with value (Probably from sqlite file).

class card

static bool check_card_setcode(uint32 code, uint32 value) Check if the setcode of card code contains value.

salix5 commented 9 months ago

@mercury233 @purerosefallen @DailyShana @edo9300 Can we merge this one?

DailyShana commented 9 months ago

If hard coding cannot be avoided, it's not worth to make such a big change.

essentially not different to the following

int32 scriptlib::card_is_set_card(lua_State *L) {
    check_param_count(L, 2);
    check_param(L, PARAM_TYPE_CARD, 1);
    card* pcard = *(card**) lua_touserdata(L, 1);
    uint32 count = lua_gettop(L) - 1;
    uint32 result = FALSE;
    for(uint32 i = 0; i < count; ++i) {
        if(lua_isnil(L, i + 2))
            continue;
        uint32 set_code = (uint32)lua_tointeger(L, i + 2);
                if(pcard->data.code==8512558 && set_code==0x13a) { result=TRUE; break;} // or hide this line in the card::is_set_card
        if(pcard->is_set_card(set_code)) {
            result = TRUE;
            break;
        }
    }
    lua_pushboolean(L, result);
    return 1;
}

I don't know if possible to add a new column 'setcode2' to the database without breaking the compatibility.

salix5 commented 9 months ago

If hard coding cannot be avoided, it's not worth to make such a big change.

essentially not different to the following

No, they are different.

I don't know if possible to add a new column 'setcode2' to the database without breaking the compatibility.

I don't know either. Maybe you can convince the mycard and YGO Omega members to add a new column?