Last active
December 28, 2015 06:19
-
-
Save rileydutton/7456233 to your computer and use it in GitHub Desktop.
"The Quiet Year" Roll20 API Script
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//To use this script, create a Roll20 Campaign with 4 decks, each one with only one suit of cards. Then on each player's turn, have them draw from the deck for the current "season" (e.g. Hearts for Spring). After they put the card into their hand, they'll receive a whisper from "The Threads of Fate" telling them what that card 'means' in the game. | |
//SPRING | |
var cardIndex = { | |
"Ace of Hearts": "What group has the highest status in the community? What must people do to gain inclusion in this group? -OR- Are there distinct family units in the community? If so, what family structures are common?", | |
"Two of Hearts": "There’s a large body of water on the map. Where is it? What does it look like? -OR- There’s a giant, man-made structure on the map. Where is it? Why is it abandoned?", | |
"Three of Hearts": "Someone new arrives. Who? -OR- Two of the community’s younger members get into a fight. What provoked them?", | |
"Four of Hearts": "What important and basic tools does the community lack? -OR- Where are you storing your food? Why is this a risky place to store things?", | |
"Five of Hearts": "There is a disquieting legend about this place. What is it? -OR- Alarming weather patterns destroy something. How and what?", | |
"Six of Hearts": "Are there children in your community? If there are, what is their role in the community? -OR- How old are the eldest members of the community? What special needs do they have?", | |
"Seven of Hearts": "Where does everyone sleep? Who is unhappy with this arrangement, and why? -OR- What natural predators roam this area? Are you safe?", | |
"Eight of Hearts": "An old piece of machinery is discovered, broken but perhaps repairable. What is it? What would it be useful for? -OR- An old piece of machinery is discovered, cursed and dangerous. How does the community destroy it?", | |
"Nine of Hearts": "A charismatic young girl convinces many to help her with an elaborate scheme. What is it? Who joins her endeavors? Start a project to reflect. -OR- A charismatic young girl tries to tempt many into sinful or dangerous activity. Why does she do this? How does the community respond?", | |
"Ten of Hearts": "There’s another community somewhere on the map. Where are they? What sets them apart from you? -OR- What belief or practice helps to unify your community?", | |
"Jack of Hearts": "You see a good omen. What is it? -OR- You see a bad omen. What is it?", | |
"Queen of Hearts": "What’s the most beautiful thing in this area? -OR- What’s the most hideous thing in this area?", | |
"King of Hearts": "A young boy starts digging in the ground, and discovers something unexpected. What is it? -OR- An old man confesses to past crimes and atrocities. What has he done?" | |
}; | |
//SUMMER | |
cardIndex["Ace of Diamonds"] = "A contingent within the community demand to be heard. Who are they? What are they asking for? -OR- A contingent within the community have acted on their frustrations. What have they damaged, and why did they damage it? Is it permanent?"; | |
cardIndex["Two of Diamonds"] = "Someone new arrives. Who? Why are they in distress? -OR- Someone leaves the community. Who? What are they looking for?"; | |
cardIndex["Three of Diamonds"] = "Summer is a time for production and tending to the earth. <strong>Start a project related to food production.</strong> -OR- Summer is a time for conquest and the gathering of might. <strong>Start a project related to military readiness and conquest.</strong>"; | |
cardIndex["Four of Diamonds"] = "The eldest among you dies. What caused the death? -OR- The eldest among you is very sick. Caring for them and searching for a cure requires the help of the entire community. <b>Do not reduce project dice this week.</b>"; | |
cardIndex["Five of Diamonds"] = "<b>A project finishes early.</b> What led to its early completion? -OR- The weather is nice and people can feel the potential all around them. <b>Start a new project.</b>"; | |
cardIndex["Six of Diamonds"] = "Outsiders arrive in the area. Why are they a threat? How are they vulnerable? -OR- Outsiders arrive in the area. How many? How are they greeted?"; | |
cardIndex["Seven of Diamonds"] = "Introduce a mystery at the edge of the map. -OR- An unattended situation becomes problematic and scary. What is it? How does it go awry?"; | |
cardIndex["Eight of Diamonds"] = "Someone tries to take control of the community by force. Do they succeed? Why do they do this? -OR- A headstrong community member decides to put one of their ideas in motion. <strong>Start a foolish project.</strong>"; | |
cardIndex["Nine of Diamonds"] = "<b>A project fails.</b> Which one? Why? -OR- Something goes foul and supplies are ruined. <b>Add a new Scarcity.</b>"; | |
cardIndex["Ten of Diamonds"] = "You discover a cache of supplies or resources. <b>Add a new Abundance.</b> -OR- A Scarcity has gone unaddressed for too long! <b>Start a project that will alleviate that Scarcity.</b>"; | |
cardIndex["Jack of Diamonds"] = "Predators and bad omens are afoot. You are careless, and someone goes missing under ominous circumstances. Who? -OR- Predators and bad omens are afoot. What measures do you take to keep everyone safe and under surveillance? <b>Do not reduce project dice this week.</b>"; | |
cardIndex["Queen of Diamonds"] = "<b>A project finishes early.</b> Which one? Why? <br/><br/><i>If there are no projects underway</i>, boredom leads to quarrel. A fight breaks out between two people. What is it about?" | |
cardIndex["King of Diamonds"] = "Summer is fleeting. <b>Discard the top two cards off the top of the deck and take two actions this week.</b>"; | |
//AUTUMN | |
cardIndex["Ace of Clubs"] = "The community becomes obsessed with a single project. Which one? Why? Choose one: <br/><br/><ul><li>They decide to take more time to ensure that it is perfect. <b>Add 3 weeks to the project die.</b></li><li>They drop everything else to work on it. <b>All other projects fail.</b></li></ul><br/><br/><i>If there are no projects underway</i>, the community becomes obsessed with a grandiose vision. <b>Hold a discussion about this vision</b>, in addition to your regular action for the week." | |
cardIndex["Two of Clubs"] = "Someone returns to the community. Who? Where were they? -OR- You find a body. Do people recognize who it is? What happened?"; | |
cardIndex["Three of Clubs"] = "Someone leaves the community after issuing a dire warning. Who? What is the warning? -OR- Someone issues a dire warning, and the community leaps into action to avoid disaster. What is the warning? <b>Start a contentious project that relates to it.</b>"; | |
cardIndex["Four of Clubs"] = "The strongest among you dies. What caused the death? -OR- The weakest among you dies. Who’s to blame for their death?"; | |
cardIndex["Five of Clubs"] = "The Parish arrives. Who are they? Why have they chosen your community, and for what? -OR- A small gang of marauders is making its way through local terrain. How many are there? What weapons do they carry?"; | |
cardIndex["Six of Clubs"] = "Introduce a dark mystery among the members of the community. -OR- Conflict flares up among community members, and as a result, <b>a project fails.</b>"; | |
cardIndex["Seven of Clubs"] = "A project just isn’t working out as expected. <b>Radically change the nature of this project (don’t modify the project die). When it resolves, you’ll be responsible for telling the community how it went.</b> -OR- Something goes foul and supplies are ruined. <b>Add a new Scarcity.</b>"; | |
cardIndex["Eight of Clubs"] = "Someone sabotages a project, and <b>the project fails as a result</b>. Who did this? Why? -OR- Someone is caught trying to sabotage the efforts of the community. How does the community respond?"; | |
cardIndex["Nine of Clubs"] = "The community works constantly and as a result <b>a project finishes early.</b> -OR- A group goes out to explore the map more thoroughly, and finds something that had been previously overlooked."; | |
cardIndex["Ten of Clubs"] = "Harvest is here and plentiful. <b>Add an Abundance.</b> -OR- Cold autumn winds drive out your enemies. <b>Remove a threatening force from the map and the area.</b>"; | |
cardIndex["Jack of Clubs"] = "<b>A project finishes early.</b> Which one? Why?<br/><br/><i>If there are no projects underway</i>, restlessness creates animosity, and animosity leads to violence. Who gets hurt?"; | |
cardIndex["Queen of Clubs"] = "Disease spreads through the community. Choose one:<br/><br/><ul><li>You spend the week quarantining and treating the disease. <b>Project dice are not reduced this week.</b></li><li>Nobody knows what to do about it. <b>Add “Health and Fertility” as a Scarcity.</b></li></ul>"; | |
cardIndex["King of Clubs"] = "A natural disaster strikes the area. What is it? Choose one:<br/><br/><ul><li>You focus on getting everyone to safety. <b>Remove an Abundance and a project fails.</b></li><li>You focus on protecting your supplies and hard work at any cost. Several people die as a result.</li></ul>" | |
//WINTER | |
cardIndex["Ace of Spades"] = "Now is the time to conserve energy and resources. <b>A project fails, but gain an Abundance.</b> -OR- Now is the time for hurried labour and final efforts. <b>A project finishes early, but gain a Scarcity.</b>"; | |
cardIndex["Two of Spades"] = "A headstrong community member takes charge of the community’s work efforts. <b>A project fails, and then a different project finishes early.</b> -OR- A headstrong community member tries to take control of the community. How are they prevented from doing this? Due to the conflict, <b>project dice are not reduced this week.</b>"; | |
cardIndex["Three of Spades"] = "Someone comes up with an ingenious solution to a big problem and as a result <b>a project finishes early</b>. What was their idea? -OR- Someone comes up with a plan to ensure safety and comfort during the coldest months. <b>Start a project related to this.</b>"; | |
cardIndex["Four of Spades"] = "All the animals and young children are crying and won’t stop. <b>Hold a discussion about this</b>, in addition to your regular action for the week. -OR- A great atrocity is revealed. What is it? Who uncovers it?"; | |
cardIndex["Five of Spades"] = "Winter elements destroy a food source. If this was your only food source, <b>add a Scarcity.</b> -OR- Winter elements leave everyone cold, tired, and miserable. <b>Project dice are not reduced this week.</b>"; | |
cardIndex["Six of Spades"] = "The time has come to consolidate your efforts and your borders. <b>Projects located outside the settlement fail, and all remaining projects are reduced by 2 this week.</b> -OR- Someone finds a curious opportunity on the edge of the map. <b>Start a project related to this discovery.</b>"; | |
cardIndex["Seven of Spades"] = "What is winter like in this area? How do community members react to the weather?"; | |
cardIndex["Eight of Spades"] = "Winter is harsh, and desperation gives rise to fear mongering. Choose one:<br/><br/><ul><li>Spend the week calming the masses and dispelling their violent sentiments. <b>The week ends immediately.</b></li><li>Declare war on someone or something. <b>This counts as starting a project.</b></li></ul>"; | |
cardIndex["Nine of Spades"] = "Someone goes missing. They’re alone in the winter elements. Choose one:<br/><br/><ul><li>The community organizes constant search parties and eventually the person is found. <b>Project dice are not reduced this week.</b></li><li> No one ever hears from that person again.</li></ul>"; | |
cardIndex["Ten of Spades"] = "In preparation for the coming year, the community begins a huge undertaking. <b>Start a project that will take at least 5 weeks to complete.</b>"; | |
cardIndex["Jack of Spades"] = "An infected outsider arrives, seeking amnesty. They have some much-needed resources with them. Choose one:<br/><br/><ul><li>Welcome them into the community. <b>Remove a Scarcity</b>, but also introduce an infection into the community.</li><li>Bar them from entry. What Scarcity could they have addressed? How does its need become more dire this week?</li>"; | |
cardIndex["Queen of Spades"] = "You see a good omen. What is it?"; | |
cardIndex["King of Spades"] = "The Frost Shepherds arrive. <b>The game is over.</b>"; | |
on("change:hand:_currentHand", function(obj) { | |
var cards = obj.get("currentHand").split(","); | |
if(!cards || cards.length < 1) return; | |
var lastCard = cards[cards.length - 1]; | |
var cardobj = getObj("card", lastCard); | |
if(!cardobj) { | |
log("Couldn't find that card! " + lastCard); | |
return; | |
} | |
if(cardobj.get("name") === "King of Spades") { | |
_.each(findObjs({_type: "deck"}), function(deckobj) { | |
deckobj.set({shown: false}); | |
}); | |
setTimeout(function() { | |
sendChat("", "/desc A voice in the wilderness cries out."); | |
setTimeout(function() { | |
sendChat("", "/desc Everything fades."); | |
}, 5000); | |
setTimeout(function() { | |
Campaign().set("playerpageid", "-J8I7yYIFKektPJV4UmW"); | |
}, 8000); | |
setTimeout(function() { | |
sendChat("", "/em Woe are we! Foolish and proud!"); | |
}, 11000); | |
setTimeout(function() { | |
sendChat("", "/desc There is only darkness."); | |
}, 15000); | |
setTimeout(function() { | |
getObj("text", "-J8I9cMDoHzr2IJbuODy").set({color: "#FFFFFF"}); | |
}, 20000); | |
}, 5000); | |
} | |
else { | |
var playerobj = getObj("player", obj.get("parentid")); | |
var msg = (cardIndex[cardobj.get('name')] || "Sorry, but I didn't recognize that card..."); | |
msg = "<br/><br/>" + msg; | |
msg = msg.replace(" -OR- ", "<hr style='border-bottom: 1px solid #999;'/>"); | |
msg = msg + "<br/><br /><span style='font-style: italic; font-size: 0.9em; color: #aaa;'>" + cardobj.get('name') + "</span>"; | |
sendChat("the Threads of Fate", "/w " + playerobj.get("displayname").split(" ")[0] + " " + msg); | |
} | |
}); | |
on("chat:message", function(obj) { | |
if(obj.content === "!advance") { | |
var alldice = findObjs({_type: "graphic", represents: findObjs({_type: "character", name:"Project Dice"})[0].id}); | |
if(alldice && alldice.length > 0) { | |
_.each(alldice, function(diceobj) { | |
var sidearray = diceobj.get("sides").split("|"); | |
var newindex = diceobj.get("currentSide") - 1; | |
if(newindex < 0) { | |
//Alert! | |
sendChat("", "/desc The project <b>" + diceobj.get("name") + "</b> has finished."); | |
return true; | |
} | |
diceobj.set({ | |
imgsrc: unescape(sidearray[newindex]), | |
currentSide: newindex | |
}); | |
}); | |
} | |
} | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Added an "!advance" command which can automatically advance project dice.