I’d like to change the ‘DEFENSE’ part to a foreign language in a sentence printed like this.
if not increase:
await ctx.message.reply("Please specify a stat to increase (HP, ATTACK, DEFENSE)")
return
increase = increase.lower()
if increase == "체력" or increase == "hp" or increase == "hitpoints" or increase == "max_hp" or increase == "maxhp":
increase = "max_hp"
elif increase == "공격" or increase == "attack" or increase == "att":
increase = "attack"
elif increase == "방어" or increase == "defense" or increase == "def" or increase == "defence":
increase = "defense"
success, new_level = character.level_up(increase)
if success:
await ctx.message.reply(f"{character.name} 는(은) 레벨 {new_level} 이 되었습니다. {increase.upper().replace('_', ' ')}의 능력이 1 성장했습니다.")
else:
await ctx.message.reply(f"{character.name} failed to level up.")
There are too many words ‘DEEFENSE’ in the CODE I’m trying to change it one by one, but I haven’t found the answer yet.
I think this sentence is the key. What does this sentence mean?
{increase.upper().replace('_', ' ')}의 능력이 1 성장했습니다.")
If want to change ‘DEFFENSE’ to another word, which part of CODE should I modify?
Please tell me if it is against the rules of the community to ask these questions. I must have made a mistake because I don’t know where to ask.
I think what you are asking is for a user to be able to type in “defence” but in a different language, is that right? If so the best way to do this is to use search and replace within the Repl (ctrl + h)
When I entered the !levelup defense command,
I’d like to revise the notice of bot.
The current notice says, ㅇㅇ advanced to level N, gaining 1 DEFENSE.
I want to change DEFENSE in this sentence to another word.
However, because there is too much DEFENSE throughout the CODE, switching to Ctrl+h results in an error. It seems to change the definition that should not be changed.
success, new_level = character.level_up(increase)
if success:
await ctx.message.reply(f"{character.name} advanced to level {new_level}, gaining 1 {increase.upper().replace('_', ' ')}.")
else:
await ctx.message.reply(f"{character.name} failed to level up.")
In my opinion, it would be important to check what the < {increase.upper().replace(‘_’, ’ ')} > part of this code means. Then I could change DEFENSE into another language…!! (Ex. 방어)
I am very sorry if this is a basic question, because I am new to Python.
You are doing well finding that particular section of code. What it is doing is turning whatever is in the variable increase to upper case and replacing any underscore characters (if they exist) with spaces.
So if I am reading this correctly you want to type !levelup defence into the bot, but have the following appear: