Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #106, #110 and enhancement #9 #111

Open
wants to merge 13 commits into
base: main
Choose a base branch
from
30 changes: 28 additions & 2 deletions src/content/features/click-match-room-veto-maps.js
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,11 @@ export default async parentElement => {
const {
matchRoomAutoVetoMapItems,
matchRoomAutoVetoMapsShuffle: shuffleMaps,
matchRoomAutoVetoMapsShuffleAmount: shuffleMapsAmount
matchRoomAutoVetoMapsShuffleAmount: shuffleMapsAmount,

// Auto veto limit variables.
matchRoomAutoVetoMapsLimit: vetoMapsLimit,
matchRoomAutoVetoMapsLimitAmount: vetoMapsLimitAmount
} = await storage.getAll()
let autoVetoItems = matchRoomAutoVetoMapItems.map(m => maps.csgo[m] || m)

Expand All @@ -72,6 +76,8 @@ export default async parentElement => {

setFeatureAttribute(FEATURE_ATTRIBUTE, votingListElement)

let vetoMapCounter = 0

const autoVeto = () => {
const isVetoTurn = select.exists('button', votingListElement)

Expand All @@ -86,7 +92,27 @@ export default async parentElement => {
)
if (vetoButtonElement) {
setTimeout(() => {
vetoButtonElement.click()
/*
* Added Auto Veto Limit:
*
* Default: vetoMapsLimit = false (No Limit on Veto)
* vetoMapsLimitAmount = 4 (Maximum a team can veto)
* vetoMapCounter = 1-4 (Keep a check on number of maps veteod)
*
* Logic: If vetoMapsLimit = false, auto veto maximum possible maps
* else check
* if counter <= set_value (default=4)
* auto veto and increment counter
* else just wait for player to veto.
*/
if (vetoMapsLimit) {
if (vetoMapCounter < vetoMapsLimitAmount) {
vetoButtonElement.click()
vetoMapCounter += 1
}
} else {
vetoButtonElement.click()
}
}, VETO_DELAY)
}
return Boolean(vetoButtonElement)
Expand Down
13 changes: 13 additions & 0 deletions src/popup/sections/veto-preferences.js
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,19 @@ export default ({ getMenuProps, getSortableProps, getSwitchProps }) => (
mapOption={option => `First ${option}`}
{...getMenuProps('matchRoomAutoVetoMapsShuffleAmount')}
/>
<ListItemSwitch
primary="Veto Limit"
secondary="Limit the amount of maps gets auto vetoed."
{...getSwitchProps('matchRoomAutoVetoMapsLimit')}
/>
<ListItemMenu
primary="Veto Limit Amount"
options={MATCH_ROOM_VETO_MAP_ITEMS.filter(
(_, index) => index % 2 === 0
).map((_, index) => index + 1)}
mapOption={option => `First ${option}`}
{...getMenuProps('matchRoomAutoVetoMapsLimitAmount')}
/>
<ListItemText secondary="Sorted by favourite to least favourite. Least favourite will be vetoed first." />
<ListItemsSortable {...getSortableProps('matchRoomAutoVetoMapItems')} />
</React.Fragment>
Expand Down
2 changes: 2 additions & 0 deletions src/shared/settings.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@ export const DEFAULTS = {
matchRoomAutoVetoMaps: false,
matchRoomAutoVetoMapsShuffle: false,
matchRoomAutoVetoMapsShuffleAmount: 3,
matchRoomAutoVetoMapsLimit: false,
matchRoomAutoVetoMapsLimitAmount: 4,
matchRoomAutoVetoMapItems: MATCH_ROOM_VETO_MAP_ITEMS,
matchRoomFocusMode: false,
matchRoomLastConnectToServer: '',
Expand Down