diff --git a/bot.py b/bot.py index 2664277fa51a102073fe7cecb9ee3dd96794b3f9..caf5038c9c39f15ac62501dcf37f02b5a911886f 100644 --- a/bot.py +++ b/bot.py @@ -99,9 +99,9 @@ class Character: def setnotes(self, newnotes): self.notes = newnotes saveCharacters() - def getAttribute(attrName): + def getAttribute(self, attrName): for attr in self.attributes: - if attributeName==attr.name: + if attrName==attr.name: return attr.level return 0 @@ -271,7 +271,7 @@ async def getchar(ctx, name = None): main+=" not" attrs = "\n-".join(attr.toString() for attr in char.attributes) comps = "\n-".join(comp.toString() for comp in char.competences) - await ctx.send("The character {0} is owned by {1} and {4} his main.\n{0} have the following attributes :\n-{2}\n{0} have the following competences :\n-{3}".format(char.name, char.owner,attrs,comps,main)) + await ctx.send("The character {0} is owned by {1} and {4} his main\nCurrent experience : {5}.\n{0} have the following attributes :\n-{2}\n{0} have the following competences :\n-{3}\nNotes :\n{6}".format(char.name, char.owner,attrs,comps,main,char.xp,char.notes)) except Exception as e: await ctx.send('Exception : {}'.format(e)) @@ -294,7 +294,7 @@ async def addattribute(ctx, attrName, value, characterName = None): char= getMainCharactersByOwner(author) else: char = getCharacterByName(characterName) - char.addAttribute(attrName, value) + char.addAttribute(attrName, int(value)) await ctx.send('The attribute {0} have been created for {1} (value : {2}).'.format(attrName,char.name,value)) except Exception as e: await ctx.send('Exception : {}'.format(e)) @@ -309,7 +309,7 @@ async def addcompetence(ctx , compName, attrName, value,characterName = None ): char= getMainCharactersByOwner(author) else: char = getCharacterByName(name) - char.addCompetence(compName, attrName, value) + char.addCompetence(compName, attrName, int(value)) await ctx.send('The competence {1} (attribute : {2}) have been created for {0} (value : {3}).'.format(char.name, compName, attrName, value)) except Exception as e: await ctx.send('Exception : {}'.format(e)) @@ -350,7 +350,10 @@ async def addnotes(ctx , value,characterName = None ): char= getMainCharactersByOwner(author) else: char = getCharacterByName(name) - newnotes = char.notes + "\n"+value + if char.notes=="": + newnotes = value + else: + newnotes = char.notes + "\n"+value char.setnotes(newnotes) await ctx.send('Notes added for {}'.format(char.name)) except Exception as e: @@ -436,11 +439,11 @@ async def r(ctx, what, characterName = None): for i in range(comp.level): roll.append(random.choice(range(1, 10 + 1))) noduplicates = set(roll) - dicebonus = roll.length - noduplicates.length + dicebonus = comp.level - len(noduplicates) attrbonus = char.getAttribute(comp.attribute) maxdice = max(roll) - res = maxdice + dicebonus + attr.level - await ctx.send('The result for the {0} check is : {1} ({2} + {3} + {4})'.format(what, res,maxdice,dicebonus,attrbonus)) + res = maxdice + dicebonus + attrbonus + await ctx.send('Roll : {5}\nThe result for the {0} check is : {1} ({2} + {3} + {4})'.format(what, res,maxdice,dicebonus,attrbonus,roll)) return else: await ctx.send("Competences not implemented yet") @@ -458,10 +461,10 @@ async def r(ctx, what, characterName = None): for i in range(attr.level): roll.append(random.choice(range(1, 10 + 1))) noduplicates = set(roll) - dicebonus = roll.length - noduplicates.length + dicebonus = attr.level - len(noduplicates) maxdice = max(roll) res = maxdice + dicebonus + attr.level - await ctx.send('The result for the {0} check is : {1} ({2} + {3} + {4})'.format(what, res,maxdice,dicebonus,attr.level)) + await ctx.send('Roll : {5}\nThe result for the {0} check is : {1} ({2} + {3} + {4})'.format(what, res,maxdice,dicebonus,attr.level,roll)) return else: await ctx.send('Character system {} not supported yet'.format(char.system)) @@ -479,6 +482,10 @@ async def on_command_error(ctx, error): loadAll() #for char in characters: +# for attr in char.attributes: +# setattr(attr, "level", int(attr.level)) +# for comp in char.competences: +# setattr(comp, "level", int(comp.level)) # setattr(char, "notes", "") # setattr(char, "xp", 0) bot.run(TOKEN) \ No newline at end of file