Paste #39555: Untitled Paste

Date: 2017/02/02 21:25:08 UTC-08:00
Type: Denizen Script

View Raw Paste Download This Paste
Copy Link


##############################
##                          ##
##        Flip Cards        ##
##            by            ##
##      ~Peashooter101      ##
##                          ##
##############################
## Denizen Script Info:
## Scripted by Peashooter101
## Scripted for the DragonPeas SMP Server
## Version: 1.0 (Initial)
##############################

FCGiveCommand:
  type: command
  name: FCGive
  description: Gives/Takes cards to the player.
  usage: /fcgive <&lt>CardName<&gt> <&lt>Quantity<&gt> <&lt>Player<&gt>
  allowed help:
  - determine <player.is_op||<context.server>>
  script:
  ##Operator Check
  - if !<player.is_op||<context.server>> {
    - narrate "<red>/fcgive <gold>>> <dark_red>You're not allowed to use this command!"
    - queue clear
  }
  ##Too Many Arguments
  - if <context.args.size> > 3 {
    - narrate "<gold>[Flip Cards] <light_purple>Invalid Command, too many arguments."
  }
  - choose <context.args.get[1]||null>:
    ##No Arguments
    - case null:
      - narrate "<gold>[Flip Cards] <light_purple>You need to provide a CardName and Quantity at minimum."
    ##CoinFlips
    - case CoinFlips:
      ##No Quantity
      - if <context.args.get[2]||null> = null {
        - narrate "<gold>[Flip Cards] <light_purple>You need to provide a Quantity."
        - queue clear
      }
      ##Not a Number
      - if <context.args.get[2]||null> !matches number {
        - narrate "<gold>[Flip Cards] <light_purple>Invalid Argument, specify a number."
        - queue clear
      }
      ##Decimal Number
      - if <context.args.get[2]> !== <context.args.get[2].round_down> {
        - narrate "<gold>[Flip Cards] <light_purple>Invalid Argument, specify a whole number."
        - queue clear
      }
      ##No Player Input
      - if <context.args.get[3]||null> == null {
        - flag <player> FCCoinFlips:+:<context.args.get[2]>
        - narrate "<gold>[Flip Cards] <light_purple>You have received <yellow><context.args.get[2]> <light_purple>CoinFlips Cards."
        - queue clear
      }
      - define playerTarget <server.match_offline_player[<context.args.get[3]||null>]||false>
      ##Invalid Player
      - if <def[playerTarget]> == false {
        - narrate "<gold>[Flip Cards] <light_purple><context.args.get[3]> is not a valid player."
        - queue clear
      }
      ##Valid Player
      - flag <def[playerTarget]> FCCoinFlips:+:<context.args.get[2]>
      - narrate "<gold>[Flip Cards] <light_purple><def[playerTarget].name> has received <yellow><context.args.get[2]> <light_purple>CoinFlips Cards."
      - queue clear
    - default:
      - narrate "<gold>[Flip Cards] <light_purple>That isn't a CardName, use <red>/fcplay <gold>to see all applicable cards."

FCPlayCardCommand:
  type: command
  name: FCPlayCard
  description: Choose a card to play.
  usage: /fcplaycard <&lt>CardName<&gt>
  script:
  ##Too Many Arguments
  - if <context.args.size> > 1 {
    - narrate "<gold>[Flip Cards] <light_purple>Invalid Command, too many arguments."
  }
  ##No Arguments (Check Cards)
  - if <context.args.size> > = 0 {
    - narrate "<gold>[Flip Cards] <light_purple>You have the following cards:"
    - narrate "<gold>CoinFlips: <yellow><player.flag[FCCoinFlips]>"
    - queue clear
  }
  ##Card Selected
  - choose <context.args.get[1]||null>:
    ##Null Value
    - case null:
      - narrate "<gold>[Flip Cards] <light_purple>You have the following cards:"
      - narrate "<gold>CoinFlips: <yellow><player.flag[FCCoinFlips]>"
      - queue clear
    ##Coin Flips
    - case CoinFlips:
      ##Has Enough Cards
      - if <player.flag[FCCoinFlips]> > 0 {
        - flag <player> FCCoinFlips:-:1
        - narrate "<gold>[Flip Cards] <light_purple>Good Luck!"
        - flag <player> FCCoinFlipsActions:0
        - flag <player> FCCoinFlipsIronWin:0
        - flag <player> FCCoinFlipsGoldWin:0
        - wait 1s
        - inventory open d:in@FCCoinFlipsGUI
        - queue clear
      }
      ##Not Enough Cards
      else {
      - narrate "<gold>[Flip Cards] <light_purple>You do not have any of these cards."
      - queue clear
      }
    ##Invalid CardName Input
    - default:
      - narrate "<gold>[Flip Cards] <light_purple>That is not a Flip Card, use <red>/fcplay <gold>to see all applicable cards."
      - queue clear

FCBlank:
  type: item
  material: black_stained_glass_pane
  display name:

##############################
##                          ##
##        Coin Flips        ##
##                          ##
##############################

FCCoinFlipsGUI:
  type: inventory
  title: <dark_blue>Flip Card <black>| <yellow>Coin Flips
  size: 27
  slots:
  - "[i@FCBlank] [i@FCBlank] [i@FCBlank] [i@FCBlank] [i@FCCoinFlipsInfo] [i@FCBlank] [i@FCBlank] [i@FCBlank] [i@FCBlank]"
  - "[i@FCBlank] [i@FCBlank] [i@FCCoinFlipsCoin] [i@FCBlank] [i@FCCoinFlipsCoin] [i@FCBlank] [i@FCCoinFlipsCoin] [i@FCBlank] [i@FCBlank]"
  - "[i@FCBlank] [i@FCBlank] [i@FCBlank] [i@FCBlank] [i@FCBlank] [i@FCBlank] [i@FCBlank] [i@FCBlank] [i@FCBlank]"

FCCoinFlipsCoin:
  type: item
  material: sunflower
  display name: <yellow>Coin
  lore:
  - <aqua>Flip Me!

FCCoinFlipsIron:
  type: item
  material: iron_ingot
  display name: <gray><bold>Iron

FCCoinFlipsGold:
  type: item
  material: gold_ingot
  display name: <yellow><bold>Gold

FCCoinFlipsInfo:
  type: item
  material: paper
  display name: <yellow>Coin Flips Card
  lore:
  - <red><bold>DO NOT EXIT THIS GUI, YOU WILL LOSE YOUR CARD!
  - <red>
  - <gold><bold>Win Conditions
  - <aqua>2/3 Gold
  - <aqua>3/3 Iron
  - <aqua>3/3 Gold

FCCoinFlipsGUIHandler:
  type: world
  events:
    on player clicks in FCCoinFlipsGUI:
    - determine cancelled
    on player drags in FCCoinFlipsGUI:
    - determine cancelled
    ##Clicks Coin
    on player clicks FCCoinFlipsCoin in FCCoinFlipsGUI:
    - flag <player> FCCoinFlipsActions:+:1
    - define slotClicked <context.slot>
    - define loop_index 1
    ##Coin Spin Sequence
    - while <def[loop_index].is[OR_LESS].than[5]> {
      - inventory set destination:<player.open_inventory> origin:i@FCCoinFlipsIron slot:<def[slotClicked]>
      - playsound <player> sound:ENTITY_PLAYER_ATTACK_SWEEP
      - inventory set destination:<player.open_inventory> origin:i@FCCoinFlipsGold slot:<def[slotClicked]>
      - playsound <player> sound:ENTITY_PLAYER_ATTACK_SWEEP
      - define loop_index <def[loop_index].add[1]>
    }
    ##Result of Coin
    - define win <util.random.int[1].to[2]>
    - if <def[win]> == 1 {
      - inventory set destination:<player.open_inventory> origin:i@FCCoinFlipsIron slot:<def[slotClicked]>
      - flag <player> FCCoinFlipsIronWin:+:1
      - playsound <player> sound:ENTITY_PLAYER_LEVELUP
    }
    - if <def[win]> == 2 {
      - inventory set destination:<player.open_inventory origin:i@FCCoinFlipsGold slot:<def[slotClicked]>
      - flag <player> FCCoinFlipsGoldWin:+:1
      - playsound <player> sound:ENTITY_PLAYER_LEVELUP
    }
    ##Win Analyzer
    - if <player.flag[FCCoinFlipsActions]> == 3 {
      ##2/3 Gold
      - if <player.flag[FCCoinFlipsGoldWin]> == 2 {
        - inventory close d:in@FCCoinFlipsGUI
        - narrate "<yellow>YOU WON TWO GOLD!"
        - queue clear
      }
      ##3/3 Iron
      - if <player.flag[FCCoinFlipsIronWin]> == 3 {
        - inventory close d:in@FCCoinFlipsGUI
        - narrate "<gray>YOU WON THREE IRON!"
        - queue clear
      }
      ##3/3 Gold
      - if <player.flag[FCCoinFlipsGoldWin]> == 3 {
        - inventory close d:in@FCCoinFlipsGUI
        - narrate "<yellow>YOU WON THREE GOLD!"
        - queue clear
      }
      ##No Wins
      - inventory close d:in@FCCoinFlipsGUI
      - narrate "<red>BETTER LUCK NEXT TIME!"
    }
    - queue clear