Advertisement
Maddosan

Raid Script 0.0.10

Nov 17th, 2019
117
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 3.26 KB | None | 0 0
  1. import json
  2. import os
  3. import codecs
  4. ScriptName = "Raid"
  5. Website = "https://www.twitch.tv/airrowstv"
  6. Description = "WIP Mini-game supervised by Eric"
  7. Creator = "Maddosan"
  8. Version = "0.0.10"
  9. Command = "!raid"
  10. Reviewer = "Airrows"
  11. #settings = {}#used as reference
  12. raid = {}
  13. raiders = []# experimental line to setup a dictionary named "raiders"
  14.  
  15. def Init():
  16.     log("Entered Init")
  17.     #global settings #reference
  18.     #work_dir = os.path.dirname(__file__)
  19.  
  20.     #try:
  21.         #with codecs.open(os.path.join(work_dir, "settings.json"), encoding='utf-8-sig') as json_file:
  22.             #settings = json.load(json_file, encoding='utf-8-sig')
  23.     #except Exception, e:
  24.         #log(str(e))
  25.         #settings = {
  26.             #"alienProbability": 0,
  27.             #"userCooldown": 0
  28.         #}
  29.     global raid
  30.     work_dir = os.path.dirname(__file__)
  31.  
  32.     try:
  33.         with codecs.open(os.path.join(work_dir, "raid.json"), encoding='utf-8-sig') as json_file:
  34.             raid = json.load(json_file, encoding='utf-8-sig')
  35.     except Exception, e:
  36.         log(str(e))
  37.         settings = {
  38.             "casualtyChance":0,
  39.             "globalCooldown": 5
  40.         }
  41.     log("Exiting Init")
  42.     return
  43.  
  44. #def Execute2(data): #this is just used as a reference
  45.     #log("Entered Execute2")
  46.  
  47.     #username = data.UserName
  48.     #if data.GetParam(0) != Command or Parent.IsOnUserCooldown(ScriptName, Command, data.User):
  49.         #return
  50.  
  51.     #if is_alien():
  52.         #send_message("I knew it! So you are an alien after all, " + username + "!")
  53.     #else:
  54.         #send_message("Alright, " + username + ", you're no alien, I suppose...")
  55.     #Parent.AddUserCooldown(ScriptName, Command, data.User, settings["userCooldown"])
  56.     #log("Exiting Execute2")
  57.     #return
  58.  
  59. def Execute(data):
  60.     log("Entered Execute")
  61.     username = data.UserName
  62.     #global raiders #placeholder incase the def Init(): doesn't work out
  63.     raiders.append({"Name": username, "Roll": (None), "Casualty": (None)}) #experimental line to add user and their roll who used !raid to be indexed in the "raiders" dictionary
  64.  
  65.     if data.GetParam(0) != Command or Parent.IsOnUserCooldown(ScriptName, Command, data.User):
  66.         return
  67.  
  68.     if has_won():
  69.         send_message("It's alright " + username + ", there's always next time...")
  70.     else:
  71.         for x in raiders:
  72.             send_message("Congratulations " + "adventurers," + " you have fought well! " + str(len(raiders)) + " raider(s) have triumphed! Lets cheer for our heroe(s) " + str(x) + "!")
  73.     Parent.AddUserCooldown(ScriptName, Command, data.User, raid["globalCooldown"])
  74.     raiders.clear()
  75.     log("Exiting Execute")
  76.     return
  77.  
  78. def Tick():
  79.     return
  80.  
  81. #def is_alien(): #used as a reference
  82.     #log("Entered is_alien")
  83.     #random_chance = Parent.GetRandom(0, 100)
  84.  
  85.     #log("Exiting is_alien")
  86.     #return random_chance <= settings["alienProbability"]
  87.  
  88. def has_won():
  89.     log("Entered has_won")
  90.     random_chance = Parent.GetRandom(0, 100)
  91.  
  92.     log("Exiting has_won")
  93.     return random_chance <= raid["casualtyChance"]
  94.  
  95. def send_message(message):
  96.     log("Entered send_message")
  97.     Parent.SendStreamMessage(message)
  98.     log("Exiting send_message")
  99.     return
  100.  
  101. def log(message):
  102.     Parent.Log(Command, message)
  103.     return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement