mirror of
				https://github.com/bra1n/townsquare.git
				synced 2025-10-21 16:55:12 +00:00 
			
		
		
		
	Unique night order bubbles for multiple role (#202)
This commit is contained in:
		
							parent
							
								
									d35b4b59c2
								
							
						
					
					
						commit
						f80ab9e68f
					
				
					 2 changed files with 22 additions and 11 deletions
				
			
		|  | @ -2,6 +2,7 @@ | |||
| 
 | ||||
| ## Upcoming version | ||||
| 
 | ||||
| - Unique night order bubble for each player with the same role | ||||
| - Adding some special votes | ||||
| - Automatic Djinn and Bootlegger | ||||
| - Updating night order | ||||
|  |  | |||
|  | @ -29,27 +29,37 @@ const getters = { | |||
|     const firstNight = [0]; | ||||
|     const otherNight = [0]; | ||||
|     fabled.forEach((role) => { | ||||
|       if (role.firstNight && !firstNight.includes(role)) { | ||||
|       if (role.firstNight) { | ||||
|         firstNight.push(role); | ||||
|       } | ||||
|       if (role.otherNight && !otherNight.includes(role)) { | ||||
|       if (role.otherNight) { | ||||
|         otherNight.push(role); | ||||
|       } | ||||
|     }); | ||||
|     players.forEach(({ role }) => { | ||||
|       if (role.firstNight && !firstNight.includes(role)) { | ||||
|         firstNight.push(role); | ||||
|     players.forEach((player) => { | ||||
|       if (player.role.firstNight) { | ||||
|         firstNight.push(player); | ||||
|       } | ||||
|       if (role.otherNight && !otherNight.includes(role)) { | ||||
|         otherNight.push(role); | ||||
|       if (player.role.otherNight) { | ||||
|         otherNight.push(player); | ||||
|       } | ||||
|     }); | ||||
|     firstNight.sort((a, b) => a.firstNight - b.firstNight); | ||||
|     otherNight.sort((a, b) => a.otherNight - b.otherNight); | ||||
|     // If x has an attribute 'role' (meaning x is a player), then, to know their night order, we look at x.role.firstNight or x.role.otherNight
 | ||||
|     // Else, (meaning x is instead a Fabled), to know their night order we look at x.firstNight or x.otherNight
 | ||||
|     firstNight.sort( | ||||
|       (a, b) => | ||||
|         (a.role ? a.role.firstNight : a.firstNight) - | ||||
|         (b.role ? b.role.firstNight : b.firstNight), | ||||
|     ); | ||||
|     otherNight.sort( | ||||
|       (a, b) => | ||||
|         (a.role ? a.role.otherNight : a.otherNight) - | ||||
|         (b.role ? b.role.otherNight : b.otherNight), | ||||
|     ); | ||||
|     const nightOrder = new Map(); | ||||
|     players.forEach((player) => { | ||||
|       const first = Math.max(firstNight.indexOf(player.role), 0); | ||||
|       const other = Math.max(otherNight.indexOf(player.role), 0); | ||||
|       const first = Math.max(firstNight.indexOf(player), 0); | ||||
|       const other = Math.max(otherNight.indexOf(player), 0); | ||||
|       nightOrder.set(player, { first, other }); | ||||
|     }); | ||||
|     fabled.forEach((role) => { | ||||
|  |  | |||
		Loading…
	
	Add table
		
		Reference in a new issue