From ff4c96a0a0ab2c0baad7d2f41c273e3f83ce48c8 Mon Sep 17 00:00:00 2001 From: Matthias Date: Wed, 4 Dec 2024 10:17:51 +0100 Subject: [PATCH] contract: update difficulty for weekly and daily --- contracts/src/models/game.cairo | 45 +++++++++++++++++++++++---------- contracts/src/types/mode.cairo | 2 +- 2 files changed, 33 insertions(+), 14 deletions(-) diff --git a/contracts/src/models/game.cairo b/contracts/src/models/game.cairo index dfd7101b..549ddfbc 100644 --- a/contracts/src/models/game.cairo +++ b/contracts/src/models/game.cairo @@ -132,19 +132,38 @@ impl GameImpl of GameTrait { fn get_difficulty(ref self: Game) -> Difficulty { let mut difficulty = self.difficulty(); if (difficulty == Difficulty::None) { // Difficulty::None meaning increasing difficulty - difficulty = Difficulty::Master; - if (self.moves < 20) { - difficulty = Difficulty::Easy; - } else if (self.moves < 40) { - difficulty = Difficulty::Medium; - } else if (self.moves < 80) { - difficulty = Difficulty::MediumHard; - } else if (self.moves < 120) { - difficulty = Difficulty::Hard; - } else if (self.moves < 160) { - difficulty = Difficulty::VeryHard; - } else if (self.moves < 200) { - difficulty = Difficulty::Expert; + + // we are in normal mode or free mode + if(self.mode.into() == Mode::Normal) { + // weekly + if (self.moves < 20) { + difficulty = Difficulty::MediumHard; + } else if (self.moves < 40) { + difficulty = Difficulty::Hard; + } else if (self.moves < 80) { + difficulty = Difficulty::VeryHard; + } else if (self.moves < 120) { + difficulty = Difficulty::Expert; + } else { + difficulty = Difficulty::Master; + } + } else { + // free mode + if (self.moves < 20) { + difficulty = Difficulty::Easy; + } else if (self.moves < 40) { + difficulty = Difficulty::Medium; + } else if (self.moves < 80) { + difficulty = Difficulty::MediumHard; + } else if (self.moves < 120) { + difficulty = Difficulty::Hard; + } else if (self.moves < 160) { + difficulty = Difficulty::VeryHard; + } else if (self.moves < 200) { + difficulty = Difficulty::Expert; + } else { + difficulty = Difficulty::Master; + } } } difficulty diff --git a/contracts/src/types/mode.cairo b/contracts/src/types/mode.cairo index ac54214e..5f2c2372 100644 --- a/contracts/src/types/mode.cairo +++ b/contracts/src/types/mode.cairo @@ -38,7 +38,7 @@ impl ModeImpl of ModeTrait { fn difficulty(self: Mode) -> Difficulty { match self { Mode::Normal => Difficulty::None, // meaning increasing difficulty - Mode::Daily => Difficulty::VeryHard, + Mode::Daily => Difficulty::Expert, Mode::Free => Difficulty::None, // meaning increasing difficulty _ => Difficulty::None, }