From fff7a822efdbfdf7ae4d68d7f370ebc8046e3b0f Mon Sep 17 00:00:00 2001 From: Maxwell Johnson Date: Tue, 12 May 2020 15:44:07 -0400 Subject: [PATCH 1/2] Functionality changes: Split scene and event tiles, so "Add Event" adds a tile even if Events are unchecked, and you always start with 4 scenes Save player names between resets Add remove cell to Event tiles --- index.html | 2 +- script.js | 174 +++++++++++++++++++++++++++++++++++------------------ 2 files changed, 116 insertions(+), 60 deletions(-) diff --git a/index.html b/index.html index 410ed49..12975bb 100644 --- a/index.html +++ b/index.html @@ -62,7 +62,7 @@ Events: - +

diff --git a/script.js b/script.js index 52e18c3..54b76c6 100644 --- a/script.js +++ b/script.js @@ -90,6 +90,7 @@ var means = [ "Work", "Wrench" ]; + var evidence = [ "Air Conditioning", "Ants", @@ -292,6 +293,7 @@ var evidence = [ "Watch", "Wig" ]; + var locations = [ [ "Living Room", @@ -324,6 +326,7 @@ var locations = [ "Toilet" ] ] + var causeOfDeathTile = [ "Suffocation", "Severe Injury", @@ -332,9 +335,9 @@ var causeOfDeathTile = [ "Poisoning", "Accident" ]; -var eventTiles = [ + +var sceneTiles = [ [ - "Brown", "Motive of Crime", "Hatred", "Power", @@ -343,7 +346,6 @@ var eventTiles = [ "Jealousy", "Justice" ],[ - "Brown", "Weather", "Sunny", "Stormy", @@ -352,7 +354,6 @@ var eventTiles = [ "Cold", "Hot" ],[ - "Brown", "Hint on Corpse", "Head", "Chest", @@ -361,7 +362,6 @@ var eventTiles = [ "Partial", "All-over" ],[ - "Brown", "General Impression", "Common", "Creative", @@ -370,7 +370,6 @@ var eventTiles = [ "Horrible", "Suspenseful" ],[ - "Brown", "Corpse Condition", "Still Warm", "Stiff", @@ -379,7 +378,6 @@ var eventTiles = [ "Intact", "Twisted" ],[ - "Brown", "Victim's Identity", "Child", "Young Adult", @@ -388,7 +386,6 @@ var eventTiles = [ "Male", "Female" ],[ - "Brown", "Murderer's Personality", "Arrogant", "Despicable", @@ -397,7 +394,6 @@ var eventTiles = [ "Forceful", "Perverted" ],[ - "Brown", "State of The Scene", "Bits and Pieces", "Ashes", @@ -406,7 +402,6 @@ var eventTiles = [ "Disorderly", "Tidy" ],[ - "Brown", "Victim's Build", "Large", "Thin", @@ -415,7 +410,6 @@ var eventTiles = [ "Disfigured", "Fit" ],[ - "Brown", "Victim's Clothes", "Neat", "Untidy", @@ -424,7 +418,6 @@ var eventTiles = [ "Bizarre", "Naked" ],[ - "Brown", "Evidence Left Behind", "Natural", "Artistic", @@ -433,7 +426,6 @@ var eventTiles = [ "Personal", "Unrelated" ],[ - "Brown", "Victim's Expression", "Peaceful", "Struggling", @@ -442,7 +434,6 @@ var eventTiles = [ "Blank", "Angry" ],[ - "Brown", "Time of Death", "Dawn", "Morning", @@ -451,7 +442,6 @@ var eventTiles = [ "Evening", "Midnight" ],[ - "Brown", "Duration of Crime", "Instanteous", "Brief", @@ -460,7 +450,6 @@ var eventTiles = [ "Few Days", "Unclear" ],[ - "Brown", "Trace at the Scene", "Fingerprint", "Footprint", @@ -469,7 +458,6 @@ var eventTiles = [ "Body Fluid", "Scar" ],[ - "Brown", "Noticed by Bystander", "Sudden sound", "Prolonged sound", @@ -478,7 +466,6 @@ var eventTiles = [ "Action", "Nothing" ],[ - "Brown", "Social Relationship", "Relatives", "Friends", @@ -487,7 +474,6 @@ var eventTiles = [ "Lovers", "Strangers" ],[ - "Brown", "Victim's Occupation", "Boss", "Professional", @@ -496,7 +482,6 @@ var eventTiles = [ "Unemployed", "Retired" ],[ - "Brown", "In Progress", "Entertainment", "Relaxation", @@ -505,7 +490,6 @@ var eventTiles = [ "Visit", "Dining" ],[ - "Brown", "Sudden Incident", "Power Failure", "Fire", @@ -514,7 +498,6 @@ var eventTiles = [ "Scream", "Nothing" ],[ - "Brown", "Day of Crime", "Weekday", "Weekend", @@ -522,41 +505,42 @@ var eventTiles = [ "Summer", "Autumn", "Winter" - ],[ - "Special", + ] +]; + +var eventTiles = [ + [ "Countdown", "The Forensic Scientist draws 2 scene tiles and substitutes them for any 2 scene tiles in the display. The game ends after the following PRESENTATION is finished." ],[ - "Special", "Erroneous Information", "The Forensic Scientist chooses 1 of the scene tiles on display, and moves its marker to new item on the same tile. Discard this event tile." ],[ - "Special", "A Good Twist", "The player who correctly solved the crime last game immediately receives a chance to do so. This does not count toward their 1 chance this game. If no player is entitled to this advantage, the Forensic Scientist discards this tile and draws another. Discard this event tile." ],[ - "Special", "A Useful Clue", "The Forensic Scientist draws 5 Scene tiles, from which they choose 1 to replace any existing tile in the display. The selected tile cannot be another event. Discard this event tile." ],[ - "Special", "Ruled Out Evidence", "Each player must flip over 1 of their own Clue Cards, removing it from consideration. This must be done without discussion. The murderer may not flip over the Key Evidence. (Take this action in counterclockwise order from the Forensic Scientist.) Discard this event tile." ],[ - "Special", "Secret Testimony", "All players except the Forensic Scientist close their eyes. The witness then opens their eyes, points to a scene tile to eliminate, then closes their eyes. All players then open their eyes and the Forensic Scientist discards the indicated tile and replaces it with a random one. Discard this event tile." ] ]; -var eventTilesCopy = eventTiles.slice(); -var playerNum = $("#playerNum option:selected").text() - 1; -var clueNum = $("#clueNum option:selected").text(); + +var sceneTilesCopy; +var eventTilesCopy; +var playerNum; +var clueNum; + $('#seed').val(Math.floor(Math.random() * 1000)); -// console.log(means[Math.floor(Math.random() * means.length)]); $("#playReset").click(function() { if (confirm("Are you sure?")) { - $("table").empty(); + saveCurNames(); + $("table").empty(); reset(); } }); @@ -565,16 +549,35 @@ function reset() { Math.seedrandom($('#seed').val()); playerNum = $("#playerNum option:selected").text() - 1; clueNum = $("#clueNum option:selected").text(); + sceneTilesCopy = sceneTiles.slice(); eventTilesCopy = eventTiles.slice(); resetSetup(); eventSetup(); } -reset(); + +// List of player names +var playerNames = [] +// Save the current player names +function saveCurNames() { + playerNames = []; + var nameBoxes = document.getElementsByName("fname"); + for (var i = 0; i < nameBoxes.length; i++) { + playerNames.push(nameBoxes[i].value); + } +} +// Restore as many of the the saved player names as we can +function restoreCurNames() { + var nameBoxes = document.getElementsByName("fname"); + + for (var i = 0; i < nameBoxes.length && i < playerNames.length; i++) { + nameBoxes[i].value = playerNames[i]; + } +} + function eventSetup(){ var eventsSetup = $("#permEvents"); eventsSetup.empty(); - //add hidden cause of DEATH var cat = 'Cause of Death'; for (var i = 0; i < causeOfDeathTile.length; i++) { @@ -599,30 +602,16 @@ function eventSetup(){ $(this).remove(); } }); - addEvent(); - addEvent(); - addEvent(); - addEvent(); + addSceneTile(); + addSceneTile(); + addSceneTile(); + addSceneTile(); $("#permEvents tr").unbind(); }); - } -function addEvent(){ - var eventsSetup = $("#events"); - var specialEventsSetup = $("#specialEvents"); - var tempEvent = eventTilesCopy.splice(Math.floor(Math.random() * eventTilesCopy.length),1)[0]; - if(tempEvent[0] === "Brown"){ - var cat = ''+ tempEvent[1] +'/tr>'; - for (var i = 2; i < tempEvent.length; i++) { - cat+= ''+ tempEvent[i] +''; - } - eventsSetup.append(cat + 'X'); - } - if(tempEvent[0] === "Special" && $('#eventsCheck').is(':checked')){ - var cat = ''; - $("#specialEvents").append(''+ tempEvent[1] + ''+ tempEvent[2] +''); - } +// Reset click callback functions for td's and .remover's +function resetClickFns() { $('td').unbind().click(function() { if ($(this).hasClass('red')) { $(this).removeClass('red'); @@ -630,10 +619,68 @@ function addEvent(){ $(this).addClass('red'); } }); - $('.remover').click(function(){ + $('.remover').unbind().click(function(){ $(this).parent('tr').remove(); }); } + +// Adds a scene (non-event) tile +function addSceneTile(){ + var scenesSetup = $("#events"); + if (sceneTilesCopy.length == 0) { + return; + } + + var idx = Math.floor(Math.random() * sceneTilesCopy.length); + var tempScene = sceneTilesCopy.splice(idx, 1)[0]; + var cat = ''; + cat += '' + tempScene[0] + '/tr>'; + for (var i = 1; i < tempScene.length; i++) { + cat += '' + tempScene[i] + ''; + } + cat += 'X'; + cat += '' + scenesSetup.append(cat); + + resetClickFns(); +} + +// Adds an event tile +function addEventTile(){ + var eventsSetup = $("#specialEvents"); + + var idx = Math.floor(Math.random() * eventTilesCopy.length); + var tempEvent = eventTilesCopy.splice(idx, 1)[0]; + var cat = ''; + cat += '' + tempEvent[0] + ''; + cat += '' + tempEvent[1] + ''; + cat += 'X'; + cat += ''; + eventsSetup.append(cat); + + resetClickFns(); +} + +// Adds a scene or event tile +// If events are not selected, will always add a scene tile +// Otherwise, randomly adds a scene or event tile based on the number +// of each remaining +function addTile(){ + if ($('#eventsCheck').is(':checked')) { + // Events are selected, choose randomly between the remaining tiles + var totalTiles = sceneTilesCopy.length + eventTilesCopy.length; + var idx = Math.floor(Math.random() * totalTiles); + if (idx < sceneTilesCopy.length) { + addSceneTile(); + } else { + addEventTile(); + } + } else { + // Events are not selected. Add a scene tile. + addSceneTile(); + } +} + function resetSetup(){ var playerTab = $("#playerTab"); playerTab.empty(); @@ -661,7 +708,12 @@ function resetSetup(){ //add header for each player for (var i = 0; i < playerNum; i++) { - var cat = '
'; + var cat = ''; + cat += ''; + cat += ''; + cat += ''; } @@ -669,10 +721,14 @@ function resetSetup(){ for (var j = 0; j < clueNum; j++) { cat+= ''+ selectedEvidence[(i * clueNum) + j] +''; } - playerTab.append(cat + ''); + cat += ''; + playerTab.append(cat); } + restoreCurNames(); + console.log('evi' + selectedEvidence); console.log('means' + selectedMeans); } +reset(); From 369d002e32290fd904bb86594c162c8362f3aec4 Mon Sep 17 00:00:00 2001 From: Sprina Wu Date: Tue, 12 May 2020 18:48:53 -0400 Subject: [PATCH 2/2] Style changes --- css/style.css | 138 ++++++++++++++++++++++++ index.html | 167 ++++++++++++++---------------- script.js => js/script.js | 5 +- seedrandom.js => js/seedrandom.js | 0 4 files changed, 217 insertions(+), 93 deletions(-) create mode 100644 css/style.css rename script.js => js/script.js (98%) rename seedrandom.js => js/seedrandom.js (100%) diff --git a/css/style.css b/css/style.css new file mode 100644 index 0000000..c42ae2d --- /dev/null +++ b/css/style.css @@ -0,0 +1,138 @@ +body, option, select, input{ + font-family: 'Inconsolata', monospace; +} + +button { + background-color: mediumseagreen; + border: none; + padding: 5px; + text-align: center; + text-decoration: none; + display: inline-block; + color: white; + font-size: 16px; + font-family: 'Inconsolata', monospace; +} +th, +td { + text-align: center; + font-size: 1.15em; + padding:.5em; +} + +.cards td{ + border-radius: 10px +} +th{ + width: 20%; +} + + +input[type=text] { + border: none; + border-bottom: 2px solid gray; + font-family: 'Inconsolata', monospace; + font-size: 1em; + width: 30%; + margin-left: 10px; + +} +input[type=text]:focus { + outline:none; + +} +.foot{ + margin-right: 20px; +} + +table { + + margin-bottom: .5em; +} + +input[type=checkbox] { + position: relative; + cursor: pointer; + margin-bottom: 6px; + } + input[type=checkbox]:before { + content: ""; + display: inline-block; + position: absolute; + width: 16px; + height: 16px; + top: 0; + left: 0; + border: 2px solid #555555; + border-radius: 3px; + background-color: white; +} + input[type=checkbox]:checked:after { + content: ""; + display: block; + width: 5px; + height: 10px; + border: solid black; + border-width: 0 2px 2px 0; + -webkit-transform: rotate(45deg); + -ms-transform: rotate(45deg); + transform: rotate(45deg); + position: absolute; + top: 2px; + left: 6px; +} + + +.red { + background: #e62929; +} + +.purple { + background: #d47db6; +} + +.hideOnLoad { + display: none; +} + +#addEvent { + float: right; +} + +#playerTab tr { + background-color: #9bbfd1; +} +#playReset{ + margin-left: 20px; + +} +#playerTab tr:nth-child(even) { + background-color: #e0a4a4; +} + +#playerTab th { + background-color: white; +} +#events tr{ + background-color: #f7f6f5; +} +#events tr:nth-child(even) { + background-color: #d1cdc9; +} + +.deleteMe{ + background-color: #e1f5e2; +} + +#permEvents tr:nth-child(even) { + background-color: #7BCC70; +} +#specialEvents{ + border: solid 1px black; +} +#specialEvents tr{ + background-color: #f7f6f5; +} +#specialEvents tr:nth-child(even) { + background-color: #d1cdc9; +} \ No newline at end of file diff --git a/index.html b/index.html index 12975bb..3b2c185 100644 --- a/index.html +++ b/index.html @@ -1,103 +1,88 @@ - + + + + + -
-

Players: - - Clues: - - Seed: - - Events: - - -

+
+

Players: + + Clues: + + Seed: + + Events: + + +

-
- -
- -
- -
- -
-
-

Setup: always add murderer and forensic scientist, the rest are investigators. exception: if > 5 players, you MAY add Accomplice and/or Witness.

-

Round 1: FS makes 1 selection for each category. Then each player makes presentation.

-

Round 2: FS draws new category, then discards an old category, then makes a new selection on the new category. Discussion, then each player makes presentation.

-

Round 3: Repeat round 2, except game ends immediately after last person makes their presentation.

-
-
+
+ +
+ +
+ +
+ +
+
+

Setup: always add murderer and forensic scientist, the rest are investigators. exception: if > 5 players, you MAY add Accomplice and/or Witness.

+

Round 1: FS makes 1 selection for each category. Then each player makes presentation.

+

Round 2: FS draws new category, then discards an old category, then makes a new selection on the new category. Discussion, then each player makes presentation.

+

Round 3: Repeat round 2, except game ends immediately after last person makes their presentation.

+
+
+ function googleTranslateElementInit() { + new google.translate.TranslateElement({ + pageLanguage: 'en' + }, 'google_translate_element'); + } + + + - - - + + + + + diff --git a/script.js b/js/script.js similarity index 98% rename from script.js rename to js/script.js index 54b76c6..2bd9e6e 100644 --- a/script.js +++ b/js/script.js @@ -638,7 +638,7 @@ function addSceneTile(){ for (var i = 1; i < tempScene.length; i++) { cat += '' + tempScene[i] + ''; } - cat += 'X'; + cat += 'X'; cat += '' scenesSetup.append(cat); @@ -654,7 +654,7 @@ function addEventTile(){ var cat = ''; cat += '' + tempEvent[0] + ''; cat += '' + tempEvent[1] + ''; - cat += 'X'; + cat += 'X'; cat += ''; eventsSetup.append(cat); @@ -722,6 +722,7 @@ function resetSetup(){ cat+= ''+ selectedEvidence[(i * clueNum) + j] +''; } cat += ''; + cat += "" playerTab.append(cat); } diff --git a/seedrandom.js b/js/seedrandom.js similarity index 100% rename from seedrandom.js rename to js/seedrandom.js