str = {}
fun = {}

str["Debug.ReloadFieldBegin"] = Debug.ReloadFieldBegin

Debug.ReloadFieldBegin = function(str_1, str_2)
  str["不洗牌"] = str_1 & DUEL_PSEUDO_SHUFFLE

  if str_2 then
    if str_2 == 3 then
    str["规则"] = "大师3"
    elseif str_2 == 4 then
      str["规则"] = "新大师"
      end
  else
    str["规则"] = "大师2020"
    end
  str["Debug.ReloadFieldBegin"](str_1, str_2)
  end

fun["通关邀请"] = function()
  local effect_1
  effect_1 = Effect.GlobalEffect()
  effect_1:SetType(EFFECT_TYPE_FIELD
    + EFFECT_TYPE_CONTINUOUS)
  effect_1:SetCode(EVENT_DAMAGE)
  function cache_1()
    cache_1 = Duel.GetLP(1)
    if cache_1 <= 0 then
      cache_1 = true
    else
      cache_1 = false
      end
    return cache_1
    end
  effect_1:SetCondition(cache_1)
  function cache_1()
    Debug.ShowHint("残局群181175613")
    return
    end
  effect_1:SetOperation(cache_1)

  Duel.RegisterEffect(effect_1
    , 0)
  end

fun["是否效果卡"] = function(card)

  cache_1 = Card.IsType(card, TYPE_SPELL)
  cache_2 = Card.IsType(card, TYPE_TRAP)
  cache_3 = Card.IsType(card, TYPE_EFFECT)

  if cache_1
  or cache_2
  or cache_3 then
    return true
    end
  return false
  end

fun["开局说明"] = function()
  cache_1 = 0
  cache_1 = cache_1 + LOCATION_DECK
  cache_1 = cache_1 + LOCATION_HAND
  cache_1 = cache_1 + LOCATION_MZONE
  cache_1 = cache_1 + LOCATION_SZONE
  cache_1 = cache_1 + LOCATION_GRAVE
  cache_1 = cache_1 + LOCATION_REMOVED
  cache_1 = cache_1 + LOCATION_EXTRA
  cache_1 = cache_1 + LOCATION_OVERLAY

  str["这个残局的效果卡数量"] = Duel.GetMatchingGroupCount(fun["是否效果卡"],0,cache_1,cache_1,nil)

  str["开局说明"] =""

  str["开局说明"] = str["开局说明"] .. str["这个残局的效果卡数量"]
  str["开局说明"] = str["开局说明"] .. " 卡"

  str["开局说明"] = str["开局说明"] .. "　"

  str["开局说明"] = str["开局说明"] .. str["规则"]

  str["开局说明"] = str["开局说明"] .. "　"

  if str["不洗牌"] == 0 then
  else
    str["开局说明"] = str["开局说明"] .. "伪洗牌"
    end

  Debug.ShowHint(str["开局说明"])
  end

fun["开局添加手卡"] = function(str_1)
  str["开局添加手卡"] = str_1
  effect_1 = Effect.GlobalEffect()
  effect_1:SetType(EFFECT_TYPE_FIELD
    + EFFECT_TYPE_CONTINUOUS)
  effect_1:SetCode(EVENT_ADJUST)
  effect_1:SetCountLimit(1)
  function cache_1()
    return true
    end
  effect_1:SetCondition(cache_1)
  function cache_1(effect_event
    , player_who_activate_the_effect)
    str["玩家选定的卡"] = Duel.SelectMatchingCard(player_who_activate_the_effect
       , Card.IsAbleToHand
       , player_who_activate_the_effect
       , LOCATION_DECK
       , 0
       , str_1
       , str_1
       , nil)
    Duel.SendtoHand(str["玩家选定的卡"]
      , nil
      , REASON_RULE)
    end
  effect_1:SetOperation(cache_1)
  Duel.RegisterEffect(effect_1
    , 0)
  end
