Skip to content

Commit

Permalink
Win tune
Browse files Browse the repository at this point in the history
  • Loading branch information
Laurent Couvidou committed Apr 27, 2014
1 parent 6e181f7 commit 8d4a486
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
11 changes: 8 additions & 3 deletions client/client.js
Expand Up @@ -72,9 +72,13 @@ socket.on("s", function(data) {
// Apply duck position, etc.
serverInfo = data["i"];

// Quack!
if ((data["u"] == "server") && (data["m"].indexOf("quack") > -1)) {
playSound("./res/quack" + Math.floor(Math.random() * 8) + ".mp3");
// Quack! Win!
if (data["u"] == "server") {
if (data["m"].indexOf("quack") > -1) {
playSound("./res/quack" + Math.floor(Math.random() * 8) + ".mp3");
} else if (data["m"] == "great success!") {
playSound("./res/win_tune.mp3");
}
}
});

Expand Down Expand Up @@ -111,6 +115,7 @@ var resources = [
"./res/quack5.mp3",
"./res/quack6.mp3",
"./res/quack7.mp3",
"./res/win_tune.mp3",
];

// Client objects
Expand Down
Binary file added res/win_tune.mp3
Binary file not shown.
2 changes: 1 addition & 1 deletion server/server.js
Expand Up @@ -36,7 +36,7 @@ io.sockets.on("connection", function(socket) {
var sanitizedUser = sanitize(data["u"]).escape();
var sanitizedMessage = sanitize(data["m"]).escape();

if (sanitizedMessage != "") {
if (sanitizedMessage != "" && sanitizedUser != "" && sanitizedUser !="server") {
var sayQuack = false;

if (sanitizedMessage == "beneath" || sanitizedMessage == "bn") {
Expand Down

0 comments on commit 8d4a486

Please sign in to comment.