Skip to content

Commit

Permalink
Adjust card rarity
Browse files Browse the repository at this point in the history
  • Loading branch information
benfrankel committed Aug 21, 2024
1 parent e3b7721 commit 00da71e
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 20 deletions.
31 changes: 16 additions & 15 deletions assets/config/card.ron
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@
description: "Sing an eighth note.",
background: "pink",
icon: "eighth_note",
max_level: 2,
max_level: 1,

action: Attack,
action_modifier: CardActionModifier(
Expand All @@ -185,7 +185,7 @@
description: "Sing a quarter note.",
background: "pink",
icon: "quarter_note",
max_level: 4,
max_level: 3,

action: Attack,
action_modifier: CardActionModifier(
Expand All @@ -198,7 +198,7 @@
description: "Sing a half note.",
background: "pink",
icon: "half_note",
min_level: 2,
min_level: 3,
max_level: 6,

action: Attack,
Expand All @@ -212,7 +212,8 @@
description: "Sing a whole note.",
background: "pink",
icon: "whole_note",
min_level: 4,
min_level: 5,
max_level: 8,

action: Attack,
action_modifier: CardActionModifier(
Expand All @@ -225,7 +226,7 @@
description: "Sing a pair of eighth notes.\n\n\"two beats, rapid fire!\"",
background: "pink",
icon: "pair",
max_level: 4,
max_level: 2,
weight: 0.5,

action: Attack,
Expand All @@ -239,8 +240,8 @@
description: "Sing a triplet of eighth notes.\n\n\"...three beats, rapid fire!\"",
background: "pink",
icon: "triplet",
max_level: 4,
weight: 0.1,
max_level: 3,
weight: 0.4,

action: Attack,
action_modifier: CardActionModifier(
Expand All @@ -255,9 +256,9 @@
// vscode-ron syntax highlighting breaks without this: '
background: "pink",
icon: "cacophony",
min_level: 4,
max_level: 7,
weight: 0.1,
min_level: 3,
max_level: 8,
weight: 0.25,

action: Attack,
action_modifier: CardActionModifier(
Expand Down Expand Up @@ -291,8 +292,8 @@
// vscode-ron syntax highlighting breaks without this: '
background: "pink",
icon: "cluster",
min_level: 8,
weight: 0.7,
min_level: 6,
weight: 0.8,

action: Attack,
action_modifier: CardActionModifier(
Expand Down Expand Up @@ -327,8 +328,8 @@
description: "Restore 10 health.",
background: "green",
icon: "quarter_rest",
min_level: 4,
max_level: 8,
min_level: 3,
max_level: 7,
weight: 0.7,

action: Heal,
Expand All @@ -343,7 +344,7 @@
description: "Restore 25% of missing health.",
background: "green",
icon: "half_rest",
min_level: 6,
min_level: 5,
max_level: 9,
weight: 0.6,

Expand Down
12 changes: 7 additions & 5 deletions src/game/card/deck.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl Deck {
return None;
}

self.active = (self.active + step).rem_euclid(self.card_keys.len() as isize);
self.active = (self.active.max(0) + step).rem_euclid(self.card_keys.len() as isize);

Some(&self.card_keys[self.active as usize])
}
Expand All @@ -51,7 +51,7 @@ impl Deck {
}

let old = self.active as usize;
self.active = (self.active + step).rem_euclid(self.card_keys.len() as isize);
self.active = (self.active.max(0) + step).rem_euclid(self.card_keys.len() as isize);

if old < self.card_keys.len() {
self.card_keys.swap(old, self.active as usize);
Expand All @@ -63,14 +63,16 @@ impl Deck {
return;
}

self.card_keys.remove(self.active as usize);
if self.active as usize >= self.card_keys.len() {
let idx = self.active.max(0) as usize;
self.card_keys.remove(idx);
if idx >= self.card_keys.len() {
self.active = 0;
}
}

pub fn add(&mut self, card_key: impl Into<String>) {
self.card_keys.insert(self.active as usize, card_key.into());
let idx = self.active.max(0) as usize;
self.card_keys.insert(idx, card_key.into());
}
}

Expand Down

0 comments on commit 00da71e

Please sign in to comment.