Skip to content

Commit

Permalink
Feature/1220: Improving /muffin command (#1276)
Browse files Browse the repository at this point in the history
* Add fun command /muffin to the funcommand app.

* Improve muffin message (add shadow)

* Improve matching nickname in tm2020 for muffin commandf

* Improve the representation of the destination nickname in the muffin command

* Improve the muffin command: use input login when player not found, add a/an to the message.
  • Loading branch information
tomvlk committed Aug 30, 2023
1 parent 10e75f1 commit 86727ef
Showing 1 changed file with 15 additions and 5 deletions.
20 changes: 15 additions & 5 deletions pyplanet/apps/contrib/funcmd/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,20 +118,30 @@ async def command_afk(self, player, data, **kwargs):
)

async def command_muffin(self, player, data, **kwargs):
# Try to match the player.
if self.instance.game.game == 'tmnext':
nickname_input = style_strip(data.login).lower()
dest_player = [p for p in self.instance.player_manager.online if style_strip(p.nickname.lower()) == nickname_input]
else:
dest_player = [p for p in self.instance.player_manager.online if p.login == data.login]

if not dest_player:
message = '$i$f00Unknown player!'
return await self.instance.chat(message, player)
# Try to get the nickname of the destination player, otherwise just show the input login.
if dest_player:
dest_nickname = dest_player[0].nickname
else:
dest_nickname = data.login

# Prepare the message.
muffin = random.choice(self.muffins)
a_word = 'a'
if muffin[0:1].lower() in ['a', 'e', 'u', 'i', 'o']:
a_word = 'an'

message = '$z$s{}$z$s$m$f90 gave {} to $z$s{}'.format(
player.nickname, random.choice(self.muffins), dest_player[0].nickname
message = '$z$s{}$z$s$m$f90 gave {} {} to $z$s{}'.format(
player.nickname, a_word, muffin, dest_nickname
)

# Send the message.
await self.instance.chat(message)

async def command_bootme(self, player, data, **kwargs):
Expand Down

0 comments on commit 86727ef

Please sign in to comment.