@@ -1443,93 +1443,54 @@ function Auxiliary.PuzzleOp(e,tp)
14431443 Duel .SetLP (0 ,0 )
14441444end
14451445
1446-
14471446function Auxiliary .StatChangeDamageStepCondition ()
14481447 return not (Duel .IsPhase (PHASE_DAMAGE ) and Duel .IsDamageCalculated ())
14491448end
14501449
1451- -- Default cost function for "You can Tribute this card; .."
1452- function Auxiliary .selfreleasecost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1453- local c = e :GetHandler ()
1454- if chk == 0 then return c :IsReleasable () end
1455- Duel .Release (c ,REASON_COST )
1456- end
1450+ -- Functions to commonly used costs:
14571451
1458- -- Default cost function for "You can banish this card; .."
1459- function Auxiliary .bfgcost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1460- local c = e :GetHandler ()
1461- if chk == 0 then return c :IsAbleToRemoveAsCost () end
1462- Duel .Remove (c ,POS_FACEUP ,REASON_COST )
1463- end
1464-
1465- Auxiliary .selfbanishcost = aux .bfgcost
1466- Auxiliary .SelfBanishCost = aux .bfgcost
1467- Auxiliary .SelfReleaseCost = aux .selfreleasecost
1468- Auxiliary .SelfTributeCost = aux .selfreleasecost
1452+ Cost = {}
14691453
1470- function Auxiliary . SelfToGraveCost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1454+ function Cost . SelfToGrave (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
14711455 local c = e :GetHandler ()
14721456 if chk == 0 then return c :IsAbleToGraveAsCost () end
14731457 Duel .SendtoGrave (c ,REASON_COST )
14741458end
1475- function Auxiliary . SelfToHandCost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1459+ function Cost . SelfToHand (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
14761460 local c = e :GetHandler ()
14771461 if chk == 0 then return c :IsAbleToHandAsCost () end
14781462 Duel .SendtoHand (c ,nil ,REASON_COST )
14791463end
1480- function Auxiliary . SelfToDeckCost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1464+ function Cost . SelfToDeck (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
14811465 local c = e :GetHandler ()
14821466 if chk == 0 then return c :IsAbleToDeckAsCost () end
14831467 Duel .SendtoDeck (c ,nil ,SEQ_DECKSHUFFLE ,REASON_COST )
14841468end
1485- function Auxiliary . SelfToExtraCost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1469+ function Cost . SelfToExtra (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
14861470 local c = e :GetHandler ()
14871471 if chk == 0 then return c :IsAbleToExtraAsCost () end
14881472 Duel .SendtoDeck (c ,nil ,SEQ_DECKSHUFFLE ,REASON_COST )
14891473end
1490- function Auxiliary . SelfDiscardCost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1474+ function Cost . SelfDiscard (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
14911475 local c = e :GetHandler ()
14921476 if chk == 0 then return c :IsDiscardable () end
14931477 Duel .SendtoGrave (c ,REASON_DISCARD |REASON_COST )
14941478end
1495- function Auxiliary . SelfDiscardToGraveCost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1479+ function Cost . SelfDiscardToGrave (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
14961480 local c = e :GetHandler ()
14971481 if chk == 0 then return c :IsDiscardable () and c :IsAbleToGraveAsCost () end
14981482 Duel .SendtoGrave (c ,REASON_DISCARD |REASON_COST )
14991483end
1500- function Auxiliary . SelfRevealCost (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1484+ function Cost . SelfReveal (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
15011485 local c = e :GetHandler ()
15021486 if chk == 0 then return not c :IsPublic () end
15031487 Duel .ConfirmCards (1 - tp ,c )
15041488 Duel .ShuffleHand (tp )
15051489end
15061490
1507- function Auxiliary .PayLPCost (lp_value ,pay_until )
1508- if not pay_until then
1509- if lp_value >= 1 then
1510- -- Pay X LP, where X is any number equal to or higher than 1
1511- return function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1512- if chk == 0 then return Duel .CheckLPCost (tp ,lp_value ) end
1513- Duel .PayLPCost (tp ,lp_value )
1514- end
1515- else
1516- -- Pay a fraction of your LP (half, one third, etc)
1517- return function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1518- if chk == 0 then return true end
1519- Duel .PayLPCost (tp ,math.floor (Duel .GetLP (tp )* lp_value ))
1520- end
1521- end
1522- else
1523- -- Pay LP so that you have X left
1524- return function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1525- local pay_lp_value = math.floor (Duel .GetLP (tp )- lp_value )
1526- if chk == 0 then return pay_lp_value > 0 and Duel .CheckLPCost (tp ,pay_lp_value ) end
1527- Duel .PayLPCost (tp ,pay_lp_value )
1528- end
1529- end
1530- end
15311491
1532- function Auxiliary .DiscardCost (filter ,other ,count )
1492+
1493+ function Cost .Discard (filter ,other ,count )
15331494 count = count or 1
15341495 filter = filter and aux .AND (filter ,Card .IsDiscardable ) or Card .IsDiscardable
15351496 return function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
@@ -1538,7 +1499,6 @@ function Auxiliary.DiscardCost(filter,other,count)
15381499 Duel .DiscardHand (tp ,filter ,count ,count ,REASON_COST |REASON_DISCARD ,exclude )
15391500 end
15401501end
1541-
15421502-- "Detach Xyz Material Cost Generator"
15431503-- Generates a function to be used by Effect.SetCost in order to detach
15441504-- a number of Xyz Materials from the Effect's handler.
@@ -1548,7 +1508,7 @@ end
15481508-- `op` optional function that gets called by passing the effect and the operated
15491509-- group of just detached materials in order to do some additional handling with
15501510-- them.
1551- function Auxiliary . dxmcostgen (min ,max ,op )
1511+ function Cost . Detach (min ,max ,op )
15521512 max = max or min
15531513 do -- Perform some sanity checks, simplifies debugging
15541514 local max_type = type (max )
@@ -1579,23 +1539,45 @@ function Auxiliary.dxmcostgen(min,max,op)
15791539 end
15801540end
15811541
1542+ -- Default cost function for "You can banish this card; .."
1543+ function Cost .SelfBanish (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1544+ local c = e :GetHandler ()
1545+ if chk == 0 then return c :IsAbleToRemoveAsCost () end
1546+ Duel .Remove (c ,POS_FACEUP ,REASON_COST )
1547+ end
15821548
1583- Cost = {}
1549+ -- Default cost function for "You can Tribute this card; .."
1550+ function Cost .SelfTribute (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1551+ local c = e :GetHandler ()
1552+ if chk == 0 then return c :IsReleasable () end
1553+ Duel .Release (c ,REASON_COST )
1554+ end
15841555
1585- Cost .SelfBanish = aux .bfgcost
1586- Cost .SelfRelease = aux .selfreleasecost
1587- Cost .SelfTribute = aux .selfreleasecost
1588- Cost .SelfToGrave = aux .SelfToGraveCost
1589- Cost .SelfToHand = aux .SelfToHandCost
1590- Cost .SelfToDeck = aux .SelfToDeckCost
1591- Cost .SelfToExtra = aux .SelfToExtraCost
1592- Cost .SelfDiscard = aux .SelfDiscardCost
1593- Cost .SelfDiscardToGrave = aux .SelfDiscardToGraveCost
1594- Cost .SelfReveal = aux .SelfRevealCost
1595-
1596- Cost .Detach = aux .dxmcostgen
1597- Cost .Discard = aux .DiscardCost
1598- Cost .PayLP = aux .PayLPCost
1556+ -- Default cost for "You can pay X LP;"
1557+ function Cost .PayLP (lp_value ,pay_until )
1558+ if not pay_until then
1559+ if lp_value >= 1 then
1560+ -- Pay X LP, where X is any number equal to or higher than 1
1561+ return function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1562+ if chk == 0 then return Duel .CheckLPCost (tp ,lp_value ) end
1563+ Duel .PayLPCost (tp ,lp_value )
1564+ end
1565+ else
1566+ -- Pay a fraction of your LP (half, one third, etc)
1567+ return function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1568+ if chk == 0 then return true end
1569+ Duel .PayLPCost (tp ,math.floor (Duel .GetLP (tp )* lp_value ))
1570+ end
1571+ end
1572+ else
1573+ -- Pay LP so that you have X left
1574+ return function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
1575+ local pay_lp_value = math.floor (Duel .GetLP (tp )- lp_value )
1576+ if chk == 0 then return pay_lp_value > 0 and Duel .CheckLPCost (tp ,pay_lp_value ) end
1577+ Duel .PayLPCost (tp ,pay_lp_value )
1578+ end
1579+ end
1580+ end
15991581
16001582function Cost .SoftOncePerChain (flag )
16011583 return function (e ,tp ,eg ,ep ,ev ,re ,r ,rp ,chk )
@@ -1629,6 +1611,9 @@ function Cost.AND(...)
16291611 end
16301612end
16311613
1614+ -- Alias for historical reasons:
1615+ Cost .SelfRelease = Cost .SelfTribute
1616+
16321617function Card .EquipByEffectLimit (e ,c )
16331618 if e :GetOwner ()~= c then return false end
16341619 local eff = {c :GetCardEffect (89785779 + EFFECT_EQUIP_LIMIT )}
0 commit comments