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

Year and Numeric Hints #10

Open
2 tasks
loljoho opened this issue Feb 27, 2019 · 2 comments
Open
2 tasks

Year and Numeric Hints #10

loljoho opened this issue Feb 27, 2019 · 2 comments
Labels
1.1 - bot Related to the bot plugin

Comments

@loljoho
Copy link
Owner

loljoho commented Feb 27, 2019

When answers have three or fewer digits (e.g. years)...

  1. First Hint: First character
  2. Second Hint: The second character; or no additional hints
  3. Third Hint: No additional hints

Instead of:

****
1***
19**
1956

Reveal hints like:

****
*9**
*95*
1956
  • First Hint: should provide a one character hint at random
  • Second Hint: should provide a one character hint at random
RELEVANT CODE

    def getHintString(self, hintNum=None):
        if hintNum == None:
            hintNum = self.hintsCounter
        hintRatio = self.registryValue('hints.hintRatio') # % to show each hint
        hint = ''
        ratio = float(hintRatio * .01)
        charMask = self.registryValue('hints.charMask', self.channel)

        # create a string with hints for all of the answers
        if self.questionType == 'kaos':
            for ans in self.answers:
                if ircutils.toLower(ans) not in self.guessedAnswers:
                    ans = str(ans)
                    hintStr = ''
                    if hintNum == 0:
                        for char in ans:
                            if char in self.unmaskedChars:
                                hintStr += char
                            else:
                                hintStr += charMask
                    elif hintNum == 1:
                        divider = int(len(ans) * ratio)
                        divider = min(divider, 3)
                        divider = min(divider, len(ans)-1)
                        hintStr += ans[:divider]
                        masked = ans[divider:]
                        for char in masked:
                            if char in self.unmaskedChars:
                                hintStr += char
                            else:
                                hintStr += charMask
                    elif hintNum == 2:
                        divider = int(len(ans) * ratio)
                        divider = min(divider, 3)
                        divider = min(divider, len(ans)-1)
                        lettersInARow = divider-1
                        maskedInARow = 0
                        hintStr += ans[:divider]
                        ansend = ans[divider:]
                        hintsend = ''
                        unmasked = 0
                        if self.registryValue('hints.vowelsHint', self.channel):
                            hintStr += self.getMaskedVowels(ansend, divider-1)
                        else:
                            hintStr += self.getMaskedRandom(ansend, divider-1)
                    hint += ' [{0}]'.format(hintStr)
        else:
            ans = str(self.answers[0])
            if hintNum == 0:
                for char in ans:
                    if char in self.unmaskedChars:
                        hint += char
                    else:
                        hint += charMask
            elif hintNum == 1:
                divider = int(len(ans) * ratio)
                divider = min(divider, 3)
                divider = min(divider, len(ans)-1)
                hint += ans[:divider]
                masked = ans[divider:]
                for char in masked:
                    if char in self.unmaskedChars:
                        hint += char
                    else:
                        hint += charMask
            elif hintNum == 2:
                divider = int(len(ans) * ratio)
                divider = min(divider, 3)
                divider = min(divider, len(ans)-1)
                lettersInARow = divider-1
                maskedInARow = 0
                hint += ans[:divider]
                ansend = ans[divider:]
                hintsend = ''
                unmasked = 0
                if self.registryValue('hints.vowelsHint', self.channel):
                    hint += self.getMaskedVowels(ansend, divider-1)
                else:
                    hint += self.getMaskedRandom(ansend, divider-1)
        
        return hint.strip()

Blarg

  • Relevant code at line 302
  • getHintString at line 256
@loljoho
Copy link
Owner Author

loljoho commented Feb 27, 2019

@loljoho loljoho added 1.1 - bot Related to the bot plugin icebox labels May 12, 2019
@loljoho loljoho removed the icebox label May 12, 2019
@loljoho
Copy link
Owner Author

loljoho commented May 15, 2019

Updated with relevant code

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
1.1 - bot Related to the bot plugin
Projects
None yet
Development

No branches or pull requests

1 participant