mirror of
				https://github.com/bra1n/townsquare.git
				synced 2025-10-21 16:55:12 +00:00 
			
		
		
		
	prevent assigning players a traveler role in a live session (fixes #13)
This commit is contained in:
		
							parent
							
								
									06a11d7208
								
							
						
					
					
						commit
						505593d1c6
					
				
					 2 changed files with 8 additions and 1 deletions
				
			
		| 
						 | 
				
			
			@ -49,7 +49,7 @@ export default {
 | 
			
		|||
      availableRoles.push({});
 | 
			
		||||
      return availableRoles;
 | 
			
		||||
    },
 | 
			
		||||
    ...mapState(["modals", "roles"]),
 | 
			
		||||
    ...mapState(["modals", "roles", "session"]),
 | 
			
		||||
    ...mapState("players", ["players"])
 | 
			
		||||
  },
 | 
			
		||||
  methods: {
 | 
			
		||||
| 
						 | 
				
			
			@ -61,6 +61,7 @@ export default {
 | 
			
		|||
          role
 | 
			
		||||
        });
 | 
			
		||||
      } else {
 | 
			
		||||
        if (this.session.isSpectator && role.team === "traveler") return;
 | 
			
		||||
        // assign to player
 | 
			
		||||
        const player = this.$store.state.players.players[this.playerIndex];
 | 
			
		||||
        this.$store.commit("players/update", {
 | 
			
		||||
| 
						 | 
				
			
			@ -105,4 +106,8 @@ ul.tokens li {
 | 
			
		|||
    z-index: 10;
 | 
			
		||||
  }
 | 
			
		||||
}
 | 
			
		||||
 | 
			
		||||
#townsquare.spectator ul.tokens li.traveler {
 | 
			
		||||
  display: none;
 | 
			
		||||
}
 | 
			
		||||
</style>
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -110,6 +110,7 @@ class LiveSession {
 | 
			
		|||
   * @param channel
 | 
			
		||||
   */
 | 
			
		||||
  connect(channel) {
 | 
			
		||||
    this._store.commit("setPlayerCount", 0);
 | 
			
		||||
    this._isSpectator = this._store.state.session.isSpectator;
 | 
			
		||||
    this._open(channel);
 | 
			
		||||
  }
 | 
			
		||||
| 
						 | 
				
			
			@ -118,6 +119,7 @@ class LiveSession {
 | 
			
		|||
   * Close the current session, if any.
 | 
			
		||||
   */
 | 
			
		||||
  disconnect() {
 | 
			
		||||
    this._store.commit("setPlayerCount", 0);
 | 
			
		||||
    if (this._socket) {
 | 
			
		||||
      this._send("bye", this._playerId);
 | 
			
		||||
      this._socket.close();
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue