Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import json
- import os
- import codecs
- ScriptName = "Raid"
- Website = "https://www.twitch.tv/airrowstv"
- Description = "WIP Mini-game supervised by Eric"
- Creator = "Maddosan"
- Version = "0.0.10"
- Command = "!raid"
- Reviewer = "Airrows"
- #settings = {}#used as reference
- raid = {}
- raiders = []# experimental line to setup a dictionary named "raiders"
- def Init():
- log("Entered Init")
- #global settings #reference
- #work_dir = os.path.dirname(__file__)
- #try:
- #with codecs.open(os.path.join(work_dir, "settings.json"), encoding='utf-8-sig') as json_file:
- #settings = json.load(json_file, encoding='utf-8-sig')
- #except Exception, e:
- #log(str(e))
- #settings = {
- #"alienProbability": 0,
- #"userCooldown": 0
- #}
- global raid
- work_dir = os.path.dirname(__file__)
- try:
- with codecs.open(os.path.join(work_dir, "raid.json"), encoding='utf-8-sig') as json_file:
- raid = json.load(json_file, encoding='utf-8-sig')
- except Exception, e:
- log(str(e))
- settings = {
- "casualtyChance":0,
- "globalCooldown": 5
- }
- log("Exiting Init")
- return
- #def Execute2(data): #this is just used as a reference
- #log("Entered Execute2")
- #username = data.UserName
- #if data.GetParam(0) != Command or Parent.IsOnUserCooldown(ScriptName, Command, data.User):
- #return
- #if is_alien():
- #send_message("I knew it! So you are an alien after all, " + username + "!")
- #else:
- #send_message("Alright, " + username + ", you're no alien, I suppose...")
- #Parent.AddUserCooldown(ScriptName, Command, data.User, settings["userCooldown"])
- #log("Exiting Execute2")
- #return
- def Execute(data):
- log("Entered Execute")
- username = data.UserName
- #global raiders #placeholder incase the def Init(): doesn't work out
- 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
- if data.GetParam(0) != Command or Parent.IsOnUserCooldown(ScriptName, Command, data.User):
- return
- if has_won():
- send_message("It's alright " + username + ", there's always next time...")
- else:
- for x in raiders:
- send_message("Congratulations " + "adventurers," + " you have fought well! " + str(len(raiders)) + " raider(s) have triumphed! Lets cheer for our heroe(s) " + str(x) + "!")
- Parent.AddUserCooldown(ScriptName, Command, data.User, raid["globalCooldown"])
- raiders.clear()
- log("Exiting Execute")
- return
- def Tick():
- return
- #def is_alien(): #used as a reference
- #log("Entered is_alien")
- #random_chance = Parent.GetRandom(0, 100)
- #log("Exiting is_alien")
- #return random_chance <= settings["alienProbability"]
- def has_won():
- log("Entered has_won")
- random_chance = Parent.GetRandom(0, 100)
- log("Exiting has_won")
- return random_chance <= raid["casualtyChance"]
- def send_message(message):
- log("Entered send_message")
- Parent.SendStreamMessage(message)
- log("Exiting send_message")
- return
- def log(message):
- Parent.Log(Command, message)
- return
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement