Skip to content

Commit

Permalink
Add rapid time control stubs
Browse files Browse the repository at this point in the history
  • Loading branch information
anoek committed Oct 12, 2024
1 parent f5df490 commit 1ede606
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 6 deletions.
8 changes: 5 additions & 3 deletions src/components/AutomatchSettings/AutomatchSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import { Modal, openModal } from "@/components/Modal";
import { dup } from "@/lib/misc";
import * as data from "@/lib/data";
import { AutomatchPreferencesBase, AutomatchTimeControlSystem, Size, Speed } from "@/lib/types";
import { AutomatchCondition, RuleSet } from "goban";
import { AutomatchCondition, JGOFTimeControlSpeed, RuleSet } from "goban";

interface Events {}

Expand Down Expand Up @@ -104,10 +104,12 @@ const ConditionSelect = (props: { value: any; onChange: (x: any) => void }) => (
</div>
);

export function getAutomatchSettings(speed: "blitz" | "live" | "correspondence") {
export function getAutomatchSettings(speed: JGOFTimeControlSpeed) {
switch (speed) {
case "blitz":
return dup(data.get("automatch.blitz", default_blitz));
case "rapid":
throw new Error("Rapid is not supported yet");
case "live":
return dup(data.get("automatch.live", default_live));
case "correspondence":
Expand All @@ -130,7 +132,7 @@ export class AutomatchSettings extends Modal<
};
}

setTab = (tab: Speed) => {
setTab = (tab: JGOFTimeControlSpeed) => {
data.set("automatch.last-tab", tab);
this.setState({ tab: tab });
};
Expand Down
3 changes: 2 additions & 1 deletion src/lib/data_schema.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import TimeControlSystem = TimeControlTypes.TimeControlSystem;
import { AutomatchPreferences } from "@/components/AutomatchSettings";
import { JosekiFilter } from "@/components/JosekiVariationFilter";
import { Challenge } from "@/lib/challenge_utils";
import { JGOFTimeControlSpeed } from "goban";

interface CachedSchema {
groups: GroupList;
Expand Down Expand Up @@ -159,7 +160,7 @@ interface PMSchema {
}

type AutomatchSchema = {
"last-tab": TimeControlSpeed;
"last-tab": JGOFTimeControlSpeed;
size_options: Size[];
} & {
[speed_key in TimeControlSpeed]: AutomatchPreferences;
Expand Down
4 changes: 2 additions & 2 deletions src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@

import * as React from "react";
import { PlayerCacheEntry } from "@/lib/player_cache";
import { GobanEngineRules, JGOFTimeControl } from "goban";
import { GobanEngineRules, JGOFTimeControl, JGOFTimeControlSpeed } from "goban";

export interface Player extends PlayerCacheEntry {
professional: boolean;
Expand Down Expand Up @@ -83,7 +83,7 @@ export interface ActiveTournament {

export type ActiveTournamentList = Array<ActiveTournament>;

export type Speed = "blitz" | "live" | "correspondence";
export type Speed = JGOFTimeControlSpeed;
export type Size = "9x9" | "13x13" | "19x19";
export type AutomatchCondition = "required" | "preferred" | "no-preference";
export type RuleSet = "japanese" | "chinese" | "aga" | "korean" | "nz" | "ing";
Expand Down
2 changes: 2 additions & 0 deletions src/views/User/GameHistoryTable.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -576,6 +576,8 @@ function getSpeedClass(speed: Speed) {
return "speed-icon ogs-turtle";
case "live":
return "speed-icon fa fa-clock-o";
case "rapid":
return "speed-icon fa fa-clock-o";
case "blitz":
return "speed-icon fa fa-bolt";
}
Expand Down

0 comments on commit 1ede606

Please sign in to comment.