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

Reformatting automatch finder box #2749

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
37 changes: 36 additions & 1 deletion src/components/AutomatchSettings/AutomatchSettings.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type AutomatchPreferences = AutomatchPreferencesBase & { size_options: Si
interface AutomatchSettingsState {
tab: Speed;
blitz_settings: AutomatchPreferences;
rapid_settings: AutomatchPreferences;
live_settings: AutomatchPreferences;
correspondence_settings: AutomatchPreferences;
}
Expand All @@ -55,6 +56,25 @@ const default_blitz: AutomatchPreferences = {
value: "disabled",
},
};
const default_rapid: AutomatchPreferences = {
upper_rank_diff: 3,
lower_rank_diff: 3,
size_options: ["19x19"],
rules: {
condition: "no-preference",
value: "japanese",
},
time_control: {
condition: "no-preference",
value: {
system: "byoyomi",
},
},
handicap: {
condition: "no-preference",
value: "enabled",
},
};
const default_live: AutomatchPreferences = {
upper_rank_diff: 3,
lower_rank_diff: 3,
Expand Down Expand Up @@ -104,10 +124,12 @@ const ConditionSelect = (props: { value: any; onChange: (x: any) => void }) => (
</div>
);

export function getAutomatchSettings(speed: "blitz" | "live" | "correspondence") {
export function getAutomatchSettings(speed: "blitz" | "live" | "rapid" | "correspondence") {
switch (speed) {
case "blitz":
return dup(data.get("automatch.blitz", default_blitz));
case "rapid":
return dup(data.get("automatch.rapid", default_rapid));
case "live":
return dup(data.get("automatch.live", default_live));
case "correspondence":
Expand All @@ -125,6 +147,7 @@ export class AutomatchSettings extends Modal<
this.state = {
tab: data.get("automatch.last-tab", "live") as Speed,
blitz_settings: data.get("automatch.blitz", default_blitz),
rapid_settings: data.get("automatch.rapid", default_rapid),
live_settings: data.get("automatch.live", default_live),
correspondence_settings: data.get("automatch.correspondence", default_correspondence),
};
Expand All @@ -139,6 +162,8 @@ export class AutomatchSettings extends Modal<
switch (this.state.tab) {
case "blitz":
return dup(this.state.blitz_settings);
case "rapid":
return dup(this.state.rapid_settings);
case "live":
return dup(this.state.live_settings);
case "correspondence":
Expand All @@ -153,6 +178,10 @@ export class AutomatchSettings extends Modal<
data.set("automatch.blitz", settings);
this.setState({ blitz_settings: settings });
break;
case "rapid":
data.set("automatch.rapid", settings);
this.setState({ rapid_settings: settings });
break;
case "live":
data.set("automatch.live", settings);
this.setState({ live_settings: settings });
Expand Down Expand Up @@ -238,6 +267,12 @@ export class AutomatchSettings extends Modal<
>
{_("Blitz")}
</button>
<button
className={this.state.tab === "rapid" ? "primary active sm" : "sm"}
onClick={() => this.setTab("rapid")}
>
{_("Rapid")}
</button>
<button
className={this.state.tab === "live" ? "primary active sm" : "sm"}
onClick={() => this.setTab("live")}
Expand Down
2 changes: 1 addition & 1 deletion src/components/TimeControl/TimeControl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
*/

export namespace TimeControlTypes {
export type TimeControlSpeed = "blitz" | "live" | "correspondence";
export type TimeControlSpeed = "blitz" | "rapid" | "live" | "correspondence";
export type TimeControlSystem =
| "fischer"
| "byoyomi"
Expand Down
56 changes: 56 additions & 0 deletions src/components/TimeControl/util.ts
Original file line number Diff line number Diff line change
Expand Up @@ -650,6 +650,27 @@ export const time_options: TimeOptionsMap = {
total_time: gen(45, 300),
},
},
rapid: {
fischer: {
initial_time: gen(5, 300),
time_increment: gen(1, 10),
max_time: gen(5, 300),
},
simple: {
per_move: gen(3, 9),
},
canadian: {
main_time: [zero].concat(gen(0, 300)),
period_time: gen(5, 30),
},
byoyomi: {
main_time: [zero].concat(gen(0, 300)),
period_time: gen(3, 30),
},
absolute: {
total_time: gen(45, 300),
},
},
live: {
fischer: {
initial_time: gen(30, 3600 * 4),
Expand Down Expand Up @@ -732,6 +753,41 @@ export const default_time_settings: DefaultTimeSettingsMap = {
pause_on_weekends: false,
},
},
rapid: {
fischer: {
initial_time: 30,
time_increment: 10,
max_time: 60,
pause_on_weekends: false,
},
byoyomi: {
main_time: 30,
period_time: 5,
periods: 5,
periods_min: 1,
periods_max: 300,
pause_on_weekends: false,
},
canadian: {
main_time: 30,
period_time: 30,
stones_per_period: 5,
stones_per_period_min: 1,
stones_per_period_max: 50,
pause_on_weekends: false,
},
simple: {
per_move: 5,
pause_on_weekends: false,
},
absolute: {
total_time: 300,
pause_on_weekends: false,
},
none: {
pause_on_weekends: false,
},
},
live: {
fischer: {
initial_time: 120,
Expand Down
5 changes: 2 additions & 3 deletions src/lib/automatch_manager.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,8 @@ class AutomatchManager extends TypedEventEmitter<Events> {

/* live game? track it, and pop up our searching toast */
if (
preferences.size_speed_options.filter(
(opt) => opt.speed === "blitz" || opt.speed === "live",
).length
preferences.size_speed_options.filter((opt) => opt.speed in ["blitz", "rapid", "live"])
.length
) {
this.last_find_match_uuid = preferences.uuid;
if (this.active_toast) {
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 @@ -20,7 +20,7 @@
* all the possible keys as well as the associated value types.
*/

import { GroupList, ActiveTournamentList, Size, RuleSet } from "./types";
import { GroupList, ActiveTournamentList, Size, Speed, RuleSet } from "./types";
import { Announcement } from "src/components/Announcements";
import { ValidSound, ValidSoundGroup } from "./sfx";
import { defaults as defaultPreferences, ValidPreference } from "./preferences";
Expand Down Expand Up @@ -159,6 +159,7 @@ interface PMSchema {
type AutomatchSchema = {
"last-tab": TimeControlSpeed;
size_options: Size[];
speed_option: Speed;
} & {
[speed_key in TimeControlSpeed]: AutomatchPreferences;
};
Expand Down
2 changes: 1 addition & 1 deletion src/lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ export interface ActiveTournament {

export type ActiveTournamentList = Array<ActiveTournament>;

export type Speed = "blitz" | "live" | "correspondence";
export type Speed = "blitz" | "rapid" | "live" | "correspondence";
export type Size = "9x9" | "13x13" | "19x19";
export type AutomatchCondition = "required" | "preferred" | "no-preference";
export type RuleSet = "japanese" | "chinese" | "aga" | "korean" | "nz" | "ing";
Expand Down
81 changes: 44 additions & 37 deletions src/views/Play/Play.styl
Original file line number Diff line number Diff line change
Expand Up @@ -61,13 +61,50 @@
display: flex;
justify-content: space-between;
align-items: center;
}

.automatch-content {

.btn-group {
.btn-group {
height: max-content;
width: auto;
display: flex;
flex-direction: row;
flex-wrap: nowrap;
justify-content: space-between;
padding: 0.25rem 0.5rem 0.25rem 0.5rem;

button {
font-weight: bold;

width: 100%;
height: 75%;
min-height: 2rem
padding: 0.5rem;
}

button::before {
content: none;
}

.automatch-play {
padding-top: 1.5rem;
padding-bottom: 1.5rem;

margin-top: 0.5rem;
margin-bottom: 0.2rem;

font-size: xx-large;
font-weight: bold;
}
}
}

.automatch-speed-name {
font-size: large;
margin-bottom: 0.3rem;
}

.rengo-management-row {
td {
padding-bottom: 2rem;
Expand Down Expand Up @@ -154,17 +191,19 @@
display: flex;
justify-content: space-around;
align-content: stretch
width: 100%;
width: auto;
flex-wrap: wrap;

padding-left: 0.3rem;
padding-right: 0.3rem;

button {
font-size: 1.1rem;
font-weight: bold;
flex-grow: 1;
flex-basis: 13rem;
max-width: 13rem;
flex-basis: 48%;
height: 4rem;
margin: 0.5rem;
margin: 0.3rem;
white-space: nowrap;
display: flex;
align-items: center;
Expand Down Expand Up @@ -229,38 +268,6 @@
padding-left: 3rem;
}

.custom-game-row {
display: flex;
justify-content: space-around;
align-content: stretch
width: 100%;

button {
font-size: 1.1rem;
font-weight: bold;
flex-grow: 1;
width: 100%;
max-width: 13rem;
margin: 0.5rem;
height: 4rem;

.fa {
margin: 0.2rem;
}
}
}

.custom-game-header {
display: flex;
justify-content: space-around;
align-content: stretch
width: 100%;
justify-content: space-between;
align-items: left;
font-size: 1.3rem;
margin-top: 1rem;
}

.showall-selector {
width: 100%;
text-align: left;
Expand Down
Loading
Loading