-
Notifications
You must be signed in to change notification settings - Fork 41
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement punishment for excessive bot substitution
- Loading branch information
Showing
27 changed files
with
1,192 additions
and
840 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
<script setup lang="ts"> | ||
import {computed, inject} from "vue"; | ||
import NumberInput from "@/components/common/NumberInput.vue"; | ||
import {useMatchStateStore} from "@/store/matchState"; | ||
import type {Team} from "@/proto/ssl_gc_common"; | ||
import type {ControlApi} from "@/providers/controlApi"; | ||
const props = defineProps<{ | ||
team: Team, | ||
}>() | ||
const store = useMatchStateStore() | ||
const control = inject<ControlApi>('control-api') | ||
const model = computed(() => { | ||
return store.matchState.teamState![props.team].botSubstitutionsLeft! | ||
}) | ||
const updateValue = (value: number | undefined) => { | ||
if (value !== undefined) { | ||
control?.UpdateTeamState({ | ||
forTeam: props.team, | ||
botSubstitutionsLeft: value, | ||
}) | ||
} | ||
} | ||
</script> | ||
|
||
<template> | ||
<NumberInput | ||
:modelValue="model" | ||
label="Bot substitutions left" | ||
@update:model-value="updateValue" | ||
/> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
package engine | ||
|
||
import ( | ||
"github.com/RoboCup-SSL/ssl-game-controller/internal/app/state" | ||
"time" | ||
) | ||
|
||
func (e *Engine) processBotSubstitution() { | ||
if e.currentState.GameState.IsHalted() { | ||
for _, team := range state.BothTeams() { | ||
if !*e.currentState.TeamInfo(team).BotSubstitutionAllowed { | ||
continue | ||
} | ||
events := e.currentState.FindGameEventsByTeam(state.GameEvent_BOT_SUBSTITUTION, team) | ||
if len(events) == 0 { | ||
continue | ||
} | ||
botSubstitutionEvent := events[len(events)-1] | ||
eventCreated := time.UnixMicro(int64(*botSubstitutionEvent.CreatedTimestamp)) | ||
if e.timeProvider().Sub(eventCreated) > e.gameConfig.BotSubstitutionTime { | ||
e.Enqueue(createBotSubstitutionEventChange(team)) | ||
} | ||
} | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.