Skip to content

Commit

Permalink
contract: update difficulty for weekly and daily
Browse files Browse the repository at this point in the history
  • Loading branch information
Matth26 committed Dec 4, 2024
1 parent 2576b30 commit ff4c96a
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 14 deletions.
45 changes: 32 additions & 13 deletions contracts/src/models/game.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion contracts/src/types/mode.cairo
Original file line number Diff line number Diff line change
Expand Up @@ -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,
}
Expand Down

0 comments on commit ff4c96a

Please sign in to comment.