Skip to content

Commit

Permalink
fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
jpinedaa committed Jun 17, 2024
1 parent 5eb740c commit a860a68
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 9 deletions.
16 changes: 8 additions & 8 deletions backend/story_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from filelock import FileLock


def fuzzy_compare(string1, string2, threshold=80):
def fuzzy_compare(string1, string2, threshold=60):
"""
Compare two strings and return True if their similarity ratio
is above the given threshold, otherwise return False.
Expand Down Expand Up @@ -111,7 +111,7 @@ def get_active_challenges(self):

def get_challenge_card_by_title(self, title):
for card in self.narratorCards:
if fuzzy_compare(card.title, title, threshold=80) and card.type != 'Place':
if fuzzy_compare(card.title, title) and card.type != 'Place':
return card
return None

Expand Down Expand Up @@ -205,13 +205,13 @@ def get_character_selected_cards(self, character):
selectedCards = []
for scene in self.scenes:
for move in scene.moves:
if fuzzy_compare(move.character, character.name, threshold=80):
if fuzzy_compare(move.character, character.name):
selectedCards += move.cardsPlayed
return selectedCards

def get_unselected_character_card(self, character, title):
for card in character.cards:
if fuzzy_compare(card.title, title, threshold=80) and card not in self.get_character_selected_cards(character):
if fuzzy_compare(card.title, title) and card not in self.get_character_selected_cards(character):
return card

def add_move(self, character, description, challenges, cardsPlayed, pickupCards):
Expand Down Expand Up @@ -242,7 +242,7 @@ def add_move(self, character, description, challenges, cardsPlayed, pickupCards)

def get_narrator_card_by_title(self, title):
for card in self.narratorCards:
if fuzzy_compare(card.title, title, threshold=80):
if fuzzy_compare(card.title, title):
return card
return None

Expand All @@ -266,7 +266,7 @@ def add_scene(self, title, description, place, challenges, pickupCards):

def get_place_by_title(self, title):
for card in self.narratorCards:
if card.type == 'Place' and fuzzy_compare(card.title, title, threshold=80):
if card.type == 'Place' and fuzzy_compare(card.title, title):
return card
return None

Expand All @@ -279,12 +279,12 @@ def get_narrator_selected_cards(self):

def get_unselected_narrator_card(self, title):
for card in self.narratorCards:
if fuzzy_compare(card.title, title, threshold=80) and card not in self.get_narrator_selected_cards():
if fuzzy_compare(card.title, title) and card not in self.get_narrator_selected_cards():
return card

def get_character_by_name(self, name):
for character in self.characters:
if fuzzy_compare(character.name, name, threshold=80):
if fuzzy_compare(character.name, name):
return character
return None

Expand Down
1 change: 1 addition & 0 deletions frontend/lib/game_state.dart
Original file line number Diff line number Diff line change
Expand Up @@ -312,6 +312,7 @@ class GameState with ChangeNotifier {
if (player != null) {
final newPlayer = Player(
newCard.title, 'Character', newCard.playerStatus!.name,
cardsIndices: player.cardsIndices,
cardIndex: cards.indexOf(newCard));
players[players.indexOf(player)] = newPlayer;
}
Expand Down
2 changes: 1 addition & 1 deletion frontend/lib/new_card_form_page.dart
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ class NewCardFormPageState extends State<NewCardFormPage> {
// }

Future<Uint8List> compressImage(Uint8List bytes,
{int targetWidth = 800, int targetHeight = 600}) async {
{int targetWidth = 300, int targetHeight = 300}) async {
// Decode the image
img.Image image = img.decodeImage(bytes)!;

Expand Down

0 comments on commit a860a68

Please sign in to comment.