Skip to content

Commit 2253e7a

Browse files
committed
hacky make challenge difficulty a string to match repo config
Signed-off-by: Robert Detjens <github@detjens.dev>
1 parent 7e5df08 commit 2253e7a

File tree

2 files changed

+10
-4
lines changed

2 files changed

+10
-4
lines changed

src/configparser/challenge.rs

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ pub struct ChallengeConfig {
157157
directory: PathBuf,
158158

159159
#[serde(default = "default_difficulty")]
160-
difficulty: i64,
160+
difficulty: String,
161161

162162
flag: FlagType,
163163

@@ -222,8 +222,12 @@ impl ChallengeConfig {
222222
}
223223
}
224224

225-
fn default_difficulty() -> i64 {
226-
1
225+
fn default_difficulty() -> String {
226+
// temporary hack to get default from repo config. will revisit when
227+
// renaming challenge -> difficulty_class
228+
get_config()
229+
.map(|c| c.defaults.difficulty.to_string())
230+
.unwrap_or("".to_string())
227231
}
228232

229233
#[derive(Debug, PartialEq, Serialize, Deserialize)]

src/deploy/frontend.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,9 @@ pub async fn render_frontend_info(
9999
let points = get_config()?
100100
.points
101101
.iter()
102-
.find(|point_category| point_category.difficulty == chal.difficulty.to_string())
102+
// note: this weird to_string() will be fixed when the challenge difficulty
103+
// moves to point_category string. this is in a weird inbetween rn
104+
.find(|point_category| point_category.difficulty == chal.difficulty)
103105
.ok_or(anyhow!("challenge points are missing in config"))?;
104106

105107
let chal_data = FrontendChalData {

0 commit comments

Comments
 (0)