Title: '&e&l●&d&l 签到七天领豪礼 &e&l●&r'

Layout:
  - '####`Notice`####'
  - ''
  - ' `One` `Two` `Three` `Four`'
  - '  `Five` `Six` `Seven`'
  - ''
  - '####*####'

Options:
  Arguments: true
  # {0} - 未解锁的显示
  # {1} - 未签到的显示
  # {2} - 已签到的显示
  # {3} - 签到记录显示 （使用 %date 作为日期变量）
  Default-Arguments:
    - '&7未解锁'
    - '&3&l点击&7进行签到'
    - '&7今天已经签到了噢！ &3&l明天&7再来吧！'
    - '&7已于 %date 签到 '
  Min-Click-Delay: 200
  Depend-Expansions: [ Vault ]

Bindings:
  
  # 设置快捷指令入口
  # (?i) 表示无视大小写
  # /sign-in
  # /daliy
  Commands:
    - '(?i)sign-in'
    - '(?i)daliy'

Events:
  Open:
    - 'sound: BLOCK_NOTE_BLOCK_PLING-1-2'
    - 'delay: 1'
    - 'update'
  
Icons:
  Notice:
    display:
      material: '5934'
      name: '&e&l●&d&l 签到七天领豪礼 &e&l●&r'
      lore:
      - ''
      - '&f&l>> &a&l活动简介'
      - ' &c&l◆ &7签到七天送豪礼'
      - ''
      - '&f&l>> &b&l活动时间'
      - ' &c&l◆ &72022.5.17 - 2023.12.17 '
      - ''
      flag:
      - HIDE_POTION_EFFECTS
      
  One:
    display:
      material: '1'
      name: '&e&l●&b&l 第一天 &e&l●&r'
      lore:
      - ''
      - '&f&l>> &a&l奖励'
      - ' &c&l◆ &7精灵糖果&3 x32'
      - ' &c&l◆ &7高级球&3 x32'
      - ' &c&l◆ &7幸运方块&3 x16'
      - ' &c&l◆ &7委托包解锁&3 x1'
      - ''
      - '&f&l>> &b&l注意'
      - ' &c&l◆ &7领取前请确保背包至少有&3&l足够空位 '
      - ' &c&l◆ &7否则后果自负'
      - ''
      - '&f&l>> &e&l操作'
      - ' &c&l◆ ${display_1}'
      - ''
      flag:
      - HIDE_POTION_EFFECTS
    actions:
      all:
        - condition: 'js: vars("${check!_1}")'
          # 签到检测不通过
          actions:
            # 退出 actions 动作组，阻止后续动作执行
            - 'return'
        - condition: ''
          # 签到检测通过，更新玩家的签到数据
          actions:
            - 'js: vars("${update_1}")'
            - 'delay: 1'
            - 'update'
        - condition: ''
          # 签到检测通过，给予玩家奖励
          actions:
            - 'Close'
            - 'Console: give %player_name% 5719 32'
            - 'Console: give %player_name% 6521 16'
            - 'Console: pjb unlock %player_name% 马洛科蒙航空'
            - 'Console: give %player_name% 7074 16'
            - 'Sound: ENTITY_PLAYER_LEVELUP-1-1.5'
            - 'cmi broadcast：&a&l新人七日第一天签到成功 &7&l每天都要来哦~~'
            - 'Tell: &7[&b系统&7] &a&l签到成功！'     
  Two:
    display:
      material: '1'
      name: '&e&l●&b&l 第二天 &e&l●&r'
      lore:
      - ''
      - '&f&l>> &a&l奖励'
      - ' &c&l◆ &7精灵糖果&3 x32'
      - ' &c&l◆ &7高级球&3 x64'
      - ' &c&l◆ &7新人5V百变怪&5 x1'
      - ' &c&l◆ &7幸运方块&3 x16'
      - ' &c&l◆ &7自定义时装&3 x1'
      - ''
      - '&f&l>> &b&l注意'
      - ' &c&l◆ &7领取前请确保背包至少有&3&l足够空位 '
      - ' &c&l◆ &7否则后果自负'
      - ''
      - '&f&l>> &e&l操作'
      - ' &c&l◆ ${display_2}'
      - ''
      flag:
      - HIDE_POTION_EFFECTS
    actions:
      all:
        - condition: 'js: vars("${check!_2}")'
          actions:
            - 'return'
        - condition: ''
          actions:
            - 'js: vars("${update_2}")'
            - 'delay: 1'
            - 'update'
        - condition: ''
          actions:
            - 'Close'
            - 'Console: give %player_name% 6521 64'
            - 'Console: give %player_name% 6521 32'
            - 'Console: give %player_name% 5936 1'
            - 'Console: givepoke %player_name% Ditto 个体:5'
            - 'Console: give %player_name% 7074 16'
            - 'Sound: ENTITY_PLAYER_LEVELUP-1-1.5'
            - 'Title: &a&l签到成功 &7&l记上一笔，hold住我的快乐！ 5 40 5'
            - 'Tell: &7[&b系统&7] &a&l签到成功！'
      
  Three:
    display:
      material: '1'
      name: '&e&l●&b&l 第三天 &e&l●&r'
      lore:
      - ''
      - '&f&l>> &a&l奖励'
      - ' &c&l◆ &7大师球&3 x2'
      - ' &c&l◆ &7幸运方块&3 x16'
      - ' &c&l◆ &7五星精灵蛋&3 x1'
      - ''
      - '&f&l>> &b&l注意'
      - ' &c&l◆ &7领取前请确保背包至少有&3&l足够空位 '
      - ' &c&l◆ &7否则后果自负'
      - ''
      - '&f&l>> &e&l操作'
      - ' &c&l◆ ${display_3}'
      - ''
      flag:
      - HIDE_POTION_EFFECTS
    actions:
      all:
        - condition: 'js: vars("${check!_3}")'
          actions:
            - 'return'
        - condition: ''
          actions:
            - 'js: vars("${update_3}")'
            - 'delay: 1'
            - 'update'
        - condition: ''
          actions:
            - 'Close'
            - 'Console: give %player_name% 6522 2'
            - 'Console: give %player_name% 7074 16'
            - 'Console: pixelextras:pe %player_name% 5 1'
            - 'Sound: ENTITY_PLAYER_LEVELUP-1-1.5'
            - 'Title: &a&l签到成功 &7&l最重要的是今天的心！ 5 40 5'
            - 'Tell: &7[&b系统&7] &a&l签到成功！'
      
  Four:
    display:
      material: '1'
      name: '&e&l●&b&l 第四天 &e&l●&r'
      lore:
      - ''
      - '&f&l>> &a&l奖励'
      - ' &c&l◆ &7幸运方块&3 x16'
      - ''
      - '&f&l>> &b&l注意'
      - ' &c&l◆ &7领取前请确保背包至少有&3&l足够空位 '
      - ' &c&l◆ &7否则后果自负'
      - ''
      - '&f&l>> &e&l操作'
      - ' &c&l◆ ${display_4}'
      - ''
      flag:
      - HIDE_POTION_EFFECTS
    actions:
      all:
        - condition: 'js: vars("${check!_4}")'
          actions:
            - 'return'
        - condition: ''
          actions:
            - 'js: vars("${update_4}")'
            - 'delay: 1'
            - 'update'
        - condition: ''
          actions:
            - 'Close'
            - 'Console: give %player_name% 7074 16'
            - 'Sound: ENTITY_PLAYER_LEVELUP-1-1.5'
            - 'Title: &a&l签到成功 &7&l我坚信，一定能到最后！ 5 40 5'
            - 'Tell: &7[&b系统&7] &a&l签到成功！'
      
  Five:
    display:
      material: '1'
      name: '&e&l●&b&l 第五天 &e&l●&r'
      lore:
      - ''
      - '&f&l>> &a&l奖励'
      - ' &c&l◆ &7牧场&3 x1'
      - ' &c&l◆ &7幸运方块&3 x16'
      - ''
      - '&f&l>> &b&l注意'
      - ' &c&l◆ &7领取前请确保背包至少有&3&l足够空位 '
      - ' &c&l◆ &7否则后果自负'
      - ''
      - '&f&l>> &e&l操作'
      - ' &c&l◆ ${display_5}'
      - ''
      flag:
      - HIDE_POTION_EFFECTS
    actions:
      all:
        - condition: 'js: vars("${check!_5}")'
          actions:
            - 'return'
        - condition: ''
          actions:
            - 'js: vars("${update_5}")'
            - 'delay: 1'
            - 'update'
        - condition: ''
          actions:
            - 'Close'
            - 'Console: give %player_name% 5409 1'
            - 'Console: give %player_name% 7074 16'
            - 'Sound: ENTITY_PLAYER_LEVELUP-1-1.5'
            - 'Title: &a&l签到成功 &7&l今天也要做个快乐小可爱！ 5 40 5'
            - 'Tell: &7[&b系统&7] &a&l签到成功！'
            - 'tell: &7[&6财务小助&7] 您的账户完成了一次交易 &a[ &c+250金币 &a]'
            - 'tell: &7[&6财务小助&7] 余额 &a[ &d%vault_eco_balance%金币 &a]'
      
  Six:
    display:
      material: '1'
      name: '&e&l●&b&l 第六天 &e&l●&r'
      lore:
      - ''
      - '&f&l>> &a&l奖励'
      - ' &c&l◆ &7幸运方块&3 x16'
      - ''
      - '&f&l>> &b&l注意'
      - ' &c&l◆ &7领取前请确保背包至少有&3&l足够空位 '
      - ' &c&l◆ &7否则后果自负'
      - ''
      - '&f&l>> &e&l操作'
      - ' &c&l◆ ${display_6}'
      - ''
      flag:
      - HIDE_POTION_EFFECTS
    actions:
      all:
        - condition: 'js: vars("${check!_6}")'
          actions:
            - 'return'
        - condition: ''
          actions:
            - 'js: vars("${update_6}")'
            - 'delay: 1'
            - 'update'
        - condition: ''
          actions:
            - 'Close'
            - 'Console: give %player_name% 7074 16'
            - 'Sound: ENTITY_PLAYER_LEVELUP-1-1.5'
            - 'Title: &a&l签到成功 &7&l只要再坚持一点点！就可以了！ 5 40 5'
            - 'Tell: &7[&b系统&7] &a&l签到成功！'
      
  Seven:
    display:
      material: '1'
      name: '&e&l●&b&l 第七天 &e&l●&r'
      lore:
      - ''
      - '&f&l>> &a&l奖励'
      - ' &c&l◆ &7六星精灵蛋&3 x2'
      - ' &c&l◆ &7巨钳螳螂6V&3 x1'
      - ' &c&l◆ &7克隆机&3 x1'
      - ' &c&l◆ &7幸运方块&3 x16'
      - ''
      - '&f&l>> &b&l注意'
      - ' &c&l◆ &7领取前请确保背包至少有&3&l足够空位 '
      - ' &c&l◆ &7否则后果自负'
      - ''
      - '&f&l>> &e&l操作'
      - ' &c&l◆ ${display_7}'
      - ''
      flag:
      - HIDE_POTION_EFFECTS
    actions:
      all:
        - condition: 'js: vars("${check!_7}")'
          actions:
            - 'return'
        - condition: ''
          actions:
            - 'js: vars("${update_7}")'
            - 'delay: 1'
            - 'update'
        - condition: ''
          actions:
            - 'Close'
            - 'Console: give %player_name% 5446 1'
            - 'Console: give %player_name% 7074 16'
            - 'Console: pixelextras:pe %player_name% 6 1'
            - '[op]:PixelExtras:givepoke %player% Scizor 等级:100 个体:6'
            - 'Sound: ENTITY_PLAYER_LEVELUP-1-1.5'
            - 'Title: &a&l签到成功 &7&l我就说嘛，我一定能坚持到最后哒！ 5 40 5'
            - 'Tell: &7[&b系统&7] &a&l签到成功！'
            - 'tell: &7[&6财务小助&7] 您的账户完成了一次交易 &a[ &c+450金币 &a]'
            - 'tell: &7[&6财务小助&7] 余额 &a[ &d%vault_eco_balance%金币 &a]'
      
  '*':
    display:
      material: 'slime_ball'
      name: '&e&l● &c&l返回 &e&l●&r'
    actions:
      all: 'menu: 新鑫菜单5'
      
  '#':
    update: -1
    display:
      material: LIGHT_BLUE_STAINED_GLASS_PANE
      name: '&r'
      flag:
      - HIDE_ATTRIBUTES
      - HIDE_UNBREAKABLE

# 全局函数
Functions:
  
  # 获取玩家的签到索引数据
  # 若不存在则初始化为 1
  index: |-
    if(vars("\{data: activity-seven_day_sign_in-index\}") == "null"){
        utils.runAction(player, "set-data: activity-seven_day_sign_in-index 1");
    }
    return varInt("\{data: activity-seven_day_sign_in-index\}");
  
  # 获取玩家的签到记录
  # 用于判断当天是否签到
  record: |-
    vars("\{data: activity-seven_day_sign_in-record\}")
  
  # 获取当天日期在今年的位置
  day: 'vars("${ke: day in year}")'
  
  # 获取目前完整日期时间
  date: 'vars("${ke: date as \"yyyy-MM-dd HH:mm:ss\" }")'
  
  # 获取显示信息
  signed-record: 'vars("{3}")'
  signed: 'vars("{2}")'
  signable: 'vars("{1}")'
  unsignable: 'vars("{0}")'
  
  # 获取展示信息
  # 参数：
  # args[0] - 签到索引 (1~7)
  display: |-
    var arg = parseInt(args[0]);
    var index = varInt("${index}");
    if (arg == index) {
        return vars("${record}") == vars("${day}") ? vars("${signed}") : vars("${signable}");
    } else {
        return arg > index ? vars("${unsignable}") : vars("${signed-record}").replace(/\%date/i, vars("${data: activity-seven_day_sign_in-record-" + arg + "}"));
    }
  
  # 判断当前是否允许签到
  # 参数：
  # args[0] - 签到索引 (1~7)
  # 
  # 注意：检测结果取反
  # 若检测结果通过返回 false 反之 true
  check!: |-
    var arg = args[0];
    return vars("${index}") != arg || vars("${record}") == vars("${day}")
  
  # 更新玩家数据
  # 参数：
  # args[0] - 签到索引 (1~7)
  # 
  # 部分数据存储说明：
  # index 索引 + 1
  # record 储存今天的日期天数
  # record-(1~7) 储存签到的日期数据
  update: |-
    var arg = parseInt(args[0]);
    utils.runAction(player, [
        "set-data: activity-seven_day_sign_in-index " + (arg + 1),
        "set-data: activity-seven_day_sign_in-record " + vars("${day}"),
        "set-data: activity-seven_day_sign_in-record-" + arg + " " + vars("${date}"),
        "delay: 3",
        "update: One, Two, Three, Four, Five, Six, Seven"
    ]);
    return false;