Skip to content

Commit

Permalink
feat(diary): add additional xp for star filling bonus
Browse files Browse the repository at this point in the history
  • Loading branch information
Hojagulyyev committed Nov 20, 2023
1 parent f30afc9 commit ffd67d5
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 5 deletions.
22 changes: 17 additions & 5 deletions apps/diaries/services.py
Original file line number Diff line number Diff line change
@@ -1,14 +1,26 @@
from rp2.business_logic import XP_PER_DAIRY_COMMIT, MESSAGE_LENGTH_WHICH_BRINGS_XP_IN_DIARY_COMMIT
from rp2.business_logic import (
XP_PER_DAIRY_COMMIT,
MESSAGE_LENGTH_WHICH_BRINGS_XP_IN_DIARY_COMMIT,
STAR_FILLING_BONUS_VALUE,
ADDITIONAL_XP_FOR_STAR_FILLING,
)

from .models import DiaryCommit


def calculate_diary_commit_xp(commit: DiaryCommit):
additional_xp_for_more_detailed_message = int(
len(commit.message) / MESSAGE_LENGTH_WHICH_BRINGS_XP_IN_DIARY_COMMIT
)
total_xp = [
XP_PER_DAIRY_COMMIT,
additional_xp_for_more_detailed_message,
]

# additional xp for more detailed message
additional_xp_for_more_detailed_message = int(
len(commit.message) / MESSAGE_LENGTH_WHICH_BRINGS_XP_IN_DIARY_COMMIT
)
total_xp.append(additional_xp_for_more_detailed_message)

# additional xp for star filling bonus
if commit.diary.commits.count() == STAR_FILLING_BONUS_VALUE:
total_xp.append(ADDITIONAL_XP_FOR_STAR_FILLING)

return sum(total_xp)
2 changes: 2 additions & 0 deletions rp2/business_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
XP_PER_DAIRY_COMMIT = 5
MESSAGE_LENGTH_WHICH_BRINGS_XP_IN_DIARY_COMMIT = 50
LEVEL_STEP_THAT_CHANGE_COLOR_DESIGN = 3
STAR_FILLING_BONUS_VALUE = 5
ADDITIONAL_XP_FOR_STAR_FILLING = 28

# ===== RULES
COMMIT_MIN_LENGTH = 10

0 comments on commit ffd67d5

Please sign in to comment.