Fluorohydride / ygopro-core

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

update release functions #516

Closed salix5 closed 10 months ago

salix5 commented 11 months ago

EFFECT_CANNOT_RELEASE

Now the signature of target function is:

--Ritual Beast Ulti-Reirautari
function s.rellimit(e,c,tp,r)
    return r&REASON_COST~=0
end

Lua functions

The definitions of following functions have changed.

The following functions have more optional arguments.

---@return integer ---@param player integer ---@param use_hand? boolean default: false ---@param reason? integer default: REASON_COST function Duel.GetReleaseGroupCount(player,use_hand,reason) end


- Duel.IsPlayerCanRelease
add 3rd param: reason (optional, default: REASON_COST)
```lua
---@return boolean
---@param player integer
---@param c? Card
---@param reason? integer default: REASON_COST
function Duel.IsPlayerCanRelease(player,c,reason) end

Release Reason

Now the reasons of release are:

Test

test_cannot_release.zip

test_cannot_release.lua Single mode script Add test card with id=1 Level 1/Earth/Warrior/ATK 1/DEF 1

c1.lua The script of 1 EFFECT_CANNOT_RELEASE with reason

インフェルノイド・アシュメダイ Infernoid Piaty From https://github.com/Fluorohydride/ygopro-scripts/pull/2222

When 1 is on the field: The 2nd effect of Infernoid Piaty cannot be activated. Black Illusion Ritual can be activated.

465uytrewq commented 11 months ago

https://github.com/Fluorohydride/ygopro-core/pull/516/files#diff-9c303fc29f7374041f51201c6208b8672f77cf296e89986d7ae02da80c451f86R1730 Might be better to change as follows (ref: https://github.com/Fluorohydride/ygopro-core/pull/357).

    effect* peffect = pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE_NONSUM);
    if(!peffect || (peffect->is_flag(EFFECT_FLAG_COUNT_LIMIT) && peffect->count_limit == 0))
        continue;
    pduel->lua->add_param(core.reason_effect, PARAM_TYPE_EFFECT);
    pduel->lua->add_param(reason, PARAM_TYPE_INT);
    pduel->lua->add_param(core.reason_player, PARAM_TYPE_INT);
    if(!peffect->check_value_condition(3))
        continue;
salix5 commented 11 months ago

https://github.com/Fluorohydride/ygopro-core/pull/516/files#diff-9c303fc29f7374041f51201c6208b8672f77cf296e89986d7ae02da80c451f86R1730 Might be better to change as follows (ref: #357).

  effect* peffect = pcard->is_affected_by_effect(EFFECT_EXTRA_RELEASE_NONSUM);
  if(!peffect || (peffect->is_flag(EFFECT_FLAG_COUNT_LIMIT) && peffect->count_limit == 0))
      continue;
  pduel->lua->add_param(core.reason_effect, PARAM_TYPE_EFFECT);
  pduel->lua->add_param(reason, PARAM_TYPE_INT);
  pduel->lua->add_param(core.reason_player, PARAM_TYPE_INT);
  if(!peffect->check_value_condition(3))
      continue;

field.cpp in #357 is merged in 289f4df2514ec848f155b5de94539309a86c4e82 Thank you!

465uytrewq commented 11 months ago

Tyrant Dragon, Insect Queen and The Unfriendly Amazon are not activate effect.

ref: https://www.db.yugioh-card.com/yugiohdb/faq_search.action?ope=4&cid=5194 ■『自分のスタンバイフェイズ毎に、このカードを除く自分のフィールド上モンスター1体を生け贄に捧げなければ、このカードを破壊する』は効果として扱いません。「味方殺しの女騎士」をフィールドに維持するためのコストになります。(チェーンブロックが作られる事はありません。)

so, EFFECT_CANNOT_RELEASE need reason_effect check.

salix5 commented 11 months ago

@465uytrewq

Edit: Release for Maintenance Cost will use REASON_MAINTENANCE

465uytrewq commented 11 months ago

would we replace REASON_COST to REASON_MAINTENANCE in Duel.Destroy/Duel.SendToGrave? (e.g. Koa'ki Meiru, Aerial Recharge)

salix5 commented 11 months ago

@465uytrewq I would hope so. But I am afraid that we need to change a lot of scripts for that. I only change the reason of Duel.Release for now.

465uytrewq commented 11 months ago

@salix5 ok, i understood. i'll check other cards to need REASON_ACTION or REASON_MAINTENANCE after these commit merge.

HKunogi commented 10 months ago

Adding more arguments should be fine, but it should prob not be the very first argument as that missalign all rest for cards that are already coded using those in an specific order, or at least, make so it can identify if the arguments being passed matches the old or new alignment and automatically use it accordingly, for card scripts not yet up-to-date to not break.

salix5 commented 9 months ago

@HKunogi https://github.com/Fluorohydride/ygopro-core/pull/534 https://github.com/Fluorohydride/ygopro-scripts/pull/2346 mercury233 has restored some of the release-related functions in order to keep the old script files working. The replacement RegEx patterns are in the pull request.

Current version:

---fixed reason: REASON_COST
---@return boolean
---@param player integer
---@param f function|nil
---@param count integer
---@param ex Card|Group|nil
---@param ... any
function Duel.CheckReleaseGroup(player,f,count,ex,...) end

---fixed reason: REASON_COST
---@return Group
---@param sel_player integer
---@param f function|nil
---@param min integer
---@param max integer
---@param ex Card|Group|nil
---@param ... any
function Duel.SelectReleaseGroup(sel_player,f,min,max,ex,...) end
---add parameters: reason, use_hand
---@return boolean
---@param player integer
---@param f function|nil
---@param count integer
---@param reason integer
---@param use_hand boolean
---@param ex Card|Group|nil
---@param ... any
function Duel.CheckReleaseGroupEx(player,f,count,reason,use_hand,ex,...) end

---add parameters: reason, use_hand
---@return Group
---@param player integer
---@param f function|nil
---@param min integer
---@param max integer
---@param reason integer
---@param use_hand boolean
---@param ex Card|Group|nil
---@param ... any
function Duel.SelectReleaseGroupEx(player,f,min,max,reason,use_hand,ex,...) end
salix5 commented 9 months ago

As a conclusion: (Suppose that accepting #534)

--after Duel.CheckReleaseGroupEx(player,f,count,reason,false,ex,...)

```lua
--before
Duel.SelectReleaseGroup(sel_player,f,min,max,ex,...)

--after
Duel.SelectReleaseGroupEx(player,f,min,max,reason,false,ex,...)

--after Duel.CheckReleaseGroupEx(player,f,count,reason,true,ex,...)

```lua
--before
Duel.SelectReleaseGroupEx(player,f,min,max,ex,...)

--after
Duel.SelectReleaseGroupEx(player,f,min,max,reason,true,ex,...)