Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update deck.rs #2

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions src/model/deck.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
use std::fmt::Debug;

use hashbag::HashBag;
use serde::{Serialize, Deserialize};

Expand Down Expand Up @@ -59,6 +61,10 @@ impl Deck {
self.mainboard.insert_many(card, count)
}

pub fn get_card(&self, card: &AbstractCard) -> AbstractCard {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I doubt the usefulness of this method. Let's say the deck does contain the given card in the mainboard. You are getting it, cloning it, and returning it to the user. However, the returned card should contain all the same information that the given card does. Based on our conversation elsewhere, I believe you want to add methods on the AbstractCard struct.

self.mainboard.get(card).unwrap().0.clone()
}

pub fn remove_card(&mut self, mut count: usize, card: &AbstractCard) -> usize {
let mut digest: usize = 0;
while count != 0 && self.mainboard.remove(card) != 0 {
Expand Down