Browse files

New samples

  • Loading branch information...
1 parent af3a6e3 commit 0fa98b7a1b260be69c4d41e376af8879b0fdcc32 Justin Dupree committed Feb 26, 2011
View
BIN .DS_Store
Binary file not shown.
View
59 groovy/dice_coin.groovy
@@ -0,0 +1,59 @@
+dice6=(Math.floor((6-0)*Math.random()) + 1) as Integer
+dice20=(Math.floor((20-0)*Math.random()) + 1) as Integer
+coin=(Math.floor((2-0)*Math.random()) + 1) as Integer
+rps=(Math.floor((3-0)*Math.random()) + 1) as Integer
+
+def heads_tails() {
+ if (coin == 1) {
+ return "You got heads."
+ } else {
+ return "You got tails."
+ }
+}
+
+ht_var = heads_tails()
+
+def rock_paper_scissors() {
+ if (rps == 1) {
+ return "You got rock."
+ } else if (rps == 2) {
+ return "You got paper."
+ } else {
+ return "You got scissors."
+ }
+}
+
+rps_var = rock_paper_scissors()
+
+def the_ask() {
+ event = ask("Welcome to the chance facilitator. Select 1 for six sided dice, 2 for twenty sided dice, 3 for a coin flip, 4 for rock paper scissors.", [
+ attempts: 3,
+ timeout:60,
+ choices: "1(one, 1), 2(two, 2), 3(three, 3), 4(four, 4)",
+ onChoice: { event->
+ say("You chose " + event.value + ".")
+ if (event.value == "1") {
+ say("You rolled a " + dice6 + ".")
+ } else if (event.value == "2") {
+ say("You rolled a " + dice20 + ".")
+ } else if (event.value == "3") {
+ say(ht_var)
+ } else {
+ say(rps_var)
+ }
+ },
+ onBadChoice: { event->
+ say("I'm sorry, I didn't understand that. Please try again.")
+ }
+ ])
+}
+
+if(currentCall.initialText != null)
+ {
+ ask("", [choices:"[ANY]"])
+ the_ask()
+ }
+else
+ {
+ the_ask()
+ }
View
BIN javascript/.DS_Store
Binary file not shown.
View
61 javascript/dice_coin.js
@@ -0,0 +1,61 @@
+var dice6=Math.floor((6-0)*Math.random()) + 1;
+var dice20=Math.floor((20-0)*Math.random()) + 1;
+var coin=Math.floor((2-0)*Math.random()) + 1;
+var rps=Math.floor((3-0)*Math.random()) + 1;
+
+var def_vox = "simon";
+
+function heads_tails() {
+ if (coin == 1) {
+ return "You got heads.";
+ } else {
+ return "You got tails.";
+ }
+}
+
+var ht_var = heads_tails();
+
+function rock_paper_scissors() {
+ if (rps == 1) {
+ return "You got rock.";
+ } else if (rps == 2) {
+ return "You got paper.";
+ } else {
+ return "You got scissors.";
+ }
+}
+
+var rps_var = rock_paper_scissors();
+
+function the_ask() {
+ ask("Welcome to the chance facilitator. Select 1 for six sided dice, 2 for twenty sided dice, 3 for a coin flip, 4 for rock paper scissors.", {
+ choices: "1(one, 1), 2(two, 2), 3(three, 3), 4(four, 4)",
+ timeout: 60.0,
+ attempts: 3,
+ onBadChoice: function(event) {
+ say("I’m sorry, I didn’t understand that. Please try again.");
+ },
+ onChoice: function(event) {
+ say("You chose " + event.value + ".");
+ if (event.value == "1") {
+ say("You rolled a " + dice6 + ".");
+ } else if (event.value == "2") {
+ say("You rolled a " + dice20 + ".");
+ } else if (event.value == "3") {
+ say(ht_var);
+ } else {
+ say(rps_var);
+ }
+ }
+ });
+}
+
+if(currentCall.initialText !== null)
+ {
+ ask("", { choices:"[ANY]" });
+ the_ask();
+ }
+else
+ {
+ the_ask();
+ }
View
BIN php/.DS_Store
Binary file not shown.
View
64 php/dice_coin.php
@@ -0,0 +1,64 @@
+<?php
+$dice6 = rand(1,6);
+$dice20 = rand(1,20);
+$coin = rand(1,2);
+$rps = rand(1,3);
+
+function heads_tails() {
+ if($coin == 1) {
+ return "You got heads.";
+ } else {
+ return "You got tails.";
+ }
+}
+
+$ht_var = heads_tails();
+
+function rock_paper_scissors() {
+ if($rps == 1) {
+ return "You got rock.";
+ } elseif ($rps == 2){
+ return "You got paper.";
+ } else {
+ return "You got scissors.";
+ }
+}
+
+$rps_var = rock_paper_scissors();
+
+function the_ask() {
+ ask("Welcome to the chance facilitator. Select 1 for six sided dice, 2 for twenty sided dice, 3 for a coin flip, 4 for rock paper scissors.", array(
+ "choices" => "1(one, 1), 2(two, 2), 3(three, 3), 4(four, 4)",
+ "timeout" => 60.0,
+ "attempts" => 3,
+ "onChoice" => "choiceFCN",
+ "onBadChoice" => "badChoiceFCN"
+ )
+ );
+}
+
+function choiceFCN($event) {
+ say("You chose " . $event->value . ".");
+ if ($event->value == "1") {
+ say("You rolled a " . (string)$dice6 . ".");
+ } else if ($event->value == "2") {
+ say("You rolled a " . (string)$dice20 . ".");
+ } else if ($event->value == "3") {
+ say($ht_var);
+ } else {
+ say($rps_var);
+ }
+}
+
+function badChoiceFCN($event) {
+ say("I'm sorry, I didn't understand that. Please try again.");
+}
+
+if($currentCall->initialText !=null) {
+ ask("", array("choices" => "[ANY]"));
+ the_ask();
+} else {
+ the_ask();
+}
+
+?>
View
53 python/dice_coin.py
@@ -0,0 +1,53 @@
+import random
+
+dice6 = random.randint(1,6)
+dice20 = random.randint(1,20)
+coin = random.randint(1,2)
+rps = random.randint(1,3)
+
+def heads_tails() :
+ if (coin == 1) :
+ return "You got heads."
+ else :
+ return "You got tails."
+
+ht_var = heads_tails()
+
+def rock_paper_scissors() :
+ if (rps == 1) :
+ return "You got rock."
+ elif (rps == 2) :
+ return "You got paper."
+ else :
+ return "You got scissors."
+
+rps_var = rock_paper_scissors()
+
+def choiceFCN(event):
+ say("You chose " + event.value + ".")
+ if (event.value == "1") :
+ say("You rolled a " + str(dice6) + ".")
+ elif (event.value == "2") :
+ say("You rolled a " + str(dice20) + ".")
+ elif (event.value == "3") :
+ say(ht_var)
+ else :
+ say(rps_var)
+
+def badChoiceFCN(event):
+ say("I'm sorry, I didn't understand that. Please try again.")
+
+def the_ask() :
+ ask("Welcome to the chance facilitator. Select 1 for six sided dice, 2 for twenty sided dice, 3 for a coin flip, 4 for rock paper scissors.", {
+ "choices":"1(one, 1), 2(two, 2), 3(three, 3), 4(four, 4)",
+ "timeout":60.0,
+ "attempts":3,
+ "onChoice": choiceFCN,
+ "onBadChoice": badChoiceFCN
+ })
+
+if(currentCall.initialText is not None) :
+ ask("", {"choices":"[ANY]"})
+ the_ask()
+else :
+ the_ask()
View
56 ruby/dice_coin.rb
@@ -0,0 +1,56 @@
+@dice6 = 1 + rand(6)
+@dice20 = 1 + rand(20)
+@coin = 1 + rand(2)
+@rps = 1 + rand(3)
+
+def heads_tails()
+ if (@coin == 1)
+ return "You got heads."
+ else
+ return "You got tails."
+ end
+end
+
+@ht_var = heads_tails()
+
+def rock_paper_scissors()
+ if (@rps == 1)
+ return "You got rock."
+ elsif (@rps == 2)
+ return "You got paper."
+ else
+ return "You got scissors"
+ end
+end
+
+@rps_var = rock_paper_scissors()
+
+def the_ask()
+ ask "Welcome to the chance facilitator. Select 1 for six sided dice, 2 for twenty sided dice, 3 for a coin flip, 4 for rock paper scissors.", {
+ :choices => "1(one, 1), 2(two, 2), 3(three, 3), 4(four, 4)",
+ :timeout => 60.0,
+ :attempts => 3,
+ :onBadChoice => lambda { |event|
+ say "I’m sorry, I didn’t understand that. Please try again."
+ },
+ :onChoice => lambda { |event|
+ say "You chose " + event.value + "."
+ if (event.value == "1")
+ say "You rolled a " + @dice6.to_s + "."
+ elsif (event.value == "2")
+ say "You rolled a " + @dice20.to_s + "."
+ elsif (event.value == "3")
+ say @ht_var
+ else
+ say @rps_var
+ end
+ }
+ }
+end
+
+if $currentCall.initialText != nil
+ ask "", :choices => "[ANY]"
+ the_ask()
+else
+ the_ask()
+end

0 comments on commit 0fa98b7

Please sign in to comment.