Skip to content

Statistic

Black Ram edited this page Jan 13, 2024 · 27 revisions

Statistic

Statistic(): Manages the statistics of the characters. Statistic() use the dictionary to store the values of the variables. I recommend changing the values with set() and improve() to avoid errors.

Example:

default mcStatistic = Statistic()
default friendStatistic = Statistic(
    values={
        "strength"      :   7,
        "intelligence"  :   7,
        "agility"       :   7,
    }
)

The best solution is to extend this class to implement some other class ex: SentimentalStatistic(Statistic), PhysicsStatistic(Statistic), GroceriesStatistic(Statistic)...

Get

(code-snippets: DR_StatisticGet)

python:
    mc_strength = mcStatistic.get("strength")

Set

(code-snippets: DR_StatisticSet)

python:
    mcStatistic.set("strength", 2)
    mcStatistic.set("strength", -1)
    mcStatistic.set("big", True)

Improvment

(code-snippets: DR_StatisticImprovment)

python:
    mcStatistic.improve("strength") # +1
    mcStatistic.improve("strength", 2)
    mcStatistic.improve("strength", -1)

Compare

(code-snippets: DR_StatisticChallenge)

$ mc_strength = mcStatistic.get("strength")
$ fr_strength = frStatistic.get("strength")
if isGreaterThan(mc_strength, fr_strength ): # mc_strength > fr_strength
    "You have won"
else:
    "You lost"

(code-snippets: DR_StatisticCompareMenu)

$ mc_strength = mcStatistic.get("strength")
menu:
    "Can ..." if isGreaterThan(mc_strength, 0 ): # mc_strength > 0
        # ...

Screen

Read more here: Screen & Translations

Sentimental Statistic

SentimentalStatistic(Statistic): is a example of an extension of Statistic() thought only of games for adults. You can see the all implementation here

Exemple:

default girlSentimental = SentimentalStatistic(gender_attracted = "M", virgin = True)
default mcSentimental = SentimentalStatistic(gender_attracted = "F", virgin = False, against = 20)
# ...

from pythonpackages.ds.character_statistics import Statistic

class SentimentalStatistic(Statistic):
    """Wiki: https://github.com/DRincs-Productions/DS-toolkit/wiki/Statistic#sentimental-statistic """

    def __init__(
        self,
        friendship: int = 0,
        favour: int = 0,
        love: int = 0,
        corruption: int = 0,
        virgin: bool = True,
        against=0,
        addiction=0,
        max_values: int = 100,
    ):

        # Statistic init
        super().__init__(
            notify_increase_dict={
                "addiction": increase_addiction_notify,
                "lust": increase_lust_notify,
                "friendship": increase_friendship_notify,
                "favour": increase_favour_notify,
                "love": increase_love_notify,
                "corruption": increase_corruption_notify,
                "anger": increase_anger_notify,
                "fear": increase_fear_notify,
            },
            notify_decrease_dict={
                "addiction": decrease_addiction_notify,
                "lust": decrease_lust_notify,
                "friendship": decrease_friendship_notify,
                "favour": decrease_favour_notify,
                "love": decrease_love_notify,
                "corruption": decrease_corruption_notify,
                "anger": decrease_anger_notify,
                "fear": decrease_fear_notify,
            },
            max_values=max_values,
        )

        # SentimentalStatistic init
        self._default_show_notify = False

        # is a contradiction to a romantic relationship
        self.against = against
        # Characteristics
        self.addiction = addiction
        # Relaction
        self.friendship = friendship
        self.favour = favour
        self.love = love
        self.corruption = corruption
        # Emblems
        self.is_virgin = virgin

        self._default_show_notify = True

    # Friendship
    @property
    def friendship(self) -> int:
        return self.get("friendship")

    @friendship.setter
    def friendship(self, value: int) -> None:
        cur_value = self.get("friendship")
        amt = value - cur_value
        if (self.anger > 0 and amt > 0):
            self.anger = self.anger - 5
            return
        self.improve("friendship", amt, max=100, min=-100)
        return

    @property
    def is_friend(self) -> bool:
        return self.friendship > 0

    # ...
Clone this wiki locally