Skip to content

Commit

Permalink
Fix broken healing potions
Browse files Browse the repository at this point in the history
We used `let Some(mut fighter) = fighter` instead of `let Some(ref mut
fighter) = fighter`.

Since the Fighter struct is a copy, this caused healing via potions to
not work.
  • Loading branch information
tomassedovic committed Aug 4, 2016
1 parent f270e6e commit 8b4b144
Show file tree
Hide file tree
Showing 7 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion doc/part-8-items.adoc
Original file line number Diff line number Diff line change
Expand Up @@ -457,7 +457,7 @@ since it will probably be used multiple times. The constant
----
/// heal by the given amount, without going over the maximum
pub fn heal(&mut self, amount: i32) {
if let Some(mut fighter) = self.fighter {
if let Some(ref mut fighter) = self.fighter {
fighter.hp += amount;
if fighter.hp > fighter.max_hp {
fighter.hp = fighter.max_hp;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/part-10-menu-saving.rs
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ impl Object {

/// heal by the given amount, without going over the maximum
pub fn heal(&mut self, amount: i32) {
if let Some(mut fighter) = self.fighter {
if let Some(ref mut fighter) = self.fighter {
fighter.hp += amount;
if fighter.hp > fighter.max_hp {
fighter.hp = fighter.max_hp;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/part-11-dungeon-progression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,7 @@ impl Object {

/// heal by the given amount, without going over the maximum
pub fn heal(&mut self, amount: i32) {
if let Some(mut fighter) = self.fighter {
if let Some(ref mut fighter) = self.fighter {
fighter.hp += amount;
if fighter.hp > fighter.max_hp {
fighter.hp = fighter.max_hp;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/part-12-monster-item-progression.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ impl Object {

/// heal by the given amount, without going over the maximum
pub fn heal(&mut self, amount: i32) {
if let Some(mut fighter) = self.fighter {
if let Some(ref mut fighter) = self.fighter {
fighter.hp += amount;
if fighter.hp > fighter.max_hp {
fighter.hp = fighter.max_hp;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/part-13-adventure-gear.rs
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ impl Object {
/// heal by the given amount, without going over the maximum
pub fn heal(&mut self, amount: i32, game: &Game) {
let max_hp = self.max_hp(game);
if let Some(mut fighter) = self.fighter {
if let Some(ref mut fighter) = self.fighter {
fighter.hp += amount;
if fighter.hp > max_hp {
fighter.hp = max_hp;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/part-8-items.rs
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ impl Object {

/// heal by the given amount, without going over the maximum
pub fn heal(&mut self, amount: i32) {
if let Some(mut fighter) = self.fighter {
if let Some(ref mut fighter) = self.fighter {
fighter.hp += amount;
if fighter.hp > fighter.max_hp {
fighter.hp = fighter.max_hp;
Expand Down
2 changes: 1 addition & 1 deletion src/bin/part-9-spells.rs
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ impl Object {

/// heal by the given amount, without going over the maximum
pub fn heal(&mut self, amount: i32) {
if let Some(mut fighter) = self.fighter {
if let Some(ref mut fighter) = self.fighter {
fighter.hp += amount;
if fighter.hp > fighter.max_hp {
fighter.hp = fighter.max_hp;
Expand Down

0 comments on commit 8b4b144

Please sign in to comment.