mirror of
				https://github.com/bra1n/townsquare.git
				synced 2025-10-21 16:55:12 +00:00 
			
		
		
		
	added night phase switch
This commit is contained in:
		
							parent
							
								
									f915a1a7f8
								
							
						
					
					
						commit
						a37add61d9
					
				
					 7 changed files with 95 additions and 7 deletions
				
			
		
							
								
								
									
										49
									
								
								src/App.vue
									
										
									
									
									
								
							
							
						
						
									
										49
									
								
								src/App.vue
									
										
									
									
									
								
							| 
						 | 
					@ -3,13 +3,17 @@
 | 
				
			||||||
    id="app"
 | 
					    id="app"
 | 
				
			||||||
    @keyup="keyup"
 | 
					    @keyup="keyup"
 | 
				
			||||||
    tabindex="-1"
 | 
					    tabindex="-1"
 | 
				
			||||||
    v-bind:class="{ screenshot: grimoire.isScreenshot }"
 | 
					    v-bind:class="{
 | 
				
			||||||
 | 
					      screenshot: grimoire.isScreenshot,
 | 
				
			||||||
 | 
					      night: grimoire.isNight
 | 
				
			||||||
 | 
					    }"
 | 
				
			||||||
    v-bind:style="{
 | 
					    v-bind:style="{
 | 
				
			||||||
      backgroundImage: grimoire.background
 | 
					      backgroundImage: grimoire.background
 | 
				
			||||||
        ? `url('${grimoire.background}')`
 | 
					        ? `url('${grimoire.background}')`
 | 
				
			||||||
        : ''
 | 
					        : ''
 | 
				
			||||||
    }"
 | 
					    }"
 | 
				
			||||||
  >
 | 
					  >
 | 
				
			||||||
 | 
					    <div class="backdrop"></div>
 | 
				
			||||||
    <transition name="blur">
 | 
					    <transition name="blur">
 | 
				
			||||||
      <Intro v-if="!players.length"></Intro>
 | 
					      <Intro v-if="!players.length"></Intro>
 | 
				
			||||||
      <TownInfo v-if="players.length && !session.nomination"></TownInfo>
 | 
					      <TownInfo v-if="players.length && !session.nomination"></TownInfo>
 | 
				
			||||||
| 
						 | 
					@ -333,4 +337,47 @@ ul {
 | 
				
			||||||
    height: 10px;
 | 
					    height: 10px;
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
}
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					/* Night phase backdrop */
 | 
				
			||||||
 | 
					#app > .backdrop {
 | 
				
			||||||
 | 
					  position: absolute;
 | 
				
			||||||
 | 
					  left: 0;
 | 
				
			||||||
 | 
					  right: 0;
 | 
				
			||||||
 | 
					  bottom: 0;
 | 
				
			||||||
 | 
					  top: 0;
 | 
				
			||||||
 | 
					  pointer-events: none;
 | 
				
			||||||
 | 
					  background: black;
 | 
				
			||||||
 | 
					  background: linear-gradient(
 | 
				
			||||||
 | 
					    180deg,
 | 
				
			||||||
 | 
					    rgba(0, 0, 0, 1) 0%,
 | 
				
			||||||
 | 
					    rgba(1, 22, 46, 1) 50%,
 | 
				
			||||||
 | 
					    rgba(0, 39, 70, 1) 100%
 | 
				
			||||||
 | 
					  );
 | 
				
			||||||
 | 
					  opacity: 0;
 | 
				
			||||||
 | 
					  transition: opacity 1s ease-in-out;
 | 
				
			||||||
 | 
					  &:after {
 | 
				
			||||||
 | 
					    content: " ";
 | 
				
			||||||
 | 
					    display: block;
 | 
				
			||||||
 | 
					    width: 100%;
 | 
				
			||||||
 | 
					    padding-right: 2000px;
 | 
				
			||||||
 | 
					    height: 100%;
 | 
				
			||||||
 | 
					    background: url("assets/clouds.png") repeat;
 | 
				
			||||||
 | 
					    background-size: 2000px auto;
 | 
				
			||||||
 | 
					    animation: move-background 120s linear infinite;
 | 
				
			||||||
 | 
					    opacity: 0.3;
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					@keyframes move-background {
 | 
				
			||||||
 | 
					  from {
 | 
				
			||||||
 | 
					    transform: translate3d(-2000px, 0px, 0px);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					  to {
 | 
				
			||||||
 | 
					    transform: translate3d(0px, 0px, 0px);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					#app.night > .backdrop {
 | 
				
			||||||
 | 
					  opacity: 0.5;
 | 
				
			||||||
 | 
					}
 | 
				
			||||||
</style>
 | 
					</style>
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
							
								
								
									
										
											BIN
										
									
								
								src/assets/clouds.png
									
										
									
									
									
										Normal file
									
								
							
							
						
						
									
										
											BIN
										
									
								
								src/assets/clouds.png
									
										
									
									
									
										Normal file
									
								
							
										
											Binary file not shown.
										
									
								
							| 
		 After Width: | Height: | Size: 416 KiB  | 
| 
						 | 
					@ -49,6 +49,14 @@
 | 
				
			||||||
            <template v-if="grimoire.isPublic">Show</template>
 | 
					            <template v-if="grimoire.isPublic">Show</template>
 | 
				
			||||||
            <em>[G]</em>
 | 
					            <em>[G]</em>
 | 
				
			||||||
          </li>
 | 
					          </li>
 | 
				
			||||||
 | 
					          <li @click="toggleNight" v-if="!session.isSpectator">
 | 
				
			||||||
 | 
					            <template v-if="!grimoire.isNight">Switch to Night</template>
 | 
				
			||||||
 | 
					            <template v-if="grimoire.isNight">Switch to Day</template>
 | 
				
			||||||
 | 
					            <em
 | 
				
			||||||
 | 
					              ><font-awesome-icon
 | 
				
			||||||
 | 
					                :icon="['fas', grimoire.isNight ? 'sun' : 'cloud-moon']"
 | 
				
			||||||
 | 
					            /></em>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
          <li @click="toggleNightOrder" v-if="players.length">
 | 
					          <li @click="toggleNightOrder" v-if="players.length">
 | 
				
			||||||
            Night order
 | 
					            Night order
 | 
				
			||||||
            <em
 | 
					            <em
 | 
				
			||||||
| 
						 | 
					@ -59,10 +67,6 @@
 | 
				
			||||||
                ]"
 | 
					                ]"
 | 
				
			||||||
            /></em>
 | 
					            /></em>
 | 
				
			||||||
          </li>
 | 
					          </li>
 | 
				
			||||||
          <li v-if="!session.isSpectator" @click="toggleModal('fabled')">
 | 
					 | 
				
			||||||
            Add Fabled
 | 
					 | 
				
			||||||
            <em><font-awesome-icon icon="dragon"/></em>
 | 
					 | 
				
			||||||
          </li>
 | 
					 | 
				
			||||||
          <li v-if="players.length">
 | 
					          <li v-if="players.length">
 | 
				
			||||||
            Zoom
 | 
					            Zoom
 | 
				
			||||||
            <em>
 | 
					            <em>
 | 
				
			||||||
| 
						 | 
					@ -138,6 +142,10 @@
 | 
				
			||||||
            Choose & Assign
 | 
					            Choose & Assign
 | 
				
			||||||
            <em>[C]</em>
 | 
					            <em>[C]</em>
 | 
				
			||||||
          </li>
 | 
					          </li>
 | 
				
			||||||
 | 
					          <li v-if="!session.isSpectator" @click="toggleModal('fabled')">
 | 
				
			||||||
 | 
					            Add Fabled
 | 
				
			||||||
 | 
					            <em><font-awesome-icon icon="dragon"/></em>
 | 
				
			||||||
 | 
					          </li>
 | 
				
			||||||
          <li @click="clearRoles" v-if="players.length">
 | 
					          <li @click="clearRoles" v-if="players.length">
 | 
				
			||||||
            Remove all
 | 
					            Remove all
 | 
				
			||||||
            <em><font-awesome-icon icon="trash-alt"/></em>
 | 
					            <em><font-awesome-icon icon="trash-alt"/></em>
 | 
				
			||||||
| 
						 | 
					@ -244,6 +252,7 @@ export default {
 | 
				
			||||||
      );
 | 
					      );
 | 
				
			||||||
      if (sessionId) {
 | 
					      if (sessionId) {
 | 
				
			||||||
        this.$store.commit("session/setSpectator", true);
 | 
					        this.$store.commit("session/setSpectator", true);
 | 
				
			||||||
 | 
					        this.$store.commit("toggleGrimoire", false);
 | 
				
			||||||
        this.$store.commit(
 | 
					        this.$store.commit(
 | 
				
			||||||
          "session/setSessionId",
 | 
					          "session/setSessionId",
 | 
				
			||||||
          sessionId
 | 
					          sessionId
 | 
				
			||||||
| 
						 | 
					@ -287,6 +296,7 @@ export default {
 | 
				
			||||||
    ...mapMutations([
 | 
					    ...mapMutations([
 | 
				
			||||||
      "toggleGrimoire",
 | 
					      "toggleGrimoire",
 | 
				
			||||||
      "toggleMenu",
 | 
					      "toggleMenu",
 | 
				
			||||||
 | 
					      "toggleNight",
 | 
				
			||||||
      "toggleNightOrder",
 | 
					      "toggleNightOrder",
 | 
				
			||||||
      "updateScreenshot",
 | 
					      "updateScreenshot",
 | 
				
			||||||
      "setZoom",
 | 
					      "setZoom",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,6 +34,11 @@
 | 
				
			||||||
          v-bind:icon="teams.traveler > 1 ? 'user-friends' : 'user'"
 | 
					          v-bind:icon="teams.traveler > 1 ? 'user-friends' : 'user'"
 | 
				
			||||||
        />
 | 
					        />
 | 
				
			||||||
      </template>
 | 
					      </template>
 | 
				
			||||||
 | 
					      <template v-if="grimoire.isNight">
 | 
				
			||||||
 | 
					        <br />
 | 
				
			||||||
 | 
					        Night phase
 | 
				
			||||||
 | 
					        <font-awesome-icon :icon="['fas', 'cloud-moon']" />
 | 
				
			||||||
 | 
					      </template>
 | 
				
			||||||
    </li>
 | 
					    </li>
 | 
				
			||||||
  </ul>
 | 
					  </ul>
 | 
				
			||||||
</template>
 | 
					</template>
 | 
				
			||||||
| 
						 | 
					@ -59,7 +64,7 @@ export default {
 | 
				
			||||||
          ).length
 | 
					          ).length
 | 
				
			||||||
      };
 | 
					      };
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
    ...mapState(["edition"]),
 | 
					    ...mapState(["edition", "grimoire"]),
 | 
				
			||||||
    ...mapState("players", ["players"])
 | 
					    ...mapState("players", ["players"])
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
};
 | 
					};
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -34,6 +34,7 @@ const faIcons = [
 | 
				
			||||||
  "SearchPlus",
 | 
					  "SearchPlus",
 | 
				
			||||||
  "Skull",
 | 
					  "Skull",
 | 
				
			||||||
  "Square",
 | 
					  "Square",
 | 
				
			||||||
 | 
					  "Sun",
 | 
				
			||||||
  "TheaterMasks",
 | 
					  "TheaterMasks",
 | 
				
			||||||
  "Times",
 | 
					  "Times",
 | 
				
			||||||
  "TimesCircle",
 | 
					  "TimesCircle",
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -50,6 +50,7 @@ export default new Vuex.Store({
 | 
				
			||||||
  },
 | 
					  },
 | 
				
			||||||
  state: {
 | 
					  state: {
 | 
				
			||||||
    grimoire: {
 | 
					    grimoire: {
 | 
				
			||||||
 | 
					      isNight: false,
 | 
				
			||||||
      isNightOrder: true,
 | 
					      isNightOrder: true,
 | 
				
			||||||
      isPublic: true,
 | 
					      isPublic: true,
 | 
				
			||||||
      isMenuOpen: false,
 | 
					      isMenuOpen: false,
 | 
				
			||||||
| 
						 | 
					@ -113,6 +114,13 @@ export default new Vuex.Store({
 | 
				
			||||||
        grimoire.isPublic ? "Town Square" : "Grimoire"
 | 
					        grimoire.isPublic ? "Town Square" : "Grimoire"
 | 
				
			||||||
      }`;
 | 
					      }`;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
 | 
					    toggleNight({ grimoire }, isNight) {
 | 
				
			||||||
 | 
					      if (isNight === true || isNight === false) {
 | 
				
			||||||
 | 
					        grimoire.isNight = isNight;
 | 
				
			||||||
 | 
					      } else {
 | 
				
			||||||
 | 
					        grimoire.isNight = !grimoire.isNight;
 | 
				
			||||||
 | 
					      }
 | 
				
			||||||
 | 
					    },
 | 
				
			||||||
    toggleNightOrder({ grimoire }) {
 | 
					    toggleNightOrder({ grimoire }) {
 | 
				
			||||||
      grimoire.isNightOrder = !grimoire.isNightOrder;
 | 
					      grimoire.isNightOrder = !grimoire.isNightOrder;
 | 
				
			||||||
    },
 | 
					    },
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
| 
						 | 
					@ -138,6 +138,10 @@ class LiveSession {
 | 
				
			||||||
        if (!this._isSpectator) return;
 | 
					        if (!this._isSpectator) return;
 | 
				
			||||||
        this._store.commit("players/move", params);
 | 
					        this._store.commit("players/move", params);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					      case "isNight":
 | 
				
			||||||
 | 
					        if (!this._isSpectator) return;
 | 
				
			||||||
 | 
					        this._store.commit("toggleNight", params);
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
      case "votingSpeed":
 | 
					      case "votingSpeed":
 | 
				
			||||||
        if (!this._isSpectator) return;
 | 
					        if (!this._isSpectator) return;
 | 
				
			||||||
        this._store.commit("session/setVotingSpeed", params);
 | 
					        this._store.commit("session/setVotingSpeed", params);
 | 
				
			||||||
| 
						 | 
					@ -205,11 +209,12 @@ class LiveSession {
 | 
				
			||||||
        ? { roleId: player.role.id }
 | 
					        ? { roleId: player.role.id }
 | 
				
			||||||
        : {})
 | 
					        : {})
 | 
				
			||||||
    }));
 | 
					    }));
 | 
				
			||||||
    const { session } = this._store.state;
 | 
					    const { session, grimoire } = this._store.state;
 | 
				
			||||||
    const { fabled } = this._store.state.players;
 | 
					    const { fabled } = this._store.state.players;
 | 
				
			||||||
    this.sendEdition();
 | 
					    this.sendEdition();
 | 
				
			||||||
    this._send("gs", {
 | 
					    this._send("gs", {
 | 
				
			||||||
      gamestate: this._gamestate,
 | 
					      gamestate: this._gamestate,
 | 
				
			||||||
 | 
					      isNight: grimoire.isNight,
 | 
				
			||||||
      nomination: session.nomination,
 | 
					      nomination: session.nomination,
 | 
				
			||||||
      votingSpeed: session.votingSpeed,
 | 
					      votingSpeed: session.votingSpeed,
 | 
				
			||||||
      lockedVote: session.lockedVote,
 | 
					      lockedVote: session.lockedVote,
 | 
				
			||||||
| 
						 | 
					@ -227,12 +232,14 @@ class LiveSession {
 | 
				
			||||||
    if (!this._isSpectator) return;
 | 
					    if (!this._isSpectator) return;
 | 
				
			||||||
    const {
 | 
					    const {
 | 
				
			||||||
      gamestate,
 | 
					      gamestate,
 | 
				
			||||||
 | 
					      isNight,
 | 
				
			||||||
      nomination,
 | 
					      nomination,
 | 
				
			||||||
      votingSpeed,
 | 
					      votingSpeed,
 | 
				
			||||||
      votes,
 | 
					      votes,
 | 
				
			||||||
      lockedVote,
 | 
					      lockedVote,
 | 
				
			||||||
      fabled
 | 
					      fabled
 | 
				
			||||||
    } = data;
 | 
					    } = data;
 | 
				
			||||||
 | 
					    this._store.commit("toggleNight", isNight);
 | 
				
			||||||
    this._store.commit("session/nomination", {
 | 
					    this._store.commit("session/nomination", {
 | 
				
			||||||
      nomination,
 | 
					      nomination,
 | 
				
			||||||
      votes,
 | 
					      votes,
 | 
				
			||||||
| 
						 | 
					@ -519,6 +526,13 @@ class LiveSession {
 | 
				
			||||||
    }
 | 
					    }
 | 
				
			||||||
  }
 | 
					  }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
 | 
					  /**
 | 
				
			||||||
 | 
					   * Send the isNight status. ST only
 | 
				
			||||||
 | 
					   */
 | 
				
			||||||
 | 
					  setIsNight() {
 | 
				
			||||||
 | 
					    if (this._isSpectator) return;
 | 
				
			||||||
 | 
					    this._send("isNight", this._store.state.grimoire.isNight);
 | 
				
			||||||
 | 
					  }
 | 
				
			||||||
  /**
 | 
					  /**
 | 
				
			||||||
   * Send the voting speed. ST only
 | 
					   * Send the voting speed. ST only
 | 
				
			||||||
   * @param votingSpeed voting speed in seconds, minimum 1
 | 
					   * @param votingSpeed voting speed in seconds, minimum 1
 | 
				
			||||||
| 
						 | 
					@ -644,6 +658,9 @@ export default store => {
 | 
				
			||||||
      case "session/setVotingSpeed":
 | 
					      case "session/setVotingSpeed":
 | 
				
			||||||
        session.setVotingSpeed(payload);
 | 
					        session.setVotingSpeed(payload);
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
 | 
					      case "toggleNight":
 | 
				
			||||||
 | 
					        session.setIsNight();
 | 
				
			||||||
 | 
					        break;
 | 
				
			||||||
      case "setEdition":
 | 
					      case "setEdition":
 | 
				
			||||||
        session.sendEdition();
 | 
					        session.sendEdition();
 | 
				
			||||||
        break;
 | 
					        break;
 | 
				
			||||||
| 
						 | 
					
 | 
				
			||||||
		Loading…
	
	Add table
		
		Reference in a new issue