Paste #39958: Untitled Paste

Date: 2017/02/16 16:27:55 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: 0.1 (Pre-Initial Release)
##############################
## Flip Cards:
## - CoinFlips (Released v0.1)
##############################

##############################
##         FC  Give         ##
##############################

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."
    - queue clear
  }
  - 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
      }
      - if <context.args.get[3]||null> == all {
        - foreach <server.list_players> {
          - flag <def[value]> FCCoinFlips:+:<context.args.get[2]>
          - narrate "<gold>[Flip Cards] <light_purple>You have received <yellow><context.args.get[2]> <light_purple>Coin Flips Cards." target:<def[value]>
        }
        - narrate "<gold>[Flip Cards] <light_purple>All players have been given <yellow><context.args.get[2]> <light_purple>Coin Flips 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."

##############################
##       FC Play Card       ##
##############################

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."
    - queue clear
  }
  ##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
        - note in@FCCoinFlipsGUI as:<player.uuid>_temporary_inventory
        - inventory open d:in@<player.uuid>_temporary_inventory
        - 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

##############################
##         FC Blank         ##
##############################
## Remember to use in all FCs
##############################

FCBlank:
  type: item
  material: black_stained_glass_pane
  display name: <black>

##############################
##    FC All GUI Handler    ##
##############################
## Checks all FCs
##############################

FCAllGUIHandler:
  type: world
  events:
    on player clicks in inventory:
    - if !<context.inventory.notable_name.ends_with[_temporary_inventory]> {
      - queue clear
    }
    - determine cancelled
    on player drags in inventory:
    - if !<context.inventory.notable_name.ends_with[_temporary_inventory]> {
      - queue clear
    }
    - determine cancelled

##############################
##                          ##
##        Coin Flips        ##
##                          ##
##############################
## Flip Card Info:
## Name - Coin Flips
## CardID - CoinFlips
## Designed by - Peashooter101
## Design Completed - 2FEB2017
##############################
## Win Conditions - Prizes:
## 2/3 Gold -
## 3/3 Iron -
## 3/3 Gold -
##############################

FCCoinFlipsGUI:
  type: inventory
  title: <dark_blue><bold>|FC| <gold><bold>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><bold>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:
    ##Clicks Coin
    on player clicks FCCoinFlipsCoin in inventory:
    - if !<context.inventory.notable_name.ends_with[_temporary_inventory]> {
      - queue clear
    }
    - define slotClicked <context.raw_slot>
    ##Coin Spin Sequence
    - repeat 5 {
      - inventory set destination:<context.inventory> origin:i@FCCoinFlipsIron slot:<def[slotClicked]>
      - playsound <player> sound:ENTITY_PLAYER_ATTACK_SWEEP
      - wait 2t
      - inventory set destination:<context.inventory> origin:i@FCCoinFlipsGold slot:<def[slotClicked]>
      - playsound <player> sound:ENTITY_PLAYER_ATTACK_SWEEP
      - wait 2t
    }
    - flag <player> FCCoinFlipsActions:+:1
    ##Result of Coin
    - define win <util.random.int[1].to[2]>
    - if <def[win]> == 1 {
      - inventory set destination:<context.inventory> origin:i@FCCoinFlipsIron slot:<def[slotClicked]>
      - inventory update destination:<context.inventory>
      - flag <player> FCCoinFlipsIronWin:+:1
      - playsound <player> sound:ENTITY_PLAYER_LEVELUP
    }
    - if <def[win]> == 2 {
      - inventory set destination:<context.inventory> origin:i@FCCoinFlipsGold slot:<def[slotClicked]>
      - inventory update destination:<context.inventory>
      - 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 {
        - wait 2s
        - inventory close d:in@FCCoinFlipsGUI
        - narrate "<yellow>YOU WON TWO GOLD!"
        - queue clear
      }
      ##3/3 Iron
      - if <player.flag[FCCoinFlipsIronWin]> == 3 {
        - wait 2s
        - inventory close d:in@FCCoinFlipsGUI
        - narrate "<gray>YOU WON THREE IRON!"
        - queue clear
      }
      ##3/3 Gold
      - if <player.flag[FCCoinFlipsGoldWin]> == 3 {
        - wait 2s
        - inventory close d:in@FCCoinFlipsGUI
        - narrate "<yellow>YOU WON THREE GOLD!"
        - queue clear
      }
      ##No Wins
      - wait 2s
      - inventory close d:in@FCCoinFlipsGUI
      - narrate "<red>BETTER LUCK NEXT TIME!"
    }
    ##Not Yet Done
    - queue clear
    - determine cancelled